about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/syntux/parser.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/syntux/parser.rs b/src/syntux/parser.rs
index 3a72fb6be88..c8d427478dc 100644
--- a/src/syntux/parser.rs
+++ b/src/syntux/parser.rs
@@ -227,8 +227,16 @@ impl<'a> Parser<'a> {
                 if !parser.eat_keyword(kw::If) {
                     return Err("Expected `if`");
                 }
+                // Inner attributes are not actually syntactically permitted here, but we don't
+                // care about inner vs outer attributes in this position. Our purpose with this
+                // special case parsing of cfg_if macros is to ensure we can correctly resolve
+                // imported modules that may have a custom `path` defined.
+                //
+                // As such, we just need to advance the parser past the attribute and up to
+                // to the opening brace.
+                // See also https://github.com/rust-lang/rust/pull/79433
                 parser
-                    .parse_attribute(false)
+                    .parse_attribute(rustc_parse::parser::attr::InnerAttrPolicy::Permitted)
                     .map_err(|_| "Failed to parse attributes")?;
             }