forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#125457 - fmease:gacs-diag-infer-plac-missing-…
…ty, r=compiler-errors Properly deal with missing/placeholder types inside GACs Fixes rust-lang#124833. r? oli-obk (rust-lang#123130)
- Loading branch information
Showing
4 changed files
with
79 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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; | ||
const Q<'a>: &'a str; | ||
} | ||
|
||
impl Trait for () { | ||
const K<T> = (); | ||
//~^ ERROR missing type for `const` item | ||
//~| ERROR mismatched types | ||
//~| ERROR mismatched types | ||
const Q = ""; | ||
//~^ ERROR missing type for `const` item | ||
//~| ERROR lifetime parameters or bounds on const `Q` do not match the trait declaration | ||
} | ||
|
||
fn main() {} |
48 changes: 48 additions & 0 deletions
48
tests/ui/generic-const-items/assoc-const-missing-type.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/assoc-const-missing-type.rs:12: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:12:15 | ||
| | ||
LL | const K<T> = (); | ||
| ^ help: provide a type for the associated constant: `()` | ||
|
||
error[E0195]: lifetime parameters or bounds on const `Q` do not match the trait declaration | ||
--> $DIR/assoc-const-missing-type.rs:16:12 | ||
| | ||
LL | const Q<'a>: &'a str; | ||
| ---- lifetimes in impl do not match this const in trait | ||
... | ||
LL | const Q = ""; | ||
| ^ lifetimes do not match const in trait | ||
|
||
error: missing type for `const` item | ||
--> $DIR/assoc-const-missing-type.rs:16:12 | ||
| | ||
LL | const Q = ""; | ||
| ^ help: provide a type for the associated constant: `: &str` | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/assoc-const-missing-type.rs:12: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 5 previous errors | ||
|
||
Some errors have detailed explanations: E0195, E0308. | ||
For more information about an error, try `rustc --explain E0195`. |