@@ -1683,8 +1683,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1683
1683
match self . resolve_crate_relative_path ( prefix. span ,
1684
1684
& prefix. segments ,
1685
1685
TypeNS ) {
1686
- Ok ( def) =>
1687
- self . record_def ( item. id , PathResolution :: new ( def, 0 ) ) ,
1686
+ Ok ( binding) => {
1687
+ let def = binding. def ( ) . unwrap ( ) ;
1688
+ self . record_def ( item. id , PathResolution :: new ( def, 0 ) ) ;
1689
+ }
1688
1690
Err ( true ) => self . record_def ( item. id , err_path_resolution ( ) ) ,
1689
1691
Err ( false ) => {
1690
1692
resolve_error ( self ,
@@ -2547,8 +2549,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2547
2549
let mk_res = |def| PathResolution :: new ( def, path_depth) ;
2548
2550
2549
2551
if path. global {
2550
- let def = self . resolve_crate_relative_path ( span, segments, namespace) ;
2551
- return def . map ( mk_res) ;
2552
+ let binding = self . resolve_crate_relative_path ( span, segments, namespace) ;
2553
+ return binding . map ( |binding| mk_res ( binding . def ( ) . unwrap ( ) ) ) ;
2552
2554
}
2553
2555
2554
2556
// Try to find a path to an item in a module.
@@ -2584,9 +2586,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2584
2586
}
2585
2587
2586
2588
let unqualified_def = resolve_identifier_with_fallback ( self , false ) ;
2587
- let def = self . resolve_module_relative_path ( span, segments, namespace) ;
2588
- match ( def , unqualified_def) {
2589
- ( Ok ( d ) , Some ( ref ud) ) if d == ud. def => {
2589
+ let qualified_binding = self . resolve_module_relative_path ( span, segments, namespace) ;
2590
+ match ( qualified_binding , unqualified_def) {
2591
+ ( Ok ( binding ) , Some ( ref ud) ) if binding . def ( ) . unwrap ( ) == ud. def => {
2590
2592
self . session
2591
2593
. add_lint ( lint:: builtin:: UNUSED_QUALIFICATIONS ,
2592
2594
id,
@@ -2596,7 +2598,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2596
2598
_ => { }
2597
2599
}
2598
2600
2599
- def . map ( mk_res)
2601
+ qualified_binding . map ( |binding| mk_res ( binding . def ( ) . unwrap ( ) ) )
2600
2602
}
2601
2603
2602
2604
// Resolve a single identifier
@@ -2707,7 +2709,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2707
2709
span : Span ,
2708
2710
segments : & [ hir:: PathSegment ] ,
2709
2711
namespace : Namespace )
2710
- -> Result < Def , bool /* true if an error was reported */ > {
2712
+ -> Result < & ' a NameBinding < ' a > ,
2713
+ bool /* true if an error was reported */ > {
2711
2714
let module_path = segments. split_last ( )
2712
2715
. unwrap ( )
2713
2716
. 1
@@ -2740,7 +2743,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2740
2743
let result = self . resolve_name_in_module ( containing_module, name, namespace, false , true ) ;
2741
2744
result. success ( ) . map ( |binding| {
2742
2745
self . check_privacy ( name, binding, span) ;
2743
- binding. def ( ) . unwrap ( )
2746
+ binding
2744
2747
} ) . ok_or ( false )
2745
2748
}
2746
2749
@@ -2750,7 +2753,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2750
2753
span : Span ,
2751
2754
segments : & [ hir:: PathSegment ] ,
2752
2755
namespace : Namespace )
2753
- -> Result < Def , bool /* true if an error was reported */ > {
2756
+ -> Result < & ' a NameBinding < ' a > ,
2757
+ bool /* true if an error was reported */ > {
2754
2758
let module_path = segments. split_last ( )
2755
2759
. unwrap ( )
2756
2760
. 1
@@ -2790,7 +2794,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2790
2794
let result = self . resolve_name_in_module ( containing_module, name, namespace, false , true ) ;
2791
2795
result. success ( ) . map ( |binding| {
2792
2796
self . check_privacy ( name, binding, span) ;
2793
- binding. def ( ) . unwrap ( )
2797
+ binding
2794
2798
} ) . ok_or ( false )
2795
2799
}
2796
2800
0 commit comments