diff options
| author | Urgau <urgau@numericable.fr> | 2024-09-18 17:44:32 +0200 |
|---|---|---|
| committer | Urgau <urgau@numericable.fr> | 2024-10-01 10:01:09 +0200 |
| commit | 57b9b1f9745a56943cc0aebc4c3ec487945f044e (patch) | |
| tree | 54688059c287db2d7f2a33ed6205fe9b3673ab4d /compiler/rustc_parse/src/parser | |
| parent | c3ce4e66a5732a5b89c9f495b44357bf6b29d424 (diff) | |
| download | rust-57b9b1f9745a56943cc0aebc4c3ec487945f044e.tar.gz rust-57b9b1f9745a56943cc0aebc4c3ec487945f044e.zip | |
Use `ast::NestedMetaItem` when evaluating cfg predicate
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index c65cf3f40f6..4aa56cb7624 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -356,8 +356,10 @@ impl<'a> Parser<'a> { } /// Parses `cfg_attr(pred, attr_item_list)` where `attr_item_list` is comma-delimited. - pub fn parse_cfg_attr(&mut self) -> PResult<'a, (ast::MetaItem, Vec<(ast::AttrItem, Span)>)> { - let cfg_predicate = self.parse_meta_item(AllowLeadingUnsafe::No)?; + pub fn parse_cfg_attr( + &mut self, + ) -> PResult<'a, (ast::NestedMetaItem, Vec<(ast::AttrItem, Span)>)> { + let cfg_predicate = self.parse_meta_item_inner()?; self.expect(&token::Comma)?; // Presumably, the majority of the time there will only be one attr. @@ -452,7 +454,7 @@ impl<'a> Parser<'a> { /// ```ebnf /// MetaItemInner = UNSUFFIXED_LIT | MetaItem ; /// ``` - fn parse_meta_item_inner(&mut self) -> PResult<'a, ast::NestedMetaItem> { + pub fn parse_meta_item_inner(&mut self) -> PResult<'a, ast::NestedMetaItem> { match self.parse_unsuffixed_meta_item_lit() { Ok(lit) => return Ok(ast::NestedMetaItem::Lit(lit)), Err(err) => err.cancel(), // we provide a better error below |
