diff options
| author | León Orell Valerian Liehr <me@fmease.dev> | 2024-05-23 19:18:07 +0200 |
|---|---|---|
| committer | León Orell Valerian Liehr <me@fmease.dev> | 2024-05-24 00:36:32 +0200 |
| commit | 24afa42a90eb035e24e5dcffbc538fb96277e3a3 (patch) | |
| tree | a81ee4fdb476af5f4f7e6a0fdcf11df083e45055 /tests/ui/generic-const-items | |
| parent | 791adf759cc065316f054961875052d5bc03e16c (diff) | |
| download | rust-24afa42a90eb035e24e5dcffbc538fb96277e3a3.tar.gz rust-24afa42a90eb035e24e5dcffbc538fb96277e3a3.zip | |
Properly deal with missing/placeholder types inside GACs
Diffstat (limited to 'tests/ui/generic-const-items')
| -rw-r--r-- | tests/ui/generic-const-items/assoc-const-missing-type.rs | 17 | ||||
| -rw-r--r-- | tests/ui/generic-const-items/assoc-const-missing-type.stderr | 32 |
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/ui/generic-const-items/assoc-const-missing-type.rs b/tests/ui/generic-const-items/assoc-const-missing-type.rs new file mode 100644 index 00000000000..80f282ea134 --- /dev/null +++ b/tests/ui/generic-const-items/assoc-const-missing-type.rs @@ -0,0 +1,17 @@ +// Ensure that we properly deal with missing/placeholder types inside GACs. +// issue: rust-lang/rust#124833 +#![feature(generic_const_items)] +#![allow(incomplete_features)] + +trait Trait { + const K<T>: T; +} + +impl Trait for () { + const K<T> = (); + //~^ ERROR missing type for `const` item + //~| ERROR mismatched types + //~| ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/generic-const-items/assoc-const-missing-type.stderr b/tests/ui/generic-const-items/assoc-const-missing-type.stderr new file mode 100644 index 00000000000..158e9a068f6 --- /dev/null +++ b/tests/ui/generic-const-items/assoc-const-missing-type.stderr @@ -0,0 +1,32 @@ +error[E0308]: mismatched types + --> $DIR/assoc-const-missing-type.rs:11:18 + | +LL | const K<T> = (); + | - ^^ expected type parameter `T`, found `()` + | | + | expected this type parameter + | + = note: expected type parameter `T` + found unit type `()` + +error: missing type for `const` item + --> $DIR/assoc-const-missing-type.rs:11:15 + | +LL | const K<T> = (); + | ^ help: provide a type for the associated constant: `()` + +error[E0308]: mismatched types + --> $DIR/assoc-const-missing-type.rs:11:18 + | +LL | const K<T> = (); + | - ^^ expected type parameter `T`, found `()` + | | + | expected this type parameter + | + = note: expected type parameter `T` + found unit type `()` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. |
