Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax extension to load an entire file into [u8] at compile-time #1654

Closed
brson opened this issue Jan 25, 2012 · 6 comments
Closed

Syntax extension to load an entire file into [u8] at compile-time #1654

brson opened this issue Jan 25, 2012 · 6 comments
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Jan 25, 2012

For testing purposes I've frequently wanted to do something like:

// Run my test on some external data
let source = str::from_bytes(#readfile("test.rs"));
...

It would read a file relative to the directory of the current source file (not sure what it would do when building stdin - probably relative to cwd).

I think nmatsakis mentioned that D can do something like this. Let's copy it.

@nikomatsakis
Copy link
Contributor

this'd be cool. might also be nice to have a variant that does the utf-8 pre-processing at compile time and yields a str.

@brson
Copy link
Contributor Author

brson commented Jan 25, 2012

@graydon
Copy link
Contributor

graydon commented Jan 26, 2012

Yeah. Could also construct a few literal/constant types.

Would also be interesting to have an #include that actually feeds the input through the parser, rather than yielding a specific literal. Maybe that's too subject to abuse though?

@brson
Copy link
Contributor Author

brson commented May 22, 2012

@paulstansifer I believe this is done. Can you confirm?

@paulstansifer
Copy link
Contributor

#include_str[] now provides this functionality. Closed by c23d6a5

@paulstansifer
Copy link
Contributor

#include_str[] now provides this functionality. Closed by c23d6a5. Graydon's parsed include suggestion is #include.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 26, 2020
Changes:
````
rustup to rust-lang#70043
map_clone: avoid suggesting `copied()` for &mut
fix redundant_pattern_matching lint
Add tests for rust-lang#1654
Don't trigger while_let_on_iterator when the iterator is recreated every iteration
Update issue_2356.stderr reference file
Update while_let_on_iterator tests
Fix while_let_on_iterator suggestion and make it MachineApplicable
Add lifetime test case for `new_ret_no_self`
rustup rust-lang#71215
Downgrade match_bool to pedantic
Run fetch before testing if master contains beta
The beta branch update should not require a force push
Add a note to the beta sections of release.md
Remove apt-get upgrade again
Always use the deploy script and templates of the master branch
README: fix lit count line
clippy_dev: make it fatal when the regex for updating lint count does not match
`predecessors_for` will be removed soon
Rustup "Remove `BodyAndCache`"
Only run (late) internal lints, when they are warn/deny/forbid
Only run cargo lints, when they are warn/deny/forbid
span_lint_and_note now takes an Option<Span> for the note_span instead of just a span
Make lint also capture blocks and closures, adjust language to mention other mutex types
don't test the code in the lint docs
Switch to matching against full paths instead of just the last element of the path
Lint for holding locks across await points
Also mention `--fix` for nightly users
fix crash on issue-69020-assoc-const-arith-overflow.rs
Address review comments
remark fixes
Update CHANGELOG.md for Rust 1.43 and 1.44
update stderr file
util/fetch_prs_between.sh: Add Markdown formatted Link
factor ifs into function, add differing mutex test
Update the changelog update documentation
Apply suggestions from PR review
update span_lint_and_help call to six args
test for mutex eq, add another test case
use if chain
cargo dev fmt
fix map import to rustc_middle
dev update_lints
fix internal clippy warnings
change visitor name to OppVisitor
use Visitor api to find Mutex::lock calls
add note about update-all-refs script, revert redundant pat to master
move closures to seperate fns, remove known problems
use span_lint_and_help, cargo dev fmt
creating suggestion
progress work on suggestion for auto fix
Implement unsafe_derive_deserialize lint
Update empty_enum.stderr
Formatting and naming
Formatting and naming
Cleanup: `node_id` -> `hir_id`
Fix issue rust-lang#2907.
Don't trigger toplevel_ref_arg for `for` loops
Cleanup: future_not_send: use `return_ty` method
Remove badge FIXME from Cargo.toml
Change note_span argument for span_lint_and_note.
Add an Option<Span> argument to span_lint_and_help.
Fixes internal lint warning in code base.
Implement collapsible_span_lint_calls lint.
````

Fixes rust-lang#71453
oli-obk pushed a commit to oli-obk/rust that referenced this issue May 2, 2020
oli-obk pushed a commit to oli-obk/rust that referenced this issue May 2, 2020
 Don't trigger while_let_on_iterator when the iterator is recreated every iteration

r? @phansch

Fixes rust-lang#1654

changelog: Fix false positive in [`while_let_on_iterator`]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: frontend (errors, parsing and HIR) A-syntaxext Area: Syntax extensions C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

4 participants