diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-08-07 20:49:36 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-07 20:49:36 +1000 | 
| commit | bcd50fd45fb92a6c96af7e91893488bd4499153c (patch) | |
| tree | 31c5bcca2a40e60d434ab0fd1821b61cfda516b4 /compiler/rustc_ast_passes/src/errors.rs | |
| parent | 61cb1e97fcf954c37d0a457a8084ed9ad8b3cb82 (diff) | |
| parent | 91e606b715ac4e8f59fac86d42ec2ad23f4ef169 (diff) | |
| download | rust-bcd50fd45fb92a6c96af7e91893488bd4499153c.tar.gz rust-bcd50fd45fb92a6c96af7e91893488bd4499153c.zip | |
Rollup merge of #137831 - estebank:auto-trait-err, r=compiler-errors
Tweak auto trait errors
Make suggestions to remove params and super traits verbose and make spans more accurate.
```
error[E0567]: auto traits cannot have generic parameters
  --> $DIR/auto-trait-validation.rs:6:19
   |
LL | auto trait Generic<T> {}
   |            -------^^^
   |            |
   |            auto trait cannot have generic parameters
error[E0568]: auto traits cannot have super traits or lifetime bounds
  --> $DIR/auto-trait-validation.rs:8:20
   |
LL | auto trait Bound : Copy {}
   |            -----   ^^^^
   |            |
   |            auto traits cannot have super traits or lifetime bounds
```
```
error[E0380]: auto traits cannot have associated items
  --> $DIR/issue-23080.rs:5:8
   |
LL | unsafe auto trait Trait {
   |                   ----- auto traits cannot have associated items
LL |     fn method(&self) {
   |        ^^^^^^
```
Diffstat (limited to 'compiler/rustc_ast_passes/src/errors.rs')
| -rw-r--r-- | compiler/rustc_ast_passes/src/errors.rs | 9 | 
1 files changed, 5 insertions, 4 deletions
| diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index 8b5873a3ef3..60f47490f12 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -344,7 +344,7 @@ pub(crate) struct ModuleNonAscii { #[diag(ast_passes_auto_generic, code = E0567)] pub(crate) struct AutoTraitGeneric { #[primary_span] - #[suggestion(code = "", applicability = "machine-applicable")] + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] pub span: Span, #[label] pub ident: Span, @@ -354,8 +354,9 @@ pub(crate) struct AutoTraitGeneric { #[diag(ast_passes_auto_super_lifetime, code = E0568)] pub(crate) struct AutoTraitBounds { #[primary_span] - #[suggestion(code = "", applicability = "machine-applicable")] - pub span: Span, + pub span: Vec<Span>, + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] + pub removal: Span, #[label] pub ident: Span, } @@ -365,7 +366,7 @@ pub(crate) struct AutoTraitBounds { pub(crate) struct AutoTraitItems { #[primary_span] pub spans: Vec<Span>, - #[suggestion(code = "", applicability = "machine-applicable")] + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] pub total: Span, #[label] pub ident: Span, | 
