Suggest removal of auto trait super traits and type params
This commit is contained in:
parent
6fba412499
commit
005fc6eacc
5 changed files with 38 additions and 1 deletions
|
|
@ -910,6 +910,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
item.ident.span,
|
||||
"auto trait cannot have generic parameters",
|
||||
);
|
||||
err.span_suggestion_verbose(
|
||||
generics.span,
|
||||
"remove the parameters for the auto trait to be valid",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
err.emit();
|
||||
}
|
||||
if !bounds.is_empty() {
|
||||
|
|
@ -922,6 +928,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
E0568,
|
||||
"auto traits cannot have super traits"
|
||||
);
|
||||
err.span_label(item.ident.span, "auto trait cannot have super traits");
|
||||
if let Some(span) = last {
|
||||
err.span_label(
|
||||
span,
|
||||
|
|
@ -931,8 +938,13 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
s = pluralize!(len)
|
||||
),
|
||||
);
|
||||
err.span_suggestion_verbose(
|
||||
generics.span.shrink_to_hi().to(span),
|
||||
"remove the super traits for the auto trait to be valid",
|
||||
String::new(),
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
}
|
||||
err.span_label(item.ident.span, "auto trait cannot have super traits");
|
||||
err.emit();
|
||||
}
|
||||
if !trait_items.is_empty() {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ LL | auto trait Generic<T> {}
|
|||
| ------- ^ cannot have this generic parameter
|
||||
| |
|
||||
| auto trait cannot have generic parameters
|
||||
|
|
||||
help: remove the parameters for the auto trait to be valid
|
||||
|
|
||||
LL | auto trait Generic {}
|
||||
| --
|
||||
|
||||
error[E0568]: auto traits cannot have super traits
|
||||
--> $DIR/auto-trait-validation.rs:5:20
|
||||
|
|
@ -13,6 +18,11 @@ LL | auto trait Bound : Copy {}
|
|||
| ----- ^^^^ cannot have this super trait
|
||||
| |
|
||||
| auto trait cannot have super traits
|
||||
|
|
||||
help: remove the super traits for the auto trait to be valid
|
||||
|
|
||||
LL | auto trait Bound {}
|
||||
| --
|
||||
|
||||
error[E0380]: auto traits cannot have methods or associated items
|
||||
--> $DIR/auto-trait-validation.rs:7:25
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ LL | auto trait Magic: Copy {}
|
|||
| ----- ^^^^ cannot have this super trait
|
||||
| |
|
||||
| auto trait cannot have super traits
|
||||
|
|
||||
help: remove the super traits for the auto trait to be valid
|
||||
|
|
||||
LL | auto trait Magic {}
|
||||
| --
|
||||
|
||||
error[E0277]: the trait bound `NoClone: std::marker::Copy` is not satisfied
|
||||
--> $DIR/traits-inductive-overflow-supertrait-oibit.rs:15:23
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ LL | auto trait Magic : Sized where Option<Self> : Magic {}
|
|||
| ----- ^^^^^ cannot have this super trait
|
||||
| |
|
||||
| auto trait cannot have super traits
|
||||
|
|
||||
help: remove the super traits for the auto trait to be valid
|
||||
|
|
||||
LL | auto trait Magic where Option<Self> : Magic {}
|
||||
| --
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,11 @@ LL | auto trait Magic: Copy {}
|
|||
| ----- ^^^^ cannot have this super trait
|
||||
| |
|
||||
| auto trait cannot have super traits
|
||||
|
|
||||
help: remove the super traits for the auto trait to be valid
|
||||
|
|
||||
LL | auto trait Magic {}
|
||||
| --
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue