Skip to content

Commit 21a6f0c

Browse files
authored
Rollup merge of rust-lang#122780 - GuillaumeGomez:rename-hir-local, r=oli-obk
Rename `hir::Local` into `hir::LetStmt` Follow-up of rust-lang#122776. As discussed on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). I made this change into a separate PR because I'm less sure about this change as is. For example, we have `visit_local` and `LocalSource` items. Is it fine to keep these two as is (I supposed it is but I prefer to ask) or not? Having `Node::Local(LetStmt)` makes things more explicit but is it going too far? r? ```@oli-obk```
2 parents e5ece90 + 43a61e9 commit 21a6f0c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+96
-96
lines changed

clippy_lints/src/assigning_clones.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn is_ok_to_suggest<'tcx>(cx: &LateContext<'tcx>, lhs: &Expr<'tcx>, call: &CallC
163163
// TODO: This check currently bails if the local variable has no initializer.
164164
// That is overly conservative - the lint should fire even if there was no initializer,
165165
// but the variable has been initialized before `lhs` was evaluated.
166-
if let Some(Node::Local(local)) = cx.tcx.hir().parent_id_iter(local).next().map(|p| cx.tcx.hir_node(p))
166+
if let Some(Node::LetStmt(local)) = cx.tcx.hir().parent_id_iter(local).next().map(|p| cx.tcx.hir_node(p))
167167
&& local.init.is_none()
168168
{
169169
return false;

clippy_lints/src/box_default.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::{is_default_equivalent, path_def_id};
66
use rustc_errors::Applicability;
77
use rustc_hir::def::Res;
88
use rustc_hir::intravisit::{walk_ty, Visitor};
9-
use rustc_hir::{Block, Expr, ExprKind, Local, Node, QPath, Ty, TyKind};
9+
use rustc_hir::{Block, Expr, ExprKind, LetStmt, Node, QPath, Ty, TyKind};
1010
use rustc_lint::{LateContext, LateLintPass, LintContext};
1111
use rustc_middle::lint::in_external_macro;
1212
use rustc_middle::ty::print::with_forced_trimmed_paths;
@@ -139,7 +139,7 @@ impl<'tcx> Visitor<'tcx> for InferVisitor {
139139

140140
fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
141141
match cx.tcx.parent_hir_node(expr.hir_id) {
142-
Node::Local(Local { ty: Some(ty), .. }) => {
142+
Node::LetStmt(LetStmt { ty: Some(ty), .. }) => {
143143
let mut v = InferVisitor::default();
144144
v.visit_ty(ty);
145145
!v.0

clippy_lints/src/casts/ref_as_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(super) fn check<'tcx>(
2424
&& let ty::RawPtr(_, to_mutbl) = cast_to.kind()
2525
&& let Some(use_cx) = expr_use_ctxt(cx, expr)
2626
// TODO: only block the lint if `cast_expr` is a temporary
27-
&& !matches!(use_cx.node, ExprUseNode::Local(_) | ExprUseNode::ConstStatic(_))
27+
&& !matches!(use_cx.node, ExprUseNode::LetStmt(_) | ExprUseNode::ConstStatic(_))
2828
{
2929
let core_or_std = if is_no_std_crate(cx) { "core" } else { "std" };
3030
let fn_name = match to_mutbl {

clippy_lints/src/casts/unnecessary_cast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub(super) fn check<'tcx>(
6666
&& let QPath::Resolved(None, Path { res, .. }) = qpath
6767
&& let Res::Local(hir_id) = res
6868
&& let parent = cx.tcx.parent_hir_node(*hir_id)
69-
&& let Node::Local(local) = parent
69+
&& let Node::LetStmt(local) = parent
7070
{
7171
if let Some(ty) = local.ty
7272
&& let TyKind::Path(qpath) = ty.kind
@@ -275,7 +275,7 @@ fn is_cast_from_ty_alias<'tcx>(cx: &LateContext<'tcx>, expr: impl Visitable<'tcx
275275
}
276276
// Local usage
277277
} else if let Res::Local(hir_id) = res
278-
&& let Node::Local(l) = cx.tcx.parent_hir_node(hir_id)
278+
&& let Node::LetStmt(l) = cx.tcx.parent_hir_node(hir_id)
279279
{
280280
if let Some(e) = l.init
281281
&& is_cast_from_ty_alias(cx, e, cast_from)

clippy_lints/src/collection_is_never_read.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item};
33
use clippy_utils::visitors::for_each_expr_with_closures;
44
use clippy_utils::{get_enclosing_block, path_to_local_id};
55
use core::ops::ControlFlow;
6-
use rustc_hir::{Block, ExprKind, HirId, LangItem, Local, Node, PatKind};
6+
use rustc_hir::{Block, ExprKind, HirId, LangItem, LetStmt, Node, PatKind};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::declare_lint_pass;
99
use rustc_span::symbol::sym;
@@ -58,7 +58,7 @@ static COLLECTIONS: [Symbol; 9] = [
5858
];
5959

6060
impl<'tcx> LateLintPass<'tcx> for CollectionIsNeverRead {
61-
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>) {
61+
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
6262
// Look for local variables whose type is a container. Search surrounding bock for read access.
6363
if match_acceptable_type(cx, local, &COLLECTIONS)
6464
&& let PatKind::Binding(_, local_id, _, _) = local.pat.kind
@@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for CollectionIsNeverRead {
7070
}
7171
}
7272

73-
fn match_acceptable_type(cx: &LateContext<'_>, local: &Local<'_>, collections: &[rustc_span::Symbol]) -> bool {
73+
fn match_acceptable_type(cx: &LateContext<'_>, local: &LetStmt<'_>, collections: &[rustc_span::Symbol]) -> bool {
7474
let ty = cx.typeck_results().pat_ty(local.pat);
7575
collections.iter().any(|&sym| is_type_diagnostic_item(cx, ty, sym))
7676
// String type is a lang item but not a diagnostic item for now so we need a separate check

clippy_lints/src/ignored_unit_patterns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for IgnoredUnitPatterns {
4646
// Ignore function parameters
4747
return;
4848
},
49-
Node::Local(local) if local.ty.is_some() => {
49+
Node::LetStmt(local) if local.ty.is_some() => {
5050
// Ignore let bindings with explicit type
5151
return;
5252
},

clippy_lints/src/let_underscore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::ty::{implements_trait, is_must_use_ty, match_type};
33
use clippy_utils::{is_from_proc_macro, is_must_use_func_call, paths};
4-
use rustc_hir::{Local, LocalSource, PatKind};
4+
use rustc_hir::{LetStmt, LocalSource, PatKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_middle::lint::in_external_macro;
77
use rustc_middle::ty::{GenericArgKind, IsSuggestable};
@@ -138,7 +138,7 @@ const SYNC_GUARD_PATHS: [&[&str]; 3] = [
138138
];
139139

140140
impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
141-
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &Local<'tcx>) {
141+
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &LetStmt<'tcx>) {
142142
if matches!(local.source, LocalSource::Normal)
143143
&& !in_external_macro(cx.tcx.sess, local.span)
144144
&& let PatKind::Wild = local.pat.kind

clippy_lints/src/let_with_type_underscore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::source::snippet;
3-
use rustc_hir::{Local, TyKind};
3+
use rustc_hir::{LetStmt, TyKind};
44
use rustc_lint::{LateContext, LateLintPass};
55
use rustc_middle::lint::in_external_macro;
66
use rustc_session::declare_lint_pass;
@@ -26,7 +26,7 @@ declare_clippy_lint! {
2626
declare_lint_pass!(UnderscoreTyped => [LET_WITH_TYPE_UNDERSCORE]);
2727

2828
impl LateLintPass<'_> for UnderscoreTyped {
29-
fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>) {
29+
fn check_local(&mut self, cx: &LateContext<'_>, local: &LetStmt<'_>) {
3030
if !in_external_macro(cx.tcx.sess, local.span)
3131
&& let Some(ty) = local.ty // Ensure that it has a type defined
3232
&& let TyKind::Infer = &ty.kind // that type is '_'

clippy_lints/src/loops/same_item_push.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub(super) fn check<'tcx>(
6262
if let Node::Pat(pat) = node
6363
&& let PatKind::Binding(bind_ann, ..) = pat.kind
6464
&& !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut))
65-
&& let Node::Local(parent_let_expr) = cx.tcx.parent_hir_node(hir_id)
65+
&& let Node::LetStmt(parent_let_expr) = cx.tcx.parent_hir_node(hir_id)
6666
&& let Some(init) = parent_let_expr.init
6767
{
6868
match init.kind {

clippy_lints/src/loops/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::{get_parent_expr, is_integer_const, path_to_local, path_to_loc
33
use rustc_ast::ast::{LitIntType, LitKind};
44
use rustc_errors::Applicability;
55
use rustc_hir::intravisit::{walk_expr, walk_local, Visitor};
6-
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, HirIdMap, Local, Mutability, PatKind};
6+
use rustc_hir::{BinOpKind, BorrowKind, Expr, ExprKind, HirId, HirIdMap, LetStmt, Mutability, PatKind};
77
use rustc_lint::LateContext;
88
use rustc_middle::hir::nested_filter;
99
use rustc_middle::ty::{self, Ty};
@@ -141,7 +141,7 @@ impl<'a, 'tcx> InitializeVisitor<'a, 'tcx> {
141141
impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
142142
type NestedFilter = nested_filter::OnlyBodies;
143143

144-
fn visit_local(&mut self, l: &'tcx Local<'_>) {
144+
fn visit_local(&mut self, l: &'tcx LetStmt<'_>) {
145145
// Look for declarations of the variable
146146
if l.pat.hir_id == self.var_id
147147
&& let PatKind::Binding(.., ident, _) = l.pat.kind

clippy_lints/src/loops/while_let_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use clippy_utils::source::snippet_with_applicability;
55
use clippy_utils::ty::needs_ordered_drop;
66
use clippy_utils::visitors::any_temporaries_need_ordered_drop;
77
use rustc_errors::Applicability;
8-
use rustc_hir::{Block, Expr, ExprKind, Local, MatchSource, Pat, StmtKind};
8+
use rustc_hir::{Block, Expr, ExprKind, LetStmt, MatchSource, Pat, StmtKind};
99
use rustc_lint::LateContext;
1010

1111
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, loop_block: &'tcx Block<'_>) {
1212
let (init, has_trailing_exprs) = match (loop_block.stmts, loop_block.expr) {
1313
([stmt, stmts @ ..], expr) => {
14-
if let StmtKind::Let(&Local {
14+
if let StmtKind::Let(&LetStmt {
1515
init: Some(e),
1616
els: None,
1717
..

clippy_lints/src/loops/while_let_on_iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::{get_enclosing_loop_or_multi_call_closure, higher, is_refutabl
66
use rustc_errors::Applicability;
77
use rustc_hir::def::Res;
88
use rustc_hir::intravisit::{walk_expr, Visitor};
9-
use rustc_hir::{Closure, Expr, ExprKind, HirId, LangItem, Local, Mutability, PatKind, UnOp};
9+
use rustc_hir::{Closure, Expr, ExprKind, HirId, LangItem, LetStmt, Mutability, PatKind, UnOp};
1010
use rustc_lint::LateContext;
1111
use rustc_middle::hir::nested_filter::OnlyBodies;
1212
use rustc_middle::ty::adjustment::Adjust;
@@ -286,7 +286,7 @@ fn needs_mutable_borrow(cx: &LateContext<'_>, iter_expr: &IterExpr, loop_expr: &
286286
self.cx.tcx.hir()
287287
}
288288

289-
fn visit_local(&mut self, l: &'tcx Local<'_>) {
289+
fn visit_local(&mut self, l: &'tcx LetStmt<'_>) {
290290
if !self.after_loop {
291291
l.pat.each_binding_or_first(&mut |_, id, _, _| {
292292
if id == self.local_id {

clippy_lints/src/manual_hash_one.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::source::snippet_opt;
44
use clippy_utils::visitors::{is_local_used, local_used_once};
55
use clippy_utils::{is_trait_method, path_to_local_id};
66
use rustc_errors::Applicability;
7-
use rustc_hir::{BindingAnnotation, ExprKind, Local, Node, PatKind, StmtKind};
7+
use rustc_hir::{BindingAnnotation, ExprKind, LetStmt, Node, PatKind, StmtKind};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::impl_lint_pass;
1010
use rustc_span::sym;
@@ -60,7 +60,7 @@ impl ManualHashOne {
6060
impl_lint_pass!(ManualHashOne => [MANUAL_HASH_ONE]);
6161

6262
impl LateLintPass<'_> for ManualHashOne {
63-
fn check_local(&mut self, cx: &LateContext<'_>, local: &Local<'_>) {
63+
fn check_local(&mut self, cx: &LateContext<'_>, local: &LetStmt<'_>) {
6464
// `let mut hasher = seg.build_hasher();`
6565
if let PatKind::Binding(BindingAnnotation::MUT, hasher, _, None) = local.pat.kind
6666
&& let Some(init) = local.init

clippy_lints/src/manual_rem_euclid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
8181
// Apply only to params or locals with annotated types
8282
match cx.tcx.parent_hir_node(hir_id) {
8383
Node::Param(..) => (),
84-
Node::Local(local) => {
84+
Node::LetStmt(local) => {
8585
let Some(ty) = local.ty else { return };
8686
if matches!(ty.kind, TyKind::Infer) {
8787
return;

clippy_lints/src/matches/infallible_destructuring_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet_with_applicability;
33
use clippy_utils::{path_to_local_id, peel_blocks, strip_pat_refs};
44
use rustc_errors::Applicability;
5-
use rustc_hir::{ByRef, ExprKind, Local, MatchSource, PatKind, QPath};
5+
use rustc_hir::{ByRef, ExprKind, LetStmt, MatchSource, PatKind, QPath};
66
use rustc_lint::LateContext;
77

88
use super::INFALLIBLE_DESTRUCTURING_MATCH;
99

10-
pub(crate) fn check(cx: &LateContext<'_>, local: &Local<'_>) -> bool {
10+
pub(crate) fn check(cx: &LateContext<'_>, local: &LetStmt<'_>) -> bool {
1111
if !local.span.from_expansion()
1212
&& let Some(expr) = local.init
1313
&& let ExprKind::Match(target, arms, MatchSource::Normal) = expr.kind

clippy_lints/src/matches/match_single_binding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
148148
fn opt_parent_assign_span<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<AssignmentExpr> {
149149
if let Node::Expr(parent_arm_expr) = cx.tcx.parent_hir_node(ex.hir_id) {
150150
return match cx.tcx.parent_hir_node(parent_arm_expr.hir_id) {
151-
Node::Local(parent_let_expr) => Some(AssignmentExpr::Local {
151+
Node::LetStmt(parent_let_expr) => Some(AssignmentExpr::Local {
152152
span: parent_let_expr.span,
153153
pat_span: parent_let_expr.pat.span(),
154154
}),

clippy_lints/src/matches/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ mod wild_in_or_pats;
2727
use clippy_config::msrvs::{self, Msrv};
2828
use clippy_utils::source::{snippet_opt, walk_span_to_context};
2929
use clippy_utils::{higher, in_constant, is_direct_expn_of, is_span_match, tokenize_with_text};
30-
use rustc_hir::{Arm, Expr, ExprKind, Local, MatchSource, Pat};
30+
use rustc_hir::{Arm, Expr, ExprKind, LetStmt, MatchSource, Pat};
3131
use rustc_lexer::TokenKind;
3232
use rustc_lint::{LateContext, LateLintPass, LintContext};
3333
use rustc_middle::lint::in_external_macro;
@@ -1124,7 +1124,7 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
11241124
}
11251125
}
11261126

1127-
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'_>) {
1127+
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'_>) {
11281128
self.infallible_destructuring_match_linted |=
11291129
local.els.is_none() && infallible_destructuring_match::check(cx, local);
11301130
}

clippy_lints/src/matches/needless_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn strip_return<'hir>(expr: &'hir Expr<'hir>) -> &'hir Expr<'hir> {
125125
fn expr_ty_matches_p_ty(cx: &LateContext<'_>, expr: &Expr<'_>, p_expr: &Expr<'_>) -> bool {
126126
match cx.tcx.parent_hir_node(p_expr.hir_id) {
127127
// Compare match_expr ty with local in `let local = match match_expr {..}`
128-
Node::Local(local) => {
128+
Node::LetStmt(local) => {
129129
let results = cx.typeck_results();
130130
return same_type_and_consts(results.node_type(local.hir_id), results.expr_ty(expr));
131131
},

clippy_lints/src/methods/clone_on_copy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub(super) fn check(
6969
_ => false,
7070
},
7171
// local binding capturing a reference
72-
Node::Local(l) if matches!(l.pat.kind, PatKind::Binding(BindingAnnotation(ByRef::Yes, _), ..)) => {
72+
Node::LetStmt(l) if matches!(l.pat.kind, PatKind::Binding(BindingAnnotation(ByRef::Yes, _), ..)) => {
7373
return;
7474
},
7575
_ => false,

clippy_lints/src/methods/iter_on_single_or_empty_collections.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, method_name: &str, re
5050
| ExprKind::Break(_, _) => true,
5151
_ => false,
5252
},
53-
Some((Node::Stmt(_) | Node::Local(_), _)) => false,
53+
Some((Node::Stmt(_) | Node::LetStmt(_), _)) => false,
5454
_ => true,
5555
};
5656

clippy_lints/src/methods/needless_collect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashMap;
1111
use rustc_errors::{Applicability, MultiSpan};
1212
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
1313
use rustc_hir::{
14-
BindingAnnotation, Block, Expr, ExprKind, HirId, HirIdSet, Local, Mutability, Node, PatKind, Stmt, StmtKind,
14+
BindingAnnotation, Block, Expr, ExprKind, HirId, HirIdSet, LetStmt, Mutability, Node, PatKind, Stmt, StmtKind,
1515
};
1616
use rustc_lint::LateContext;
1717
use rustc_middle::hir::nested_filter;
@@ -85,7 +85,7 @@ pub(super) fn check<'tcx>(
8585
);
8686
}
8787
},
88-
Node::Local(l) => {
88+
Node::LetStmt(l) => {
8989
if let PatKind::Binding(BindingAnnotation::NONE | BindingAnnotation::MUT, id, _, None) = l.pat.kind
9090
&& let ty = cx.typeck_results().expr_ty(collect_expr)
9191
&& [sym::Vec, sym::VecDeque, sym::BinaryHeap, sym::LinkedList]
@@ -424,7 +424,7 @@ fn get_expr_and_hir_id_from_stmt<'v>(stmt: &'v Stmt<'v>) -> Option<(&'v Expr<'v>
424424
match stmt.kind {
425425
StmtKind::Expr(expr) | StmtKind::Semi(expr) => Some((expr, None)),
426426
StmtKind::Item(..) => None,
427-
StmtKind::Let(Local { init, pat, .. }) => {
427+
StmtKind::Let(LetStmt { init, pat, .. }) => {
428428
if let PatKind::Binding(_, hir_id, ..) = pat.kind {
429429
init.map(|init_expr| (init_expr, Some(hir_id)))
430430
} else {

clippy_lints/src/methods/readonly_write_lock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, receiver
2424
&& let Node::Expr(unwrap_call_expr) = cx.tcx.parent_hir_node(expr.hir_id)
2525
&& is_unwrap_call(cx, unwrap_call_expr)
2626
&& let parent = cx.tcx.parent_hir_node(unwrap_call_expr.hir_id)
27-
&& let Node::Local(local) = parent
27+
&& let Node::LetStmt(local) = parent
2828
&& let Some(mir) = enclosing_mir(cx.tcx, expr.hir_id)
2929
&& let Some((local, _)) = mir
3030
.local_decls

clippy_lints/src/methods/str_splitn.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use clippy_utils::{is_diag_item_method, match_def_path, path_to_local_id, paths}
88
use core::ops::ControlFlow;
99
use rustc_errors::Applicability;
1010
use rustc_hir::{
11-
BindingAnnotation, Expr, ExprKind, HirId, LangItem, Local, MatchSource, Node, Pat, PatKind, QPath, Stmt, StmtKind,
11+
BindingAnnotation, Expr, ExprKind, HirId, LangItem, LetStmt, MatchSource, Node, Pat, PatKind, QPath, Stmt, StmtKind,
1212
};
1313
use rustc_lint::LateContext;
1414
use rustc_middle::ty;
@@ -128,7 +128,7 @@ fn check_manual_split_once_indirect(
128128
) -> Option<()> {
129129
let ctxt = expr.span.ctxt();
130130
let mut parents = cx.tcx.hir().parent_iter(expr.hir_id);
131-
if let (_, Node::Local(local)) = parents.next()?
131+
if let (_, Node::LetStmt(local)) = parents.next()?
132132
&& let PatKind::Binding(BindingAnnotation::MUT, iter_binding_id, iter_ident, None) = local.pat.kind
133133
&& let (iter_stmt_id, Node::Stmt(_)) = parents.next()?
134134
&& let (_, Node::Block(enclosing_block)) = parents.next()?
@@ -198,7 +198,7 @@ fn indirect_usage<'tcx>(
198198
binding: HirId,
199199
ctxt: SyntaxContext,
200200
) -> Option<IndirectUsage<'tcx>> {
201-
if let StmtKind::Let(&Local {
201+
if let StmtKind::Let(&LetStmt {
202202
pat: Pat {
203203
kind: PatKind::Binding(BindingAnnotation::NONE, _, ident, None),
204204
..

clippy_lints/src/methods/unnecessary_fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn needs_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {
2020

2121
// some common cases where turbofish isn't needed:
2222
// - assigned to a local variable with a type annotation
23-
if let hir::Node::Local(local) = parent
23+
if let hir::Node::LetStmt(local) = parent
2424
&& local.ty.is_some()
2525
{
2626
return false;

clippy_lints/src/mixed_read_write_in_expression.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint, span_lint_and_note};
22
use clippy_utils::{get_parent_expr, path_to_local, path_to_local_id};
33
use rustc_hir::intravisit::{walk_expr, Visitor};
4-
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, HirId, Local, Node, Stmt, StmtKind};
4+
use rustc_hir::{BinOpKind, Block, Expr, ExprKind, HirId, LetStmt, Node, Stmt, StmtKind};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_middle::ty;
77
use rustc_session::declare_lint_pass;
@@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for EvalOrderDependence {
9898
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
9999
match stmt.kind {
100100
StmtKind::Let(local) => {
101-
if let Local { init: Some(e), .. } = local {
101+
if let LetStmt { init: Some(e), .. } = local {
102102
DivergenceVisitor { cx }.visit_expr(e);
103103
}
104104
},

clippy_lints/src/mut_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for MutableKeyType {
121121
}
122122
}
123123

124-
fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::Local<'_>) {
124+
fn check_local(&mut self, cx: &LateContext<'_>, local: &hir::LetStmt<'_>) {
125125
if let hir::PatKind::Wild = local.pat.kind {
126126
return;
127127
}

0 commit comments

Comments
 (0)