@@ -38,7 +38,7 @@ Overlapping is sometimes partially allowed:
38381 . for marker traits
39392 . under [ specialization] ( traits/specialization.md )
4040
41- but normally isn't.
41+ It normally isn't.
4242
4343The overlap check has various modes (see [ ` OverlapMode ` ] ).
4444Importantly, there's the explicit negative impl check, and the implicit negative impl check.
@@ -65,7 +65,7 @@ In this example, we'd get:
6565` MyCustomErrorType: From<&str> ` and ` MyCustomErrorType: From<?E> ` , giving ` ?E = &str ` .
6666
6767And thus, these two implementations would overlap.
68- However, libstd provides ` &str: !Error ` , and therefore guarantees that there
68+ However, libstd provides ` &str: !Error ` , and therefore guarantees that there
6969will never be a positive implementation of ` &str: Error ` , and thus there is no overlap.
7070
7171Note that for this kind of negative impl check, we must have explicit negative implementations provided.
@@ -78,18 +78,17 @@ This is not currently stable.
7878This check is done in [ ` impl_intersection_has_impossible_obligation ` ] ,
7979and does not rely on negative trait implementations and is stable.
8080
81- Let's say there's a
81+ Let's say there's a
8282``` rust
8383impl From <MyLocalType > for Box <dyn Error > {} // in your own crate
8484impl <E > From <E > for Box <dyn Error > where E : Error {} // in std
8585```
8686
87- This would give: ` Box<dyn Error>: From<MyLocalType> ` , and ` Box<dyn Error>: From<?E> ` ,
87+ This would give: ` Box<dyn Error>: From<MyLocalType> ` , and ` Box<dyn Error>: From<?E> ` ,
8888giving ` ?E = MyLocalType ` .
8989
9090In your crate there's no ` MyLocalType: Error ` , downstream crates cannot implement ` Error ` (a remote trait) for ` MyLocalType ` (a remote type).
9191Therefore, these two impls do not overlap.
9292Importantly, this works even if there isn't a ` impl !Error for MyLocalType ` .
9393
9494[ `impl_intersection_has_impossible_obligation` ] : https://doc.rust-lang.org/beta/nightly-rustc/rustc_trait_selection/traits/coherence/fn.impl_intersection_has_impossible_obligation.html
95-
0 commit comments