Skip to content

Commit

Permalink
Update to nightly-2020-12-19
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Mar 31, 2021
1 parent 714fb0d commit 7c43d03
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 52 deletions.
6 changes: 3 additions & 3 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-2020-12-14` toolchain.
You can install it by using `rustup install nightly-2020-12-14` if you already have rustup.
It's recommended to use `nightly-2020-12-19` toolchain.
You can install it by using `rustup install nightly-2020-12-19` if you already have rustup.
Then you can do:

```sh
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2020-11-19
$ cargo +nightly-2020-12-14 install --git https://github.com/rust-lang/rust-semverver
$ cargo +nightly-2020-12-19 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-2020-12-14"
channel = "nightly-2020-12-19"
components = ["llvm-tools-preview", "rustc-dev"]
107 changes: 59 additions & 48 deletions src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,61 +211,72 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
let res: Vec<_> = preds
.iter()
.map(|p| {
match p.skip_binder() {
Trait(existential_trait_ref) => {
let trait_ref = Binder::bind(existential_trait_ref)
.with_self_ty(self.tcx, dummy_self);
let did = trait_ref.skip_binder().def_id;
let substs = trait_ref.skip_binder().substs;

// TODO: here, the substs could also be already translated
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, did, substs)
{
let target_trait_ref = TraitRef {
def_id: target_def_id,
substs: target_substs,
};
Trait(ExistentialTraitRef::erase_self_ty(
self.tcx,
target_trait_ref,
))
} else {
success.set(false);
err_pred
p.map_bound(|p| {
match p {
Trait(existential_trait_ref) => {
let trait_ref = Binder::bind(existential_trait_ref)
.with_self_ty(self.tcx, dummy_self);
let did = trait_ref.skip_binder().def_id;
let substs = trait_ref.skip_binder().substs;

// TODO: here, the substs could also be already translated
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, did, substs)
{
let target_trait_ref = TraitRef {
def_id: target_def_id,
substs: target_substs,
};
Trait(ExistentialTraitRef::erase_self_ty(
self.tcx,
target_trait_ref,
))
} else {
success.set(false);
err_pred
}
}
}
Projection(existential_projection) => {
let projection_pred = Binder::bind(existential_projection)
.with_self_ty(self.tcx, dummy_self);
let item_def_id =
projection_pred.skip_binder().projection_ty.item_def_id;
let substs =
projection_pred.skip_binder().projection_ty.substs;

// TODO: here, the substs could also be already translated
if let Some((target_def_id, target_substs)) = self
.translate_orig_substs(index_map, item_def_id, substs)
{
Projection(ExistentialProjection {
item_def_id: target_def_id,
// TODO: should be it's own method in rustc
substs: self.tcx.intern_substs(&target_substs[1..]),
ty,
})
} else {
success.set(false);
err_pred
Projection(existential_projection) => {
let projection_pred =
Binder::bind(existential_projection)
.with_self_ty(self.tcx, dummy_self);
let item_def_id = projection_pred
.skip_binder()
.projection_ty
.item_def_id;
let substs =
projection_pred.skip_binder().projection_ty.substs;

// TODO: here, the substs could also be already translated
if let Some((target_def_id, target_substs)) = self
.translate_orig_substs(
index_map,
item_def_id,
substs,
)
{
Projection(ExistentialProjection {
item_def_id: target_def_id,
// TODO: should be it's own method in rustc
substs: self
.tcx
.intern_substs(&target_substs[1..]),
ty,
})
} else {
success.set(false);
err_pred
}
}
AutoTrait(did) => AutoTrait(self.translate_orig(did)),
}
AutoTrait(did) => AutoTrait(self.translate_orig(did)),
}
})
})
.collect();

if success.get() {
let target_preds = self.tcx.mk_existential_predicates(res.iter());
self.tcx.mk_dynamic(Binder::bind(target_preds), region)
let target_preds = self.tcx.mk_poly_existential_predicates(res.iter());
self.tcx.mk_dynamic(target_preds, region)
} else {
ty
}
Expand Down

0 comments on commit 7c43d03

Please sign in to comment.