Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit a4e492a

Browse files
committed
1 parent 8d6f407 commit a4e492a

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ repository and compiled from source or installed from
2727
of the nightly toolchain is supported at any given time.
2828

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

3434
```sh
35-
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-11-15
36-
$ cargo +nightly-2021-11-15 install --git https://github.com/rust-lang/rust-semverver
35+
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-11-30
36+
$ cargo +nightly-2021-11-30 install --git https://github.com/rust-lang/rust-semverver
3737
```
3838

3939
You'd also need `cmake` for some dependencies, and a few common libraries (if you hit

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# NOTE: Keep in sync with nightly date on README
22
[toolchain]
3-
channel = "nightly-2021-11-15"
3+
channel = "nightly-2021-11-30"
44
components = ["llvm-tools-preview", "rustc-dev"]

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(rustc_private)]
2+
#![feature(exhaustive_patterns)]
23
#![allow(clippy::similar_names)]
34
#![allow(clippy::single_match_else)]
45
#![allow(clippy::too_many_lines)]

src/translate.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
166166
use rustc_middle::ty::TypeAndMut;
167167
use rustc_middle::ty::{AdtDef, Binder, ExistentialProjection, ExistentialTraitRef};
168168

169-
orig.fold_with(&mut BottomUpFolder {
169+
let Ok(result) = orig.fold_with(&mut BottomUpFolder {
170170
tcx: self.tcx,
171171
ty_op: |ty| {
172172
match *ty.kind() {
@@ -327,7 +327,8 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
327327
},
328328
lt_op: |region| self.translate_region(region),
329329
ct_op: |konst| konst, // TODO: translate consts
330-
})
330+
});
331+
result
331332
}
332333

333334
/// Translate a region.
@@ -558,12 +559,12 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceCleanupFolder<'a, 'tcx> {
558559
self.infcx.tcx
559560
}
560561

561-
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
562+
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
562563
use rustc_middle::ty::TyKind;
563564
use rustc_middle::ty::TypeAndMut;
564565

565-
let t1 = ty.super_fold_with(self);
566-
match *t1.kind() {
566+
let t1 = ty.super_fold_with(self)?;
567+
Ok(match *t1.kind() {
567568
TyKind::Ref(region, ty, mutbl) if region.needs_infer() => {
568569
let ty_and_mut = TypeAndMut { ty, mutbl };
569570
self.infcx
@@ -572,15 +573,15 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceCleanupFolder<'a, 'tcx> {
572573
}
573574
TyKind::Infer(_) => self.infcx.tcx.ty_error(),
574575
_ => t1,
575-
}
576+
})
576577
}
577578

578-
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> {
579-
let r1 = r.super_fold_with(self);
580-
if r1.needs_infer() {
579+
fn fold_region(&mut self, r: Region<'tcx>) -> Result<Region<'tcx>, Self::Error> {
580+
let r1 = r.super_fold_with(self)?;
581+
Ok(if r1.needs_infer() {
581582
self.infcx.tcx.lifetimes.re_erased
582583
} else {
583584
r1
584-
}
585+
})
585586
}
586587
}

src/typeck.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,11 @@ impl<'a, 'tcx> TypeComparisonContext<'a, 'tcx> {
254254
RegionckMode::default(),
255255
);
256256

257-
let err = self
257+
let Ok(folded) = self
258258
.infcx
259259
.resolve_vars_if_possible(err)
260-
.fold_with(&mut self.folder.clone())
261-
.lift_to_tcx(lift_tcx)
262-
.unwrap();
260+
.fold_with(&mut self.folder.clone());
261+
let err = folded.lift_to_tcx(lift_tcx).unwrap();
263262

264263
Some(err)
265264
} else {
@@ -288,11 +287,11 @@ impl<'a, 'tcx> TypeComparisonContext<'a, 'tcx> {
288287
errors
289288
.iter()
290289
.map(|err| {
291-
self.infcx
290+
let Ok(folded) = self
291+
.infcx
292292
.resolve_vars_if_possible(err.obligation.predicate)
293-
.fold_with(&mut self.folder.clone())
294-
.lift_to_tcx(lift_tcx)
295-
.unwrap()
293+
.fold_with(&mut self.folder.clone());
294+
folded.lift_to_tcx(lift_tcx).unwrap()
296295
})
297296
.collect()
298297
})

0 commit comments

Comments
 (0)