@@ -7,7 +7,7 @@ use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintC
7
7
use rustc:: ty;
8
8
use rustc:: { declare_tool_lint, lint_array} ;
9
9
use rustc_errors:: Applicability ;
10
- use syntax_pos:: symbol:: keywords:: SelfUpper ;
10
+ use syntax_pos:: { symbol:: keywords:: SelfUpper , Span } ;
11
11
12
12
/// **What it does:** Checks for unnecessary repetition of structure name when a
13
13
/// replacement with `Self` is applicable.
@@ -55,11 +55,11 @@ impl LintPass for UseSelf {
55
55
56
56
const SEGMENTS_MSG : & str = "segments should be composed of at least 1 element" ;
57
57
58
- fn span_use_self_lint ( cx : & LateContext < ' _ , ' _ > , path : & Path ) {
58
+ fn span_use_self_lint ( cx : & LateContext < ' _ , ' _ > , span : Span ) {
59
59
span_lint_and_sugg (
60
60
cx,
61
61
USE_SELF ,
62
- path . span ,
62
+ span,
63
63
"unnecessary structure name repetition" ,
64
64
"use the applicable keyword" ,
65
65
"Self" . to_owned ( ) ,
@@ -92,7 +92,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TraitImplTyVisitor<'a, 'tcx> {
92
92
} ;
93
93
94
94
if !is_self_ty {
95
- span_use_self_lint ( self . cx , path) ;
95
+ span_use_self_lint ( self . cx , path. span ) ;
96
96
}
97
97
}
98
98
}
@@ -221,10 +221,10 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
221
221
fn visit_path ( & mut self , path : & ' tcx Path , _id : HirId ) {
222
222
if path. segments . last ( ) . expect ( SEGMENTS_MSG ) . ident . name != SelfUpper . name ( ) {
223
223
if self . item_path . def == path. def {
224
- span_use_self_lint ( self . cx , path) ;
224
+ span_use_self_lint ( self . cx , path. segments . first ( ) . expect ( SEGMENTS_MSG ) . ident . span ) ;
225
225
} else if let Def :: StructCtor ( ctor_did, CtorKind :: Fn ) = path. def {
226
226
if self . item_path . def . opt_def_id ( ) == self . cx . tcx . parent_def_id ( ctor_did) {
227
- span_use_self_lint ( self . cx , path) ;
227
+ span_use_self_lint ( self . cx , path. span ) ;
228
228
}
229
229
}
230
230
}
0 commit comments