Closed
Description
In this example, I get an (incorrect) compilation error:
#![feature(never_type)]
struct Foo {
field1: !,
field2: Option<&'static Bar>,
}
struct Bar {
field1: &'static Foo
}
fn test_a() {
let x: Option<Foo> = None;
match x { None => () }
}
fn test_b() {
let x: Option<Bar> = None;
match x { None => () }
}
fn main() { }
But if you comment out test_a
, you don't. This is because the inhabitedness code, if it starts from Foo
, incorrectly caches a result for Bar
-- the result is incorrect because Bar
did not fully explore Foo
, since we found a cycle.
Encountered while fixing #44137 -- I will fix en passante.