Properly deal with missing/placeholder types inside GACs

This commit is contained in:
León Orell Valerian Liehr 2024-05-23 19:18:07 +02:00
parent 791adf759c
commit 24afa42a90
No known key found for this signature in database
GPG key ID: D17A07215F68E713
3 changed files with 58 additions and 4 deletions

View file

@ -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() {}

View file

@ -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`.