File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -332,7 +332,8 @@ impl LintPass for HardwiredLints {
332332#[ derive( PartialEq ,  RustcEncodable ,  RustcDecodable ,  Debug ) ]  
333333pub  enum  BuiltinLintDiagnostics  { 
334334    Normal , 
335-     BareTraitObject ( Span ,  /* is_global */  bool ) 
335+     BareTraitObject ( Span ,  /* is_global */  bool ) , 
336+     AbsPathWithModule ( Span ) , 
336337} 
337338
338339impl  BuiltinLintDiagnostics  { 
@@ -347,6 +348,23 @@ impl BuiltinLintDiagnostics {
347348                } ; 
348349                db. span_suggestion ( span,  "use `dyn`" ,  sugg) ; 
349350            } 
351+             BuiltinLintDiagnostics :: AbsPathWithModule ( span)  => { 
352+                 let  sugg = match  sess. codemap ( ) . span_to_snippet ( span)  { 
353+                     Ok ( ref  s)  => { 
354+                         // FIXME(Manishearth) ideally the emitting code 
355+                         // can tell us whether or not this is global 
356+                         let  opt_colon = if  s. trim_left ( ) . starts_with ( "::" )  { 
357+                             "" 
358+                         }  else  { 
359+                             "::" 
360+                         } ; 
361+ 
362+                         format ! ( "crate{}{}" ,  opt_colon,  s) 
363+                     } 
364+                     Err ( _)  => format ! ( "crate::<path>" ) 
365+                 } ; 
366+                 db. span_suggestion ( span,  "use `crate`" ,  sugg) ; 
367+             } 
350368        } 
351369    } 
352370} 
Original file line number Diff line number Diff line change @@ -3344,11 +3344,14 @@ impl<'a> Resolver<'a> {
33443344                                } 
33453345
33463346                                if  !is_crate { 
3347-                                     self . session . buffer_lint ( 
3347+                                     let  diag = lint:: builtin:: BuiltinLintDiagnostics 
3348+                                                    :: AbsPathWithModule ( path_span) ; 
3349+                                     self . session . buffer_lint_with_diagnostic ( 
33483350                                        lint:: builtin:: ABSOLUTE_PATH_STARTING_WITH_MODULE , 
33493351                                        id,  path_span, 
3350-                                         "Fully-qualified paths must start with `self`, `super`, 
3351-                                         `crate`, or an external crate name in the 2018 edition" ) ; 
3352+                                         "Absolute paths must start with `self`, `super`, \  
3353+ , 
3354+                                         diag) ; 
33523355                                } 
33533356                            } 
33543357                        } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments