@@ -37,7 +37,7 @@ use crate::hir::{self, ParamName};
3737use crate :: hir:: HirVec ;
3838use crate :: hir:: map:: { DefKey , DefPathData , Definitions } ;
3939use crate :: hir:: def_id:: { DefId , DefIndex , DefIndexAddressSpace , CRATE_DEF_INDEX } ;
40- use crate :: hir:: def:: { Res , DefKind , PathResolution , PerNS } ;
40+ use crate :: hir:: def:: { Res , DefKind , PartialRes , PerNS } ;
4141use crate :: hir:: { GenericArg , ConstArg } ;
4242use crate :: lint:: builtin:: { self , PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES ,
4343 ELIDED_LIFETIMES_IN_PATHS } ;
@@ -145,11 +145,11 @@ pub trait Resolver {
145145 is_value : bool ,
146146 ) -> hir:: Path ;
147147
148- /// Obtain the resolution for a `NodeId`.
149- fn get_resolution ( & mut self , id : NodeId ) -> Option < PathResolution > ;
148+ /// Obtain resolution for a `NodeId` with a single resolution .
149+ fn get_partial_res ( & mut self , id : NodeId ) -> Option < PartialRes > ;
150150
151- /// Obtain the possible resolutions for the given `use` statement .
152- fn get_import ( & mut self , id : NodeId ) -> PerNS < Option < PathResolution > > ;
151+ /// Obtain per-namespace resolutions for `use` statement with the given `NoedId` .
152+ fn get_import_res ( & mut self , id : NodeId ) -> PerNS < Option < Res < NodeId > > > ;
153153
154154 /// We must keep the set of definitions up to date as we add nodes that weren't in the AST.
155155 /// This should only return `None` during testing.
@@ -821,7 +821,7 @@ impl<'a> LoweringContext<'a> {
821821 }
822822
823823 fn expect_full_res ( & mut self , id : NodeId ) -> Res < NodeId > {
824- self . resolver . get_resolution ( id) . map_or ( Res :: Err , |pr| {
824+ self . resolver . get_partial_res ( id) . map_or ( Res :: Err , |pr| {
825825 if pr. unresolved_segments ( ) != 0 {
826826 bug ! ( "path not fully resolved: {:?}" , pr) ;
827827 }
@@ -830,12 +830,7 @@ impl<'a> LoweringContext<'a> {
830830 }
831831
832832 fn expect_full_res_from_use ( & mut self , id : NodeId ) -> impl Iterator < Item = Res < NodeId > > {
833- self . resolver . get_import ( id) . present_items ( ) . map ( |pr| {
834- if pr. unresolved_segments ( ) != 0 {
835- bug ! ( "path not fully resolved: {:?}" , pr) ;
836- }
837- pr. base_res ( )
838- } )
833+ self . resolver . get_import_res ( id) . present_items ( )
839834 }
840835
841836 fn diagnostic ( & self ) -> & errors:: Handler {
@@ -1842,13 +1837,13 @@ impl<'a> LoweringContext<'a> {
18421837 let qself_position = qself. as_ref ( ) . map ( |q| q. position ) ;
18431838 let qself = qself. as_ref ( ) . map ( |q| self . lower_ty ( & q. ty , itctx. reborrow ( ) ) ) ;
18441839
1845- let resolution = self . resolver
1846- . get_resolution ( id)
1847- . unwrap_or_else ( || PathResolution :: new ( Res :: Err ) ) ;
1840+ let partial_res = self . resolver
1841+ . get_partial_res ( id)
1842+ . unwrap_or_else ( || PartialRes :: new ( Res :: Err ) ) ;
18481843
1849- let proj_start = p. segments . len ( ) - resolution . unresolved_segments ( ) ;
1844+ let proj_start = p. segments . len ( ) - partial_res . unresolved_segments ( ) ;
18501845 let path = P ( hir:: Path {
1851- res : self . lower_res ( resolution . base_res ( ) ) ,
1846+ res : self . lower_res ( partial_res . base_res ( ) ) ,
18521847 segments : p. segments [ ..proj_start]
18531848 . iter ( )
18541849 . enumerate ( )
@@ -1869,7 +1864,7 @@ impl<'a> LoweringContext<'a> {
18691864 krate : def_id. krate ,
18701865 index : this. def_key ( def_id) . parent . expect ( "missing parent" ) ,
18711866 } ;
1872- let type_def_id = match resolution . base_res ( ) {
1867+ let type_def_id = match partial_res . base_res ( ) {
18731868 Res :: Def ( DefKind :: AssociatedTy , def_id) if i + 2 == proj_start => {
18741869 Some ( parent_def_id ( self , def_id) )
18751870 }
@@ -1886,7 +1881,7 @@ impl<'a> LoweringContext<'a> {
18861881 }
18871882 _ => None ,
18881883 } ;
1889- let parenthesized_generic_args = match resolution . base_res ( ) {
1884+ let parenthesized_generic_args = match partial_res . base_res ( ) {
18901885 // `a::b::Trait(Args)`
18911886 Res :: Def ( DefKind :: Trait , _)
18921887 if i + 1 == proj_start => ParenthesizedGenericArgs :: Ok ,
@@ -1940,7 +1935,7 @@ impl<'a> LoweringContext<'a> {
19401935
19411936 // Simple case, either no projections, or only fully-qualified.
19421937 // E.g., `std::mem::size_of` or `<I as Iterator>::Item`.
1943- if resolution . unresolved_segments ( ) == 0 {
1938+ if partial_res . unresolved_segments ( ) == 0 {
19441939 return hir:: QPath :: Resolved ( qself, path) ;
19451940 }
19461941
@@ -2792,7 +2787,7 @@ impl<'a> LoweringContext<'a> {
27922787 && bound_pred. bound_generic_params . is_empty ( ) =>
27932788 {
27942789 if let Some ( Res :: Def ( DefKind :: TyParam , def_id) ) = self . resolver
2795- . get_resolution ( bound_pred. bounded_ty . id )
2790+ . get_partial_res ( bound_pred. bounded_ty . id )
27962791 . map ( |d| d. base_res ( ) )
27972792 {
27982793 if let Some ( node_id) =
@@ -3946,7 +3941,7 @@ impl<'a> LoweringContext<'a> {
39463941 let node = match p. node {
39473942 PatKind :: Wild => hir:: PatKind :: Wild ,
39483943 PatKind :: Ident ( ref binding_mode, ident, ref sub) => {
3949- match self . resolver . get_resolution ( p. id ) . map ( |d| d. base_res ( ) ) {
3944+ match self . resolver . get_partial_res ( p. id ) . map ( |d| d. base_res ( ) ) {
39503945 // `None` can occur in body-less function signatures
39513946 res @ None | res @ Some ( Res :: Local ( _) ) => {
39523947 let canonical_id = match res {
0 commit comments