Skip to content

Commit 2c23c7f

Browse files
committedFeb 1, 2023
Erase regions before uninhabited check
1 parent dc1d9d5 commit 2c23c7f

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)
Please sign in to comment.