thir-unsafeck query loops on closures in const-generics · Issue #87414 · rust-lang/rust (original) (raw)
I tried this code with -Z thir-unsafeck=on
:
fn bad() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() } fn main() {}
I expected to see this happen: It compiles, as it does under the MIR checker
Instead, this happened:
error[E0391]: cycle detected when simplifying constant for the type system `bad::{constant#0}`
--> y.rs:1:45
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires simplifying constant for the type system `bad::{constant#0}`...
--> y.rs:1:45
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const-evaluating + checking `bad::{constant#0}`...
--> y.rs:1:45
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `bad::{constant#0}`...
--> y.rs:1:45
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires processing MIR for `bad::{constant#0}`...
--> y.rs:1:45
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires unsafety-checking `bad::{constant#0}`...
--> y.rs:1:45
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^
note: ...which requires unsafety-checking `bad::{constant#0}::{closure#0}`...
--> y.rs:1:47
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^
note: ...which requires building MIR for `bad::{constant#0}::{closure#0}`...
--> y.rs:1:47
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^
note: ...which requires unsafety-checking `bad::{constant#0}::{closure#0}`...
--> y.rs:1:47
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^
note: ...which requires unsafety-checking `bad`...
--> y.rs:1:1
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires building THIR for `bad`...
--> y.rs:1:1
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires type-checking `bad`...
--> y.rs:1:1
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which again requires simplifying constant for the type system `bad::{constant#0}`, completing the cycle
note: cycle used when checking that `bad` is well-formed
--> y.rs:1:1
|
1 | fn bad<T>() -> Box<dyn Iterator<Item = [(); { |x: u32| { x }; 4 }]>> { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Meta
rustc --version --verbose
:
$ rustc +local --version --verbose
rustc 1.55.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.55.0-dev
LLVM version: 12.0.1