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
Rollup merge of rust-lang#66253 - ohadravid:improve-errors-after-re-rebalance-coherence, r=estebank
Improve errors after re rebalance coherence
Following rust-lang#65247, I noticed that some error messages should be updated to reflect the changes of `re_rebalance_coherence` (also there was a [note](https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html#teaching-users) in the RFC about it).
First, error message `E0210` was updated to match the RFC, and I also tried to improve a little the error when the "order" of types is problematic.
For code like this:
```
#![feature(re_rebalance_coherence)] // Now stable
struct Wrap<T>(T);
impl<T> From<Wrap<T>> for T {
fn from(x: Wrap<T>) -> T {
x.0
}
}
```
The old error was:
```
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
--> src/lib.rs:5:6
|
5 | impl<T> From<Wrap<T>> for T {
| ^ type parameter `T` must be used as the type parameter for some local type
|
= note: only traits defined in the current crate can be implemented for a type parameter
```
and the new error is:
```
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
--> main.rs:66:6
|
66 | impl<T> From<Wrap<T>> for T {
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Wrap<T>`)
|
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
= 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
```
I tried to point at the uncovered `T`, but couldn't get something which was reliable (but I'll be happy to try if someone points me in the right direction).
r? @estebank
cc @nikomatsakisFixesrust-lang#65247
Copy file name to clipboardExpand all lines: src/test/ui/coherence/coherence-bigint-param.stderr
+4-3
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,11 @@
1
-
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
1
+
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`BigInt`)
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 used as the type parameter for some local type
5
+
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`BigInt`)
6
6
|
7
-
= note: only traits defined in the current crate can be implemented for a type parameter
7
+
= note: implementing a foreign trait is only possible if at least one of the types for which is it 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
| ^ type parameter `T` must be used as the type parameter for some local type
5
+
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
6
6
|
7
-
= note: only traits defined in the current crate can be implemented for a type parameter
7
+
= note: implementing a foreign trait is only possible if at least one of the types for which is it 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
8
9
9
-
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
10
+
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
| ^ type parameter `T` must be used as the type parameter for some local type
14
+
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
14
15
|
15
-
= note: only traits defined in the current crate can be implemented for a type parameter
16
+
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
17
+
= 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
| ^ type parameter `T` must be used as the type parameter for some local type
5
+
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
6
6
|
7
-
= note: only traits defined in the current crate can be implemented for a type parameter
7
+
= note: implementing a foreign trait is only possible if at least one of the types for which is it 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
8
9
9
-
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
10
+
error[E0210]: type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
| ^ type parameter `T` must be used as the type parameter for some local type
14
+
| ^ type parameter `T` must be covered by another type when it appears before the first local type (`Local`)
14
15
|
15
-
= note: only traits defined in the current crate can be implemented for a type parameter
16
+
= note: implementing a foreign trait is only possible if at least one of the types for which is it implemented is local, and no uncovered type parameters appear before that first local type
17
+
= 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
0 commit comments