Fix suggestion on AutoTraitItems diagnostic

This commit is contained in:
Jonathan Brouwer 2026-02-08 10:23:31 +01:00
parent 13c38730d9
commit 953aa57c75
No known key found for this signature in database
GPG key ID: 13619B051B673C52
4 changed files with 16 additions and 11 deletions

View file

@ -503,7 +503,7 @@ pub(crate) struct AutoTraitItems {
#[primary_span]
pub spans: Vec<Span>,
#[suggestion(
"remove the super traits or lifetime bounds",
"remove the associated items",
code = "",
applicability = "machine-applicable",
style = "tool-only"

View file

@ -1,9 +1,9 @@
error[E0380]: auto traits cannot have associated items
--> $DIR/assoc-ty.rs:10:10
--> $DIR/assoc-ty.rs:11:10
|
LL | auto trait Trait {
| ----- auto traits cannot have associated items
LL |
...
LL | type Output;
| ^^^^^^
@ -12,8 +12,9 @@ error[E0658]: auto traits are experimental and possibly buggy
|
LL | / auto trait Trait {
LL | |
LL | | type Output;
LL | |
LL | | type Output;
... |
LL | | }
| |_^
|
@ -22,7 +23,7 @@ LL | | }
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0308]: mismatched types
--> $DIR/assoc-ty.rs:15:36
--> $DIR/assoc-ty.rs:17:36
|
LL | let _: <() as Trait>::Output = ();
| --------------------- ^^ expected associated type, found `()`

View file

@ -1,9 +1,9 @@
error[E0380]: auto traits cannot have associated items
--> $DIR/assoc-ty.rs:10:10
--> $DIR/assoc-ty.rs:11:10
|
LL | auto trait Trait {
| ----- auto traits cannot have associated items
LL |
...
LL | type Output;
| ^^^^^^
@ -12,8 +12,9 @@ error[E0658]: auto traits are experimental and possibly buggy
|
LL | / auto trait Trait {
LL | |
LL | | type Output;
LL | |
LL | | type Output;
... |
LL | | }
| |_^
|
@ -22,13 +23,13 @@ LL | | }
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0271]: type mismatch resolving `<() as Trait>::Output normalizes-to _`
--> $DIR/assoc-ty.rs:15:12
--> $DIR/assoc-ty.rs:17:12
|
LL | let _: <() as Trait>::Output = ();
| ^^^^^^^^^^^^^^^^^^^^^ types differ
error[E0271]: type mismatch resolving `<() as Trait>::Output normalizes-to _`
--> $DIR/assoc-ty.rs:15:12
--> $DIR/assoc-ty.rs:17:12
|
LL | let _: <() as Trait>::Output = ();
| ^^^^^^^^^^^^^^^^^^^^^ types differ

View file

@ -7,13 +7,16 @@
auto trait Trait {
//~^ ERROR auto traits are experimental and possibly buggy
//~| HELP add `#![feature(auto_traits)]` to the crate attributes to enable
type Output;
//~^ ERROR auto traits cannot have associated items
//~| HELP remove the associated items
}
fn main() {
let _: <() as Trait>::Output = ();
//[current]~^ ERROR mismatched types
//[next]~^^ ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _`
//[current]~| HELP consider constraining the associated type `<() as Trait>::Output` to `()` or calling a method that returns `<() as Trait>::Output`
//[next]~^^^ ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _`
//[next]~| ERROR type mismatch resolving `<() as Trait>::Output normalizes-to _`
}