@@ -76,7 +76,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
76
76
}
77
77
78
78
if unbounds. len ( ) > 1 {
79
- tcx . dcx ( ) . emit_err ( errors:: MultipleRelaxedDefaultBounds {
79
+ self . dcx ( ) . emit_err ( errors:: MultipleRelaxedDefaultBounds {
80
80
spans : unbounds. iter ( ) . map ( |ptr| ptr. span ) . collect ( ) ,
81
81
} ) ;
82
82
}
@@ -90,7 +90,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
90
90
continue ;
91
91
}
92
92
// There was a `?Trait` bound, but it was not `?Sized`; warn.
93
- tcx . dcx ( ) . span_warn (
93
+ self . dcx ( ) . span_warn (
94
94
unbound. span ,
95
95
"relaxing a default bound only does something for `?Sized`; \
96
96
all other traits are not bound by default",
@@ -310,7 +310,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
310
310
duplicates
311
311
. entry ( assoc_item. def_id )
312
312
. and_modify ( |prev_span| {
313
- tcx . dcx ( ) . emit_err ( errors:: ValueOfAssociatedStructAlreadySpecified {
313
+ self . dcx ( ) . emit_err ( errors:: ValueOfAssociatedStructAlreadySpecified {
314
314
span : constraint. span ,
315
315
prev_span : * prev_span,
316
316
item_name : constraint. ident ,
@@ -338,7 +338,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
338
338
. into ( ) ,
339
339
ty:: GenericParamDefKind :: Type { .. } => {
340
340
let guar = * emitted_bad_param_err. get_or_insert_with ( || {
341
- tcx . dcx ( ) . emit_err (
341
+ self . dcx ( ) . emit_err (
342
342
crate :: errors:: ReturnTypeNotationIllegalParam :: Type {
343
343
span : path_span,
344
344
param_span : tcx. def_span ( param. def_id ) ,
@@ -349,7 +349,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
349
349
}
350
350
ty:: GenericParamDefKind :: Const { .. } => {
351
351
let guar = * emitted_bad_param_err. get_or_insert_with ( || {
352
- tcx . dcx ( ) . emit_err (
352
+ self . dcx ( ) . emit_err (
353
353
crate :: errors:: ReturnTypeNotationIllegalParam :: Const {
354
354
span : path_span,
355
355
param_span : tcx. def_span ( param. def_id ) ,
@@ -371,7 +371,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
371
371
{
372
372
alias_ty. into ( )
373
373
} else {
374
- return Err ( tcx . dcx ( ) . emit_err ( crate :: errors:: ReturnTypeNotationOnNonRpitit {
374
+ return Err ( self . dcx ( ) . emit_err ( crate :: errors:: ReturnTypeNotationOnNonRpitit {
375
375
span : constraint. span ,
376
376
ty : tcx. liberate_late_bound_regions ( assoc_item. def_id , output) ,
377
377
fn_span : tcx. hir ( ) . span_if_local ( assoc_item. def_id ) ,
@@ -417,7 +417,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
417
417
let ty = alias_term
418
418
. map_bound ( |alias| tcx. type_of ( alias. def_id ) . instantiate ( tcx, alias. args ) ) ;
419
419
let ty =
420
- check_assoc_const_binding_type ( tcx , constraint. ident , ty, constraint. hir_id ) ;
420
+ check_assoc_const_binding_type ( self , constraint. ident , ty, constraint. hir_id ) ;
421
421
tcx. feed_anon_const_type ( anon_const. def_id , ty:: EarlyBinder :: bind ( ty) ) ;
422
422
}
423
423
@@ -426,7 +426,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
426
426
427
427
match constraint. kind {
428
428
hir:: AssocItemConstraintKind :: Equality { .. } if let ty:: AssocKind :: Fn = assoc_kind => {
429
- return Err ( tcx . dcx ( ) . emit_err ( crate :: errors:: ReturnTypeNotationEqualityBound {
429
+ return Err ( self . dcx ( ) . emit_err ( crate :: errors:: ReturnTypeNotationEqualityBound {
430
430
span : constraint. span ,
431
431
} ) ) ;
432
432
}
@@ -462,7 +462,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
462
462
late_bound_in_term,
463
463
|br_name| {
464
464
struct_span_code_err ! (
465
- tcx . dcx( ) ,
465
+ self . dcx( ) ,
466
466
constraint. span,
467
467
E0582 ,
468
468
"binding for associated type `{}` references {}, \
@@ -519,7 +519,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
519
519
///
520
520
/// [^1]: <https://github.com/rust-lang/project-const-generics/issues/28>.
521
521
fn check_assoc_const_binding_type < ' tcx > (
522
- tcx : TyCtxt < ' tcx > ,
522
+ cx : & dyn HirTyLowerer < ' tcx > ,
523
523
assoc_const : Ident ,
524
524
ty : ty:: Binder < ' tcx , Ty < ' tcx > > ,
525
525
hir_id : hir:: HirId ,
@@ -536,13 +536,14 @@ fn check_assoc_const_binding_type<'tcx>(
536
536
}
537
537
538
538
let mut collector = GenericParamAndBoundVarCollector {
539
- tcx ,
539
+ cx ,
540
540
params : Default :: default ( ) ,
541
541
vars : Default :: default ( ) ,
542
542
depth : ty:: INNERMOST ,
543
543
} ;
544
544
let mut guar = ty. visit_with ( & mut collector) . break_value ( ) ;
545
545
546
+ let tcx = cx. tcx ( ) ;
546
547
let ty_note = ty
547
548
. make_suggestable ( tcx, false , None )
548
549
. map ( |ty| crate :: errors:: TyOfAssocConstBindingNote { assoc_const, ty } ) ;
@@ -556,7 +557,7 @@ fn check_assoc_const_binding_type<'tcx>(
556
557
for index in collector. params {
557
558
let param = generics. param_at ( index as _ , tcx) ;
558
559
let is_self_param = param. name == rustc_span:: symbol:: kw:: SelfUpper ;
559
- guar. get_or_insert ( tcx . dcx ( ) . emit_err ( crate :: errors:: ParamInTyOfAssocConstBinding {
560
+ guar. get_or_insert ( cx . dcx ( ) . emit_err ( crate :: errors:: ParamInTyOfAssocConstBinding {
560
561
span : assoc_const. span ,
561
562
assoc_const,
562
563
param_name : param. name ,
@@ -574,7 +575,7 @@ fn check_assoc_const_binding_type<'tcx>(
574
575
} ) ) ;
575
576
}
576
577
for ( var_def_id, var_name) in collector. vars {
577
- guar. get_or_insert ( tcx . dcx ( ) . emit_err (
578
+ guar. get_or_insert ( cx . dcx ( ) . emit_err (
578
579
crate :: errors:: EscapingBoundVarInTyOfAssocConstBinding {
579
580
span : assoc_const. span ,
580
581
assoc_const,
@@ -590,14 +591,14 @@ fn check_assoc_const_binding_type<'tcx>(
590
591
Ty :: new_error ( tcx, guar)
591
592
}
592
593
593
- struct GenericParamAndBoundVarCollector < ' tcx > {
594
- tcx : TyCtxt < ' tcx > ,
594
+ struct GenericParamAndBoundVarCollector < ' a , ' tcx > {
595
+ cx : & ' a dyn HirTyLowerer < ' tcx > ,
595
596
params : FxIndexSet < u32 > ,
596
597
vars : FxIndexSet < ( DefId , Symbol ) > ,
597
598
depth : ty:: DebruijnIndex ,
598
599
}
599
600
600
- impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for GenericParamAndBoundVarCollector < ' tcx > {
601
+ impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for GenericParamAndBoundVarCollector < ' _ , ' tcx > {
601
602
type Result = ControlFlow < ErrorGuaranteed > ;
602
603
603
604
fn visit_binder < T : TypeVisitable < TyCtxt < ' tcx > > > (
@@ -620,7 +621,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GenericParamAndBoundVarCollector<'tcx>
620
621
ty:: BoundTyKind :: Param ( def_id, name) => ( def_id, name) ,
621
622
ty:: BoundTyKind :: Anon => {
622
623
let reported = self
623
- . tcx
624
+ . cx
624
625
. dcx ( )
625
626
. delayed_bug ( format ! ( "unexpected anon bound ty: {:?}" , bt. var) ) ;
626
627
return ControlFlow :: Break ( reported) ;
@@ -643,7 +644,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GenericParamAndBoundVarCollector<'tcx>
643
644
ty:: BrNamed ( def_id, name) => ( def_id, name) ,
644
645
ty:: BrAnon | ty:: BrEnv => {
645
646
let guar = self
646
- . tcx
647
+ . cx
647
648
. dcx ( )
648
649
. delayed_bug ( format ! ( "unexpected bound region kind: {:?}" , br. kind) ) ;
649
650
return ControlFlow :: Break ( guar) ;
@@ -661,7 +662,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GenericParamAndBoundVarCollector<'tcx>
661
662
self . params . insert ( param. index ) ;
662
663
}
663
664
ty:: ConstKind :: Bound ( db, ty:: BoundVar { .. } ) if db >= self . depth => {
664
- let guar = self . tcx . dcx ( ) . delayed_bug ( "unexpected escaping late-bound const var" ) ;
665
+ let guar = self . cx . dcx ( ) . delayed_bug ( "unexpected escaping late-bound const var" ) ;
665
666
return ControlFlow :: Break ( guar) ;
666
667
}
667
668
_ if ct. has_param ( ) || ct. has_bound_vars ( ) => return ct. super_visit_with ( self ) ,
0 commit comments