Skip to content

Commit 7c5e03f

Browse files
committed
sembr src/coherence.md
1 parent c4673dc commit 7c5e03f

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

src/coherence.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ Coherence checking is what detects both of trait impls and inherent impls overla
88
Overlapping trait impls always produce an error,
99
while overlapping inherent impls result in an error only if they have methods with the same name.
1010

11-
Checking for overlaps is split in two parts. First there's the [overlap check(s)](#overlap-checks),
11+
Checking for overlaps is split in two parts.
12+
First there's the [overlap check(s)](#overlap-checks),
1213
which finds overlaps between traits and inherent implementations that the compiler currently knows about.
1314

1415
However, Coherence also results in an error if any other impls **could** exist,
15-
even if they are currently unknown.
16+
even if they are currently unknown.
1617
This affects impls which may get added to upstream crates in a backwards compatible way,
17-
and impls from downstream crates.
18+
and impls from downstream crates.
1819
This is called the Orphan check.
1920

2021
## Overlap checks
@@ -25,7 +26,7 @@ Overlap checks always consider pairs of implementations, comparing them to each
2526

2627
Overlap checking for inherent impl blocks is done through `fn check_item` (in coherence/inherent_impls_overlap.rs),
2728
where you can very clearly see that (at least for small `n`), the check really performs `n^2`
28-
comparisons between impls.
29+
comparisons between impls.
2930

3031
In the case of traits, this check is currently done as part of building the [specialization graph](traits/specialization.md),
3132
to handle specializing impls overlapping with their parent, but this may change in the future.
@@ -37,7 +38,7 @@ Overlapping is sometimes partially allowed:
3738
1. for marker traits
3839
2. under [specialization](traits/specialization.md)
3940

40-
but normally isn't.
41+
but normally isn't.
4142

4243
The overlap check has various modes (see [`OverlapMode`]).
4344
Importantly, there's the explicit negative impl check, and the implicit negative impl check.
@@ -47,9 +48,9 @@ Both try to prove that an overlap is definitely impossible.
4748

4849
### The explicit negative impl check
4950

50-
This check is done in [`impl_intersection_has_negative_obligation`].
51+
This check is done in [`impl_intersection_has_negative_obligation`].
5152

52-
This check tries to find a negative trait implementation.
53+
This check tries to find a negative trait implementation.
5354
For example:
5455

5556
```rust

0 commit comments

Comments
 (0)