Skip to content

Commit 3e0995a

Browse files
authored
Rollup merge of #107532 - compiler-errors:erase-regions-in-uninhabited, 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
2 parents 6917040 + 2c23c7f commit 3e0995a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14841484
}
14851485
}
14861486
None => {
1487-
if !sig.output().is_privately_uninhabited(self.tcx(), self.param_env) {
1487+
// The signature in this call can reference region variables,
1488+
// so erase them before calling a query.
1489+
let output_ty = self.tcx().erase_regions(sig.output());
1490+
if !output_ty.is_privately_uninhabited(self.tcx(), self.param_env) {
14881491
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
14891492
}
14901493
}

tests/ui/uninhabited/issue-107505.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// compile-flags: --crate-type=lib
2+
// check-pass
3+
4+
// Make sure we don't pass inference variables to uninhabitedness checks in borrowck
5+
6+
struct Command<'s> {
7+
session: &'s (),
8+
imp: std::convert::Infallible,
9+
}
10+
11+
fn command(_: &()) -> Command<'_> {
12+
unreachable!()
13+
}
14+
15+
fn with_session<'s>(a: &std::process::Command, b: &'s ()) -> Command<'s> {
16+
a.get_program();
17+
command(b)
18+
}

0 commit comments

Comments
 (0)