From d42d1d33f029ac09d4848c102b53ca39da6d0f4e Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 18 Dec 2020 20:00:59 +0100 Subject: Fix parsing of active cfg_attr --- crates/hir_def/src/attr.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs index b8d9c2682..68d05c54d 100644 --- a/crates/hir_def/src/attr.rs +++ b/crates/hir_def/src/attr.rs @@ -167,6 +167,7 @@ impl RawAttrs { }); cfg.pop(); // `,` ends up in here + let attr = Subtree { delimiter: None, token_trees: attr }; let cfg = Subtree { delimiter: subtree.delimiter, token_trees: cfg }; let cfg = CfgExpr::parse(&cfg); @@ -174,8 +175,7 @@ impl RawAttrs { if cfg_options.check(&cfg) == Some(false) { None } else { - let attr = Subtree { delimiter: None, token_trees: attr }; - let attr = ast::Attr::parse(&attr.to_string()).ok()?; + let attr = ast::Attr::parse(&format!("#[{}]", attr)).ok()?; let hygiene = Hygiene::new_unhygienic(); // FIXME Attr::from_src(attr, &hygiene) } -- cgit v1.2.3