Skip to content

Commit 5c0673c

Browse files
refactor: update cfg_if attr parsing
1 parent 4f32ce8 commit 5c0673c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: src/syntux/parser.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,16 @@ impl<'a> Parser<'a> {
227227
if !parser.eat_keyword(kw::If) {
228228
return Err("Expected `if`");
229229
}
230+
// Inner attributes are not actually syntactically permitted here, but we don't
231+
// care about inner vs outer attributes in this position. Our purpose with this
232+
// special case parsing of cfg_if macros is to ensure we can correctly resolve
233+
// imported modules that may have a custom `path` defined.
234+
//
235+
// As such, we just need to advance the parser past the attribute and up to
236+
// to the opening brace.
237+
// See also https://github.com/rust-lang/rust/pull/79433
230238
parser
231-
.parse_attribute(false)
239+
.parse_attribute(rustc_parse::parser::attr::InnerAttrPolicy::Permitted)
232240
.map_err(|_| "Failed to parse attributes")?;
233241
}
234242

0 commit comments

Comments
 (0)