1- use crate :: reexport:: Name ;
21use crate :: utils:: { contains_name, higher, iter_input_pats, snippet, span_lint_and_then} ;
32use rustc_hir:: intravisit:: FnKind ;
43use rustc_hir:: {
@@ -10,6 +9,7 @@ use rustc_middle::lint::in_external_macro;
109use rustc_middle:: ty;
1110use rustc_session:: { declare_lint_pass, declare_tool_lint} ;
1211use rustc_span:: source_map:: Span ;
12+ use rustc_span:: symbol:: Symbol ;
1313
1414declare_clippy_lint ! {
1515 /// **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
123123 check_expr ( cx, & body. value , & mut bindings) ;
124124}
125125
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 ) > ) {
127127 let len = bindings. len ( ) ;
128128 for stmt in block. stmts {
129129 match stmt. kind {
@@ -138,7 +138,7 @@ fn check_block<'tcx>(cx: &LateContext<'tcx>, block: &'tcx Block<'_>, bindings: &
138138 bindings. truncate ( len) ;
139139}
140140
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 ) > ) {
142142 if in_external_macro ( cx. sess ( ) , local. span ) {
143143 return ;
144144 }
@@ -173,7 +173,7 @@ fn check_pat<'tcx>(
173173 pat : & ' tcx Pat < ' _ > ,
174174 init : Option < & ' tcx Expr < ' _ > > ,
175175 span : Span ,
176- bindings : & mut Vec < ( Name , Span ) > ,
176+ bindings : & mut Vec < ( Symbol , Span ) > ,
177177) {
178178 // TODO: match more stuff / destructuring
179179 match pat. kind {
@@ -254,7 +254,7 @@ fn check_pat<'tcx>(
254254
255255fn lint_shadow < ' tcx > (
256256 cx : & LateContext < ' tcx > ,
257- name : Name ,
257+ name : Symbol ,
258258 span : Span ,
259259 pattern_span : Span ,
260260 init : Option < & ' tcx Expr < ' _ > > ,
@@ -315,7 +315,7 @@ fn lint_shadow<'tcx>(
315315 }
316316}
317317
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 ) > ) {
319319 if in_external_macro ( cx. sess ( ) , expr. span ) {
320320 return ;
321321 }
@@ -351,7 +351,7 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, bindings: &mut
351351 }
352352}
353353
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 ) > ) {
355355 match ty. kind {
356356 TyKind :: Slice ( ref sty) => check_ty ( cx, sty, bindings) ,
357357 TyKind :: Array ( ref fty, ref anon_const) => {
@@ -371,7 +371,7 @@ fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: &'tcx Ty<'_>, bindings: &mut Vec<(
371371 }
372372}
373373
374- fn is_self_shadow ( name : Name , expr : & Expr < ' _ > ) -> bool {
374+ fn is_self_shadow ( name : Symbol , expr : & Expr < ' _ > ) -> bool {
375375 match expr. kind {
376376 ExprKind :: Box ( ref inner) | ExprKind :: AddrOf ( _, _, ref inner) => is_self_shadow ( name, inner) ,
377377 ExprKind :: Block ( ref block, _) => {
@@ -383,6 +383,6 @@ fn is_self_shadow(name: Name, expr: &Expr<'_>) -> bool {
383383 }
384384}
385385
386- fn path_eq_name ( name : Name , path : & Path < ' _ > ) -> bool {
386+ fn path_eq_name ( name : Symbol , path : & Path < ' _ > ) -> bool {
387387 !path. is_global ( ) && path. segments . len ( ) == 1 && path. segments [ 0 ] . ident . as_str ( ) == name. as_str ( )
388388}
0 commit comments