Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Oct 15, 2021
1 parent a3657c0 commit 0905e42
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 99 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ repository and compiled from source or installed from
of the nightly toolchain is supported at any given time.

<!-- NOTE: Keep in sync with nightly date on rust-toolchain. -->
It's recommended to use `nightly-2021-09-30` toolchain.
You can install it by using `rustup install nightly-2021-09-30` if you already have rustup.
It's recommended to use `nightly-2021-10-15` toolchain.
You can install it by using `rustup install nightly-2021-10-15` if you already have rustup.
Then you can do:

```sh
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-09-30
$ cargo +nightly-2021-09-30 install --git https://github.com/rust-lang/rust-semverver
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-10-15
$ cargo +nightly-2021-10-15 install --git https://github.com/rust-lang/rust-semverver
```

You'd also need `cmake` for some dependencies, and a few common libraries (if you hit
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Keep in sync with nightly date on README
[toolchain]
channel = "nightly-2021-09-30"
channel = "nightly-2021-10-15"
components = ["llvm-tools-preview", "rustc-dev"]
175 changes: 85 additions & 90 deletions src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,102 +376,97 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
predicate: Predicate<'tcx>,
) -> Option<Predicate<'tcx>> {
use rustc_middle::ty::{
CoercePredicate, OutlivesPredicate, PredicateKind, ProjectionPredicate, ProjectionTy,
self, SubtypePredicate, ToPredicate, TraitPredicate, WithOptConstParam,
self, CoercePredicate, OutlivesPredicate, PredicateKind, ProjectionPredicate,
ProjectionTy, SubtypePredicate, ToPredicate, TraitPredicate, WithOptConstParam,
};

let pred = match predicate.kind().skip_binder() {
PredicateKind::Trait(pred) => PredicateKind::Trait(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.trait_ref.def_id,
pred.trait_ref.substs,
) {
TraitPredicate {
trait_ref: TraitRef {
def_id: target_def_id,
substs: target_substs,
},
constness: pred.constness,
}
} else {
return None;
},
),
PredicateKind::RegionOutlives(pred) => PredicateKind::RegionOutlives({
let l = self.translate_region(pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::TypeOutlives(pred) => PredicateKind::TypeOutlives({
let l = self.translate(index_map, pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::Projection(pred) => PredicateKind::Projection(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.projection_ty.item_def_id,
pred.projection_ty.substs,
) {
ProjectionPredicate {
projection_ty: ProjectionTy {
substs: target_substs,
item_def_id: target_def_id,
},
ty: self.translate(index_map, pred.ty),
}
} else {
return None;
},
),
PredicateKind::WellFormed(ty) => {
PredicateKind::WellFormed(self.translate(index_map, ty))
}
PredicateKind::ObjectSafe(did) => {
PredicateKind::ObjectSafe(self.translate_orig(did))
}
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
self.translate_orig(did),
self.translate(index_map, substs),
kind,
),
PredicateKind::Subtype(pred) => PredicateKind::Subtype({
let l = self.translate(index_map, pred.a);
let r = self.translate(index_map, pred.b);
SubtypePredicate {
a_is_expected: pred.a_is_expected,
a: l,
b: r,
PredicateKind::Trait(pred) => PredicateKind::Trait(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.trait_ref.def_id,
pred.trait_ref.substs,
) {
TraitPredicate {
trait_ref: TraitRef {
def_id: target_def_id,
substs: target_substs,
},
constness: pred.constness,
}
}),
PredicateKind::Coerce(pred) => PredicateKind::Coerce({
let a = self.translate(index_map, pred.a);
let b = self.translate(index_map, pred.b);
CoercePredicate { a, b }
}),
PredicateKind::ConstEvaluatable(uv) => {
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, uv.def.did, uv.substs(self.tcx))
{
// TODO: We could probably use translated version for
// `WithOptConstParam::const_param_did`
let const_param = WithOptConstParam::unknown(target_def_id);
PredicateKind::ConstEvaluatable(Unevaluated::new(
const_param,
target_substs,
))
} else {
return None;
} else {
return None;
},
),
PredicateKind::RegionOutlives(pred) => PredicateKind::RegionOutlives({
let l = self.translate_region(pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::TypeOutlives(pred) => PredicateKind::TypeOutlives({
let l = self.translate(index_map, pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::Projection(pred) => PredicateKind::Projection(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.projection_ty.item_def_id,
pred.projection_ty.substs,
) {
ProjectionPredicate {
projection_ty: ProjectionTy {
substs: target_substs,
item_def_id: target_def_id,
},
ty: self.translate(index_map, pred.ty),
}
} else {
return None;
},
),
PredicateKind::WellFormed(ty) => {
PredicateKind::WellFormed(self.translate(index_map, ty))
}
PredicateKind::ObjectSafe(did) => PredicateKind::ObjectSafe(self.translate_orig(did)),
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
self.translate_orig(did),
self.translate(index_map, substs),
kind,
),
PredicateKind::Subtype(pred) => PredicateKind::Subtype({
let l = self.translate(index_map, pred.a);
let r = self.translate(index_map, pred.b);
SubtypePredicate {
a_is_expected: pred.a_is_expected,
a: l,
b: r,
}
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
self.translate(index_map, c1),
self.translate(index_map, c2),
),
// NOTE: Only used for Chalk trait solver
PredicateKind::TypeWellFormedFromEnv(_) => unimplemented!(),
};
}),
PredicateKind::Coerce(pred) => PredicateKind::Coerce({
let a = self.translate(index_map, pred.a);
let b = self.translate(index_map, pred.b);
CoercePredicate { a, b }
}),
PredicateKind::ConstEvaluatable(uv) => {
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, uv.def.did, uv.substs(self.tcx))
{
// TODO: We could probably use translated version for
// `WithOptConstParam::const_param_did`
let const_param = WithOptConstParam::unknown(target_def_id);
PredicateKind::ConstEvaluatable(Unevaluated::new(const_param, target_substs))
} else {
return None;
}
}
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
self.translate(index_map, c1),
self.translate(index_map, c2),
),
// NOTE: Only used for Chalk trait solver
PredicateKind::TypeWellFormedFromEnv(_) => unimplemented!(),
};

Some(ty::Binder::dummy(pred).to_predicate(self.tcx))
}
Expand Down
5 changes: 2 additions & 3 deletions src/traverse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use crate::{
typeck::{BoundContext, TypeComparisonContext},
};
use log::{debug, info};
use rustc_const_eval::const_eval::is_const_fn;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res, Res::Def};
use rustc_hir::def_id::DefId;
use rustc_hir::hir_id::HirId;
Expand Down Expand Up @@ -363,8 +362,8 @@ fn diff_fn<'tcx>(changes: &mut ChangeSet, tcx: TyCtxt<'tcx>, old: Res, new: Res)
let old_def_id = old.def_id();
let new_def_id = new.def_id();

let old_const = is_const_fn(tcx, old_def_id);
let new_const = is_const_fn(tcx, new_def_id);
let old_const = tcx.is_const_fn(old_def_id);
let new_const = tcx.is_const_fn(new_def_id);

if old_const != new_const {
changes.add_change(
Expand Down
2 changes: 1 addition & 1 deletion src/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ 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_middle::ty::{BoundConstness, self, ToPredicate, TraitPredicate};
use rustc_middle::ty::{self, BoundConstness, ToPredicate, TraitPredicate};

let predicate = ty::Binder::dummy(PredicateKind::Trait(TraitPredicate {
trait_ref: checked_trait_ref,
Expand Down

0 comments on commit 0905e42

Please sign in to comment.