Only show "same type from differnt version" note when relevant
This commit is contained in:
parent
8a568d9f15
commit
81b0de4356
@ -1750,6 +1750,7 @@ pub(super) fn report_similar_impl_candidates(
|
|||||||
{
|
{
|
||||||
span.push_span_label(sp, label);
|
span.push_span_label(sp, label);
|
||||||
}
|
}
|
||||||
|
let mut points_at_type = false;
|
||||||
if let Some(found_type) = found_type {
|
if let Some(found_type) = found_type {
|
||||||
span.push_span_label(
|
span.push_span_label(
|
||||||
self.tcx.def_span(found_type),
|
self.tcx.def_span(found_type),
|
||||||
@ -1772,6 +1773,7 @@ pub(super) fn report_similar_impl_candidates(
|
|||||||
candidate_span,
|
candidate_span,
|
||||||
"this type implements the required trait",
|
"this type implements the required trait",
|
||||||
);
|
);
|
||||||
|
points_at_type = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1783,6 +1785,11 @@ pub(super) fn report_similar_impl_candidates(
|
|||||||
StringPart::highlighted(format!("{crate_name}")),
|
StringPart::highlighted(format!("{crate_name}")),
|
||||||
StringPart::normal("` in the dependency graph\n".to_string()),
|
StringPart::normal("` in the dependency graph\n".to_string()),
|
||||||
]);
|
]);
|
||||||
|
if points_at_type {
|
||||||
|
// We only clarify that the same type from different crate versions are not the
|
||||||
|
// same when we *find* the same type coming from different crate versions, otherwise
|
||||||
|
// it could be that it was a type provided by a different crate than the one that
|
||||||
|
// provides the trait, and mentioning this adds verbosity without clarification.
|
||||||
err.highlighted_note(vec![
|
err.highlighted_note(vec![
|
||||||
StringPart::normal(
|
StringPart::normal(
|
||||||
"two types coming from two different versions of the same crate are \
|
"two types coming from two different versions of the same crate are \
|
||||||
@ -1791,6 +1798,7 @@ pub(super) fn report_similar_impl_candidates(
|
|||||||
),
|
),
|
||||||
StringPart::highlighted("even if they look the same".to_string()),
|
StringPart::highlighted("even if they look the same".to_string()),
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
err.highlighted_help(vec![
|
err.highlighted_help(vec![
|
||||||
StringPart::normal("you can use `".to_string()),
|
StringPart::normal("you can use `".to_string()),
|
||||||
StringPart::highlighted("cargo tree".to_string()),
|
StringPart::highlighted("cargo tree".to_string()),
|
||||||
|
Loading…
Reference in New Issue
Block a user