diff --git a/tests/ui/impl-trait/rpit/const_check_false_cycle.current.stderr b/tests/ui/impl-trait/rpit/const_check_false_cycle.current.stderr new file mode 100644 index 00000000000..78c7c164f59 --- /dev/null +++ b/tests/ui/impl-trait/rpit/const_check_false_cycle.current.stderr @@ -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`. diff --git a/tests/ui/impl-trait/rpit/const_check_false_cycle.rs b/tests/ui/impl-trait/rpit/const_check_false_cycle.rs new file mode 100644 index 00000000000..5b6b667e1fa --- /dev/null +++ b/tests/ui/impl-trait/rpit/const_check_false_cycle.rs @@ -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() {}