Skip to content

Commit

Permalink
Only show "same type from differnt version" note when relevant
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Aug 28, 2024
1 parent fe23bd8 commit 926ea65
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
{
span.push_span_label(sp, label);
}
let mut points_at_type = false;
if let Some(found_type) = found_type {
span.push_span_label(
self.tcx.def_span(found_type),
Expand All @@ -1725,6 +1726,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
candidate_span,
"this type implements the required trait",
);
points_at_type = true;
}
}
}
Expand All @@ -1739,14 +1741,20 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
StringPart::normal("` in the dependency graph\n".to_string()),
],
);
err.highlighted_note(vec![
StringPart::normal(
"two types coming from two different versions of the same crate are \
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![
StringPart::normal(
"two types coming from two different versions of the same crate are \
different types "
.to_string(),
),
StringPart::highlighted("even if they look the same".to_string()),
]);
.to_string(),
),
StringPart::highlighted("even if they look the same".to_string()),
]);
}
err.highlighted_help(vec![
StringPart::normal("you can use `".to_string()),
StringPart::highlighted("cargo tree".to_string()),
Expand Down

0 comments on commit 926ea65

Please sign in to comment.