@@ -37,7 +37,7 @@ use crate::hir::{self, ParamName};
37
37
use crate :: hir:: HirVec ;
38
38
use crate :: hir:: map:: { DefKey , DefPathData , Definitions } ;
39
39
use 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 } ;
41
41
use crate :: hir:: { GenericArg , ConstArg } ;
42
42
use crate :: lint:: builtin:: { self , PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES ,
43
43
ELIDED_LIFETIMES_IN_PATHS } ;
@@ -145,11 +145,11 @@ pub trait Resolver {
145
145
is_value : bool ,
146
146
) -> hir:: Path ;
147
147
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 > ;
150
150
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 > > > ;
153
153
154
154
/// We must keep the set of definitions up to date as we add nodes that weren't in the AST.
155
155
/// This should only return `None` during testing.
@@ -821,7 +821,7 @@ impl<'a> LoweringContext<'a> {
821
821
}
822
822
823
823
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| {
825
825
if pr. unresolved_segments ( ) != 0 {
826
826
bug ! ( "path not fully resolved: {:?}" , pr) ;
827
827
}
@@ -830,12 +830,7 @@ impl<'a> LoweringContext<'a> {
830
830
}
831
831
832
832
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 ( )
839
834
}
840
835
841
836
fn diagnostic ( & self ) -> & errors:: Handler {
@@ -1842,13 +1837,13 @@ impl<'a> LoweringContext<'a> {
1842
1837
let qself_position = qself. as_ref ( ) . map ( |q| q. position ) ;
1843
1838
let qself = qself. as_ref ( ) . map ( |q| self . lower_ty ( & q. ty , itctx. reborrow ( ) ) ) ;
1844
1839
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 ) ) ;
1848
1843
1849
- let proj_start = p. segments . len ( ) - resolution . unresolved_segments ( ) ;
1844
+ let proj_start = p. segments . len ( ) - partial_res . unresolved_segments ( ) ;
1850
1845
let path = P ( hir:: Path {
1851
- res : self . lower_res ( resolution . base_res ( ) ) ,
1846
+ res : self . lower_res ( partial_res . base_res ( ) ) ,
1852
1847
segments : p. segments [ ..proj_start]
1853
1848
. iter ( )
1854
1849
. enumerate ( )
@@ -1869,7 +1864,7 @@ impl<'a> LoweringContext<'a> {
1869
1864
krate : def_id. krate ,
1870
1865
index : this. def_key ( def_id) . parent . expect ( "missing parent" ) ,
1871
1866
} ;
1872
- let type_def_id = match resolution . base_res ( ) {
1867
+ let type_def_id = match partial_res . base_res ( ) {
1873
1868
Res :: Def ( DefKind :: AssociatedTy , def_id) if i + 2 == proj_start => {
1874
1869
Some ( parent_def_id ( self , def_id) )
1875
1870
}
@@ -1886,7 +1881,7 @@ impl<'a> LoweringContext<'a> {
1886
1881
}
1887
1882
_ => None ,
1888
1883
} ;
1889
- let parenthesized_generic_args = match resolution . base_res ( ) {
1884
+ let parenthesized_generic_args = match partial_res . base_res ( ) {
1890
1885
// `a::b::Trait(Args)`
1891
1886
Res :: Def ( DefKind :: Trait , _)
1892
1887
if i + 1 == proj_start => ParenthesizedGenericArgs :: Ok ,
@@ -1940,7 +1935,7 @@ impl<'a> LoweringContext<'a> {
1940
1935
1941
1936
// Simple case, either no projections, or only fully-qualified.
1942
1937
// E.g., `std::mem::size_of` or `<I as Iterator>::Item`.
1943
- if resolution . unresolved_segments ( ) == 0 {
1938
+ if partial_res . unresolved_segments ( ) == 0 {
1944
1939
return hir:: QPath :: Resolved ( qself, path) ;
1945
1940
}
1946
1941
@@ -2792,7 +2787,7 @@ impl<'a> LoweringContext<'a> {
2792
2787
&& bound_pred. bound_generic_params . is_empty ( ) =>
2793
2788
{
2794
2789
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 )
2796
2791
. map ( |d| d. base_res ( ) )
2797
2792
{
2798
2793
if let Some ( node_id) =
@@ -3946,7 +3941,7 @@ impl<'a> LoweringContext<'a> {
3946
3941
let node = match p. node {
3947
3942
PatKind :: Wild => hir:: PatKind :: Wild ,
3948
3943
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 ( ) ) {
3950
3945
// `None` can occur in body-less function signatures
3951
3946
res @ None | res @ Some ( Res :: Local ( _) ) => {
3952
3947
let canonical_id = match res {
0 commit comments