@@ -42,7 +42,7 @@ but 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.
45- Both try to apply negative reasoning to prove that an overlap is definitely impossible.
45+ Both try to prove that an overlap is definitely impossible.
4646
4747[ `OverlapMode` ] : https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/traits/specialization_graph/enum.OverlapMode.html
4848
@@ -54,15 +54,17 @@ This check tries to find a negative trait implementation.
5454For example:
5555
5656``` rust
57+ struct MyCustomErrorType ;
58+
5759struct MyCustomBox <T : ? Sized >(Box <T >)
5860
5961// both in your own crate
60- impl From <& str > for MyCustomBox < dyn Error > {}
61- impl <E > From <E > for MyCustomBox < dyn Error > where E : Error {}
62+ impl From <& str > for MyCustomErrorType {}
63+ impl <E > From <E > for MyCustomErrorType where E : Error {}
6264```
6365
6466In this example, we'd get:
65- ` MyCustomBox<dyn Error> : From<&str>` and ` MyCustomBox<dyn Error> : From<?E>` , giving ` ?E = &str ` .
67+ ` MyCustomErrorType : From<&str>` and ` MyCustomErrorType : From<?E>` , giving ` ?E = &str ` .
6668
6769And thus, these two implementations would overlap.
6870However, libstd provides ` &str: !Error ` , and therefore guarantees that there
@@ -71,7 +73,7 @@ will never be a positive implementation of `&str: Error`, and thus there is no o
7173Note that for this kind of negative impl check, we must have explicit negative implementations provided.
7274This is not currently stable.
7375
74- [ `impl_intersection_has_negative_obligation` ] : https://doc.rust-lang.org/beta/nightly-rustc/rustc_trait_selection/traits/coherence/fn.impl_intersection_has_impossible_obligation.htmlhttps://doc.rust-lang.org/beta/nightly-rustc/rustc_trait_selection/traits/coherence/fn. impl_intersection_has_negative_obligation.html
76+ [ `impl_intersection_has_negative_obligation` ] : https://doc.rust-lang.org/beta/nightly-rustc/rustc_trait_selection/traits/coherence/fn.impl_intersection_has_negative_obligation.html
7577
7678### The implicit negative impl check
7779
@@ -93,5 +95,3 @@ Importantly, this works even if there isn't a `impl !Error for MyLocalType`.
9395
9496[ `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
9597
96-
97-
0 commit comments