Skip to content

Commit

Permalink
Fix breakage due to rust-lang/rust#73503
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok committed Nov 18, 2020
1 parent ea2137c commit 0438c49
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 41 deletions.
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2020-07-23
nightly-2020-07-28
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Needs a nightly feature, doesn't bring that much to the table
// FIXME: Apply Clippy lint once or-patterns are stabilized (rust-lang/rust#54883)
#![allow(clippy::unnested_or_patterns)]
#![deny(warnings)]
// #![deny(warnings)]

extern crate rustc_hir;
extern crate rustc_infer;
Expand Down
66 changes: 34 additions & 32 deletions src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,14 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
Binder, OutlivesPredicate, PredicateKind, ProjectionPredicate, ProjectionTy,
SubtypePredicate, ToPredicate, TraitPredicate, WithOptConstParam,
};
use rustc_middle::ty::PredicateAtom;

Some(match predicate.kind() {
PredicateKind::Trait(trait_predicate, constness) => PredicateKind::Trait(
Binder::bind(
Some(match predicate.skip_binders() {
PredicateAtom::Trait(trait_predicate, constness) => PredicateAtom::Trait(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
trait_predicate.skip_binder().trait_ref.def_id,
trait_predicate.skip_binder().trait_ref.substs,
trait_predicate.trait_ref.def_id,
trait_predicate.trait_ref.substs,
) {
TraitPredicate {
trait_ref: TraitRef {
Expand All @@ -386,84 +386,86 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
} else {
return None;
},
),
*constness,
constness,
)
.to_predicate(self.tcx),
PredicateKind::RegionOutlives(region_outlives_predicate) => {
PredicateKind::RegionOutlives(region_outlives_predicate.map_bound(|r_pred| {
PredicateAtom::RegionOutlives(region_outlives_predicate) => {
PredicateAtom::RegionOutlives({
let r_pred = region_outlives_predicate;
let l = self.translate_region(r_pred.0);
let r = self.translate_region(r_pred.1);
OutlivesPredicate(l, r)
}))
})
.to_predicate(self.tcx)
}
PredicateKind::TypeOutlives(type_outlives_predicate) => {
PredicateKind::TypeOutlives(type_outlives_predicate.map_bound(|r_pred| {
PredicateAtom::TypeOutlives(type_outlives_predicate) => {
PredicateAtom::TypeOutlives({
let r_pred = type_outlives_predicate;
let l = self.translate(index_map, &r_pred.0);
let r = self.translate_region(r_pred.1);
OutlivesPredicate(l, r)
}))
})
.to_predicate(self.tcx)
}
PredicateKind::Projection(projection_predicate) => {
PredicateKind::Projection(Binder::bind(
PredicateAtom::Projection(projection_predicate) => {
PredicateAtom::Projection(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
projection_predicate.skip_binder().projection_ty.item_def_id,
projection_predicate.skip_binder().projection_ty.substs,
projection_predicate.projection_ty.item_def_id,
projection_predicate.projection_ty.substs,
) {
ProjectionPredicate {
projection_ty: ProjectionTy {
substs: target_substs,
item_def_id: target_def_id,
},
ty: self.translate(index_map, &projection_predicate.skip_binder().ty),
ty: self.translate(index_map, &projection_predicate.ty),
}
} else {
return None;
},
))
)
.to_predicate(self.tcx)
}
PredicateKind::WellFormed(ty) => {
PredicateKind::WellFormed(self.translate(index_map, &ty)).to_predicate(self.tcx)
PredicateAtom::WellFormed(ty) => {
PredicateAtom::WellFormed(self.translate(index_map, &ty)).to_predicate(self.tcx)
}
PredicateKind::ObjectSafe(did) => {
PredicateKind::ObjectSafe(self.translate_orig(*did)).to_predicate(self.tcx)
PredicateAtom::ObjectSafe(did) => {
PredicateAtom::ObjectSafe(self.translate_orig(did)).to_predicate(self.tcx)
}
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
self.translate_orig(*did),
PredicateAtom::ClosureKind(did, substs, kind) => PredicateAtom::ClosureKind(
self.translate_orig(did),
self.translate(index_map, &substs),
*kind,
kind,
)
.to_predicate(self.tcx),
PredicateKind::Subtype(subtype_predicate) => {
PredicateKind::Subtype(subtype_predicate.map_bound(|s_pred| {
PredicateAtom::Subtype(subtype_predicate) => {
PredicateAtom::Subtype({
let s_pred = subtype_predicate;
let l = self.translate(index_map, &s_pred.a);
let r = self.translate(index_map, &s_pred.b);
SubtypePredicate {
a_is_expected: s_pred.a_is_expected,
a: l,
b: r,
}
}))
})
.to_predicate(self.tcx)
}
PredicateKind::ConstEvaluatable(param, orig_substs) => {
PredicateAtom::ConstEvaluatable(param, orig_substs) => {
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, param.did, orig_substs)
{
// TODO: We could probably use translated version for
// `WithOptConstParam::const_param_did`
let const_param = WithOptConstParam::unknown(target_def_id);
PredicateKind::ConstEvaluatable(const_param, target_substs)
PredicateAtom::ConstEvaluatable(const_param, target_substs)
.to_predicate(self.tcx)
} else {
return None;
}
}
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
PredicateAtom::ConstEquate(c1, c2) => PredicateAtom::ConstEquate(
self.translate(index_map, &c1),
self.translate(index_map, &c2),
)
Expand Down
5 changes: 3 additions & 2 deletions src/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ fn diff_traits<'tcx>(
use rustc_hir::Unsafety::Unsafe;
use rustc_middle::ty::subst::GenericArgKind::Type;
use rustc_middle::ty::{ParamTy, PredicateKind, TyS};
use rustc_middle::ty::PredicateAtom;

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

for bound in old_param_env.caller_bounds() {
if let PredicateKind::Trait(pred, _) = *bound.kind() {
let trait_ref = pred.skip_binder().trait_ref;
if let PredicateAtom::Trait(pred, _) = bound.skip_binders() {
let trait_ref = pred.trait_ref;

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

Expand Down
11 changes: 6 additions & 5 deletions src/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rustc_middle::{
error::TypeError,
fold::TypeFoldable,
subst::{GenericArg, InternalSubsts, SubstsRef},
GenericParamDefKind, ParamEnv, Predicate, PredicateKind, ToPredicate, TraitRef, Ty, TyCtxt,
GenericParamDefKind, ParamEnv, Predicate, ToPredicate, TraitRef, Ty, TyCtxt,
},
};
use rustc_trait_selection::traits::FulfillmentContext;
Expand Down Expand Up @@ -73,12 +73,13 @@ impl<'a, 'tcx> BoundContext<'a, 'tcx> {
/// Register the trait bound represented by a `TraitRef`.
pub fn register_trait_ref(&mut self, checked_trait_ref: TraitRef<'tcx>) {
use rustc_hir::Constness;
use rustc_middle::ty::{Binder, TraitPredicate};
use rustc_middle::ty::{TraitPredicate};
use rustc_middle::ty::PredicateAtom;

let predicate = PredicateKind::Trait(
Binder::bind(TraitPredicate {
let predicate = PredicateAtom::Trait(
TraitPredicate {
trait_ref: checked_trait_ref,
}),
},
Constness::NotConst,
)
.to_predicate(self.infcx.tcx);
Expand Down

0 comments on commit 0438c49

Please sign in to comment.