Skip to content

Commit 53b2c7c

Browse files
oli-obkjdonszelmann
authored andcommitted
Rename value field to expr to simplify later commits' diffs
1 parent a611773 commit 53b2c7c

File tree

14 files changed

+28
-30
lines changed

14 files changed

+28
-30
lines changed

Diff for: compiler/rustc_ast/src/ast.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1759,7 +1759,7 @@ pub enum AttrArgs {
17591759
/// Span of the `=` token.
17601760
eq_span: Span,
17611761

1762-
value: AttrArgsEq,
1762+
expr: AttrArgsEq,
17631763
},
17641764
}
17651765

@@ -1804,7 +1804,7 @@ impl AttrArgs {
18041804
match self {
18051805
AttrArgs::Empty => None,
18061806
AttrArgs::Delimited(args) => Some(args.dspan.entire()),
1807-
AttrArgs::Eq { eq_span, value } => Some(eq_span.to(value.span())),
1807+
AttrArgs::Eq { eq_span, expr } => Some(eq_span.to(expr.span())),
18081808
}
18091809
}
18101810

@@ -1814,7 +1814,7 @@ impl AttrArgs {
18141814
match self {
18151815
AttrArgs::Empty => TokenStream::default(),
18161816
AttrArgs::Delimited(args) => args.tokens.clone(),
1817-
AttrArgs::Eq { value, .. } => TokenStream::from_ast(value.unwrap_ast()),
1817+
AttrArgs::Eq { expr, .. } => TokenStream::from_ast(expr.unwrap_ast()),
18181818
}
18191819
}
18201820
}
@@ -1828,10 +1828,10 @@ where
18281828
match self {
18291829
AttrArgs::Empty => {}
18301830
AttrArgs::Delimited(args) => args.hash_stable(ctx, hasher),
1831-
AttrArgs::Eq { value: AttrArgsEq::Ast(expr), .. } => {
1831+
AttrArgs::Eq { expr: AttrArgsEq::Ast(expr), .. } => {
18321832
unreachable!("hash_stable {:?}", expr);
18331833
}
1834-
AttrArgs::Eq { eq_span, value: AttrArgsEq::Hir(lit) } => {
1834+
AttrArgs::Eq { eq_span, expr: AttrArgsEq::Hir(lit) } => {
18351835
eq_span.hash_stable(ctx, hasher);
18361836
lit.hash_stable(ctx, hasher);
18371837
}

Diff for: compiler/rustc_ast/src/attr/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl AttrItem {
268268
/// ```
269269
fn value_str(&self) -> Option<Symbol> {
270270
match &self.args {
271-
AttrArgs::Eq { value, .. } => value.value_str(),
271+
AttrArgs::Eq { expr, .. } => expr.value_str(),
272272
AttrArgs::Delimited(_) | AttrArgs::Empty => None,
273273
}
274274
}
@@ -492,7 +492,7 @@ impl MetaItemKind {
492492
MetaItemKind::list_from_tokens(tokens.clone()).map(MetaItemKind::List)
493493
}
494494
AttrArgs::Delimited(..) => None,
495-
AttrArgs::Eq { value: AttrArgsEq::Ast(expr), .. } => match expr.kind {
495+
AttrArgs::Eq { expr: AttrArgsEq::Ast(expr), .. } => match expr.kind {
496496
ExprKind::Lit(token_lit) => {
497497
// Turn failures to `None`, we'll get parse errors elsewhere.
498498
MetaItemLit::from_token_lit(token_lit, expr.span)
@@ -501,7 +501,7 @@ impl MetaItemKind {
501501
}
502502
_ => None,
503503
},
504-
AttrArgs::Eq { value: AttrArgsEq::Hir(lit), .. } => {
504+
AttrArgs::Eq { expr: AttrArgsEq::Hir(lit), .. } => {
505505
Some(MetaItemKind::NameValue(lit.clone()))
506506
}
507507
}
@@ -704,7 +704,7 @@ pub fn mk_attr_name_value_str(
704704
tokens: None,
705705
});
706706
let path = Path::from_ident(Ident::new(name, span));
707-
let args = AttrArgs::Eq { eq_span: span, value: AttrArgsEq::Ast(expr) };
707+
let args = AttrArgs::Eq { eq_span: span, expr: AttrArgsEq::Ast(expr) };
708708
mk_attr(g, style, unsafety, path, args, span)
709709
}
710710

Diff for: compiler/rustc_ast/src/mut_visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
451451
match args {
452452
AttrArgs::Empty => {}
453453
AttrArgs::Delimited(args) => visit_delim_args(vis, args),
454-
AttrArgs::Eq { eq_span, value } => {
455-
vis.visit_expr(value.unwrap_ast_mut());
454+
AttrArgs::Eq { eq_span, expr } => {
455+
vis.visit_expr(expr.unwrap_ast_mut());
456456
vis.visit_span(eq_span);
457457
}
458458
}

Diff for: compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ pub fn walk_attr_args<'a, V: Visitor<'a>>(visitor: &mut V, args: &'a AttrArgs) -
12871287
match args {
12881288
AttrArgs::Empty => {}
12891289
AttrArgs::Delimited(_args) => {}
1290-
AttrArgs::Eq { value, .. } => try_visit!(visitor.visit_expr(value.unwrap_ast())),
1290+
AttrArgs::Eq { expr, .. } => try_visit!(visitor.visit_expr(expr.unwrap_ast())),
12911291
}
12921292
V::Result::output()
12931293
}

Diff for: compiler/rustc_ast_lowering/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
896896
// This is an inert key-value attribute - it will never be visible to macros
897897
// after it gets lowered to HIR. Therefore, we can extract literals to handle
898898
// nonterminals in `#[doc]` (e.g. `#[doc = $e]`).
899-
&AttrArgs::Eq { eq_span, ref value } => {
900-
let expr = value.unwrap_ast();
899+
&AttrArgs::Eq { eq_span, ref expr } => {
900+
let expr = expr.unwrap_ast();
901901
// In valid code the value always ends up as a single literal. Otherwise, a dummy
902902
// literal suffices because the error is handled elsewhere.
903903
let lit = if let ExprKind::Lit(token_lit) = expr.kind
@@ -913,7 +913,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
913913
span: DUMMY_SP,
914914
}
915915
};
916-
AttrArgs::Eq { eq_span, value: AttrArgsEq::Hir(lit) }
916+
AttrArgs::Eq { eq_span, expr: AttrArgsEq::Hir(lit) }
917917
}
918918
}
919919
}

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,14 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
648648
AttrArgs::Empty => {
649649
self.print_path(&item.path, false, 0);
650650
}
651-
AttrArgs::Eq { value: AttrArgsEq::Ast(expr), .. } => {
651+
AttrArgs::Eq { expr: AttrArgsEq::Ast(expr), .. } => {
652652
self.print_path(&item.path, false, 0);
653653
self.space();
654654
self.word_space("=");
655655
let token_str = self.expr_to_string(expr);
656656
self.word(token_str);
657657
}
658-
AttrArgs::Eq { value: AttrArgsEq::Hir(lit), .. } => {
658+
AttrArgs::Eq { expr: AttrArgsEq::Hir(lit), .. } => {
659659
self.print_path(&item.path, false, 0);
660660
self.space();
661661
self.word_space("=");

Diff for: compiler/rustc_parse/src/parser/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ impl<'a> Parser<'a> {
13761376
AttrArgs::Delimited(args)
13771377
} else if self.eat(&token::Eq) {
13781378
let eq_span = self.prev_token.span;
1379-
AttrArgs::Eq { eq_span, value: AttrArgsEq::Ast(self.parse_expr_force_collect()?) }
1379+
AttrArgs::Eq { eq_span, expr: AttrArgsEq::Ast(self.parse_expr_force_collect()?) }
13801380
} else {
13811381
AttrArgs::Empty
13821382
})

Diff for: compiler/rustc_parse/src/validate_attr.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub fn parse_meta<'a>(psess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Met
7070
parse_in(psess, tokens.clone(), "meta list", |p| p.parse_meta_seq_top())?;
7171
MetaItemKind::List(nmis)
7272
}
73-
AttrArgs::Eq { value: AttrArgsEq::Ast(expr), .. } => {
73+
AttrArgs::Eq { expr: AttrArgsEq::Ast(expr), .. } => {
7474
if let ast::ExprKind::Lit(token_lit) = expr.kind {
7575
let res = ast::MetaItemLit::from_token_lit(token_lit, expr.span);
7676
let res = match res {
@@ -116,9 +116,7 @@ pub fn parse_meta<'a>(psess: &'a ParseSess, attr: &Attribute) -> PResult<'a, Met
116116
return Err(err);
117117
}
118118
}
119-
AttrArgs::Eq { value: AttrArgsEq::Hir(lit), .. } => {
120-
MetaItemKind::NameValue(lit.clone())
121-
}
119+
AttrArgs::Eq { expr: AttrArgsEq::Hir(lit), .. } => MetaItemKind::NameValue(lit.clone()),
122120
},
123121
})
124122
}

