File tree Expand file tree Collapse file tree 6 files changed +58
-3
lines changed
compiler/rustc_builtin_macros/src Expand file tree Collapse file tree 6 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -148,9 +148,7 @@ pub(crate) fn expand_include<'cx>(
148148 let mut p = unwrap_or_emit_fatal ( new_parser_from_file (
149149 self . psess ,
150150 & self . path ,
151- // Don't strip frontmatter for backward compatibility, `---` may be the start of a
152- // manifold negation. FIXME: Ideally, we wouldn't strip shebangs here either.
153- StripTokens :: Shebang ,
151+ StripTokens :: Nothing ,
154152 Some ( self . span ) ,
155153 ) ) ;
156154 let expr = parse_expr ( & mut p) . ok ( ) ?;
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env my-rust-expr-evaluator
2+
3+ 2 * (1 + 3)
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env my-rust-script-runner
2+
3+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ // FIXME: Description.
2+
3+ fn main ( ) {
4+ // expr ctxt
5+ _ = include ! ( "auxiliary/shebang-expr.rs" ) ;
6+ //~^ ERROR non-expression macro in expression position
7+ //~? ERROR expected `[`, found `/`
8+
9+ // stmt ctxt (reuses expr expander)
10+ include ! ( "auxiliary/shebang-expr.rs" ) ;
11+ //~^ ERROR non-statement macro in statement position
12+ //~? ERROR expected `[`, found `/`
13+ }
14+
Original file line number Diff line number Diff line change 1+ error: expected `[`, found `/`
2+ --> $DIR/auxiliary/shebang-expr.rs:1:3
3+ |
4+ LL | #!/usr/bin/env my-rust-expr-evaluator
5+ | ^ expected `[`
6+ |
7+ = note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not
8+ = help: if you meant this to be a shebang interpreter directive, move it to the very start of the file
9+
10+ error: non-expression macro in expression position: include
11+ --> $DIR/shebang-in-expr-ctxt.rs:5:9
12+ |
13+ LL | _ = include!("auxiliary/shebang-expr.rs");
14+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
16+ error: expected `[`, found `/`
17+ --> $DIR/auxiliary/shebang-expr.rs:1:3
18+ |
19+ LL | #!/usr/bin/env my-rust-expr-evaluator
20+ | ^ expected `[`
21+ |
22+ = note: the token sequence `#!` here looks like the start of a shebang interpreter directive but it is not
23+ = help: if you meant this to be a shebang interpreter directive, move it to the very start of the file
24+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
25+
26+ error: non-statement macro in statement position: include
27+ --> $DIR/shebang-in-expr-ctxt.rs:10:5
28+ |
29+ LL | include!("auxiliary/shebang-expr.rs");
30+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31+
32+ error: aborting due to 4 previous errors
33+
Original file line number Diff line number Diff line change 1+ // FIXME: Description.
2+ //@ check-pass
3+
4+ include ! ( "auxiliary/shebang-items.rs" ) ;
You can’t perform that action at this time.
0 commit comments