@@ -85,10 +85,9 @@ pub enum PredicateFilter {
85
85
86
86
#[ derive( Debug ) ]
87
87
pub enum RegionInferReason < ' a > {
88
- /// Lifetime on a trait object behind a reference.
89
- /// This allows inferring information from the reference.
90
- BorrowedObjectLifetimeDefault ,
91
- /// A trait object's lifetime.
88
+ /// Lifetime on a trait object that is spelled explicitly, e.g. `+ 'a` or `+ '_`.
89
+ ExplicitObjectLifetime ,
90
+ /// A trait object's lifetime when it is elided, e.g. `dyn Any`.
92
91
ObjectLifetimeDefault ,
93
92
/// Generic lifetime parameter
94
93
Param ( & ' a ty:: GenericParamDef ) ,
@@ -1057,7 +1056,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1057
1056
1058
1057
// Find the type of the associated item, and the trait where the associated
1059
1058
// item is declared.
1060
- let bound = match ( & qself_ty. kind ( ) , qself_res) {
1059
+ let bound = match ( qself_ty. kind ( ) , qself_res) {
1061
1060
( _, Res :: SelfTyAlias { alias_to : impl_def_id, is_trait_impl : true , .. } ) => {
1062
1061
// `Self` in an impl of a trait -- we have a concrete self type and a
1063
1062
// trait reference.
@@ -1999,16 +1998,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
1999
1998
}
2000
1999
}
2001
2000
2002
- /// Lower a type from the HIR to our internal notion of a type.
2003
- pub fn lower_ty ( & self , hir_ty : & hir:: Ty < ' tcx > ) -> Ty < ' tcx > {
2004
- self . lower_ty_common ( hir_ty, false , false )
2005
- }
2006
-
2007
- /// Lower a type inside of a path from the HIR to our internal notion of a type.
2008
- pub fn lower_ty_in_path ( & self , hir_ty : & hir:: Ty < ' tcx > ) -> Ty < ' tcx > {
2009
- self . lower_ty_common ( hir_ty, false , true )
2010
- }
2011
-
2012
2001
fn lower_delegation_ty ( & self , idx : hir:: InferDelegationKind ) -> Ty < ' tcx > {
2013
2002
let delegation_sig = self . tcx ( ) . inherit_sig_for_delegation_item ( self . item_def_id ( ) ) ;
2014
2003
match idx {
@@ -2026,7 +2015,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2026
2015
/// 2. `in_path`: Whether the type appears inside of a path.
2027
2016
/// Used to provide correct diagnostics for bare trait object types.
2028
2017
#[ instrument( level = "debug" , skip( self ) , ret) ]
2029
- fn lower_ty_common ( & self , hir_ty : & hir:: Ty < ' tcx > , borrowed : bool , in_path : bool ) -> Ty < ' tcx > {
2018
+ pub fn lower_ty ( & self , hir_ty : & hir:: Ty < ' tcx > ) -> Ty < ' tcx > {
2030
2019
let tcx = self . tcx ( ) ;
2031
2020
2032
2021
let result_ty = match & hir_ty. kind {
@@ -2036,7 +2025,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2036
2025
hir:: TyKind :: Ref ( region, mt) => {
2037
2026
let r = self . lower_lifetime ( region, RegionInferReason :: Reference ) ;
2038
2027
debug ! ( ?r) ;
2039
- let t = self . lower_ty_common ( mt. ty , true , false ) ;
2028
+ let t = self . lower_ty ( mt. ty ) ;
2040
2029
Ty :: new_ref ( tcx, r, t, mt. mutbl )
2041
2030
}
2042
2031
hir:: TyKind :: Never => tcx. types . never ,
@@ -2065,20 +2054,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2065
2054
)
2066
2055
}
2067
2056
hir:: TyKind :: TraitObject ( bounds, lifetime, repr) => {
2068
- self . prohibit_or_lint_bare_trait_object_ty ( hir_ty, in_path ) ;
2057
+ self . prohibit_or_lint_bare_trait_object_ty ( hir_ty) ;
2069
2058
2070
2059
let repr = match repr {
2071
2060
TraitObjectSyntax :: Dyn | TraitObjectSyntax :: None => ty:: Dyn ,
2072
2061
TraitObjectSyntax :: DynStar => ty:: DynStar ,
2073
2062
} ;
2074
- self . lower_trait_object_ty (
2075
- hir_ty. span ,
2076
- hir_ty. hir_id ,
2077
- bounds,
2078
- lifetime,
2079
- borrowed,
2080
- repr,
2081
- )
2063
+ self . lower_trait_object_ty ( hir_ty. span , hir_ty. hir_id , bounds, lifetime, repr)
2082
2064
}
2083
2065
hir:: TyKind :: Path ( hir:: QPath :: Resolved ( maybe_qself, path) ) => {
2084
2066
debug ! ( ?maybe_qself, ?path) ;
@@ -2106,7 +2088,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
2106
2088
}
2107
2089
hir:: TyKind :: Path ( hir:: QPath :: TypeRelative ( qself, segment) ) => {
2108
2090
debug ! ( ?qself, ?segment) ;
2109
- let ty = self . lower_ty_common ( qself, false , true ) ;
2091
+ let ty = self . lower_ty ( qself) ;
2110
2092
self . lower_assoc_path ( hir_ty. hir_id , hir_ty. span , ty, qself, segment, false )
2111
2093
. map ( |( ty, _, _) | ty)
2112
2094
. unwrap_or_else ( |guar| Ty :: new_error ( tcx, guar) )
0 commit comments