We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a18bd8a commit dfe7c65Copy full SHA for dfe7c65
compiler/rustc_parse/src/parser/attr.rs
@@ -130,7 +130,14 @@ impl<'a> Parser<'a> {
130
let style =
131
if this.eat(exp!(Not)) { ast::AttrStyle::Inner } else { ast::AttrStyle::Outer };
132
133
- this.expect(exp!(OpenBracket))?;
+ let bracket_res = this.expect(exp!(OpenBracket));
134
+ // If `#!` is not followed by `[`
135
+ if bracket_res.is_err() && style == ast::AttrStyle::Inner {
136
+ return Err(bracket_res
137
+ .unwrap_err()
138
+ .with_note("shebangs `#!` must be at the start of the file"));
139
+ }
140
+ bracket_res?;
141
let item = this.parse_attr_item(ForceCollect::No)?;
142
this.expect(exp!(CloseBracket))?;
143
let attr_sp = lo.to(this.prev_token.span);
0 commit comments