@@ -85,10 +85,9 @@ pub enum PredicateFilter {
8585
8686#[ derive( Debug ) ]
8787pub 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`.
9291 ObjectLifetimeDefault ,
9392 /// Generic lifetime parameter
9493 Param ( & ' a ty:: GenericParamDef ) ,
@@ -1999,16 +1998,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
19991998 }
20001999 }
20012000
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-
20122001 fn lower_delegation_ty ( & self , idx : hir:: InferDelegationKind ) -> Ty < ' tcx > {
20132002 let delegation_sig = self . tcx ( ) . inherit_sig_for_delegation_item ( self . item_def_id ( ) ) ;
20142003 match idx {
@@ -2026,7 +2015,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20262015 /// 2. `in_path`: Whether the type appears inside of a path.
20272016 /// Used to provide correct diagnostics for bare trait object types.
20282017 #[ 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 > {
20302019 let tcx = self . tcx ( ) ;
20312020
20322021 let result_ty = match & hir_ty. kind {
@@ -2036,7 +2025,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20362025 hir:: TyKind :: Ref ( region, mt) => {
20372026 let r = self . lower_lifetime ( region, RegionInferReason :: Reference ) ;
20382027 debug ! ( ?r) ;
2039- let t = self . lower_ty_common ( mt. ty , true , false ) ;
2028+ let t = self . lower_ty ( mt. ty ) ;
20402029 Ty :: new_ref ( tcx, r, t, mt. mutbl )
20412030 }
20422031 hir:: TyKind :: Never => tcx. types . never ,
@@ -2065,20 +2054,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
20652054 )
20662055 }
20672056 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) ;
20692058
20702059 let repr = match repr {
20712060 TraitObjectSyntax :: Dyn | TraitObjectSyntax :: None => ty:: Dyn ,
20722061 TraitObjectSyntax :: DynStar => ty:: DynStar ,
20732062 } ;
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)
20822064 }
20832065 hir:: TyKind :: Path ( hir:: QPath :: Resolved ( maybe_qself, path) ) => {
20842066 debug ! ( ?maybe_qself, ?path) ;
@@ -2106,7 +2088,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
21062088 }
21072089 hir:: TyKind :: Path ( hir:: QPath :: TypeRelative ( qself, segment) ) => {
21082090 debug ! ( ?qself, ?segment) ;
2109- let ty = self . lower_ty_common ( qself, false , true ) ;
2091+ let ty = self . lower_ty ( qself) ;
21102092 self . lower_assoc_path ( hir_ty. hir_id , hir_ty. span , ty, qself, segment, false )
21112093 . map ( |( ty, _, _) | ty)
21122094 . unwrap_or_else ( |guar| Ty :: new_error ( tcx, guar) )
0 commit comments