Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for Error in core #103765

Closed
2 of 6 tasks
Tracked by #18
lukas-code opened this issue Oct 30, 2022 · 20 comments · Fixed by #125951
Closed
2 of 6 tasks
Tracked by #18

Tracking Issue for Error in core #103765

lukas-code opened this issue Oct 30, 2022 · 20 comments · Fixed by #125951
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@lukas-code
Copy link
Member

lukas-code commented Oct 30, 2022

(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

@lukas-code lukas-code added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 30, 2022
@lukas-code
Copy link
Member Author

@rustbot label B-unstable A-error-handling

@rustbot
Copy link
Collaborator

rustbot commented Oct 30, 2022

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.

@robamler
Copy link
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.

@yaahc
Copy link
Member

yaahc commented Jan 19, 2023

@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.

@robamler
Copy link
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.)

@yaahc
Copy link
Member

yaahc commented Jan 23, 2023

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.

@robamler
Copy link
Contributor

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

@SimonIT

This comment was marked as off-topic.

@yaahc

This comment was marked as off-topic.

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jun 7, 2024
@rfcbot
Copy link

rfcbot commented Jun 7, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@bors bors closed this as completed in cbda797 Jun 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 8, 2024
Rollup merge of rust-lang#125951 - slanterns:error_in_core_stabilization, r=Amanieu

Stabilize `error_in_core`

Closes: rust-lang#103765.

`@rustbot` label: +T-libs-api

r? libs-api
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 13, 2024
…anieu

Stabilize `error_in_core`

Closes: rust-lang/rust#103765.

`@rustbot` label: +T-libs-api

r? libs-api
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jun 14, 2024
apoelstra added a commit to apoelstra/rust-miniscript that referenced this issue Jun 14, 2024
In later commits we will need the ability to box a generic error (on
pain of drowning in massive sets of generic constraints, blowing up
compile time and binary size).

Ideally we could just use a Box<dyn error::Error> but the Error trait is
not available on std
(tracking issue: rust-lang/rust#103765 ).

However, when we *do* have std on, we'd like our error traits to work
naturally, not lose source information, etc. So we introduce a newtype
and have all its internals gated on std vs non-std, and expose internal
constructors that must be used on types that implement std::Error when
std is on, and implement core::fmt::Display when it's not.
linkmauve added a commit to linkmauve/rust-stringprep that referenced this issue Jun 23, 2024
As almost nothing actually depends on std, there is no need to keep a
dependency on it.  This allows users such as the jid crate to actually
be no_std as well.

The only exception is std::error::Error, which is now exposed as
core::error::Error in nightly but not yet stabilized, see
rust-lang/rust#103765
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2024
…anieu

Stabilize `error_in_core`

Closes: rust-lang/rust#103765.

`@rustbot` label: +T-libs-api

r? libs-api
copybara-service bot pushed a commit to project-oak/oak that referenced this issue Jul 29, 2024
- use core::Error unstable feature. It's an upcoming stable feature (rust-lang/rust#103765)

- remove thiserror dependency. There's no _good_ way to support thiserror in no_std. Definitely not without bringing in some experimental code or forked thiserror crate

Change-Id: I245311bb82596fdb3a1912da25a831693370e164
@wmmc88
Copy link

wmmc88 commented Aug 19, 2024

Is this targeted for release for 1.81.0? I see no mention of it in https://releases.rs/docs/1.81.0/

@faern
Copy link
Contributor

faern commented Aug 20, 2024

Is this targeted for release for 1.81.0? I see no mention of it in https://releases.rs/docs/1.81.0/

It is. You can see in the docs for the beta that the core::error module is stable. Compare with docs for stable.

@m4rch3n1ng
Copy link

I see no mention of it in https://releases.rs/docs/1.81.0/

it doesn't show up on releases.rs, because the stabiliziation pr #125951 is not marked with the relnotes label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.