Skip to content

Commit 034c25f

Browse files
nikomatsakislcnr
authored andcommitted
make to_predicate take a tcx argument
1 parent cad8fe9 commit 034c25f

File tree

22 files changed

+102
-92
lines changed

22 files changed

+102
-92
lines changed

src/librustc_infer/traits/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
3333
cause,
3434
recursion_depth: 0,
3535
param_env,
36-
predicate: trait_ref.without_const().to_predicate(),
36+
predicate: trait_ref.without_const().to_predicate(infcx.tcx),
3737
},
3838
);
3939
}

src/librustc_infer/traits/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ pub fn elaborate_trait_ref<'tcx>(
9999
tcx: TyCtxt<'tcx>,
100100
trait_ref: ty::PolyTraitRef<'tcx>,
101101
) -> Elaborator<'tcx> {
102-
elaborate_predicates(tcx, std::iter::once(trait_ref.without_const().to_predicate()))
102+
elaborate_predicates(tcx, std::iter::once(trait_ref.without_const().to_predicate(tcx)))
103103
}
104104

105105
pub fn elaborate_trait_refs<'tcx>(
106106
tcx: TyCtxt<'tcx>,
107107
trait_refs: impl Iterator<Item = ty::PolyTraitRef<'tcx>>,
108108
) -> Elaborator<'tcx> {
109-
let predicates = trait_refs.map(|trait_ref| trait_ref.without_const().to_predicate());
109+
let predicates = trait_refs.map(|trait_ref| trait_ref.without_const().to_predicate(tcx));
110110
elaborate_predicates(tcx, predicates)
111111
}
112112

src/librustc_middle/ty/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,11 +1295,11 @@ impl<'tcx> ToPolyTraitRef<'tcx> for PolyTraitPredicate<'tcx> {
12951295
}
12961296

12971297
pub trait ToPredicate<'tcx> {
1298-
fn to_predicate(&self) -> Predicate<'tcx>;
1298+
fn to_predicate(&self, tcx: TyCtxt<'tcx>) -> Predicate<'tcx>;
12991299
}
13001300

13011301
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
1302-
fn to_predicate(&self) -> Predicate<'tcx> {
1302+
fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13031303
ty::PredicateKind::Trait(
13041304
ty::Binder::dummy(ty::TraitPredicate { trait_ref: self.value }),
13051305
self.constness,
@@ -1308,7 +1308,7 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<TraitRef<'tcx>> {
13081308
}
13091309

13101310
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&TraitRef<'tcx>> {
1311-
fn to_predicate(&self) -> Predicate<'tcx> {
1311+
fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13121312
ty::PredicateKind::Trait(
13131313
ty::Binder::dummy(ty::TraitPredicate { trait_ref: *self.value }),
13141314
self.constness,
@@ -1317,31 +1317,31 @@ impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&TraitRef<'tcx>> {
13171317
}
13181318

13191319
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<PolyTraitRef<'tcx>> {
1320-
fn to_predicate(&self) -> Predicate<'tcx> {
1320+
fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13211321
ty::PredicateKind::Trait(self.value.to_poly_trait_predicate(), self.constness)
13221322
}
13231323
}
13241324

13251325
impl<'tcx> ToPredicate<'tcx> for ConstnessAnd<&PolyTraitRef<'tcx>> {
1326-
fn to_predicate(&self) -> Predicate<'tcx> {
1326+
fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13271327
ty::PredicateKind::Trait(self.value.to_poly_trait_predicate(), self.constness)
13281328
}
13291329
}
13301330

13311331
impl<'tcx> ToPredicate<'tcx> for PolyRegionOutlivesPredicate<'tcx> {
1332-
fn to_predicate(&self) -> Predicate<'tcx> {
1332+
fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13331333
PredicateKind::RegionOutlives(*self)
13341334
}
13351335
}
13361336

13371337
impl<'tcx> ToPredicate<'tcx> for PolyTypeOutlivesPredicate<'tcx> {
1338-
fn to_predicate(&self) -> Predicate<'tcx> {
1338+
fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13391339
PredicateKind::TypeOutlives(*self)
13401340
}
13411341
}
13421342

