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

thir-unsafeck query loops when trying to compute frozenness #87713

Closed
syvb opened this issue Aug 3, 2021 · 4 comments
Closed

thir-unsafeck query loops when trying to compute frozenness #87713

syvb opened this issue Aug 3, 2021 · 4 comments
Labels
-Zthir-unsafeck Unstable option: THIR unsafeck C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@syvb
Copy link
Contributor

syvb commented Aug 3, 2021

I tried this code with -Z thir-unsafeck:

// from src/test/ui/impl-trait/recursive-impl-trait-type-indirect.rs
fn closure_ref_capture() -> impl Sized {
    let x = closure_ref_capture();
    move || { &x; }
}
fn main() {}

I expected to see this happen: It errors with cannot resolve opaque type and a warning

Instead, this happened: There is also a query loop:

error[E0391]: cycle detected when computing type of `closure_ref_capture::{opaque#0}`
 --> freeze2.rs:2:29
  |
2 | fn closure_ref_capture() -> impl Sized {
  |                             ^^^^^^^^^^
  |
note: ...which requires borrow-checking `closure_ref_capture`...
 --> freeze2.rs:2:1
  |
2 | fn closure_ref_capture() -> impl Sized {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing `closure_ref_capture`...
 --> freeze2.rs:2:1
  |
2 | fn closure_ref_capture() -> impl Sized {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing MIR for `closure_ref_capture`...
 --> freeze2.rs:2:1
  |
2 | fn closure_ref_capture() -> impl Sized {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires unsafety-checking `closure_ref_capture`...
 --> freeze2.rs:2:1
  |
2 | fn closure_ref_capture() -> impl Sized {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires building MIR for `closure_ref_capture`...
 --> freeze2.rs:2:1
  |
2 | fn closure_ref_capture() -> impl Sized {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires unsafety-checking `closure_ref_capture`...
 --> freeze2.rs:4:16
  |
4 |     move || { &x; }
  |                ^
  = note: ...which requires computing whether `impl Sized` is freeze...
  = note: ...which requires evaluating trait selection obligation `impl Sized: std::marker::Freeze`...
  = note: ...which again requires computing type of `closure_ref_capture::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
 --> freeze2.rs:2:1
  |
2 | fn closure_ref_capture() -> impl Sized {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This also happens when using the new unsafety checker with ui/generator/layout-error.rs, ui/impl-trait/recursive-impl-trait-type-indirect.rs, ui/impl-trait/unsafety-checking-cycle.rs, and ui/type-alias-impl-traiissue-52843-closure-constrain.rs.

Meta

rustc --version --verbose:

rustc 1.56.0-dev

@syvb syvb added the C-bug Category: This is a bug. label Aug 3, 2021
@syvb

This comment has been minimized.

@rustbot

This comment has been minimized.

@LeSeulArtichaut LeSeulArtichaut added -Zthir-unsafeck Unstable option: THIR unsafeck T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 3, 2021
@syvb
Copy link
Contributor Author

syvb commented Aug 7, 2021

This was fixed by #87737.

@syvb syvb closed this as completed Aug 7, 2021
@LeSeulArtichaut
Copy link
Contributor

LeSeulArtichaut commented Aug 7, 2021

For the record, #87737 didn't solve all cases of this. There is also #87850 which affects both the THIR and MIR unsafety checkers.
Interestingly the MIR unsafeck also had this issue which was solved in a similar way with 4af0952.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zthir-unsafeck Unstable option: THIR unsafeck C-bug Category: This is a bug. 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

3 participants