From fdff100545850376e0f48d382ca3f92c959ff1cc Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Fri, 8 Mar 2024 06:36:37 +0000 Subject: [PATCH] Add regression test --- .../const_check_false_cycle.current.stderr | 34 +++++++++++++++++++ .../rpit/const_check_false_cycle.rs | 15 ++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/ui/impl-trait/rpit/const_check_false_cycle.current.stderr create mode 100644 tests/ui/impl-trait/rpit/const_check_false_cycle.rs 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() {}