Suggesting an available assoc item is always maybe-incorrect
This commit is contained in:
parent
cefe1dcef0
commit
ef121f28d8
@ -126,12 +126,14 @@ pub enum AssocItemNotFoundSugg<'a> {
|
|||||||
assoc_kind: &'static str,
|
assoc_kind: &'static str,
|
||||||
suggested_name: Symbol,
|
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 {
|
Other {
|
||||||
#[primary_span]
|
#[primary_span]
|
||||||
span: Span,
|
span: Span,
|
||||||
#[applicability]
|
|
||||||
applicability: Applicability,
|
|
||||||
ty_param_name: &'a str,
|
ty_param_name: &'a str,
|
||||||
assoc_kind: &'static str,
|
assoc_kind: &'static str,
|
||||||
suggested_name: Symbol,
|
suggested_name: Symbol,
|
||||||
|
@ -269,20 +269,10 @@ pub(super) fn complain_about_assoc_item_not_found<I>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we still couldn't find any associated item, and only one associated item exists,
|
// 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() {
|
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 {
|
err.sugg = Some(errors::AssocItemNotFoundSugg::Other {
|
||||||
span: assoc_name.span,
|
span: assoc_name.span,
|
||||||
applicability,
|
|
||||||
ty_param_name,
|
ty_param_name,
|
||||||
assoc_kind: assoc_kind_str,
|
assoc_kind: assoc_kind_str,
|
||||||
suggested_name: *candidate_name,
|
suggested_name: *candidate_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user