1
- use crate :: reexport:: Name ;
2
1
use crate :: utils:: { contains_name, higher, iter_input_pats, snippet, span_lint_and_then} ;
3
2
use rustc_hir:: intravisit:: FnKind ;
4
3
use rustc_hir:: {
@@ -10,6 +9,7 @@ use rustc_middle::lint::in_external_macro;
10
9
use rustc_middle:: ty;
11
10
use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
12
11
use rustc_span:: source_map:: Span ;
12
+ use rustc_span:: symbol:: Symbol ;
13
13
14
14
declare_clippy_lint ! {
15
15
/// **What it does:** Checks for bindings that shadow other bindings already in
@@ -123,7 +123,7 @@ fn check_fn<'tcx>(cx: &LateContext<'tcx>, decl: &'tcx FnDecl<'_>, body: &'tcx Bo
123
123
check_expr ( cx, & body. value , & mut bindings) ;
124
124
}
125
125
126
- fn check_block < ' tcx > ( cx : & LateContext < ' tcx > , block : & ' tcx Block < ' _ > , bindings : & mut Vec < ( Name , Span ) > ) {
126
+ fn check_block < ' tcx > ( cx : & LateContext < ' tcx > , block : & ' tcx Block < ' _ > , bindings : & mut Vec < ( Symbol , Span ) > ) {
127
127
let len = bindings. len ( ) ;
128
128
for stmt in block. stmts {
129
129
match stmt. kind {
@@ -138,7 +138,7 @@ fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>, bindings: &
138
138
bindings. truncate ( len) ;
139
139
}
140
140
141
- fn check_local < ' tcx > ( cx : & LateContext < ' tcx > , local : & ' tcx Local < ' _ > , bindings : & mut Vec < ( Name , Span ) > ) {
141
+ fn check_local < ' tcx > ( cx : & LateContext < ' tcx > , local : & ' tcx Local < ' _ > , bindings : & mut Vec < ( Symbol , Span ) > ) {
142
142
if in_external_macro ( cx. sess ( ) , local. span ) {
143
143
return ;
144
144
}
@@ -173,7 +173,7 @@ fn check_pat<'tcx>(
173
173
pat : & ' tcx Pat < ' _ > ,
174
174
init : Option < & ' tcx Expr < ' _ > > ,
175
175
span : Span ,
176
- bindings : & mut Vec < ( Name , Span ) > ,
176
+ bindings : & mut Vec < ( Symbol , Span ) > ,
177
177
) {
178
178
// TODO: match more stuff / destructuring
179
179
match pat. kind {
@@ -254,7 +254,7 @@ fn check_pat<'tcx>(
254
254
255
255
fn lint_shadow < ' tcx > (
256
256
cx : & LateContext < ' tcx > ,
257
- name : Name ,
257
+ name : Symbol ,
258
258
span : Span ,
259
259
pattern_span : Span ,
260
260
init : Option < & ' tcx Expr < ' _ > > ,
@@ -315,7 +315,7 @@ fn lint_shadow<'tcx>(
315
315
}
316
316
}
317
317
318
- fn check_expr < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > , bindings : & mut Vec < ( Name , Span ) > ) {
318
+ fn check_expr < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' _ > , bindings : & mut Vec < ( Symbol , Span ) > ) {
319
319
if in_external_macro ( cx. sess ( ) , expr. span ) {
320
320
return ;
321
321
}
@@ -351,7 +351,7 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut
351
351
}
352
352
}
353
353
354
- fn check_ty < ' tcx > ( cx : & LateContext < ' tcx > , ty : & ' tcx Ty < ' _ > , bindings : & mut Vec < ( Name , Span ) > ) {
354
+ fn check_ty < ' tcx > ( cx : & LateContext < ' tcx > , ty : & ' tcx Ty < ' _ > , bindings : & mut Vec < ( Symbol , Span ) > ) {
355
355
match ty. kind {
356
356
TyKind :: Slice ( ref sty) => check_ty ( cx, sty, bindings) ,
357
357
TyKind :: Array ( ref fty, ref anon_const) => {
@@ -371,7 +371,7 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(
371
371
}
372
372
}
373
373
374
- fn is_self_shadow ( name : Name , expr : & Expr < ' _ > ) -> bool {
374
+ fn is_self_shadow ( name : Symbol , expr : & Expr < ' _ > ) -> bool {
375
375
match expr. kind {
376
376
ExprKind :: Box ( ref inner) | ExprKind :: AddrOf ( _, _, ref inner) => is_self_shadow ( name, inner) ,
377
377
ExprKind :: Block ( ref block, _) => {
@@ -383,6 +383,6 @@ fn is_self_shadow(name: Name, expr: &Expr<'_>) -> bool {
383
383
}
384
384
}
385
385
386
- fn path_eq_name ( name : Name , path : & Path < ' _ > ) -> bool {
386
+ fn path_eq_name ( name : Symbol , path : & Path < ' _ > ) -> bool {
387
387
!path. is_global ( ) && path. segments . len ( ) == 1 && path. segments [ 0 ] . ident . as_str ( ) == name. as_str ( )
388
388
}
0 commit comments