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: An issue tracking the progress of sth. like the implementation of an RFC 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: An issue tracking the progress of sth. like the implementation of an RFC 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.

thomcc pushed a commit to tcdi/postgrestd that referenced this issue Feb 10, 2023
Add tracking issue to `error_in_core`

This was merged in rust-lang/rust#99917 without a tracking issue, so I'm creating one now: rust-lang/rust#103765
@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
@jhpratt jhpratt moved this from Stabilized to Landed in Upcoming & recently stabilized features Jul 26, 2024
@jhpratt jhpratt moved this from Landed to Stabilized in Upcoming & recently stabilized features Jul 26, 2024
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

@jhpratt jhpratt moved this from Stabilized to Landed in Upcoming & recently stabilized features Sep 5, 2024
github-merge-queue bot pushed a commit to smithy-lang/smithy-rs that referenced this issue Nov 5, 2024
## Motivation and Context
Smithy-rs CI and our release pipeline have exposed another place,
[sdk-adhoc-test](https://github.com/smithy-lang/smithy-rs/tree/main/aws/sdk-adhoc-test),
where we should place a Cargo lockfile but we currently don't.
Specifically, running `./gradlew aws:sdk-adhoc-test:check`on the current
main is encountering the following error:
```
error[E0658]: use of unstable library feature 'error_in_core'
  --> /opt/cargo/registry/src/index.crates.io-6f17d22bba15001f/idna-1.0.3/src/lib.rs:78:6
   |
78 | impl core::error::Error for Errors {}
   |      ^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #103765 <rust-lang/rust#103765> for more information
```
We're supposed to pin `idna` to 0.5.0
([example](https://github.com/smithy-lang/smithy-rs/blob/62caa4639497bc9b18f57e51a30265899d9b511e/aws/sdk/Cargo.lock#L2812-L2819)),
but `sdk-adhoc-test` uses 1.0.3.

This PR will fix the problem by copying the checked-in SDK lockfile to
`sdk-adhoc-test`.

## Testing
- [x] `./gradlew aws:sdk-adhoc-test:check` from the repo root has passed
- [ ] Tests in CI

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
astralblue added a commit to openrankprotocol/openrank that referenced this issue Nov 7, 2024
Fixes the error:

```
   Compiling idna v1.0.3
error[E0658]: use of unstable library feature 'error_in_core'
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/idna-1.0.3/src/lib.rs:78:6
   |
78 | impl core::error::Error for Errors {}
   |      ^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #103765 <rust-lang/rust#103765> for more information
```
astralblue added a commit to openrankprotocol/openrank that referenced this issue Nov 7, 2024
Fixes the error:

```
   Compiling idna v1.0.3
error[E0658]: use of unstable library feature 'error_in_core'
  --> /home/ubuntu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/idna-1.0.3/src/lib.rs:78:6
   |
78 | impl core::error::Error for Errors {}
   |      ^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #103765 <rust-lang/rust#103765> for more information
```
pitoniak32 added a commit to pitoniak32/opentelemetry-rust that referenced this issue Nov 17, 2024
idna dep of url is failing to compile on stable because default_features is false.
std is a default feature that disables the unstable use of error_in_core.

error[E0658]: use of unstable library feature 'error_in_core'
error: could not compile `idna` (lib) due to previous error

rust-lang/rust#103765
https://github.com/servo/rust-url/blob/main/url/Cargo.toml#L35
github-merge-queue bot pushed a commit to paritytech/polkadot-sdk that referenced this issue Nov 26, 2024
The semver-check is failing with the following
[error](https://github.com/paritytech/polkadot-sdk/actions/runs/11908981132/job/33185572284):

```bash
error[E0658]: use of unstable library feature 'error_in_core'
  --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/frame-decode-0.5.0/src/decoding/extrinsic_decoder.rs:56:6
   |
56 | impl core::error::Error for ExtrinsicDecodeError {}
   |      ^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #103765 <rust-lang/rust#103765> for more information
   = help: add `#![feature(error_in_core)]` to the crate attributes to enable
   = note: this compiler was built on 2024-05-31; consider upgrading it if it is out of date
```

This is related to the toolchain nightly version 1.80. In rust, 1.81 the
`core::error::Error` is stable.

After updating the rust-toolchain, parity-publish crate must be updated
as well.
The `cargo-semver-checks` dependency of `parity-publish` crate is
updated from 0.34 to 0.38.
This update enables rustdoc v36 that fixes the following
[issue](https://github.com/paritytech/polkadot-sdk/actions/runs/11912689841/job/33196936011):


```bash
 validating prdocs...
checking file changes...
checking semver changes...
(1/18) building frame-support-HEAD...
(2/18) building frame-support-28.0.0...
Error: rustdoc format v36 for file /__w/polkadot-sdk/polkadot-sdk/target/doc/frame_support.new is not supported
```

This PR is pending on a release of parity-publish to version 0.9.0
(fixes already on origin/master)

---------

Signed-off-by: Alexandru Vasile <[email protected]>
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: An issue tracking the progress of sth. like the implementation of an RFC 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.