@@ -566,6 +566,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
566566 Ok ( def) => self . record_def ( tref. trait_ref . ref_id , def) ,
567567 Err ( _) => {
568568 // error already reported
569+ self . record_def ( tref. trait_ref . ref_id , err_path_resolution ( ) )
569570 }
570571 }
571572 intravisit:: walk_poly_trait_ref ( self , tref, m) ;
@@ -2005,6 +2006,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20052006 prefix. span ,
20062007 ResolutionError :: FailedToResolve (
20072008 & path_names_to_string ( prefix, 0 ) ) ) ;
2009+ self . record_def ( item. id , err_path_resolution ( ) ) ;
20082010 }
20092011 }
20102012 }
@@ -2164,6 +2166,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21642166 resolve_error ( self ,
21652167 eq_pred. span ,
21662168 ResolutionError :: UndeclaredAssociatedType ) ;
2169+ self . record_def ( eq_pred. id , err_path_resolution ( ) ) ;
21672170 }
21682171 }
21692172 }
@@ -2194,6 +2197,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21942197 self . record_def ( trait_ref. ref_id , path_res) ;
21952198 new_val = Some ( ( path_res. base_def . def_id ( ) , trait_ref. clone ( ) ) ) ;
21962199 new_id = Some ( path_res. base_def . def_id ( ) ) ;
2200+ } else {
2201+ self . record_def ( trait_ref. ref_id , err_path_resolution ( ) ) ;
21972202 }
21982203 intravisit:: walk_trait_ref ( self , trait_ref) ;
21992204 }
@@ -2463,6 +2468,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
24632468 self . record_def ( ty. id , def) ;
24642469 }
24652470 None => {
2471+ self . record_def ( ty. id , err_path_resolution ( ) ) ;
2472+
24662473 // Keep reporting some errors even if they're ignored above.
24672474 self . resolve_path ( ty. id , path, 0 , TypeNS , true ) ;
24682475
@@ -2545,6 +2552,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
25452552 ResolutionError :: DeclarationShadowsEnumVariantOrUnitLikeStruct (
25462553 renamed)
25472554 ) ;
2555+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
25482556 }
25492557 FoundConst ( def, lp, _) if const_ok => {
25502558 debug ! ( "(resolving pattern) resolving `{}` to constant" , renamed) ;
@@ -2564,6 +2572,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
25642572 ResolutionError :: OnlyIrrefutablePatternsAllowedHere ( def. def_id ( ) ,
25652573 name)
25662574 ) ;
2575+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
25672576 }
25682577 BareIdentifierPatternUnresolved => {
25692578 debug ! ( "(resolving pattern) binding `{}`" , renamed) ;
@@ -2647,6 +2656,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26472656 resolve_error ( & self ,
26482657 path. span ,
26492658 ResolutionError :: StaticVariableReference ) ;
2659+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
26502660 }
26512661 _ => {
26522662 // If anything ends up here entirely resolved,
@@ -2665,6 +2675,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26652675 . name
26662676 . as_str ( ) )
26672677 ) ;
2678+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
26682679 } else {
26692680 let const_name = path. segments
26702681 . last ( )
@@ -2684,6 +2695,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26842695 ResolutionError :: UnresolvedEnumVariantStructOrConst (
26852696 & path. segments . last ( ) . unwrap ( ) . identifier . name . as_str ( ) )
26862697 ) ;
2698+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
26872699 }
26882700 intravisit:: walk_path ( self , path) ;
26892701 }
@@ -2726,6 +2738,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
27262738 & path. segments . last ( ) . unwrap ( ) . identifier . name . as_str ( )
27272739 )
27282740 ) ;
2741+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
27292742 }
27302743 }
27312744 } else {
@@ -2737,6 +2750,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
27372750 . identifier
27382751 . name
27392752 . as_str ( ) ) ) ;
2753+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
27402754 }
27412755 intravisit:: walk_pat ( self , pattern) ;
27422756 }
@@ -2754,6 +2768,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
27542768 ResolutionError :: DoesNotNameAStruct (
27552769 & * path_names_to_string ( path, 0 ) )
27562770 ) ;
2771+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
27572772 }
27582773 }
27592774 intravisit:: walk_path ( self , path) ;
@@ -3430,6 +3445,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
34303445 } else {
34313446 self . session . span_help ( expr. span , & msg) ;
34323447 }
3448+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
34333449 } else {
34343450 // Write the result into the def map.
34353451 debug ! ( "(resolving expr) resolved `{}`" ,
@@ -3454,6 +3470,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
34543470 let type_res = self . with_no_errors ( |this| {
34553471 this. resolve_path ( expr. id , path, 0 , TypeNS , false )
34563472 } ) ;
3473+
3474+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
34573475 match type_res. map ( |r| r. base_def ) {
34583476 Some ( DefTy ( struct_id, _) ) if self . structs . contains_key ( & struct_id) => {
34593477 resolve_error (
@@ -3540,6 +3558,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35403558 ResolutionError :: DoesNotNameAStruct (
35413559 & * path_names_to_string ( path, 0 ) )
35423560 ) ;
3561+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
35433562 }
35443563 }
35453564
@@ -3562,6 +3581,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35623581 ExprBreak ( Some ( label) ) | ExprAgain ( Some ( label) ) => {
35633582 match self . search_label ( label. node . name ) {
35643583 None => {
3584+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
35653585 resolve_error ( self ,
35663586 label. span ,
35673587 ResolutionError :: UndeclaredLabel ( & label. node . name . as_str ( ) ) )
@@ -3811,6 +3831,14 @@ fn module_to_string(module: &Module) -> String {
38113831 names_to_string ( & names. into_iter ( ) . rev ( ) . collect :: < Vec < ast:: Name > > ( ) )
38123832}
38133833
3834+ fn err_path_resolution ( ) -> PathResolution {
3835+ PathResolution {
3836+ base_def : DefErr ,
3837+ last_private : LastMod ( AllPublic ) ,
3838+ depth : 0 ,
3839+ }
3840+ }
3841+
38143842
38153843pub struct CrateMap {
38163844 pub def_map : RefCell < DefMap > ,
@@ -3836,7 +3864,6 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
38363864 let mut resolver = create_resolver ( session, ast_map, krate, make_glob_map, None ) ;
38373865
38383866 resolver. resolve_crate ( krate) ;
3839- session. abort_if_errors ( ) ;
38403867
38413868 check_unused:: check_crate ( & mut resolver, krate) ;
38423869
0 commit comments