@@ -404,7 +404,7 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
404
404
let bound_vars = tcx. late_bound_vars ( binding. hir_id ) ;
405
405
ty:: Binder :: bind_with_vars ( subst_output, bound_vars)
406
406
} else {
407
- // Append the generic arguments of the associated type to the `trait_ref`.
407
+ // Append the generic arguments of the associated type or const to the `trait_ref`.
408
408
candidate. map_bound ( |trait_ref| {
409
409
let ident = Ident :: new ( assoc_item. name , binding. item_name . span ) ;
410
410
let item_segment = hir:: PathSegment {
@@ -415,19 +415,24 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
415
415
infer_args : false ,
416
416
} ;
417
417
418
- let args_trait_ref_and_assoc_item = self . create_args_for_associated_item (
418
+ let alias_args = self . create_args_for_associated_item (
419
419
path_span,
420
420
assoc_item. def_id ,
421
421
& item_segment,
422
422
trait_ref. args ,
423
423
) ;
424
+ debug ! ( ?alias_args) ;
424
425
425
- debug ! ( ?args_trait_ref_and_assoc_item) ;
426
-
427
- ty:: AliasTy :: new ( tcx, assoc_item. def_id , args_trait_ref_and_assoc_item)
426
+ // Note that we're indeed also using `AliasTy` (alias *type*) for associated
427
+ // *constants* to represent *const projections*. Alias *term* would be a more
428
+ // appropriate name but alas.
429
+ ty:: AliasTy :: new ( tcx, assoc_item. def_id , alias_args)
428
430
} )
429
431
} ;
430
432
433
+ // FIXME(fmease): This doesn't check actually seem to work for assoc consts.
434
+ // We want to deny escaping late-bound vars in general anyways for assoc consts.
435
+ // If the diagnostic *is* reachable, update it (“type” → “term” or similar).
431
436
if !speculative {
432
437
// Find any late-bound regions declared in `ty` that are not
433
438
// declared in the trait-ref or assoc_item. These are not well-formed.
@@ -436,20 +441,20 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
436
441
//
437
442
// for<'a> <T as Iterator>::Item = &'a str // <-- 'a is bad
438
443
// for<'a> <T as FnMut<(&'a u32,)>>::Output = &'a str // <-- 'a is ok
439
- if let ConvertedBindingKind :: Equality ( ty ) = binding. kind {
440
- let late_bound_in_trait_ref =
444
+ if let ConvertedBindingKind :: Equality ( term ) = binding. kind {
445
+ let late_bound_in_projection_ty =
441
446
tcx. collect_constrained_late_bound_regions ( & projection_ty) ;
442
- let late_bound_in_ty =
443
- tcx. collect_referenced_late_bound_regions ( & trait_ref. rebind ( ty . node ) ) ;
444
- debug ! ( ?late_bound_in_trait_ref ) ;
445
- debug ! ( ?late_bound_in_ty ) ;
447
+ let late_bound_in_term =
448
+ tcx. collect_referenced_late_bound_regions ( & trait_ref. rebind ( term . node ) ) ;
449
+ debug ! ( ?late_bound_in_projection_ty ) ;
450
+ debug ! ( ?late_bound_in_term ) ;
446
451
447
452
// FIXME: point at the type params that don't have appropriate lifetimes:
448
453
// struct S1<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
449
454
// ---- ---- ^^^^^^^
450
455
self . validate_late_bound_regions (
451
- late_bound_in_trait_ref ,
452
- late_bound_in_ty ,
456
+ late_bound_in_projection_ty ,
457
+ late_bound_in_term ,
453
458
|br_name| {
454
459
struct_span_err ! (
455
460
tcx. dcx( ) ,
0 commit comments