-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Stabilize (only) the never type #58184
Copy link
Copy link
Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-never_type`#![feature(never_type)]``#![feature(never_type)]`T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-never_type`#![feature(never_type)]``#![feature(never_type)]`T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is an alternative to #57012 that does not propose changing the type inference fallback (yet). This unblocks
TryFromandTryInto#33417.#49593 has now been fixed. This was the reason for the previous revert of stabilization (#50121).
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.never_typefeature gate is stable, although some of the behaviours it used to gate now live behind the newexhaustive_patternsfeature 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_patternsfeature 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 type inference changes proposed in Summary issue - stabilization of
!#48950 are not part of this proposal, since they can break some previously-valid programs and the mitigations discussed in Stabilize never_type *again* #57012 are not ready yet.This change is moved to a new dedicated feature gate,
inference_fallback_to_never, instead ofnever_type.