Skip to content

Commit ef121f2

Browse files
committed
Suggesting an available assoc item is always maybe-incorrect
1 parent cefe1dc commit ef121f2

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,14 @@ pub enum AssocItemNotFoundSugg<'a> {
126126
assoc_kind: &'static str,
127127
suggested_name: Symbol,
128128
},
129-
#[suggestion(hir_analysis_assoc_item_not_found_other_sugg, code = "{suggested_name}")]
129+
#[suggestion(
130+
hir_analysis_assoc_item_not_found_other_sugg,
131+
code = "{suggested_name}",
132+
applicability = "maybe-incorrect"
133+
)]
130134
Other {
131135
#[primary_span]
132136
span: Span,
133-
#[applicability]
134-
applicability: Applicability,
135137
ty_param_name: &'a str,
136138
assoc_kind: &'static str,
137139
suggested_name: Symbol,

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,10 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
269269
}
270270

271271
// If we still couldn't find any associated item, and only one associated item exists,
272-
// suggests using it.
272+
// suggest using it.
273273
if let [candidate_name] = all_candidate_names.as_slice() {
274-
// This should still compile, except on `#![feature(associated_type_defaults)]`
275-
// where it could suggests `type A = Self::A`, thus recursing infinitely.
276-
let applicability =
277-
if assoc_kind == ty::AssocKind::Type && tcx.features().associated_type_defaults {
278-
Applicability::Unspecified
279-
} else {
280-
Applicability::MaybeIncorrect
281-
};
282-
283274
err.sugg = Some(errors::AssocItemNotFoundSugg::Other {
284275
span: assoc_name.span,
285-
applicability,
286276
ty_param_name,
287277
assoc_kind: assoc_kind_str,
288278
suggested_name: *candidate_name,

0 commit comments

Comments
 (0)