-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Tracking Issue for never type fallback change #148922
Copy link
Copy link
Open
Labels
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 teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
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 teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
This is a tracking issue for the never type fallback change.
Summary
Stabilization of the never type (aka
!) requires (or required, depending on when you read this) a breaking change to how inference works with it.This issue is tracking said change and is used to refer to it in compiler diagnostics.
Effect on your code
In rare cases code that used to compile won't anymore. It is always possible to make code compile again by annotating types more explicitly.
See migration section in the edition guide.
Never type fallback
Never type fallback is an implementation detail of how Rust compiler handles "never to any" coercions. Specifically, at every coercion site if
rustcsees a value of type!, it inserts a never to any coercion to an new inference variable.In some cases the resulting type of the inference variable can't be inferred from the surrounding code. To prevent errors in such cases,
rustcsets such inference variables (i.e. ones that come from never to any coercions and can't be inferred otherwise) to a "fallback".The change
Due to historic reasons the fallback type used to be
(). That caused confusing behavior and other problems, as such we are changing the fallback to!.However, that can break code which depended on fallback type being
(). In such cases you can explicitly set the type to(), as to not even trigger the fallback at all.Timeline
!on edition 2024 only (see edition guide)!on all editions (required for the never type stabilization)About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.