@@ -2,9 +2,11 @@ use std::fmt::Debug;
22use std:: ops:: ControlFlow ;
33
44use derive_where:: derive_where;
5+ #[ cfg_attr( feature = "nightly" , allow( rustc:: non_glob_import_of_type_ir_inherent) ) ]
6+ use rustc_type_ir:: inherent:: Ty as _;
57use rustc_type_ir:: inherent:: * ;
68use rustc_type_ir:: {
7- self as ty, InferCtxtLike , Interner , TrivialTypeTraversalImpls , TypeVisitable ,
9+ self as ty, InferCtxtLike , Interner , TrivialTypeTraversalImpls , Ty , TypeVisitable ,
810 TypeVisitableExt , TypeVisitor ,
911} ;
1012use tracing:: instrument;
@@ -47,7 +49,7 @@ pub enum Conflict {
4749pub fn trait_ref_is_knowable < Infcx , I , E > (
4850 infcx : & Infcx ,
4951 trait_ref : ty:: TraitRef < I > ,
50- mut lazily_normalize_ty : impl FnMut ( I :: Ty ) -> Result < I :: Ty , E > ,
52+ mut lazily_normalize_ty : impl FnMut ( Ty < I > ) -> Result < Ty < I > , E > ,
5153) -> Result < Result < ( ) , Conflict > , E >
5254where
5355 Infcx : InferCtxtLike < Interner = I > ,
@@ -115,14 +117,14 @@ impl From<bool> for IsFirstInputType {
115117
116118#[ derive_where( Debug ; I : Interner , T : Debug ) ]
117119pub enum OrphanCheckErr < I : Interner , T > {
118- NonLocalInputType ( Vec < ( I :: Ty , IsFirstInputType ) > ) ,
120+ NonLocalInputType ( Vec < ( Ty < I > , IsFirstInputType ) > ) ,
119121 UncoveredTyParams ( UncoveredTyParams < I , T > ) ,
120122}
121123
122124#[ derive_where( Debug ; I : Interner , T : Debug ) ]
123125pub struct UncoveredTyParams < I : Interner , T > {
124126 pub uncovered : T ,
125- pub local_ty : Option < I :: Ty > ,
127+ pub local_ty : Option < Ty < I > > ,
126128}
127129
128130/// Checks whether a trait-ref is potentially implementable by a crate.
@@ -222,8 +224,8 @@ pub fn orphan_check_trait_ref<Infcx, I, E: Debug>(
222224 infcx : & Infcx ,
223225 trait_ref : ty:: TraitRef < I > ,
224226 in_crate : InCrate ,
225- lazily_normalize_ty : impl FnMut ( I :: Ty ) -> Result < I :: Ty , E > ,
226- ) -> Result < Result < ( ) , OrphanCheckErr < I , I :: Ty > > , E >
227+ lazily_normalize_ty : impl FnMut ( Ty < I > ) -> Result < Ty < I > , E > ,
228+ ) -> Result < Result < ( ) , OrphanCheckErr < I , Ty < I > > > , E >
227229where
228230 Infcx : InferCtxtLike < Interner = I > ,
229231 I : Interner ,
@@ -262,14 +264,14 @@ struct OrphanChecker<'a, Infcx, I: Interner, F> {
262264 lazily_normalize_ty : F ,
263265 /// Ignore orphan check failures and exclusively search for the first local type.
264266 search_first_local_ty : bool ,
265- non_local_tys : Vec < ( I :: Ty , IsFirstInputType ) > ,
267+ non_local_tys : Vec < ( Ty < I > , IsFirstInputType ) > ,
266268}
267269
268270impl < ' a , Infcx , I , F , E > OrphanChecker < ' a , Infcx , I , F >
269271where
270272 Infcx : InferCtxtLike < Interner = I > ,
271273 I : Interner ,
272- F : FnOnce ( I :: Ty ) -> Result < I :: Ty , E > ,
274+ F : FnOnce ( Ty < I > ) -> Result < Ty < I > , E > ,
273275{
274276 fn new ( infcx : & ' a Infcx , in_crate : InCrate , lazily_normalize_ty : F ) -> Self {
275277 OrphanChecker {
@@ -282,12 +284,12 @@ where
282284 }
283285 }
284286
285- fn found_non_local_ty ( & mut self , t : I :: Ty ) -> ControlFlow < OrphanCheckEarlyExit < I , E > > {
287+ fn found_non_local_ty ( & mut self , t : Ty < I > ) -> ControlFlow < OrphanCheckEarlyExit < I , E > > {
286288 self . non_local_tys . push ( ( t, self . in_self_ty . into ( ) ) ) ;
287289 ControlFlow :: Continue ( ( ) )
288290 }
289291
290- fn found_uncovered_ty_param ( & mut self , ty : I :: Ty ) -> ControlFlow < OrphanCheckEarlyExit < I , E > > {
292+ fn found_uncovered_ty_param ( & mut self , ty : Ty < I > ) -> ControlFlow < OrphanCheckEarlyExit < I , E > > {
291293 if self . search_first_local_ty {
292294 return ControlFlow :: Continue ( ( ) ) ;
293295 }
@@ -305,23 +307,23 @@ where
305307
306308enum OrphanCheckEarlyExit < I : Interner , E > {
307309 NormalizationFailure ( E ) ,
308- UncoveredTyParam ( I :: Ty ) ,
309- LocalTy ( I :: Ty ) ,
310+ UncoveredTyParam ( Ty < I > ) ,
311+ LocalTy ( Ty < I > ) ,
310312}
311313
312314impl < ' a , Infcx , I , F , E > TypeVisitor < I > for OrphanChecker < ' a , Infcx , I , F >
313315where
314316 Infcx : InferCtxtLike < Interner = I > ,
315317 I : Interner ,
316- F : FnMut ( I :: Ty ) -> Result < I :: Ty , E > ,
318+ F : FnMut ( Ty < I > ) -> Result < Ty < I > , E > ,
317319{
318320 type Result = ControlFlow < OrphanCheckEarlyExit < I , E > > ;
319321
320322 fn visit_region ( & mut self , _r : I :: Region ) -> Self :: Result {
321323 ControlFlow :: Continue ( ( ) )
322324 }
323325
324- fn visit_ty ( & mut self , ty : I :: Ty ) -> Self :: Result {
326+ fn visit_ty ( & mut self , ty : Ty < I > ) -> Self :: Result {
325327 let ty = self . infcx . shallow_resolve ( ty) ;
326328 let ty = match ( self . lazily_normalize_ty ) ( ty) {
327329 Ok ( norm_ty) if norm_ty. is_ty_var ( ) => ty,
0 commit comments