negative impls integrated into coherence
See original GitHub issueProposal
Summary and problem statement
@yaahc and I have been investigating the possibility of integrating ‘negative impls’ into coherence. The precise motivation is to enable
impl !Error for &str { }
and then, in a downstream crate, support
impl From<&str> for Box<dyn Error>> { }
impl<E> From<E> for Box<dyn Error>>
where
E: Error, { }
Note that this would not permit where T: !Trait
syntax, although we could in principle support that, though we would have to be careful about what it means (in particular, it would be relatively easy to support if what it means is “there is a negative impl”).
Motivation, use-cases, and solution sketches
- Supporting the project group’s work, as described above
Prioritization
Fits under error handling, and is also a kind of core enabler likely to arise elsewhere
Links and related work
- Tracking isssue for negative impls https://github.com/rust-lang/rust/issues/68318
- Implementation of negative impls https://github.com/rust-lang/rust/pull/68004
- Interactions with marker traits and overlapping impls https://github.com/rust-lang/rust/issues/29864
Initial people involved
nikomatsakis, yaahc
What happens now?
This issue is part of the experimental MCP process described in RFC 2936. Once this issue is filed, a Zulip topic will be opened for discussion, and the lang-team will review open MCPs in its weekly triage meetings. You should receive feedback within a week or two.
This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:11 (10 by maintainers)
As an experiment I implemented
async fn main
in the compiler using this feature (branch). This uses the following negative trait bounds to allow us toimpl Termination for Future<T>
:There was figuring out to do regarding
dyn
traits which might need to be improved; but overall this feature has been incredibly useful and is a missing piece to enableasync fn main
to be implemented.(I’m willing to be liason. We should revisit official assignment of liason in future lang team meeting; today’s only has two team members present.)