diff --git a/rust-toolchain b/rust-toolchain index 3e0f3c66..ce197494 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2020-07-23 +nightly-2020-07-28 diff --git a/src/lib.rs b/src/lib.rs index 7f46a102..fca8e45d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/translate.rs b/src/translate.rs index 26fdd0dd..6c9684ba 100644 --- a/src/translate.rs +++ b/src/translate.rs @@ -368,14 +368,14 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> { Binder, OutlivesPredicate, PredicateKind, ProjectionPredicate, ProjectionTy, SubtypePredicate, ToPredicate, TraitPredicate, }; + 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 { @@ -386,60 +386,62 @@ 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 { @@ -447,10 +449,10 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> { a: l, b: r, } - })) + }) .to_predicate(self.tcx) } - PredicateKind::ConstEvaluatable(orig_did, orig_substs) => { + PredicateAtom::ConstEvaluatable(orig_did, orig_substs) => { if let Some((target_def_id, target_substs)) = self.translate_orig_substs(index_map, orig_did.did, orig_substs) { @@ -458,13 +460,13 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> { // 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), ) diff --git a/src/traverse.rs b/src/traverse.rs index 4c35d538..e5efe3c4 100644 --- a/src/traverse.rs +++ b/src/traverse.rs @@ -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: {:?}", @@ -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); diff --git a/src/typeck.rs b/src/typeck.rs index 91a16b4f..c26462b7 100644 --- a/src/typeck.rs +++ b/src/typeck.rs @@ -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; @@ -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);