diff options
| author | Michael Goulet <michael@errs.io> | 2023-01-31 20:43:18 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-02-01 01:14:34 +0000 |
| commit | 2c23c7f0cd7a665bbd7b173ebfc26cae223304e3 (patch) | |
| tree | 2435fada593c6467dca3b2f88fd310f80fc3aa99 | |
| parent | dc1d9d50fba2f6a1ccab8748a0050cde38253f60 (diff) | |
| download | rust-2c23c7f0cd7a665bbd7b173ebfc26cae223304e3.tar.gz rust-2c23c7f0cd7a665bbd7b173ebfc26cae223304e3.zip | |
Erase regions before uninhabited check
| -rw-r--r-- | compiler/rustc_borrowck/src/type_check/mod.rs | 5 | ||||
| -rw-r--r-- | tests/ui/uninhabited/issue-107505.rs | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index 06087b0c579..0a78bc0030b 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -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); } } diff --git a/tests/ui/uninhabited/issue-107505.rs b/tests/ui/uninhabited/issue-107505.rs new file mode 100644 index 00000000000..61598541ddf --- /dev/null +++ b/tests/ui/uninhabited/issue-107505.rs @@ -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) +} |
