question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

negative impls integrated into coherence

See original GitHub issue

Proposal

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

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:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
yoshuawuytscommented, Nov 30, 2021

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 to impl Termination for Future<T>:

impl !Future for ! {}
impl !Future for () {}
impl<E: ?Sized> !Future for Result<!, E> {}
impl<E: ?Sized> !Future for Result<(), E> {}

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 enable async fn main to be implemented.

1reaction
pnkfelixcommented, Jul 27, 2021

(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.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Explicit negative impls to fix `Pin` soundness hole
fcp merge. To stabilize, we need a proper RFC and a "well-rounded" semantics (in particular I would want to integrate with coherence, or...
Read more >
Coherence check - {{INITIATIVE_NAME}} initiative
We define the negative of a where clause Negative(WC) as a partial function that converts T: Trait to T: !Trait : Negative(P0: Trait<P1...Pn>)...
Read more >
Triage meeting 2021-12-14 - HackMD
Pending lang team project proposals · “negative impls integrated into coherence” lang-team#96 · "Deprecate target_vendor " lang-team#102 · “Async fundamentals ...
Read more >
Commits · 37e186087c28891d04dd67c8657c9affc8cdc59a · sun ...
permit negative impls for non-auto traits This is a prototype impl that extends `impl !Trait` beyond auto traits. It is not integrated with...
Read more >
cXi - River Thames Conditions - Environment Agency - GOV.UK
#safe Brendons forehead, Yonah lake fishing report, Tribal calls airbattle, Coherent argument essay! Julie orser odermatt, Types of awards in the army, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found