@@ -1034,6 +1034,8 @@ enum PathResult<'a> {
10341034 NonModule ( PathResolution ) ,
10351035 Indeterminate ,
10361036 Failed ( Span , String , bool /* is the error from the last segment? */ ) ,
1037+ /// Encountered an error that is reported elsewhere
1038+ Ignore ,
10371039}
10381040
10391041enum ModuleKind {
@@ -1766,6 +1768,7 @@ impl<'a> Resolver<'a> {
17661768 error_callback ( self , span, ResolutionError :: FailedToResolve ( & msg) ) ;
17671769 Def :: Err
17681770 }
1771+ PathResult :: Ignore => Def :: Err ,
17691772 } ;
17701773
17711774 let segments: Vec < _ > = segments. iter ( ) . map ( |seg| {
@@ -3693,7 +3696,7 @@ impl<'a> Resolver<'a> {
36933696 resolve_error ( self , span, ResolutionError :: FailedToResolve ( & msg) ) ;
36943697 err_path_resolution ( )
36953698 }
3696- PathResult :: Module ( ..) | PathResult :: Failed ( ..) => return None ,
3699+ PathResult :: Module ( ..) | PathResult :: Failed ( ..) | PathResult :: Ignore => return None ,
36973700 PathResult :: Indeterminate => bug ! ( "indetermined path result in resolve_qpath" ) ,
36983701 } ;
36993702
@@ -3925,8 +3928,11 @@ impl<'a> Resolver<'a> {
39253928 } ) ;
39263929 if let Some ( candidate) = candidates. get ( 0 ) {
39273930 format ! ( "did you mean `{}`?" , candidate. path)
3928- } else {
3931+ } else if !ident . is_used_keyword ( ) {
39293932 format ! ( "maybe a missing `extern crate {};`?" , ident)
3933+ } else {
3934+ // the parser will already have complained about the keyword being used
3935+ return PathResult :: Ignore ;
39303936 }
39313937 } else if i == 0 {
39323938 format ! ( "use of undeclared type or module `{}`" , ident)
0 commit comments