Remove AssignDesugar span

This commit is contained in:
Cameron Steffen
2025-10-28 08:16:43 -05:00
parent 34a8c7368c
commit a45c6dd2c0
8 changed files with 11 additions and 19 deletions

View File

@@ -1242,13 +1242,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
let rhs = self.lower_expr(rhs);
// Introduce a `let` for destructuring: `let (lhs1, lhs2) = t`.
let destructure_let = self.stmt_let_pat(
None,
whole_span,
Some(rhs),
pat,
hir::LocalSource::AssignDesugar(self.lower_span(eq_sign_span)),
);
let destructure_let =
self.stmt_let_pat(None, whole_span, Some(rhs), pat, hir::LocalSource::AssignDesugar);
// `a = lhs1; b = lhs2;`.
let stmts = self.arena.alloc_from_iter(std::iter::once(destructure_let).chain(assignments));

View File

@@ -2975,8 +2975,7 @@ pub enum LocalSource {
/// A desugared `<expr>.await`.
AwaitDesugar,
/// A desugared `expr = expr`, where the LHS is a tuple, struct, array or underscore expression.
/// The span is that of the `=` sign.
AssignDesugar(Span),
AssignDesugar,
/// A contract `#[ensures(..)]` attribute injects a let binding for the check that runs at point of return.
Contract,
}
@@ -5013,7 +5012,7 @@ mod size_asserts {
static_assert_size!(ImplItemKind<'_>, 40);
static_assert_size!(Item<'_>, 88);
static_assert_size!(ItemKind<'_>, 64);
static_assert_size!(LetStmt<'_>, 72);
static_assert_size!(LetStmt<'_>, 64);
static_assert_size!(Param<'_>, 32);
static_assert_size!(Pat<'_>, 80);
static_assert_size!(PatKind<'_>, 56);

View File

@@ -1112,8 +1112,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::Stmt {
kind:
hir::StmtKind::Let(hir::LetStmt {
source:
hir::LocalSource::AssignDesugar(_),
source: hir::LocalSource::AssignDesugar,
..
}),
..

View File

@@ -152,7 +152,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
// We can't suggest `drop()` when we're on the top level.
drop_fn_start_end: can_use_init
.map(|init| (local.span.until(init.span), init.span.shrink_to_hi())),
is_assign_desugar: matches!(local.source, rustc_hir::LocalSource::AssignDesugar(_)),
is_assign_desugar: matches!(local.source, rustc_hir::LocalSource::AssignDesugar),
};
if is_sync_lock {
let span = MultiSpan::from_span(pat.span);

View File

@@ -2897,8 +2897,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
for (_, node) in tcx.hir_parent_iter(var_id.0) {
// FIXME(khuey) at what point is it safe to bail on the iterator?
// Can we stop at the first non-Pat node?
if matches!(node, Node::LetStmt(&LetStmt { source: LocalSource::AssignDesugar(_), .. }))
{
if matches!(node, Node::LetStmt(&LetStmt { source: LocalSource::AssignDesugar, .. })) {
return false;
}
}

View File

@@ -133,7 +133,7 @@ impl<'tcx> LateLintPass<'tcx> for Shadow {
.tcx
.hir_parent_iter(pat.hir_id)
.find(|(_, node)| !matches!(node, Node::Pat(_) | Node::PatField(_)))
&& let LocalSource::AssignDesugar(_) = let_stmt.source
&& let LocalSource::AssignDesugar = let_stmt.source
{
return;
}

View File

@@ -374,7 +374,7 @@ fn expr_has_unnecessary_safety_comment<'tcx>(
hir::Stmt {
kind:
hir::StmtKind::Let(hir::LetStmt {
source: hir::LocalSource::AssignDesugar(_),
source: hir::LocalSource::AssignDesugar,
..
}),
..

View File

@@ -105,10 +105,10 @@ hir-stats - Semi 32 (NN.N%) 1
hir-stats Arm 80 (NN.N%) 2 40
hir-stats WherePredicate 72 (NN.N%) 3 24
hir-stats - BoundPredicate 72 (NN.N%) 3
hir-stats Local 72 (NN.N%) 1 72
hir-stats InlineAsm 72 (NN.N%) 1 72
hir-stats Body 72 (NN.N%) 3 24
hir-stats Param 64 (NN.N%) 2 32
hir-stats Local 64 (NN.N%) 1 64
hir-stats GenericArg 64 (NN.N%) 4 16
hir-stats - Type 16 (NN.N%) 1
hir-stats - Lifetime 48 (NN.N%) 3
@@ -119,5 +119,5 @@ hir-stats TraitItemId 8 (NN.N%) 2 4
hir-stats ImplItemId 8 (NN.N%) 2 4
hir-stats ForeignItemId 4 (NN.N%) 1 4
hir-stats ----------------------------------------------------------------
hir-stats Total 8_624 173
hir-stats Total 8_616 173
hir-stats ================================================================