about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2024-06-10 03:38:09 +0200
committerLeón Orell Valerian Liehr <me@fmease.dev>2024-07-23 01:18:18 +0200
commitef121f28d8684d32306becb7577b4e36d7c0ff08 (patch)
treed10c55dc0f072e0e60c2294638c6bf93335f7ac6
parentcefe1dcef0e21f4d0c8ea856ad61c1936dfb7913 (diff)
downloadrust-ef121f28d8684d32306becb7577b4e36d7c0ff08.tar.gz
rust-ef121f28d8684d32306becb7577b4e36d7c0ff08.zip
Suggesting an available assoc item is always maybe-incorrect
-rw-r--r--compiler/rustc_hir_analysis/src/errors.rs8
-rw-r--r--compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs12
2 files changed, 6 insertions, 14 deletions
diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs
index c83788928a9..d1f9ad9d58b 100644
--- a/compiler/rustc_hir_analysis/src/errors.rs
+++ b/compiler/rustc_hir_analysis/src/errors.rs
@@ -126,12 +126,14 @@ pub enum AssocItemNotFoundSugg<'a> {
         assoc_kind: &'static str,
         suggested_name: Symbol,
     },
-    #[suggestion(hir_analysis_assoc_item_not_found_other_sugg, code = "{suggested_name}")]
+    #[suggestion(
+        hir_analysis_assoc_item_not_found_other_sugg,
+        code = "{suggested_name}",
+        applicability = "maybe-incorrect"
+    )]
     Other {
         #[primary_span]
         span: Span,
-        #[applicability]
-        applicability: Applicability,
         ty_param_name: &'a str,
         assoc_kind: &'static str,
         suggested_name: Symbol,
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 8ff6ced8b39..40675a1edba 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
@@ -269,20 +269,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
         }
 
         // If we still couldn't find any associated item, and only one associated item exists,
-        // suggests using it.
+        // suggest using it.
         if let [candidate_name] = all_candidate_names.as_slice() {
-            // This should still compile, except on `#![feature(associated_type_defaults)]`
-            // where it could suggests `type A = Self::A`, thus recursing infinitely.
-            let applicability =
-                if assoc_kind == ty::AssocKind::Type && tcx.features().associated_type_defaults {
-                    Applicability::Unspecified
-                } else {
-                    Applicability::MaybeIncorrect
-                };
-
             err.sugg = Some(errors::AssocItemNotFoundSugg::Other {
                 span: assoc_name.span,
-                applicability,
                 ty_param_name,
                 assoc_kind: assoc_kind_str,
                 suggested_name: *candidate_name,