Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Apr 11, 2022
1 parent 559efa9 commit 9c14eaa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
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-11-30"
channel = "nightly-2021-12-05"
components = ["llvm-tools-preview", "rustc-dev"]
18 changes: 9 additions & 9 deletions src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
use rustc_middle::ty::TypeAndMut;
use rustc_middle::ty::{AdtDef, Binder, ExistentialProjection, ExistentialTraitRef};

let Ok(result) = orig.fold_with(&mut BottomUpFolder {
let result = orig.fold_with(&mut BottomUpFolder {
tcx: self.tcx,
ty_op: |ty| {
match *ty.kind() {
Expand Down Expand Up @@ -559,12 +559,12 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceCleanupFolder<'a, 'tcx> {
self.infcx.tcx
}

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

let t1 = ty.super_fold_with(self)?;
Ok(match *t1.kind() {
let t1 = ty.super_fold_with(self);
match *t1.kind() {
TyKind::Ref(region, ty, mutbl) if region.needs_infer() => {
let ty_and_mut = TypeAndMut { ty, mutbl };
self.infcx
Expand All @@ -573,15 +573,15 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceCleanupFolder<'a, 'tcx> {
}
TyKind::Infer(_) => self.infcx.tcx.ty_error(),
_ => t1,
})
}
}

fn fold_region(&mut self, r: Region<'tcx>) -> Result<Region<'tcx>, Self::Error> {
let r1 = r.super_fold_with(self)?;
Ok(if r1.needs_infer() {
fn fold_region(&mut self, r: Region<'tcx>) -> Region<'tcx> {
let r1 = r.super_fold_with(self);
if r1.needs_infer() {
self.infcx.tcx.lifetimes.re_erased
} else {
r1
})
}
}
}
15 changes: 8 additions & 7 deletions src/typeck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,12 @@ impl<'a, 'tcx> TypeComparisonContext<'a, 'tcx> {
RegionckMode::default(),
);

let Ok(folded) = self
let err = self
.infcx
.resolve_vars_if_possible(err)
.fold_with(&mut self.folder.clone());
let err = folded.lift_to_tcx(lift_tcx).unwrap();
.fold_with(&mut self.folder.clone())
.lift_to_tcx(lift_tcx)
.unwrap();

Some(err)
} else {
Expand Down Expand Up @@ -287,11 +288,11 @@ impl<'a, 'tcx> TypeComparisonContext<'a, 'tcx> {
errors
.iter()
.map(|err| {
let Ok(folded) = self
.infcx
self.infcx
.resolve_vars_if_possible(err.obligation.predicate)
.fold_with(&mut self.folder.clone());
folded.lift_to_tcx(lift_tcx).unwrap()
.fold_with(&mut self.folder.clone())
.lift_to_tcx(lift_tcx)
.unwrap()
})
.collect()
})
Expand Down

0 comments on commit 9c14eaa

Please sign in to comment.