@@ -1703,6 +1703,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1703
1703
{
1704
1704
span. push_span_label ( sp, label) ;
1705
1705
}
1706
+ let mut points_at_type = false ;
1706
1707
if let Some ( found_type) = found_type {
1707
1708
span. push_span_label (
1708
1709
self . tcx . def_span ( found_type) ,
@@ -1725,6 +1726,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1725
1726
candidate_span,
1726
1727
"this type implements the required trait" ,
1727
1728
) ;
1729
+ points_at_type = true ;
1728
1730
}
1729
1731
}
1730
1732
}
@@ -1739,14 +1741,20 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1739
1741
StringPart :: normal( "` in the dependency graph\n " . to_string( ) ) ,
1740
1742
] ,
1741
1743
) ;
1742
- err. highlighted_note ( vec ! [
1743
- StringPart :: normal(
1744
- "two types coming from two different versions of the same crate are \
1744
+ if points_at_type {
1745
+ // We only clarify that the same type from different crate versions are not the
1746
+ // same when we *find* the same type coming from different crate versions, otherwise
1747
+ // it could be that it was a type provided by a different crate than the one that
1748
+ // provides the trait, and mentioning this adds verbosity without clarification.
1749
+ err. highlighted_note ( vec ! [
1750
+ StringPart :: normal(
1751
+ "two types coming from two different versions of the same crate are \
1745
1752
different types "
1746
- . to_string( ) ,
1747
- ) ,
1748
- StringPart :: highlighted( "even if they look the same" . to_string( ) ) ,
1749
- ] ) ;
1753
+ . to_string( ) ,
1754
+ ) ,
1755
+ StringPart :: highlighted( "even if they look the same" . to_string( ) ) ,
1756
+ ] ) ;
1757
+ }
1750
1758
err. highlighted_help ( vec ! [
1751
1759
StringPart :: normal( "you can use `" . to_string( ) ) ,
1752
1760
StringPart :: highlighted( "cargo tree" . to_string( ) ) ,
0 commit comments