Skip to content

Commit 4f527e9

Browse files
committed
Remove span from hir::Arm.
1 parent 6ec2356 commit 4f527e9

File tree

11 files changed

+15
-13
lines changed

11 files changed

+15
-13
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
627627
});
628628
let hir_id = self.next_id(arm.span);
629629
self.lower_attrs(hir_id, &arm.attrs);
630-
hir::Arm { hir_id, pat, guard, body: self.lower_expr(&arm.body), span: arm.span }
630+
hir::Arm { hir_id, pat, guard, body: self.lower_expr(&arm.body) }
631631
}
632632

633633
/// Lower an `async` construct to a generator that is then wrapped so it implements `Future`.
@@ -2169,6 +2169,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
21692169
}
21702170

21712171
fn arm(&mut self, pat: &'hir hir::Pat<'hir>, expr: &'hir hir::Expr<'hir>) -> hir::Arm<'hir> {
2172-
hir::Arm { hir_id: self.next_id(expr.span), pat, guard: None, span: expr.span, body: expr }
2172+
hir::Arm { hir_id: self.next_id(expr.span), pat, guard: None, body: expr }
21732173
}
21742174
}

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,6 @@ pub struct Local<'hir> {
11791179
pub struct Arm<'hir> {
11801180
#[stable_hasher(ignore)]
11811181
pub hir_id: HirId,
1182-
pub span: Span,
11831182
/// If this pattern and the optional guard matches, then `body` is evaluated.
11841183
pub pat: &'hir Pat<'hir>,
11851184
/// Optional guard clause.

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ impl<'thir, 'tcx> Cx<'thir, 'tcx> {
839839
body: self.mirror_expr(arm.body),
840840
lint_level: LintLevel::Explicit(arm.hir_id),
841841
scope: region::Scope { id: arm.hir_id.local_id, data: region::ScopeData::Node },
842-
span: arm.span,
842+
span: self.tcx.hir().span(arm.hir_id),
843843
}
844844
}
845845

compiler/rustc_passes/src/check_attr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,8 @@ impl Visitor<'tcx> for CheckAttrVisitor<'tcx> {
12381238
}
12391239

12401240
fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) {
1241-
self.check_attributes(arm.hir_id, &arm.span, Target::Arm, None);
1241+
let span = self.tcx.hir().span(arm.hir_id);
1242+
self.check_attributes(arm.hir_id, &span, Target::Arm, None);
12421243
intravisit::walk_arm(self, arm);
12431244
}
12441245

src/tools/clippy/clippy_lints/src/loops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ declare_lint_pass!(Loops => [
541541
impl<'tcx> LateLintPass<'tcx> for Loops {
542542
#[allow(clippy::too_many_lines)]
543543
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
544-
if let Some((pat, arg, body, span)) = higher::for_loop(expr) {
544+
if let Some((pat, arg, body, span)) = higher::for_loop(cx, expr) {
545545
// we don't want to check expanded macros
546546
// this check is not at the top of the function
547547
// since higher::for_loop expressions are marked as expansions

src/tools/clippy/clippy_lints/src/matches.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,8 @@ fn check_match_single_binding<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[A
12961296
// a macro. See PR #6435
12971297
if_chain! {
12981298
if let Some(match_snippet) = snippet_opt(cx, expr.span);
1299-
if let Some(arm_snippet) = snippet_opt(cx, arms[0].span);
1299+
let arm_span = cx.tcx.hir().span(arms[0].hir_id);
1300+
if let Some(arm_snippet) = snippet_opt(cx, arm_span);
13001301
if let Some(ex_snippet) = snippet_opt(cx, ex.span);
13011302
let rest_snippet = match_snippet.replace(&arm_snippet, "").replace(&ex_snippet, "");
13021303
if rest_snippet.contains("=>");

src/tools/clippy/clippy_lints/src/methods/iter_next_slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>, ite
1717
// since it is already covered by `&loops::ITER_NEXT_LOOP`
1818
let mut parent_expr_opt = get_parent_expr(cx, expr);
1919
while let Some(parent_expr) = parent_expr_opt {
20-
if higher::for_loop(parent_expr).is_some() {
20+
if higher::for_loop(cx, parent_expr).is_some() {
2121
return;
2222
}
2323
parent_expr_opt = get_parent_expr(cx, parent_expr);

src/tools/clippy/clippy_lints/src/mut_mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
5252
return;
5353
}
5454

55-
if let Some((_, arg, body, _)) = higher::for_loop(expr) {
55+
if let Some((_, arg, body, _)) = higher::for_loop(self.cx, expr) {
5656
// A `for` loop lowers to:
5757
// ```rust
5858
// match ::std::iter::Iterator::next(&mut iter) {

src/tools/clippy/clippy_lints/src/ranges.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ fn check_reversed_empty_range(cx: &LateContext<'_>, expr: &Expr<'_>) {
441441
fn is_for_loop_arg(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
442442
let mut cur_expr = expr;
443443
while let Some(parent_expr) = get_parent_expr(cx, cur_expr) {
444-
match higher::for_loop(parent_expr) {
444+
match higher::for_loop(cx, parent_expr) {
445445
Some((_, args, _, _)) if args.hir_id == expr.hir_id => return true,
446446
_ => cur_expr = parent_expr,
447447
}

src/tools/clippy/clippy_lints/src/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec {
5555

5656
// search for `for _ in vec![…]`
5757
if_chain! {
58-
if let Some((_, arg, _, _)) = higher::for_loop(expr);
58+
if let Some((_, arg, _, _)) = higher::for_loop(cx, expr);
5959
if let Some(vec_args) = higher::vec_macro(cx, arg);
6060
if is_copy(cx, vec_type(cx.typeck_results().expr_ty_adjusted(arg)));
6161
then {

0 commit comments

Comments
 (0)