negative_impls
and auto_traits
experimental features allow trait impls to overlap
#74629
Labels
A-auto-traits
Area: auto traits (e.g., `auto trait Send {}`)
C-bug
Category: This is a bug.
F-auto_traits
`#![feature(auto_traits)]`
F-negative_impls
#![feature(negative_impls)]
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
requires-nightly
This issue requires a nightly compiler in some way.
S-bug-has-test
Status: This bug is tracked inside the repo by a `known-bug` test.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
I tried this code (this is the most minimal example that I could create, though I think that there may exist a simpler one. my original code: playground):
(playground)
I expected to see a compilation error because
0
and1
implementations are clearly overlapping each other. E.g.: withT = Test, F = ()
all bounds are true, making both implementations appliable (Test: Fold<Nil>
,Test: Fold<()>
are true because of2
,Is<Test>: NotNil
is true because ofauto trait
& lack of negative implementation).However, this code compiles with the latest nightly (
1.47.0-nightly (2020-07-20 f9a3086363f214f2b56b)
)To make things even weirder, this does not compile:
(playground)
Error
But this does compile:
(playground)
And lastly, if you'll try to add a constant to the trait & print it, the compiler will ICE.
Backtrace
The text was updated successfully, but these errors were encountered: