@@ -42,7 +42,7 @@ but normally isn't.
42
42
43
43
The overlap check has various modes (see [ ` OverlapMode ` ] ).
44
44
Importantly, 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.
46
46
47
47
[ `OverlapMode` ] : https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/traits/specialization_graph/enum.OverlapMode.html
48
48
@@ -54,15 +54,17 @@ This check tries to find a negative trait implementation.
54
54
For example:
55
55
56
56
``` rust
57
+ struct MyCustomErrorType ;
58
+
57
59
struct MyCustomBox <T : ? Sized >(Box <T >)
58
60
59
61
// 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 {}
62
64
```
63
65
64
66
In 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 ` .
66
68
67
69
And thus, these two implementations would overlap.
68
70
However, 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
71
73
Note that for this kind of negative impl check, we must have explicit negative implementations provided.
72
74
This is not currently stable.
73
75
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
75
77
76
78
### The implicit negative impl check
77
79
@@ -93,5 +95,3 @@ Importantly, this works even if there isn't a `impl !Error for MyLocalType`.
93
95
94
96
[ `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
97
96
-
97
-
0 commit comments