-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Replace uninhabited error enums in std with never #49039
Conversation
@bors: try @rust-lang/infra, mind doing a crater run on this? |
Replace uninhabited error enums in std with never Luckily I only found two, and one of them isn't in beta yet, so can disappear completely 😎 Are there any others I forgot? (There are lots in things like liblibc and libstd/sys, but AFAIK those don't matter, nor do things like `btree::node::LeafOrInternal` or `str::pattern::RejectAndMatch`.) The unstable `convert::Infallible` is being handled by #49038⚠️ This change may be a 1.26-or-never one. cc #48950 (comment) r? @alexcrichton
☀️ Test successful - status-travis |
I've inserted it above the two other pending PRs due to the claimed urgency. Still, we'll likely need to wait 9 to 10 days (March 25th) to get a crater result (5 days for the current two to finish, and 5 more days for running this), which is dangerously close to the beta promotion date (March 28th). If this is really urgent we could postpone #48814 (that started just 4 hours ago) and run this immediately. (cc @aidanhs) But since you are changing the stable type |
@kennytm The thing that I think is I'm fairly confident in this change, so I hope that Mar25 will be fine. |
Crater run started |
Any news from crater, @aidanhs? It's now been 6 days. |
Apologies, I've been pretty busy over the past week. A quick scan of the results shows at least one legit failure (prom-attire) Hi @alexcrichton (crater requester/PR reviewer)! Crater results are at: http://cargobomb-reports.s3.amazonaws.com/pr-49039/index.html. 'Blacklisted' crates (spurious failures etc) can be found here. If you see any spurious failures not on the list, please make a PR against that file. (interested observers: Crater is a tool for testing the impact of changes on the crates.io ecosystem. You can find out more at the repo if you're curious) |
Two minor legit regressions involving custom xkpwgen-0.6.1 (unreachable code in `#[derive(StructOpt)]`)
prom-attire-0.1.0
|
@scottmcm mind looking into those errors to see what's going on? |
Luckily I only found two, and one of them isn't in beta yet, so can disappear completely :)
The |
The pub fn demo(x: !) -> Box<std::error::Error> {
Box::new(x)
} error[E0277]: the trait bound `std::error::Error: std::marker::Sized` is not satisfied
--> src/lib.rs:4:5
|
4 | Box::new(x)
| ^^^^^^^^ `std::error::Error` does not have a constant size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `std::error::Error`
= note: required by `<std::boxed::Box<T>>::new`
Apparently this is just another "coercions and inference hate each other" 😞 Edit 2: FYI @Nemo157: regardless of whether this PR lands, you may still want to update the proc-macro to handle user types with |
@scottmcm I think that's just because |
/// [`FromStr`]: ../../std/str/trait.FromStr.html | ||
/// [`String`]: struct.String.html | ||
/// [`from_str`]: ../../std/str/trait.FromStr.html#tymethod.from_str | ||
#[stable(feature = "str_parse_error", since = "1.5.0")] | ||
#[derive(Copy)] | ||
pub enum ParseError {} | ||
pub type ParseError = !; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't do this because people can impl
it. You should (almost) never change stable nominal types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While there's no problem with impl MyTrait for ParseError
(you can impl
through type aliases and there are no stable impls for !
), @eddyb pointed out on IRC that impl MyTrait for fn()->!
and impl MyTrait for fn()->ParseError
are allowed on stable, so this may not be allowed even though the break found by crater is allowed inference/coercion changes (it's possible to write in a way that works before&after by specifying the type explicitly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was informed on IRC that this could be fine because it's the only such type and you can't impl
trait for !
on stable, but that's not enough, e.g.:
trait Trait {}
impl Trait for fn() -> ! {}
impl Trait for fn() -> ParseError {}
Reproduction for the structopt case: #![deny(warnings)]
fn foo() -> Result<(), !> {
Ok(())
}
fn main() {
let bar = foo() .map_err(|e| e.to_string());
println!("{:?}", bar);
}
|
Ok, I can see at least four options here:
Thoughts, libs folks? |
This compiles: #[allow(unreachable_code)]
pub fn demo(x: !) -> Box<std::error::Error> {
Box::new(x) as _
} So I don’t think that |
But then if you actually have that precise signature (rather than something more generic) you can take advantage of the unreachability / universal coercion: pub fn demo(x: !) -> Box<std::error::Error> {
x
} |
That's an elegant fix, @SimonSapin. The code in the case is macro-generated, like Any thoughts on whether we should take this, #49404, or something else? I think if we're going to do something, it needs to be soon because of things stabilizing in 1.26... |
Oh I didn’t consider the macro-generated case. Does the explicit conversion to DST with I’ll bring this up with libs team member today. |
Any news, @SimonSapin? (Sorry for pinging again, but with where we are in the 1.26 timeline...) |
Libs has a dedicated time slot at the Berlin All Hands in ~4 hours. I moved this to near the top of the agenda. My personal opinion is that:
|
I can confirm |
The libs team discussed this and while a work-around is possible for this specific The ideal outcome would be to tweak the language’s coercion rules so that |
I've opened a tracking issue for this at #49593 |
I've beta-nominated this in case we can fix the coercion rule easily and decided to keep Also marking as blocked by #49593. |
☔ The latest upstream changes (presumably #49669) made this pull request unmergeable. Please resolve the merge conflicts. |
Given that ! stabilization is being reverted, I'm going to close this for now |
Luckily I only found two, and one of them isn't in beta yet, so can disappear completely 😎
Are there any others I forgot? (There are lots in things like liblibc and libstd/sys, but AFAIK those don't matter, nor do things like
btree::node::LeafOrInternal
orstr::pattern::RejectAndMatch
.)The unstable
convert::Infallible
is being handled by #49038cc #48950 (comment)
r? @alexcrichton