@@ -1750,6 +1750,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17501750 {
17511751 span. push_span_label ( sp, label) ;
17521752 }
1753+ let mut points_at_type = false ;
17531754 if let Some ( found_type) = found_type {
17541755 span. push_span_label (
17551756 self . tcx . def_span ( found_type) ,
@@ -1772,6 +1773,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17721773 candidate_span,
17731774 "this type implements the required trait" ,
17741775 ) ;
1776+ points_at_type = true ;
17751777 }
17761778 }
17771779 }
@@ -1783,14 +1785,20 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
17831785 StringPart :: highlighted( format!( "{crate_name}" ) ) ,
17841786 StringPart :: normal( "` in the dependency graph\n " . to_string( ) ) ,
17851787 ] ) ;
1786- err. highlighted_note ( vec ! [
1787- StringPart :: normal(
1788- "two types coming from two different versions of the same crate are \
1788+ if points_at_type {
1789+ // We only clarify that the same type from different crate versions are not the
1790+ // same when we *find* the same type coming from different crate versions, otherwise
1791+ // it could be that it was a type provided by a different crate than the one that
1792+ // provides the trait, and mentioning this adds verbosity without clarification.
1793+ err. highlighted_note ( vec ! [
1794+ StringPart :: normal(
1795+ "two types coming from two different versions of the same crate are \
17891796 different types "
1790- . to_string( ) ,
1791- ) ,
1792- StringPart :: highlighted( "even if they look the same" . to_string( ) ) ,
1793- ] ) ;
1797+ . to_string( ) ,
1798+ ) ,
1799+ StringPart :: highlighted( "even if they look the same" . to_string( ) ) ,
1800+ ] ) ;
1801+ }
17941802 err. highlighted_help ( vec ! [
17951803 StringPart :: normal( "you can use `" . to_string( ) ) ,
17961804 StringPart :: highlighted( "cargo tree" . to_string( ) ) ,
0 commit comments