Diff for: compiler/rustc_resolve/src/rustdoc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ pub fn attrs_to_doc_fragments<'a>(
220220

221221
fn span_for_value(attr: &ast::Attribute) -> Span {
222222
if let ast::AttrKind::Normal(normal) = &attr.kind
223-
&& let ast::AttrArgs::Eq { value, .. } = &normal.item.args
223+
&& let ast::AttrArgs::Eq { expr, .. } = &normal.item.args
224224
{
225-
value.span().with_ctxt(attr.span.ctxt())
225+
expr.span().with_ctxt(attr.span.ctxt())
226226
} else {
227227
attr.span
228228
}

Diff for: compiler/rustc_trait_selection/src/error_reporting/traits/on_unimplemented.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ impl<'tcx> OnUnimplementedDirective {
639639
let report_span = match &item.args {
640640
AttrArgs::Empty => item.path.span,
641641
AttrArgs::Delimited(args) => args.dspan.entire(),
642-
AttrArgs::Eq { eq_span, value } => eq_span.to(value.span()),
642+
AttrArgs::Eq { eq_span, expr } => eq_span.to(expr.span()),
643643
};
644644

645645
if let Some(item_def_id) = item_def_id.as_local() {

Diff for: src/tools/clippy/clippy_lints/src/attrs/should_panic_without_expect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_span::sym;
99

1010
pub(super) fn check(cx: &EarlyContext<'_>, attr: &Attribute) {
1111
if let AttrKind::Normal(normal_attr) = &attr.kind {
12-
if let AttrArgs::Eq { value: AttrArgsEq::Ast(_), .. } = &normal_attr.item.args {
12+
if let AttrArgs::Eq { expr: AttrArgsEq::Ast(_), .. } = &normal_attr.item.args {
1313
// `#[should_panic = ".."]` found, good
1414
return;
1515
}

Diff for: src/tools/clippy/clippy_lints/src/doc/include_in_doc_without_cfg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn check(cx: &LateContext<'_>, attrs: &[Attribute]) {
1212
if !attr.span.from_expansion()
1313
&& let AttrKind::Normal(ref normal) = attr.kind
1414
&& normal.item.path == sym::doc
15-
&& let AttrArgs::Eq { value: AttrArgsEq::Hir(ref meta), .. } = normal.item.args
15+
&& let AttrArgs::Eq { expr: AttrArgsEq::Hir(ref meta), .. } = normal.item.args
1616
&& !attr.span.contains(meta.span)
1717
// Since the `include_str` is already expanded at this point, we can only take the
1818
// whole attribute snippet and then modify for our suggestion.

Diff for: src/tools/clippy/clippy_lints/src/large_include_file.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl LateLintPass<'_> for LargeIncludeFile {
9696
&& let AttrKind::Normal(ref normal) = attr.kind
9797
&& let Some(doc) = attr.doc_str()
9898
&& doc.as_str().len() as u64 > self.max_file_size
99-
&& let AttrArgs::Eq { value: AttrArgsEq::Hir(ref meta), .. } = normal.item.args
99+
&& let AttrArgs::Eq { expr: AttrArgsEq::Hir(ref meta), .. } = normal.item.args
100100
&& !attr.span.contains(meta.span)
101101
// Since the `include_str` is already expanded at this point, we can only take the
102102
// whole attribute snippet and then modify for our suggestion.

Diff for: src/tools/clippy/clippy_utils/src/ast_utils.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -872,8 +872,8 @@ pub fn eq_attr_args(l: &AttrArgs, r: &AttrArgs) -> bool {
872872
match (l, r) {
873873
(Empty, Empty) => true,
874874
(Delimited(la), Delimited(ra)) => eq_delim_args(la, ra),
875-
(Eq { value: AttrArgsEq::Ast(le), .. }, Eq{ value: AttrArgsEq::Ast(re), .. }) => eq_expr(le, re),
876-
(Eq { value: AttrArgsEq::Hir(ll), .. }, Eq{ value: AttrArgsEq::Hir(rl), .. }) => ll.kind == rl.kind,
875+
(Eq { expr: AttrArgsEq::Ast(le), .. }, Eq{ expr: AttrArgsEq::Ast(re), .. }) => eq_expr(le, re),
876+
(Eq { expr: AttrArgsEq::Hir(ll), .. }, Eq{ expr: AttrArgsEq::Hir(rl), .. }) => ll.kind == rl.kind,
877877
_ => false,
878878
}
879879
}

0 commit comments

Comments
 (0)