@@ -566,6 +566,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
566
566
Ok ( def) => self . record_def ( tref. trait_ref . ref_id , def) ,
567
567
Err ( _) => {
568
568
// error already reported
569
+ self . record_def ( tref. trait_ref . ref_id , err_path_resolution ( ) )
569
570
}
570
571
}
571
572
intravisit:: walk_poly_trait_ref ( self , tref, m) ;
@@ -2005,6 +2006,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2005
2006
prefix. span ,
2006
2007
ResolutionError :: FailedToResolve (
2007
2008
& path_names_to_string ( prefix, 0 ) ) ) ;
2009
+ self . record_def ( item. id , err_path_resolution ( ) ) ;
2008
2010
}
2009
2011
}
2010
2012
}
@@ -2164,6 +2166,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2164
2166
resolve_error ( self ,
2165
2167
eq_pred. span ,
2166
2168
ResolutionError :: UndeclaredAssociatedType ) ;
2169
+ self . record_def ( eq_pred. id , err_path_resolution ( ) ) ;
2167
2170
}
2168
2171
}
2169
2172
}
@@ -2194,6 +2197,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2194
2197
self . record_def ( trait_ref. ref_id , path_res) ;
2195
2198
new_val = Some ( ( path_res. base_def . def_id ( ) , trait_ref. clone ( ) ) ) ;
2196
2199
new_id = Some ( path_res. base_def . def_id ( ) ) ;
2200
+ } else {
2201
+ self . record_def ( trait_ref. ref_id , err_path_resolution ( ) ) ;
2197
2202
}
2198
2203
intravisit:: walk_trait_ref ( self , trait_ref) ;
2199
2204
}
@@ -2463,6 +2468,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2463
2468
self . record_def ( ty. id , def) ;
2464
2469
}
2465
2470
None => {
2471
+ self . record_def ( ty. id , err_path_resolution ( ) ) ;
2472
+
2466
2473
// Keep reporting some errors even if they're ignored above.
2467
2474
self . resolve_path ( ty. id , path, 0 , TypeNS , true ) ;
2468
2475
@@ -2545,6 +2552,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2545
2552
ResolutionError :: DeclarationShadowsEnumVariantOrUnitLikeStruct (
2546
2553
renamed)
2547
2554
) ;
2555
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2548
2556
}
2549
2557
FoundConst ( def, lp, _) if const_ok => {
2550
2558
debug ! ( "(resolving pattern) resolving `{}` to constant" , renamed) ;
@@ -2564,6 +2572,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2564
2572
ResolutionError :: OnlyIrrefutablePatternsAllowedHere ( def. def_id ( ) ,
2565
2573
name)
2566
2574
) ;
2575
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2567
2576
}
2568
2577
BareIdentifierPatternUnresolved => {
2569
2578
debug ! ( "(resolving pattern) binding `{}`" , renamed) ;
@@ -2647,6 +2656,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2647
2656
resolve_error ( & self ,
2648
2657
path. span ,
2649
2658
ResolutionError :: StaticVariableReference ) ;
2659
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2650
2660
}
2651
2661
_ => {
2652
2662
// If anything ends up here entirely resolved,
@@ -2665,6 +2675,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2665
2675
. name
2666
2676
. as_str ( ) )
2667
2677
) ;
2678
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2668
2679
} else {
2669
2680
let const_name = path. segments
2670
2681
. last ( )
@@ -2684,6 +2695,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2684
2695
ResolutionError :: UnresolvedEnumVariantStructOrConst (
2685
2696
& path. segments . last ( ) . unwrap ( ) . identifier . name . as_str ( ) )
2686
2697
) ;
2698
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2687
2699
}
2688
2700
intravisit:: walk_path ( self , path) ;
2689
2701
}
@@ -2726,6 +2738,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2726
2738
& path. segments . last ( ) . unwrap ( ) . identifier . name . as_str ( )
2727
2739
)
2728
2740
) ;
2741
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2729
2742
}
2730
2743
}
2731
2744
} else {
@@ -2737,6 +2750,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2737
2750
. identifier
2738
2751
. name
2739
2752
. as_str ( ) ) ) ;
2753
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2740
2754
}
2741
2755
intravisit:: walk_pat ( self , pattern) ;
2742
2756
}
@@ -2754,6 +2768,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2754
2768
ResolutionError :: DoesNotNameAStruct (
2755
2769
& * path_names_to_string ( path, 0 ) )
2756
2770
) ;
2771
+ self . record_def ( pattern. id , err_path_resolution ( ) ) ;
2757
2772
}
2758
2773
}
2759
2774
intravisit:: walk_path ( self , path) ;
@@ -3430,6 +3445,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3430
3445
} else {
3431
3446
self . session . span_help ( expr. span , & msg) ;
3432
3447
}
3448
+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
3433
3449
} else {
3434
3450
// Write the result into the def map.
3435
3451
debug ! ( "(resolving expr) resolved `{}`" ,
@@ -3454,6 +3470,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3454
3470
let type_res = self . with_no_errors ( |this| {
3455
3471
this. resolve_path ( expr. id , path, 0 , TypeNS , false )
3456
3472
} ) ;
3473
+
3474
+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
3457
3475
match type_res. map ( |r| r. base_def ) {
3458
3476
Some ( DefTy ( struct_id, _) ) if self . structs . contains_key ( & struct_id) => {
3459
3477
resolve_error (
@@ -3540,6 +3558,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3540
3558
ResolutionError :: DoesNotNameAStruct (
3541
3559
& * path_names_to_string ( path, 0 ) )
3542
3560
) ;
3561
+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
3543
3562
}
3544
3563
}
3545
3564
@@ -3562,6 +3581,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3562
3581
ExprBreak ( Some ( label) ) | ExprAgain ( Some ( label) ) => {
3563
3582
match self . search_label ( label. node . name ) {
3564
3583
None => {
3584
+ self . record_def ( expr. id , err_path_resolution ( ) ) ;
3565
3585
resolve_error ( self ,
3566
3586
label. span ,
3567
3587
ResolutionError :: UndeclaredLabel ( & label. node . name . as_str ( ) ) )
@@ -3811,6 +3831,14 @@ fn module_to_string(module: &Module) -> String {
3811
3831
names_to_string ( & names. into_iter ( ) . rev ( ) . collect :: < Vec < ast:: Name > > ( ) )
3812
3832
}
3813
3833
3834
+ fn err_path_resolution ( ) -> PathResolution {
3835
+ PathResolution {
3836
+ base_def : DefErr ,
3837
+ last_private : LastMod ( AllPublic ) ,
3838
+ depth : 0 ,
3839
+ }
3840
+ }
3841
+
3814
3842
3815
3843
pub struct CrateMap {
3816
3844
pub def_map : RefCell < DefMap > ,
@@ -3836,7 +3864,6 @@ pub fn resolve_crate<'a, 'tcx>(session: &'a Session,
3836
3864
let mut resolver = create_resolver ( session, ast_map, krate, make_glob_map, None ) ;
3837
3865
3838
3866
resolver. resolve_crate ( krate) ;
3839
- session. abort_if_errors ( ) ;
3840
3867
3841
3868
check_unused:: check_crate ( & mut resolver, krate) ;
3842
3869
0 commit comments