Skip to content

Commit bd9efd5

Browse files
Rename hir::Local into hir::LetStmt
1 parent 879899c commit bd9efd5

28 files changed

+66
-66
lines changed

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::Local(LetStmt { ty: Some(ty), .. }) => {
143143
let mut v = InferVisitor::default();
144144
v.visit_ty(ty);
145145
!v.0

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/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/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/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/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
}

0 commit comments

Comments
 (0)