@@ -83,15 +83,15 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
8383
8484 for trait_projection in collector. types . into_iter ( ) . rev ( ) {
8585 let impl_opaque_args = trait_projection. args . rebase_onto ( tcx, trait_m. def_id , impl_m_args) ;
86- let hidden_ty = hidden_tys[ & trait_projection. kind . def_id ( ) ]
87- . instantiate ( tcx, impl_opaque_args)
88- . skip_norm_wip ( ) ;
86+ let hidden_ty =
87+ hidden_tys[ & trait_projection. kind ] . instantiate ( tcx, impl_opaque_args) . skip_norm_wip ( ) ;
8988
9089 // If the hidden type is not an opaque, then we have "refined" the trait signature.
91- let ty:: Alias (
92- impl_opaque @ ty:: AliasTy { kind : ty:: Opaque { def_id : impl_opaque_def_id } , .. } ,
93- ) = * hidden_ty. kind ( )
94- else {
90+ let impl_opaque = if let ty:: Alias ( alias) = * hidden_ty. kind ( )
91+ && let Some ( impl_opaque) = alias. try_to_opaque ( )
92+ {
93+ impl_opaque
94+ } else {
9595 report_mismatched_rpitit_signature (
9696 tcx,
9797 trait_m_sig_with_self_for_diag,
@@ -105,7 +105,7 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
105105
106106 // This opaque also needs to be from the impl method -- otherwise,
107107 // it's a refinement to a TAIT.
108- if !tcx. hir_get_if_local ( impl_opaque_def_id ) . is_some_and ( |node| {
108+ if !tcx. hir_get_if_local ( impl_opaque . kind ) . is_some_and ( |node| {
109109 matches ! (
110110 node. expect_opaque_ty( ) . origin,
111111 hir:: OpaqueTyOrigin :: AsyncFn { parent, .. } | hir:: OpaqueTyOrigin :: FnReturn { parent, .. }
@@ -124,13 +124,13 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
124124 }
125125
126126 trait_bounds. extend (
127- tcx. item_bounds ( trait_projection. kind . def_id ( ) )
127+ tcx. item_bounds ( trait_projection. kind )
128128 . iter_instantiated ( tcx, trait_projection. args )
129129 . map ( Unnormalized :: skip_norm_wip) ,
130130 ) ;
131131 impl_bounds. extend ( elaborate (
132132 tcx,
133- tcx. explicit_item_bounds ( impl_opaque_def_id )
133+ tcx. explicit_item_bounds ( impl_opaque . kind )
134134 . iter_instantiated_copied ( tcx, impl_opaque. args )
135135 . map ( Unnormalized :: skip_norm_wip) ,
136136 ) ) ;
@@ -231,7 +231,7 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
231231 // is literally unrepresentable in the type system; however, we may be
232232 // promising stronger outlives guarantees if we capture *fewer* regions.
233233 for ( trait_projection, impl_opaque) in pairs {
234- let impl_variances = tcx. variances_of ( impl_opaque. kind . def_id ( ) ) ;
234+ let impl_variances = tcx. variances_of ( impl_opaque. kind ) ;
235235 let impl_captures: FxIndexSet < _ > = impl_opaque
236236 . args
237237 . iter ( )
@@ -240,7 +240,7 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
240240 . map ( |( arg, _) | arg)
241241 . collect ( ) ;
242242
243- let trait_variances = tcx. variances_of ( trait_projection. kind . def_id ( ) ) ;
243+ let trait_variances = tcx. variances_of ( trait_projection. kind ) ;
244244 let mut trait_captures = FxIndexSet :: default ( ) ;
245245 for ( arg, variance) in trait_projection. args . iter ( ) . zip_eq ( trait_variances) {
246246 if * variance != ty:: Invariant {
@@ -252,7 +252,7 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
252252 if !trait_captures. iter ( ) . all ( |arg| impl_captures. contains ( arg) ) {
253253 report_mismatched_rpitit_captures (
254254 tcx,
255- impl_opaque. kind . def_id ( ) . expect_local ( ) ,
255+ impl_opaque. kind . expect_local ( ) ,
256256 trait_captures,
257257 is_internal,
258258 ) ;
@@ -262,18 +262,19 @@ pub(crate) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
262262
263263struct ImplTraitInTraitCollector < ' tcx > {
264264 tcx : TyCtxt < ' tcx > ,
265- types : FxIndexSet < ty:: AliasTy < ' tcx > > ,
265+ types : FxIndexSet < ty:: ProjectionAliasTy < ' tcx > > ,
266266}
267267
268268impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for ImplTraitInTraitCollector < ' tcx > {
269269 fn visit_ty ( & mut self , ty : Ty < ' tcx > ) {
270- if let ty:: Alias ( proj @ ty:: AliasTy { kind : ty:: Projection { def_id } , .. } ) = * ty. kind ( )
271- && self . tcx . is_impl_trait_in_trait ( def_id)
270+ if let ty:: Alias ( alias) = * ty. kind ( )
271+ && let Some ( proj) = alias. try_to_projection ( )
272+ && self . tcx . is_impl_trait_in_trait ( proj. kind )
272273 {
273274 if self . types . insert ( proj) {
274275 for ( pred, _) in self
275276 . tcx
276- . explicit_item_bounds ( def_id )
277+ . explicit_item_bounds ( proj . kind )
277278 . iter_instantiated_copied ( self . tcx , proj. args )
278279 . map ( Unnormalized :: skip_norm_wip)
279280 {
0 commit comments