Rollup merge of #133746 - oli-obk:push-xwyrylxmrtvq, r=jieyouxu
Change `AttrArgs::Eq` to a struct variant Cleanups for simplifying https://github.com/rust-lang/rust/pull/131808 Basically changes `AttrArgs::Eq` to a struct variant and then avoids several matches on `AttrArgsEq` in favor of methods on it. This will make future refactorings simpler, as they can either keep methods or switch to field accesses without having to restructure code
This commit is contained in:
commit
6f9f17fc08
16 changed files with 68 additions and 52 deletions
|
@ -1376,7 +1376,7 @@ impl<'a> Parser<'a> {
|
|||
AttrArgs::Delimited(args)
|
||||
} else if self.eat(&token::Eq) {
|
||||
let eq_span = self.prev_token.span;
|
||||
AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
|
||||
AttrArgs::Eq { eq_span, value: AttrArgsEq::Ast(self.parse_expr_force_collect()?) }
|
||||
} else {
|
||||
AttrArgs::Empty
|
||||
})
|
||||
|
|
|
@ -43,7 +43,7 @@ pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
|
|||
}
|
||||
}
|
||||
_ => {
|
||||
if let AttrArgs::Eq(..) = attr_item.args {
|
||||
if let AttrArgs::Eq { .. } = attr_item.args {
|
||||
// All key-value attributes are restricted to meta-item syntax.
|
||||
match parse_meta(psess, attr) {
|
||||
Ok(_) => {}
|
||||
|
@ -70,7 +70,7 @@ pub fn parse_meta<'a>(psess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Met
|
|||
parse_in(psess, tokens.clone(), "meta list", |p| p.parse_meta_seq_top())?;
|
||||
MetaItemKind::List(nmis)
|
||||
}
|
||||
AttrArgs::Eq(_, AttrArgsEq::Ast(expr)) => {
|
||||
AttrArgs::Eq { value: AttrArgsEq::Ast(expr), .. } => {
|
||||
if let ast::ExprKind::Lit(token_lit) = expr.kind {
|
||||
let res = ast::MetaItemLit::from_token_lit(token_lit, expr.span);
|
||||
let res = match res {
|
||||
|
@ -116,7 +116,9 @@ pub fn parse_meta<'a>(psess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Met
|
|||
return Err(err);
|
||||
}
|
||||
}
|
||||
AttrArgs::Eq(_, AttrArgsEq::Hir(lit)) => MetaItemKind::NameValue(lit.clone()),
|
||||
AttrArgs::Eq { value: AttrArgsEq::Hir(lit), .. } => {
|
||||
MetaItemKind::NameValue(lit.clone())
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue