diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-07-18 08:09:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-18 08:09:01 +0200 |
| commit | a13d7dbecf6ea190b1edb274702e09a6e42b7838 (patch) | |
| tree | bd0d159699064e461cc4d08448c733b61f14f340 /compiler/rustc_hir_analysis/src | |
| parent | b2b14deca5a098f4ec8083e4355439d35fbeb667 (diff) | |
| parent | e38032fb3ad5736934ea1ff1ecc43e8af4c47a87 (diff) | |
| download | rust-a13d7dbecf6ea190b1edb274702e09a6e42b7838.tar.gz rust-a13d7dbecf6ea190b1edb274702e09a6e42b7838.zip | |
Rollup merge of #127878 - estebank:assoc-item-removal, r=fmease
Fix associated item removal suggestion
We were previously telling people to write what was already there, instead of removal (treating it as a `help`). We now properly suggest to remove the code that needs to be removed.
```
error[E0229]: associated item constraints are not allowed here
--> $DIR/E0229.rs:13:25
|
LL | fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
| ^^^^^^^ associated item constraint not allowed here
|
help: consider removing this associated item binding
|
LL - fn baz<I>(x: &<I as Foo<A = Bar>>::A) {}
LL + fn baz<I>(x: &<I as Foo>::A) {}
|
```
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
| -rw-r--r-- | compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 5e595488ea7..cd0451b4165 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -1257,14 +1257,12 @@ pub fn prohibit_assoc_item_constraint( }; // Now emit the suggestion - if let Ok(suggestion) = tcx.sess.source_map().span_to_snippet(removal_span) { - e.span_suggestion_verbose( - removal_span, - format!("consider removing this associated item {}", constraint.kind.descr()), - suggestion, - Applicability::MaybeIncorrect, - ); - } + e.span_suggestion_verbose( + removal_span, + format!("consider removing this associated item {}", constraint.kind.descr()), + "", + Applicability::MaybeIncorrect, + ); }; // Suggest replacing the associated item binding with a generic argument. |
