Add a test for suboptimal diagnostics

This commit is contained in:
Shoyu Vanilla
2026-10-05 05:27:31 +00:00
parent adfb5d30b5
commit 59df6010d5
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
//@ compile-flags: -Znext-solver
// FIXME: The diagnostics here are suboptimal.
// See <https://github.com/rust-lang/rust/issues/163784>.
#![feature(type_alias_impl_trait)]
//~^^^^^^ ERROR: overflow evaluating the requirement `X == _`
// TAIT with self-referencing bounds
type X = impl std::ops::Add<Output = X>;
struct Foo;
impl Foo {
#[define_opaque(X)]
pub fn new() -> X {
//~^ ERROR: item does not constrain `X::{opaque#0}`
0i32
}
}
fn main() {}

View File

@@ -0,0 +1,18 @@
error: item does not constrain `X::{opaque#0}`
--> $DIR/overflowing-opaque-incorrectly-unconstrained.rs:16:12
|
LL | pub fn new() -> X {
| ^^^
|
= note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]`
note: this opaque type is supposed to be constrained
--> $DIR/overflowing-opaque-incorrectly-unconstrained.rs:10:10
|
LL | type X = impl std::ops::Add<Output = X>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0275]: overflow evaluating the requirement `X == _`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0275`.