From a328b7de9fdf5047dbed5bb63053003f145f773b Mon Sep 17 00:00:00 2001 From: jdonszelmann Date: Fri, 6 Sep 2024 15:57:56 +0200 Subject: [PATCH] fix comments after discussion --- src/coherence.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/coherence.md b/src/coherence.md index a34e1e8dd..024716f53 100644 --- a/src/coherence.md +++ b/src/coherence.md @@ -42,7 +42,7 @@ but normally isn't. The overlap check has various modes (see [`OverlapMode`]). Importantly, there's the explicit negative impl check, and the implicit negative impl check. -Both try to apply negative reasoning to prove that an overlap is definitely impossible. +Both try to prove that an overlap is definitely impossible. [`OverlapMode`]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/traits/specialization_graph/enum.OverlapMode.html @@ -54,15 +54,15 @@ This check tries to find a negative trait implementation. For example: ```rust -struct MyCustomBox(Box) +struct MyCustomErrorType; // both in your own crate -impl From<&str> for MyCustomBox {} -impl From for MyCustomBox where E: Error {} +impl From<&str> for MyCustomErrorType {} +impl From for MyCustomErrorType where E: Error {} ``` In this example, we'd get: -`MyCustomBox: From<&str>` and `MyCustomBox: From`, giving `?E = &str`. +`MyCustomErrorType: From<&str>` and `MyCustomErrorType: From`, giving `?E = &str`. And thus, these two implementations would overlap. However, libstd provides `&str: !Error`, and therefore guarantees that there @@ -71,7 +71,7 @@ will never be a positive implementation of `&str: Error`, and thus there is no o Note that for this kind of negative impl check, we must have explicit negative implementations provided. This is not currently stable. -[`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 +[`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 ### The implicit negative impl check @@ -93,5 +93,3 @@ Importantly, this works even if there isn't a `impl !Error for MyLocalType`. [`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 - -