@@ -7,7 +7,7 @@ use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintC
77use rustc:: ty;
88use rustc:: { declare_tool_lint, lint_array} ;
99use rustc_errors:: Applicability ;
10- use syntax_pos:: symbol:: keywords:: SelfUpper ;
10+ use syntax_pos:: { symbol:: keywords:: SelfUpper , Span } ;
1111
1212/// **What it does:** Checks for unnecessary repetition of structure name when a
1313/// replacement with `Self` is applicable.
@@ -55,11 +55,11 @@ impl LintPass for UseSelf {
5555
5656const SEGMENTS_MSG : & str = "segments should be composed of at least 1 element" ;
5757
58- fn span_use_self_lint ( cx : & LateContext < ' _ , ' _ > , path : & Path ) {
58+ fn span_use_self_lint ( cx : & LateContext < ' _ , ' _ > , span : Span ) {
5959 span_lint_and_sugg (
6060 cx,
6161 USE_SELF ,
62- path . span ,
62+ span,
6363 "unnecessary structure name repetition" ,
6464 "use the applicable keyword" ,
6565 "Self" . to_owned ( ) ,
@@ -92,7 +92,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TraitImplTyVisitor<'a, 'tcx> {
9292 } ;
9393
9494 if !is_self_ty {
95- span_use_self_lint ( self . cx , path) ;
95+ span_use_self_lint ( self . cx , path. span ) ;
9696 }
9797 }
9898 }
@@ -221,10 +221,10 @@ impl<'a, 'tcx> Visitor<'tcx> for UseSelfVisitor<'a, 'tcx> {
221221 fn visit_path ( & mut self , path : & ' tcx Path , _id : HirId ) {
222222 if path. segments . last ( ) . expect ( SEGMENTS_MSG ) . ident . name != SelfUpper . name ( ) {
223223 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 ) ;
225225 } else if let Def :: StructCtor ( ctor_did, CtorKind :: Fn ) = path. def {
226226 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 ) ;
228228 }
229229 }
230230 }
0 commit comments