@@ -1034,6 +1034,8 @@ enum PathResult<'a> {
1034
1034
NonModule ( PathResolution ) ,
1035
1035
Indeterminate ,
1036
1036
Failed ( Span , String , bool /* is the error from the last segment? */ ) ,
1037
+ /// Encountered an error that is reported elsewhere
1038
+ Ignore ,
1037
1039
}
1038
1040
1039
1041
enum ModuleKind {
@@ -1766,6 +1768,7 @@ impl<'a> Resolver<'a> {
1766
1768
error_callback ( self , span, ResolutionError :: FailedToResolve ( & msg) ) ;
1767
1769
Def :: Err
1768
1770
}
1771
+ PathResult :: Ignore => Def :: Err ,
1769
1772
} ;
1770
1773
1771
1774
let segments: Vec < _ > = segments. iter ( ) . map ( |seg| {
@@ -3693,7 +3696,7 @@ impl<'a> Resolver<'a> {
3693
3696
resolve_error ( self , span, ResolutionError :: FailedToResolve ( & msg) ) ;
3694
3697
err_path_resolution ( )
3695
3698
}
3696
- PathResult :: Module ( ..) | PathResult :: Failed ( ..) => return None ,
3699
+ PathResult :: Module ( ..) | PathResult :: Failed ( ..) | PathResult :: Ignore => return None ,
3697
3700
PathResult :: Indeterminate => bug ! ( "indetermined path result in resolve_qpath" ) ,
3698
3701
} ;
3699
3702
@@ -3925,8 +3928,11 @@ impl<'a> Resolver<'a> {
3925
3928
} ) ;
3926
3929
if let Some ( candidate) = candidates. get ( 0 ) {
3927
3930
format ! ( "did you mean `{}`?" , candidate. path)
3928
- } else {
3931
+ } else if !ident . is_used_keyword ( ) {
3929
3932
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 ;
3930
3936
}
3931
3937
} else if i == 0 {
3932
3938
format ! ( "use of undeclared type or module `{}`" , ident)
0 commit comments