From 20c622e4564bed8f6e4f9ef8b05c3a004d45e6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 29 Sep 2023 16:17:22 +0000 Subject: [PATCH] Tweak wording --- compiler/rustc_hir_analysis/src/astconv/errors.rs | 3 ++- tests/rustdoc-ui/issues/issue-96287.stderr | 2 +- tests/ui/traits/issue-59029-1.stderr | 4 ++-- tests/ui/type-alias-impl-trait/not_well_formed.stderr | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/astconv/errors.rs b/compiler/rustc_hir_analysis/src/astconv/errors.rs index 0cac434f450..9e18767a7c3 100644 --- a/compiler/rustc_hir_analysis/src/astconv/errors.rs +++ b/compiler/rustc_hir_analysis/src/astconv/errors.rs @@ -191,10 +191,11 @@ pub(crate) fn complain_about_assoc_type_not_found( .collect::>()[..] { let trait_name = self.tcx().def_path_str(*best_trait); + let an = if suggested_name != assoc_name.name { "a similarly named" } else { "an" }; err.span_label( assoc_name.span, format!( - "there is a similarly named associated type `{suggested_name}` in the \ + "there is {an} associated type `{suggested_name}` in the \ trait `{trait_name}`", ), ); diff --git a/tests/rustdoc-ui/issues/issue-96287.stderr b/tests/rustdoc-ui/issues/issue-96287.stderr index ee5ab2ba45b..c4809a311fc 100644 --- a/tests/rustdoc-ui/issues/issue-96287.stderr +++ b/tests/rustdoc-ui/issues/issue-96287.stderr @@ -2,7 +2,7 @@ error[E0220]: associated type `Assoc` not found for `V` --> $DIR/issue-96287.rs:7:33 | LL | pub type Foo = impl Trait; - | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` + | ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc` | help: consider restricting type parameter `V` | diff --git a/tests/ui/traits/issue-59029-1.stderr b/tests/ui/traits/issue-59029-1.stderr index 51354bcc545..5c47eefcd6c 100644 --- a/tests/ui/traits/issue-59029-1.stderr +++ b/tests/ui/traits/issue-59029-1.stderr @@ -2,13 +2,13 @@ error[E0220]: associated type `Res` not found for `Self` --> $DIR/issue-59029-1.rs:5:52 | LL | trait MkSvc = Svc where Self::Res: Svc; - | ^^^ there is a similarly named associated type `Res` in the trait `Svc` + | ^^^ there is an associated type `Res` in the trait `Svc` error[E0220]: associated type `Res` not found for `Self` --> $DIR/issue-59029-1.rs:5:52 | LL | trait MkSvc = Svc where Self::Res: Svc; - | ^^^ there is a similarly named associated type `Res` in the trait `Svc` + | ^^^ there is an associated type `Res` in the trait `Svc` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/type-alias-impl-trait/not_well_formed.stderr b/tests/ui/type-alias-impl-trait/not_well_formed.stderr index e89cae2d104..b267e6a7544 100644 --- a/tests/ui/type-alias-impl-trait/not_well_formed.stderr +++ b/tests/ui/type-alias-impl-trait/not_well_formed.stderr @@ -2,7 +2,7 @@ error[E0220]: associated type `Assoc` not found for `V` --> $DIR/not_well_formed.rs:11:29 | LL | type Foo = impl Trait; - | ^^^^^ there is a similarly named associated type `Assoc` in the trait `TraitWithAssoc` + | ^^^^^ there is an associated type `Assoc` in the trait `TraitWithAssoc` | help: consider restricting type parameter `V` |