You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Slightly tweak the diagnostic for uncovered type parameters
The diagnostic is generally very noisy.
This commit tries to make it slightly less cluttered and more legible by
1. stopping to reuse the lengthy primary message as the primary label.
This duplication didn't increase the information content and only
turned the diagnostic into a letter and symbol soup.
Instead, we now pick a succinct label ("uncovered type parameter")
that immediately(!) signals to the users in red what is wrong with
the highlighted type parameter.
2. breaking some information-dense notes into multiple lines.
Finally, this rephrases the slightly awkward and confusing
"type parameter […] must be used as a type parameter for […] type" to
"type parameter […] must be used as an argument to […] type".
.with_span_label(param.span,"uncovered type parameter");
1996
1998
if diag.is_error(){
1997
1999
diag.code(E0210);
1998
2000
}
1999
2001
2000
-
let note = "implementing a foreign trait is only possible if at least one of the types for which it is implemented is local";
2002
+
let note = "\
2003
+
implementing a foreign trait is only possible if \
2004
+
at least one of the types for which it is implemented is local";
2005
+
2001
2006
ifletSome(local_ty) = local_ty {
2002
-
let msg = format!(
2003
-
"type parameter `{param}` must be covered by another type when it appears before the first local type (`{local_ty}`)"
2004
-
);
2005
-
diag.primary_message(msg.clone());
2006
-
diag.span_label(param.span, msg);
2007
+
diag.primary_message(format!(
2008
+
"type parameter `{param}` must be covered by another type when \
2009
+
it appears before the first local type (`{local_ty}`)"
2010
+
));
2011
+
2007
2012
diag.note(format!(
2008
-
"{note}, and no uncovered type parameters appear before that first local type"
2013
+
"{note},\nand no uncovered type parameters appear before that first local type"
2009
2014
));
2010
-
diag.note("in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last");
2011
-
}else{
2012
-
let msg = format!(
2013
-
"type parameter `{param}` must be used as the type parameter for some local type"
2015
+
diag.note(
2016
+
"in this case, 'before' refers to the following order: \
Copy file name to clipboardExpand all lines: tests/ui/coherence/coherence-bigint-param.stderr
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,12 @@ error[E0210]: type parameter `T` must be covered by another type when it appears
2
2
--> $DIR/coherence-bigint-param.rs:8:6
3
3
|
4
4
LL | impl<T> Remote1<BigInt> for T { }
5
-
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`BigInt`)
5
+
| ^ uncovered type parameter
6
6
|
7
-
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local, and no uncovered type parameters appear before that first local type
8
-
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`, where `T0` is the first and `Tn` is the last
7
+
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local,
8
+
and no uncovered type parameters appear before that first local type
9
+
= note: in this case, 'before' refers to the following order: `impl<..> ForeignTrait<T1, ..., Tn> for T0`,
0 commit comments