Skip to content

Commit e2e7fac

Browse files
refactor: update cfg_if attr parsing
1 parent 9b18cc0 commit e2e7fac

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/formatting/syntux/parser.rs

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

0 commit comments

Comments
 (0)