13431343
impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
1344-
fn to_predicate(&self) -> Predicate<'tcx> {
1344+
fn to_predicate(&self, _tcx: TyCtxt<'tcx>) -> Predicate<'tcx> {
13451345
PredicateKind::Projection(*self)
13461346
}
13471347
}
@@ -1619,7 +1619,7 @@ pub struct ConstnessAnd<T> {
16191619
pub value: T,
16201620
}
16211621

1622-
// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate()` to ensure that
1622+
// FIXME(ecstaticmorse): Audit all occurrences of `without_const().to_predicate(tcx)` to ensure that
16231623
// the constness of trait bounds is being propagated correctly.
16241624
pub trait WithConstness: Sized {
16251625
#[inline]

src/librustc_middle/ty/sty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,15 +612,15 @@ impl<'tcx> Binder<ExistentialPredicate<'tcx>> {
612612
use crate::ty::ToPredicate;
613613
match *self.skip_binder() {
614614
ExistentialPredicate::Trait(tr) => {
615-
Binder(tr).with_self_ty(tcx, self_ty).without_const().to_predicate()
615+
Binder(tr).with_self_ty(tcx, self_ty).without_const().to_predicate(tcx)
616616
}
617617
ExistentialPredicate::Projection(p) => {
618618
ty::PredicateKind::Projection(Binder(p.with_self_ty(tcx, self_ty)))
619619
}
620620
ExistentialPredicate::AutoTrait(did) => {
621621
let trait_ref =
622622
Binder(ty::TraitRef { def_id: did, substs: tcx.mk_substs_trait(self_ty, &[]) });
623-
trait_ref.without_const().to_predicate()
623+
trait_ref.without_const().to_predicate(tcx)
624624
}
625625
}
626626
}

src/librustc_trait_selection/traits/error_reporting/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
308308
"{}",
309309
message.unwrap_or_else(|| format!(
310310
"the trait bound `{}` is not satisfied{}",
311-
trait_ref.without_const().to_predicate(),
311+
trait_ref.without_const().to_predicate(tcx),
312312
post_message,
313313
))
314314
);
@@ -1021,13 +1021,13 @@ trait InferCtxtPrivExt<'tcx> {
10211021

10221022
fn note_obligation_cause(
10231023
&self,
1024-
err: &mut DiagnosticBuilder<'_>,
1024+
err: &mut DiagnosticBuilder<'tcx>,
10251025
obligation: &PredicateObligation<'tcx>,
10261026
);
10271027

10281028
fn suggest_unsized_bound_if_applicable(
10291029
&self,
1030-
err: &mut DiagnosticBuilder<'_>,
1030+
err: &mut DiagnosticBuilder<'tcx>,
10311031
obligation: &PredicateObligation<'tcx>,
10321032
);
10331033

@@ -1390,7 +1390,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
13901390
) -> PredicateObligation<'tcx> {
13911391
let new_trait_ref =
13921392
ty::TraitRef { def_id, substs: self.tcx.mk_substs_trait(output_ty, &[]) };
1393-
Obligation::new(cause, param_env, new_trait_ref.without_const().to_predicate())
1393+
Obligation::new(cause, param_env, new_trait_ref.without_const().to_predicate(self.tcx))
13941394
}
13951395

13961396
fn maybe_report_ambiguity(
@@ -1629,7 +1629,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
16291629
let obligation = Obligation::new(
16301630
ObligationCause::dummy(),
16311631
param_env,
1632-
cleaned_pred.without_const().to_predicate(),
1632+
cleaned_pred.without_const().to_predicate(selcx.tcx()),
16331633
);
16341634

16351635
self.predicate_may_hold(&obligation)
@@ -1638,7 +1638,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
16381638

16391639
fn note_obligation_cause(
16401640
&self,
1641-
err: &mut DiagnosticBuilder<'_>,
1641+
err: &mut DiagnosticBuilder<'tcx>,
16421642
obligation: &PredicateObligation<'tcx>,
16431643
) {
16441644
// First, attempt to add note to this error with an async-await-specific
@@ -1656,7 +1656,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
16561656

16571657
fn suggest_unsized_bound_if_applicable(
16581658
&self,
1659-
err: &mut DiagnosticBuilder<'_>,
1659+
err: &mut DiagnosticBuilder<'tcx>,
16601660
obligation: &PredicateObligation<'tcx>,
16611661
) {
16621662
if let (

0 commit comments

Comments
 (0)