Skip to content

Commit e956819

Browse files
committed
Accept RFC rust-lang#1268. Add notes on motivation and unresolved questions.
1 parent 2871102 commit e956819

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

0000-allow-overlapping-impls-on-marker-traits.md text/1268-allow-overlapping-impls-on-marker-traits.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ While specialization will certainly make all cases not covered today possible,
1818
removing the restriction entirely will improve the ergonomics in several edge
1919
cases.
2020

21+
Some examples include:
22+
23+
- the coercible trait design presents at [RFC #91][91];
24+
- the `ExnSafe` trait proposed in [RFC #1236][1236].
25+
26+
[91]: https://github.com/rust-lang/rfcs/pull/91
27+
[1236]: https://github.com/rust-lang/rfcs/pull/1236
28+
2129
# Detailed design
2230

2331
For the purpose of this RFC, the definition of a marker trait is a trait with no
@@ -110,4 +118,23 @@ specify the empty impl for any overlap that might occur.
110118

111119
# Unresolved questions
112120

113-
None at this time.
121+
How can we implement this design? Simply lifting the coherence
122+
restrictions is easy enough, but we will encounter some challenges
123+
when we come to test whether a given trait impl holds. For example, if
124+
we have something like:
125+
126+
```rust
127+
impl<T:Send> MarkerTrait for T { }
128+
impl<T:Sync> MarkerTrait for T { }
129+
```
130+
131+
means that a type `Foo: MarkerTrait` can hold *either* by `Foo: Send`
132+
*or* by `Foo: Sync`. Today, we prefer to break down an obligation like
133+
`Foo: MarkerTrait` into component obligations (e.g., `Foo: Send`). Due
134+
to coherence, there is always one best way to do this (sort of ---
135+
where clauses complicate matters). That is, except for complications
136+
due to type inference, there is a best impl to choose. But under this
137+
proposal, there would not be. Experimentation is needed (similar
138+
concerns arise with the proposals around specialization, so it may be
139+
that progress on that front will answer the questions raised here).
140+

0 commit comments

Comments
 (0)