@@ -4,7 +4,7 @@ use rustc_hir::def::DefKind;
4
4
use rustc_hir:: def_id:: { DefId , DefIdMap , LocalDefId } ;
5
5
use rustc_hir:: intravisit:: { self , Visitor } ;
6
6
use rustc_middle:: query:: Providers ;
7
- use rustc_middle:: ty:: { self , GenericArgs , ImplTraitInTraitData , Ty , TyCtxt } ;
7
+ use rustc_middle:: ty:: { self , ImplTraitInTraitData , TyCtxt } ;
8
8
use rustc_span:: symbol:: kw;
9
9
10
10
pub ( crate ) fn provide ( providers : & mut Providers ) {
@@ -284,48 +284,8 @@ fn associated_type_for_impl_trait_in_trait(
284
284
// Copy defaultness of the containing function.
285
285
trait_assoc_ty. defaultness ( tcx. defaultness ( fn_def_id) ) ;
286
286
287
- // Copy type_of of the opaque.
288
- trait_assoc_ty. type_of ( ty:: EarlyBinder :: bind ( Ty :: new_opaque (
289
- tcx,
290
- opaque_ty_def_id. to_def_id ( ) ,
291
- GenericArgs :: identity_for_item ( tcx, opaque_ty_def_id) ,
292
- ) ) ) ;
293
-
294
287
trait_assoc_ty. is_type_alias_impl_trait ( false ) ;
295
288
296
- // Copy generics_of of the opaque type item but the trait is the parent.
297
- trait_assoc_ty. generics_of ( {
298
- let opaque_ty_generics = tcx. generics_of ( opaque_ty_def_id) ;
299
- let opaque_ty_parent_count = opaque_ty_generics. parent_count ;
300
- let mut params = opaque_ty_generics. params . clone ( ) ;
301
-
302
- let parent_generics = tcx. generics_of ( trait_def_id) ;
303
- let parent_count = parent_generics. parent_count + parent_generics. params . len ( ) ;
304
-
305
- let mut trait_fn_params = tcx. generics_of ( fn_def_id) . params . clone ( ) ;
306
-
307
- for param in & mut params {
308
- param. index = param. index + parent_count as u32 + trait_fn_params. len ( ) as u32
309
- - opaque_ty_parent_count as u32 ;
310
- }
311
-
312
- trait_fn_params. extend ( params) ;
313
- params = trait_fn_params;
314
-
315
- let param_def_id_to_index =
316
- params. iter ( ) . map ( |param| ( param. def_id , param. index ) ) . collect ( ) ;
317
-
318
- ty:: Generics {
319
- parent : Some ( trait_def_id. to_def_id ( ) ) ,
320
- parent_count,
321
- params,
322
- param_def_id_to_index,
323
- has_self : opaque_ty_generics. has_self ,
324
- has_late_bound_regions : opaque_ty_generics. has_late_bound_regions ,
325
- host_effect_index : parent_generics. host_effect_index ,
326
- }
327
- } ) ;
328
-
329
289
// There are no inferred outlives for the synthesized associated type.
330
290
trait_assoc_ty. inferred_outlives_of ( & [ ] ) ;
331
291
@@ -382,8 +342,9 @@ fn associated_type_for_impl_trait_in_impl(
382
342
impl_assoc_ty. defaultness ( tcx. defaultness ( impl_fn_def_id) ) ;
383
343
384
344
// Copy generics_of the trait's associated item but the impl as the parent.
385
- // FIXME(-Zlower-impl-trait-in-trait-to-assoc-ty) resolves to the trait instead of the impl
386
- // generics.
345
+ // FIXME: This may be detrimental to diagnostics, as we resolve the early-bound vars
346
+ // here to paramswhose parent are items in the trait. We could synthesize new params
347
+ // here, but it seems overkill.
387
348
impl_assoc_ty. generics_of ( {
388
349
let trait_assoc_generics = tcx. generics_of ( trait_assoc_def_id) ;
389
350
let trait_assoc_parent_count = trait_assoc_generics. parent_count ;
0 commit comments