Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inhabitedness cache handles cycles incorrectly #44402

Closed
nikomatsakis opened this issue Sep 7, 2017 · 3 comments
Closed

inhabitedness cache handles cycles incorrectly #44402

nikomatsakis opened this issue Sep 7, 2017 · 3 comments
Assignees
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

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.

@nikomatsakis nikomatsakis added I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 7, 2017
@nikomatsakis nikomatsakis self-assigned this Sep 7, 2017
@alexcrichton alexcrichton added the C-bug Category: This is a bug. label Sep 8, 2017
@bstrie
Copy link
Contributor

bstrie commented Sep 14, 2017

I know the text of the bug implies that this will be fixed relatively soon, yet I'm still nominating because of my perpetual quest to let no soundness bug go unprioritized. :) If this happens to get closed before you get around to discussing it, all the better!

@nikomatsakis
Copy link
Contributor Author

Will be fixed by #44501. I'm going to categorize this as P-medium -- I think it only affects unstable code, and I think it just causes things to fail to compile that should have compiled.

@nikomatsakis
Copy link
Contributor Author

triage: P-medium

@rust-highfive rust-highfive added P-medium Medium priority and removed I-nominated labels Sep 14, 2017
@bstrie bstrie added the B-unstable Blocker: Implemented in the nightly compiler and unstable. label Sep 20, 2017
@bors bors closed this as completed in 5c26509 Oct 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants