Skip to content

Commit f8f4174

Browse files
committed
WIP: Fix breakage due to rust-lang/rust#73503
See rust-lang/rust#73503
1 parent b257e0e commit f8f4174

File tree

4 files changed

+44
-40
lines changed

4 files changed

+44
-40
lines changed

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
nightly-2020-07-23
1+
nightly-2020-07-28

src/translate.rs

+34-32
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,14 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
368368
Binder, OutlivesPredicate, PredicateKind, ProjectionPredicate, ProjectionTy,
369369
SubtypePredicate, ToPredicate, TraitPredicate, WithOptConstParam,
370370
};
371+
use rustc_middle::ty::PredicateAtom;
371372

372-
Some(match predicate.kind() {
373-
PredicateKind::Trait(trait_predicate, constness) => PredicateKind::Trait(
374-
Binder::bind(
373+
Some(match predicate.skip_binders() {
374+
PredicateAtom::Trait(trait_predicate, constness) => PredicateAtom::Trait(
375375
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
376376
index_map,
377-
trait_predicate.skip_binder().trait_ref.def_id,
378-
trait_predicate.skip_binder().trait_ref.substs,
377+
trait_predicate.trait_ref.def_id,
378+
trait_predicate.trait_ref.substs,
379379
) {
380380
TraitPredicate {
381381
trait_ref: TraitRef {
@@ -386,84 +386,86 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
386386
} else {
387387
return None;
388388
},
389-
),
390-
*constness,
389+
constness,
391390
)
392391
.to_predicate(self.tcx),
393-
PredicateKind::RegionOutlives(region_outlives_predicate) => {
394-
PredicateKind::RegionOutlives(region_outlives_predicate.map_bound(|r_pred| {
392+
PredicateAtom::RegionOutlives(region_outlives_predicate) => {
393+
PredicateAtom::RegionOutlives({
394+
let r_pred = region_outlives_predicate;
395395
let l = self.translate_region(r_pred.0);
396396
let r = self.translate_region(r_pred.1);
397397
OutlivesPredicate(l, r)
398-
}))
398+
})
399399
.to_predicate(self.tcx)
400400
}
401-
PredicateKind::TypeOutlives(type_outlives_predicate) => {
402-
PredicateKind::TypeOutlives(type_outlives_predicate.map_bound(|r_pred| {
401+
PredicateAtom::TypeOutlives(type_outlives_predicate) => {
402+
PredicateAtom::TypeOutlives({
403+
let r_pred = type_outlives_predicate;
403404
let l = self.translate(index_map, &r_pred.0);
404405
let r = self.translate_region(r_pred.1);
405406
OutlivesPredicate(l, r)
406-
}))
407+
})
407408
.to_predicate(self.tcx)
408409
}
409-
PredicateKind::Projection(projection_predicate) => {
410-
PredicateKind::Projection(Binder::bind(
410+
PredicateAtom::Projection(projection_predicate) => {
411+
PredicateAtom::Projection(
411412
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
412413
index_map,
413-
projection_predicate.skip_binder().projection_ty.item_def_id,
414-
projection_predicate.skip_binder().projection_ty.substs,
414+
projection_predicate.projection_ty.item_def_id,
415+
projection_predicate.projection_ty.substs,
415416
) {
416417
ProjectionPredicate {
417418
projection_ty: ProjectionTy {
418419
substs: target_substs,
419420
item_def_id: target_def_id,
420421
},
421-
ty: self.translate(index_map, &projection_predicate.skip_binder().ty),
422+
ty: self.translate(index_map, &projection_predicate.ty),
422423
}
423424
} else {
424425
return None;
425426
},
426-
))
427+
)
427428
.to_predicate(self.tcx)
428429
}
429-
PredicateKind::WellFormed(ty) => {
430-
PredicateKind::WellFormed(self.translate(index_map, &ty)).to_predicate(self.tcx)
430+
PredicateAtom::WellFormed(ty) => {
431+
PredicateAtom::WellFormed(self.translate(index_map, &ty)).to_predicate(self.tcx)
431432
}
432-
PredicateKind::ObjectSafe(did) => {
433-
PredicateKind::ObjectSafe(self.translate_orig(*did)).to_predicate(self.tcx)
433+
PredicateAtom::ObjectSafe(did) => {
434+
PredicateAtom::ObjectSafe(self.translate_orig(did)).to_predicate(self.tcx)
434435
}
435-
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
436-
self.translate_orig(*did),
436+
PredicateAtom::ClosureKind(did, substs, kind) => PredicateAtom::ClosureKind(
437+
self.translate_orig(did),
437438
self.translate(index_map, &substs),
438-
*kind,
439+
kind,
439440
)
440441
.to_predicate(self.tcx),
441-
PredicateKind::Subtype(subtype_predicate) => {
442-
PredicateKind::Subtype(subtype_predicate.map_bound(|s_pred| {
442+
PredicateAtom::Subtype(subtype_predicate) => {
443+
PredicateAtom::Subtype({
444+
let s_pred = subtype_predicate;
443445
let l = self.translate(index_map, &s_pred.a);
444446
let r = self.translate(index_map, &s_pred.b);
445447
SubtypePredicate {
446448
a_is_expected: s_pred.a_is_expected,
447449
a: l,
448450
b: r,
449451
}
450-
}))
452+
})
451453
.to_predicate(self.tcx)
452454
}
453-
PredicateKind::ConstEvaluatable(param, orig_substs) => {
455+
PredicateAtom::ConstEvaluatable(param, orig_substs) => {
454456
if let Some((target_def_id, target_substs)) =
455457
self.translate_orig_substs(index_map, param.did, orig_substs)
456458
{
457459
// TODO: We could probably use translated version for
458460
// `WithOptConstParam::const_param_did`
459461
let const_param = WithOptConstParam::unknown(target_def_id);
460-
PredicateKind::ConstEvaluatable(const_param, target_substs)
462+
PredicateAtom::ConstEvaluatable(const_param, target_substs)
461463
.to_predicate(self.tcx)
462464
} else {
463465
return None;
464466
}
465467
}
466-
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
468+
PredicateAtom::ConstEquate(c1, c2) => PredicateAtom::ConstEquate(
467469
self.translate(index_map, &c1),
468470
self.translate(index_map, &c2),
469471
)

src/traverse.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ fn diff_traits<'tcx>(
571571
use rustc_hir::Unsafety::Unsafe;
572572
use rustc_middle::ty::subst::GenericArgKind::Type;
573573
use rustc_middle::ty::{ParamTy, PredicateKind, TyS};
574+
use rustc_middle::ty::PredicateAtom;
574575

575576
debug!(
576577
"diff_traits: old: {:?}, new: {:?}, output: {:?}",
@@ -592,8 +593,8 @@ fn diff_traits<'tcx>(
592593
let old_param_env = tcx.param_env(old);
593594

594595
for bound in old_param_env.caller_bounds() {
595-
if let PredicateKind::Trait(pred, _) = *bound.kind() {
596-
let trait_ref = pred.skip_binder().trait_ref;
596+
if let PredicateAtom::Trait(pred, _) = bound.skip_binders() {
597+
let trait_ref = pred.trait_ref;
597598

598599
debug!("trait_ref substs (old): {:?}", trait_ref.substs);
599600

src/typeck.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_middle::{
1818
error::TypeError,
1919
fold::TypeFoldable,
2020
subst::{GenericArg, InternalSubsts, SubstsRef},
21-
GenericParamDefKind, ParamEnv, Predicate, PredicateKind, ToPredicate, TraitRef, Ty, TyCtxt,
21+
GenericParamDefKind, ParamEnv, Predicate, ToPredicate, TraitRef, Ty, TyCtxt,
2222
},
2323
};
2424
use rustc_trait_selection::traits::FulfillmentContext;
@@ -73,12 +73,13 @@ impl<'a, 'tcx> BoundContext<'a, 'tcx> {
7373
/// Register the trait bound represented by a `TraitRef`.
7474
pub fn register_trait_ref(&mut self, checked_trait_ref: TraitRef<'tcx>) {
7575
use rustc_hir::Constness;
76-
use rustc_middle::ty::{Binder, TraitPredicate};
76+
use rustc_middle::ty::{TraitPredicate};
77+
use rustc_middle::ty::PredicateAtom;
7778

78-
let predicate = PredicateKind::Trait(
79-
Binder::bind(TraitPredicate {
79+
let predicate = PredicateAtom::Trait(
80+
TraitPredicate {
8081
trait_ref: checked_trait_ref,
81-
}),
82+
},
8283
Constness::NotConst,
8384
)
8485
.to_predicate(self.infcx.tcx);

0 commit comments

Comments
 (0)