Skip to content

Tracking Issue for Error in core #103765

Closed

Description

@lukas-code

(This was merged a while ago without a tracking issue, so I'm creating this one here now.)

Feature gate: #![feature(error_in_core)]

This is a tracking issue for moving the Error trait to the core library.

Public API

// core::error
pub trait Error: Debug + Display  {
    /* same API as std::error::Error */
}

// unstable in core, stable in std
impl dyn Error + 'static [+ Send [+ Sync]] {
    pub fn is<T: Error + 'static>(&self) -> bool;
    pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T>;
    pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>;
}

// unstable in alloc, stable in std
impl dyn Error [+ Send [+ Sync]] {
    pub fn downcast<T: Error + 'static>(self: Box<Self>) -> Result<Box<T>, Box<Self>>;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

Activity

  1. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on Oct 30, 2022
  2. lukas-code commented on Oct 30, 2022

    @lukas-code
    ContributorAuthor

    @rustbot label B-unstable A-error-handling

  3. rustbot commented on Oct 30, 2022

    @rustbot
    Collaborator

    Error: Label B-unstable can only be set by Rust team members

    Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

  4. added a commit that references this issue on Oct 31, 2022
  5. robamler commented on Dec 29, 2022

    @robamler
    Contributor

    I'm excited about this feature, so if there's anything I can do to help pushing it over the finish line I'd be happy to help. I'm fairly experienced with programming in Rust and I've been silently following various Rust features from RFC to stabilization, but I haven't myself contributed to the compiler or standard library yet.

    I think this feature could turn out to be a considerable improvement to Rust. There are quite a few small-ish crates out there that only perform well-specified pure-function-like operations. I can imagine that many of these crates could trivially be no_std compatible by default (without even requiring a cargo feature gate) were it not for their error types implementing std::error::Error.

  6. yaahc commented on Jan 19, 2023

    @yaahc
    Member

    @robamler that would be lovely, I'm happy to hand off and help coordinate that work. I've been focused on governance work since august and haven't had much time for pushing this across the finish line.

    I believe the current blockers for this are resolving issues in the provider / generic member access APIs

    This comment by @dtolnay best outlines the issues that still need to be resolved: #99301 (comment)

    Let me know if you have any further questions. The zulip is probably the best way to reach me quickly. I'm not keeping on top of github notifications right now since I still need to unsubscribe to a bunch of things to turn down the volume of notifications I get daily.

  7. robamler commented on Jan 21, 2023

    @robamler
    Contributor

    @yaahc Thank you for the references!

    Do #![feature(error_in_core)] and #![feature(error_generic_member_access)] really have to be stabilized together? Maybe I'm missing something here, but it looks like the most pragmatic way forward would be to

    1. first stabilize error_in_core with your implementation in Move Error trait into core #99917, except that the method core::error::Error::provide would still be unstable with #![feature(error_generic_member_access)], just as std::error::Error::provide is today; and
    2. then resolve any issues that are blocking #![feature(error_generic_member_access)] from stabilization; once those are resolved, both std::error::Error::provide and core::error::Error::provide would become available on stable.

    (I'll reach out on zulip if I don't get any response here; just wanted to leave this comment here as a kind of documentation in case I can't figure this out and someone else needs to take over.)

  8. yaahc commented on Jan 23, 2023

    @yaahc
    Member

    I think in theory we could stabilize error-in-core before provider but I'm worried since we removed fn backtrace on the basis of the provider API, if we lock error into core we can never add fn backtrace back, and if we end up with some unavoidable blocker to stabilizing provider we may end up in a worse situation than we started.

  9. robamler commented on Jan 28, 2023

    @robamler
    Contributor

    I see, thanks! So I understand that maybe #99301 should be resolved first. I'm following up with the discussion there.

  10. SimonIT commented on Feb 9, 2023

    @SimonIT
  11. yaahc commented on Feb 10, 2023

    @yaahc
  12. zdivelbiss commented on Apr 1, 2023

    @zdivelbiss

    Is there a FCP on the horizon for this feature? It seems relatively straight-forward insofar as its featureset, and it would be nice to allow thing like anyhow to take advantage of core::error::Error on stable.

  13. added
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    on May 16, 2023
  14. 40 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE]disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions