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

Move the Error trait into core (without fn backtrace) #90328

Closed
wants to merge 5 commits into from

Conversation

yaahc
Copy link
Member

@yaahc yaahc commented Oct 26, 2021

current status: it works!

@rust-highfive
Copy link
Collaborator

r? @dtolnay

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 26, 2021
@yaahc

This comment has been minimized.

@yaahc
Copy link
Member Author

yaahc commented Oct 26, 2021

r? @spastorino

@rust-highfive rust-highfive assigned spastorino and unassigned dtolnay Oct 26, 2021
@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Member

lqd commented Oct 27, 2021

Since the recent negative impls PR hasn't reached the beta compiler yet, this will also need a few #[cfg(not(bootstrap))] to go past these first errors. And likely more: if I understand correctly, a lot of std's impl Errors (the trait impls, and inherent impls like the various impl dyn Errors) also need to be moved to either core or alloc, right ?

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 28, 2021
@rust-log-analyzer

This comment has been minimized.

@spastorino
Copy link
Member

@spastorino before adding the impl !Error for &str line I got this error

error[E0119]: conflicting implementations of trait core::convert::From<&str> for type boxed::Box<dyn core::error::Error + core::marker::Send + core::marker::Sync>
--> library/alloc/src/boxed.rs:1982:1
|
1880 | impl<'a, E: Error + Send + Sync + 'a> From for Box<dyn Error + Send + Sync + 'a> {
| ----------------------------------------------------------------------------------- first implementation here
...
1982 | impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for boxed::Box<dyn core::error::Error + core::marker::Send + core::marker::Sync>
|
= note: upstream crates may add a new impl of trait core::error::Error for type &str in future versions

error[E0119]: conflicting implementations of trait core::convert::From<&str> for type boxed::Box<dyn core::error::Error>
--> library/alloc/src/boxed.rs:2005:1
|
1848 | impl<'a, E: Error + 'a> From for Box<dyn Error + 'a> {
| ------------------------------------------------------- first implementation here
...
2005 | impl From<&str> for Box {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for boxed::Box<dyn core::error::Error>
|
= note: upstream crates may add a new impl of trait core::error::Error for type &str in future versions

For more information about this error, try rustc --explain E0119.
error: could not compile alloc due to 2 previous errors
Build completed unsuccessfully in 0:00:00

And now I get this error:

error[E0119]: conflicting implementations of trait core::convert::From<&str> for type boxed::Box<dyn core::error::Error + core::marker::Send + core::marker::Sync>
--> library/alloc/src/boxed.rs:1982:1
|
1880 | impl<'a, E: Error + Send + Sync + 'a> From for Box<dyn Error + Send + Sync + 'a> {
| ----------------------------------------------------------------------------------- first implementation here
...
1982 | impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for boxed::Box<dyn core::error::Error + core::marker::Send + core::marker::Sync>

error[E0119]: conflicting implementations of trait core::convert::From<&str> for type boxed::Box<dyn core::error::Error>
--> library/alloc/src/boxed.rs:2005:1
|
1848 | impl<'a, E: Error + 'a> From for Box<dyn Error + 'a> {
| ------------------------------------------------------- first implementation here
...
2005 | impl From<&str> for Box {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for boxed::Box<dyn core::error::Error>

I was talking with Niko about negative impls today and I fear that this may be a case that's similar to what Yoshua was dealing with. More info https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/negative.20impls.20in.20coherence

We may need to do something like https://smallcultfollowing.com/babysteps/blog/2018/02/09/maximally-minimal-specialization-always-applicable-impls/ from what we've talked with Niko. We'd be working on that and will let you know once we land a fix.

@JohnCSimon
Copy link
Member

Returning to author to address broken tests
@rustbot label: +S-waiting-on-author -S-waiting-on-review

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 16, 2021
@rust-log-analyzer

This comment has been minimized.

@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 6, 2022
@yaahc yaahc mentioned this pull request Feb 9, 2022
4 tasks
@JohnCSimon JohnCSimon added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 6, 2022
}
}

impl core::error::Error for MyCoreError {} //~ ERROR use of unstable library feature 'error_in_core'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that the unstable attributes don't actually work the way I expected them to. I had expected this to be an error the same way the it is in the above test but it actually compiles just fine...

@Dylan-DPC
Copy link
Member

@yaahc any updates?

@yaahc
Copy link
Member Author

yaahc commented Jun 17, 2022

This is superceded by #98072 and a subsequent PR to move Error into core once #95956 has landed

@yaahc yaahc closed this Jun 17, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 14, 2022
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of rust-lang#90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Jul 15, 2022
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of rust-lang/rust#90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
@yaahc yaahc deleted the error-in-core branch July 18, 2022 17:55
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 20, 2022
Move Error trait into core

This PR moves the error trait from the standard library into a new unstable `error` module within the core library. The goal of this PR is to help unify error reporting across the std and no_std ecosystems, as well as open the door to integrating the error trait into the panic reporting system when reporting panics whose source is an errors (such as via `expect`).

This PR is a rewrite of rust-lang#90328 using new compiler features that have been added to support error in core.
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Aug 23, 2022
Move Error trait into core

This PR moves the error trait from the standard library into a new unstable `error` module within the core library. The goal of this PR is to help unify error reporting across the std and no_std ecosystems, as well as open the door to integrating the error trait into the panic reporting system when reporting panics whose source is an errors (such as via `expect`).

This PR is a rewrite of rust-lang#90328 using new compiler features that have been added to support error in core.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 23, 2022
Move Error trait into core

This PR moves the error trait from the standard library into a new unstable `error` module within the core library. The goal of this PR is to help unify error reporting across the std and no_std ecosystems, as well as open the door to integrating the error trait into the panic reporting system when reporting panics whose source is an errors (such as via `expect`).

This PR is a rewrite of rust-lang#90328 using new compiler features that have been added to support error in core.
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request Sep 15, 2022
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of rust-lang/rust#90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
workingjubilee pushed a commit to tcdi/postgrestd that referenced this pull request Sep 15, 2022
Move Error trait into core

This PR moves the error trait from the standard library into a new unstable `error` module within the core library. The goal of this PR is to help unify error reporting across the std and no_std ecosystems, as well as open the door to integrating the error trait into the panic reporting system when reporting panics whose source is an errors (such as via `expect`).

This PR is a rewrite of rust-lang/rust#90328 using new compiler features that have been added to support error in core.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.