Skip to content

Commit

Permalink
Rollup merge of #107532 - compiler-errors:erase-regions-in-uninhabite…
Browse files Browse the repository at this point in the history
…d, r=jackh726

Erase regions before doing uninhabited check in borrowck

~Also, fingerprint query keys/values when debug assertions are enabled. This should make it easier to check for issues like this without `-Cincremental`, and make UI tests a bit cleaner.~ edit: moving that to a separate PR

Fixes #107505
  • Loading branch information
matthiaskrgr authored Feb 2, 2023
2 parents 6917040 + 2c23c7f commit 3e0995a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
}
None => {
if !sig.output().is_privately_uninhabited(self.tcx(), self.param_env) {
// The signature in this call can reference region variables,
// so erase them before calling a query.
let output_ty = self.tcx().erase_regions(sig.output());
if !output_ty.is_privately_uninhabited(self.tcx(), self.param_env) {
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
}
}
Expand Down
18 changes: 18 additions & 0 deletions tests/ui/uninhabited/issue-107505.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// compile-flags: --crate-type=lib
// check-pass

// Make sure we don't pass inference variables to uninhabitedness checks in borrowck

struct Command<'s> {
session: &'s (),
imp: std::convert::Infallible,
}

fn command(_: &()) -> Command<'_> {
unreachable!()
}

fn with_session<'s>(a: &std::process::Command, b: &'s ()) -> Command<'s> {
a.get_program();
command(b)
}

0 comments on commit 3e0995a

Please sign in to comment.