Associated types appear to cover or hide generic parameters in orphan rules checking #107377
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-coherence
Area: Coherence
A-trait-system
Area: Trait system
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Here’s a soundness issue in the orphan rules checker. @rustbot label I-unsound, A-traits, A-associated-items, T-compiler.
One crate
foo
definesIf a downstream crate uses
foo
and tries to implementit fails as expected
and rightfully so, since other crates depending on
foo
might define animpl<T> Trait<T> for OtherLocal {}
that overlaps.But we can circumvent this error using a trait with an associated type, violating the orphan rules!
(compiles fine)
I have only managed to turn this into an ICE during code generation so far, not UB at run-time, but I would be surprised if there wasn’t a way to actually exploit this bug, hence the label. I’ll look back into this in the next few days and either post a soundness exploit, or at least the way to achieve ICE.
The text was updated successfully, but these errors were encountered: