Skip to content

Commit 7e94cc3

Browse files
committed
Update E0210 to match RFC 2451
1 parent eb981a1 commit 7e94cc3

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/librustc_typeck/error_codes.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,8 +2058,13 @@ E0210: r##"
20582058
This error indicates a violation of one of Rust's orphan rules for trait
20592059
implementations. The rule concerns the use of type parameters in an
20602060
implementation of a foreign trait (a trait defined in another crate), and
2061-
states that type parameters must be "covered" by a local type. To understand
2062-
what this means, it is perhaps easiest to consider a few examples.
2061+
states that type parameters must be "covered" by a local type.
2062+
2063+
When implementing a foreign trait for a foreign type,
2064+
the trait must have one or more type parameters.
2065+
A type local to your crate must appear before any use of any type parameters.
2066+
2067+
To understand what this means, it is perhaps easier to consider a few examples.
20632068
20642069
If `ForeignTrait` is a trait defined in some external crate `foo`, then the
20652070
following trait `impl` is an error:
@@ -2117,12 +2122,17 @@ impl<P1, ..., Pm> ForeignTrait<T1, ..., Tn> for T0 { ... }
21172122
21182123
where `P1, ..., Pm` are the type parameters of the `impl` and `T0, ..., Tn`
21192124
are types. One of the types `T0, ..., Tn` must be a local type (this is another
2120-
orphan rule, see the explanation for E0117). Let `i` be the smallest integer
2121-
such that `Ti` is a local type. Then no type parameter can appear in any of the
2122-
`Tj` for `j < i`.
2125+
orphan rule, see the explanation for E0117).
21232126
2124-
For information on the design of the orphan rules, see [RFC 1023].
2127+
Both of the folowing must be true:
2128+
1. At least one of the types T0..=Tn must be a local type.
2129+
Let Ti be the first such type.
2130+
2. No uncovered type parameters P1..=Pm may appear in T0..Ti (excluding Ti).
2131+
2132+
For information on the design of the orphan rules,
2133+
see [RFC 2451] and [RFC 1023].
21252134
2135+
[RFC 2451]: https://rust-lang.github.io/rfcs/2451-re-rebalancing-coherence.html
21262136
[RFC 1023]: https://github.com/rust-lang/rfcs/blob/master/text/1023-rebalancing-coherence.md
21272137
"##,
21282138

0 commit comments

Comments
 (0)