-
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
Summary issue - stabilization of !
#48950
Comments
I had a thought that I think needs to be resolved in the same release as this stabilization: Is there an existing stable uninhabited type in The one that comes to mind for me is |
@scottmcm I don't think there's a ton of motivation to do that -- I believe that, when all is said and done, empty enums and |
Still, interesting thought. Maybe nicer just for simplicity? cc @rust-lang/libs -- see @scottmcm's suggestion above about making uninhabited types like |
I had always assumed that all of the void errors would turn into type aliases for |
Yeah I was also personally under the impression that we'd change the types to be aliases and run crater to see if it actually had any fallout (as at the time I don't think we expected much) |
Well, I just r+'d the |
Well I only found 3 (ParseError, unstable Infallible, and new-for-1.26 ParsePathError) so PR up: #49039 |
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
Not sure if this is a regression you care about but the findshlibs crate now fails compiling some tests on beta and nightly as a result of this stabilization: https://travis-ci.org/gimli-rs/findshlibs/jobs/364806360 The code in question: match panic::catch_unwind(|| { TargetSharedLibrary::each(|_| panic!("uh oh")); }) {
Ok(()) => panic!("Expected a panic, but didn't get one"),
Err(any) => {
assert!(any.is::<&'static str>(), "panic value should be a &'static str");
assert_eq!(*any.downcast_ref::<&'static str>().unwrap(), "uh oh");
}
} Error message:
|
@canndrew looking at @mitsuhiko's issue, and just thinking generally -- I was wondering -- what is the classic example of why fallback to |
Nominating for brief lang-team discussion around this final point |
For what it’s worth the fallback change caused some previously-valid In short: generic FFI bindings in the |
@SimonSapin ah yes thanks for raising that |
Cross-posted my question to the main tracking issue, and added a few details. That seems like a better place to have this conversation. |
warning: lint resolve_trait_on_defaulted_unit has been removed: converted into hard error, see rust-lang/rust#48950 warning: conservative_impl_trait has been stable since 1.26.0. Attribute no longer needed
closing since we have started a new round of stabilization in #57012 and so we should try to capture all concerns and other threads of conversation there. |
The reverse conversion unfortunately causes unexpected errors like: ``` error[E0277]: the trait bound `!: std::convert::From<()>` is not satisfied --> src/librustc_metadata/encoder.rs:105:9 | 105 | self.emit_usize(seq.len)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<()>` is not implemented for `!` | = help: the following implementations were found: <! as std::convert::From<std::convert::Infallible>> = note: the trait is implemented for `()`. Possibly this error has been caused by changes to Rust's type-inference algorithm (see: rust-lang#48950 for more info). Consider whether you meant to use the type `()` here instead. = note: required by `std::convert::From::from` ``` I don’t understand why this error happens. If I’m reading the code correctly the return types of `emit_usize` and of the method that contains line 105 are both `Result<(), !>`, so the expansion of the `?` operator should involve `!: From<!>`, not `From<()>`. Is this a type inference bug?
`msg_send!` with an unconstrained return type used to be deduced to have the return type `()`. This is no longer the case after the stabilization of the `!` (never) type (rust-lang/rust#48950), and it'll be deduced to be `!`. This commit adds explicit return types to preserve the old behavior.
What is being stabilized
!
is now a full-fledged type and can now be used in any type position (eg. RFC 1216). The!
type can coerce into any other type, see https://github.com/rust-lang/rust/tree/master/src/test/run-fail/adjust_never.rs for an example.Type inference will now default unconstrained type variables to
!
instead of()
. Theresolve_trait_on_defaulted_unit
lint has been retired. An example of where this comes up is if you have something like:Under the old rules this would deserialize a
()
, whereas under the new rules it will deserialize a!
.The
never_type
feature gate is stable, although some of the behaviours it used to gate now live behind the newexhaustive_patterns
feature gate (see below).What is not being stabilized
Exhaustive pattern-matching for uninhabited types. eg.
This code will still complain that
Ok(_)
is a refutable pattern. This can be fixed by using theexhaustive_patterns
feature gate. See RFC 1872 for progress on this issue. See https://github.com/rust-lang/rust/tree/master/src/test/ui/feature-gate-exhaustive-patterns.rs for the testcase which confirms that this behaviour is still gated.The text was updated successfully, but these errors were encountered: