Add regression test

This commit is contained in:
Oli Scherer 2024-03-08 06:36:37 +00:00
parent 2ccafed862
commit fdff100545
2 changed files with 49 additions and 0 deletions

View file

@ -0,0 +1,34 @@
error[E0391]: cycle detected when computing type of opaque `f::{opaque#0}`
--> $DIR/const_check_false_cycle.rs:9:17
|
LL | const fn f() -> impl Eq {
| ^^^^^^^
|
note: ...which requires borrow-checking `f`...
--> $DIR/const_check_false_cycle.rs:9:1
|
LL | const fn f() -> impl Eq {
| ^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires promoting constants in MIR for `f`...
--> $DIR/const_check_false_cycle.rs:9:1
|
LL | const fn f() -> impl Eq {
| ^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires const checking `f`...
--> $DIR/const_check_false_cycle.rs:9:1
|
LL | const fn f() -> impl Eq {
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: ...which requires computing whether `f::{opaque#0}` is freeze...
= note: ...which requires evaluating trait selection obligation `f::{opaque#0}: core::marker::Freeze`...
= note: ...which again requires computing type of opaque `f::{opaque#0}`, completing the cycle
note: cycle used when computing type of `f::{opaque#0}`
--> $DIR/const_check_false_cycle.rs:9:17
|
LL | const fn f() -> impl Eq {
| ^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0391`.

View file

@ -0,0 +1,15 @@
//! This test causes a cycle error when checking whether the
//! return type is `Freeze` during const checking, even though
//! the information is readily available.
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@[next] check-pass
const fn f() -> impl Eq {
//[current]~^ ERROR cycle detected
g()
}
const fn g() {}
fn main() {}