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