@@ -149,7 +149,6 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
149
149
polarity,
150
150
param_ty,
151
151
bounds,
152
- false ,
153
152
only_self_bounds,
154
153
) ;
155
154
}
@@ -231,14 +230,13 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
231
230
/// **A note on binders:** given something like `T: for<'a> Iterator<Item = &'a u32>`, the
232
231
/// `trait_ref` here will be `for<'a> T: Iterator`. The `binding` data however is from *inside*
233
232
/// the binder (e.g., `&'a u32`) and hence may reference bound regions.
234
- #[ instrument( level = "debug" , skip( self , bounds, speculative , dup_bindings, path_span) ) ]
233
+ #[ instrument( level = "debug" , skip( self , bounds, dup_bindings, path_span) ) ]
235
234
pub ( super ) fn add_predicates_for_ast_type_binding (
236
235
& self ,
237
236
hir_ref_id : hir:: HirId ,
238
237
trait_ref : ty:: PolyTraitRef < ' tcx > ,
239
238
binding : & hir:: TypeBinding < ' tcx > ,
240
239
bounds : & mut Bounds < ' tcx > ,
241
- speculative : bool ,
242
240
dup_bindings : & mut FxIndexMap < DefId , Span > ,
243
241
path_span : Span ,
244
242
only_self_bounds : OnlySelfBounds ,
@@ -317,19 +315,17 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
317
315
}
318
316
tcx. check_stability ( assoc_item. def_id , Some ( hir_ref_id) , binding. span , None ) ;
319
317
320
- if !speculative {
321
- dup_bindings
322
- . entry ( assoc_item. def_id )
323
- . and_modify ( |prev_span| {
324
- tcx. dcx ( ) . emit_err ( errors:: ValueOfAssociatedStructAlreadySpecified {
325
- span : binding. span ,
326
- prev_span : * prev_span,
327
- item_name : binding. ident ,
328
- def_path : tcx. def_path_str ( assoc_item. container_id ( tcx) ) ,
329
- } ) ;
330
- } )
331
- . or_insert ( binding. span ) ;
332
- }
318
+ dup_bindings
319
+ . entry ( assoc_item. def_id )
320
+ . and_modify ( |prev_span| {
321
+ tcx. dcx ( ) . emit_err ( errors:: ValueOfAssociatedStructAlreadySpecified {
322
+ span : binding. span ,
323
+ prev_span : * prev_span,
324
+ item_name : binding. ident ,
325
+ def_path : tcx. def_path_str ( assoc_item. container_id ( tcx) ) ,
326
+ } ) ;
327
+ } )
328
+ . or_insert ( binding. span ) ;
333
329
334
330
let projection_ty = if let ty:: AssocKind :: Fn = assoc_kind {
335
331
let mut emitted_bad_param_err = None ;
@@ -433,9 +429,8 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
433
429
} ) ;
434
430
435
431
// Provide the resolved type of the associated constant to `type_of(AnonConst)`.
436
- if !speculative
437
- && let hir:: TypeBindingKind :: Equality { term : hir:: Term :: Const ( anon_const) } =
438
- binding. kind
432
+ if let hir:: TypeBindingKind :: Equality { term : hir:: Term :: Const ( anon_const) } =
433
+ binding. kind
439
434
{
440
435
let ty = alias_ty. map_bound ( |ty| tcx. type_of ( ty. def_id ) . instantiate ( tcx, ty. args ) ) ;
441
436
// Since the arguments passed to the alias type above may contain early-bound
@@ -463,42 +458,40 @@ impl<'tcx> dyn AstConv<'tcx> + '_ {
463
458
hir:: Term :: Const ( ct) => ty:: Const :: from_anon_const ( tcx, ct. def_id ) . into ( ) ,
464
459
} ;
465
460
466
- if !speculative {
467
- // Find any late-bound regions declared in `ty` that are not
468
- // declared in the trait-ref or assoc_item. These are not well-formed.
469
- //
470
- // Example:
471
- //
472
- // for<'a> <T as Iterator>::Item = &'a str // <-- 'a is bad
473
- // for<'a> <T as FnMut<(&'a u32,)>>::Output = &'a str // <-- 'a is ok
474
- let late_bound_in_projection_ty =
475
- tcx. collect_constrained_late_bound_regions ( projection_ty) ;
476
- let late_bound_in_term =
477
- tcx. collect_referenced_late_bound_regions ( trait_ref. rebind ( term) ) ;
478
- debug ! ( ?late_bound_in_projection_ty) ;
479
- debug ! ( ?late_bound_in_term) ;
461
+ // Find any late-bound regions declared in `ty` that are not
462
+ // declared in the trait-ref or assoc_item. These are not well-formed.
463
+ //
464
+ // Example:
465
+ //
466
+ // for<'a> <T as Iterator>::Item = &'a str // <-- 'a is bad
467
+ // for<'a> <T as FnMut<(&'a u32,)>>::Output = &'a str // <-- 'a is ok
468
+ let late_bound_in_projection_ty =
469
+ tcx. collect_constrained_late_bound_regions ( projection_ty) ;
470
+ let late_bound_in_term =
471
+ tcx. collect_referenced_late_bound_regions ( trait_ref. rebind ( term) ) ;
472
+ debug ! ( ?late_bound_in_projection_ty) ;
473
+ debug ! ( ?late_bound_in_term) ;
480
474
481
- // FIXME: point at the type params that don't have appropriate lifetimes:
482
- // struct S1<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
483
- // ---- ---- ^^^^^^^
484
- // NOTE(associated_const_equality): This error should be impossible to trigger
485
- // with associated const equality bounds.
486
- self . validate_late_bound_regions (
487
- late_bound_in_projection_ty,
488
- late_bound_in_term,
489
- |br_name| {
490
- struct_span_code_err ! (
491
- tcx. dcx( ) ,
492
- binding. span,
493
- E0582 ,
494
- "binding for associated type `{}` references {}, \
495
- which does not appear in the trait input types",
496
- binding. ident,
497
- br_name
498
- )
499
- } ,
500
- ) ;
501
- }
475
+ // FIXME: point at the type params that don't have appropriate lifetimes:
476
+ // struct S1<F: for<'a> Fn(&i32, &i32) -> &'a i32>(F);
477
+ // ---- ---- ^^^^^^^
478
+ // NOTE(associated_const_equality): This error should be impossible to trigger
479
+ // with associated const equality bounds.
480
+ self . validate_late_bound_regions (
481
+ late_bound_in_projection_ty,
482
+ late_bound_in_term,
483
+ |br_name| {
484
+ struct_span_code_err ! (
485
+ tcx. dcx( ) ,
486
+ binding. span,
487
+ E0582 ,
488
+ "binding for associated type `{}` references {}, \
489
+ which does not appear in the trait input types",
490
+ binding. ident,
491
+ br_name
492
+ )
493
+ } ,
494
+ ) ;
502
495
503
496
// "Desugar" a constraint like `T: Iterator<Item = u32>` this to
504
497
// the "projection predicate" for:
0 commit comments