-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
stabilize never type #155499
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
base: main
Are you sure you want to change the base?
stabilize never type #155499
Changes from all commits
158e13d
7c696e5
1b2826d
8a92d57
21d61d5
2b86b05
58fcec2
f42429a
39dec73
aaafa9e
bf0800b
65963cd
4b87bb8
e71bafa
95a0b68
288eadd
8e6f818
c5013a1
fc2e81c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -263,9 +263,7 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>( | |
| // resolves to itself. We interpret this as the | ||
| // no values of the hidden type ever being constructed, | ||
| // so we can just make the hidden type be `!`. | ||
| // For backwards compatibility reasons, we fall back to | ||
| // `()` until we the diverging default is changed. | ||
| EarlyBinder::bind(tcx, tcx.types.unit) | ||
| EarlyBinder::bind(tcx, tcx.types.never) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change looks right to me, but I feel like I don't have enough type system knowledge to be 100% sure about this change. I wonder why this wasn't affected by the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC this wasn't affected by the attribute on purpose, but I don't remember the details. |
||
| } | ||
| } | ||
| DefiningScopeKind::MirBorrowck => match tcx.mir_borrowck(owner_def_id) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -493,24 +493,14 @@ impl<'tcx> LoweredTy<'tcx> { | |
| } | ||
|
|
||
| fn never_type_behavior(tcx: TyCtxt<'_>) -> (DivergingFallbackBehavior, DivergingBlockBehavior) { | ||
| // FIXME(waffle): rip out the whole system which allows you to choose never type fallback | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to do this immediately after this PR lands, so that this is not forgotten. Rust analyzer seems to have its own copy of this enum, funnily enough.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| let (fallback, block) = parse_never_type_options_attr(tcx); | ||
| let fallback = fallback.unwrap_or_else(|| default_fallback(tcx)); | ||
| let fallback = fallback.unwrap_or_else(|| DivergingFallbackBehavior::ToNever); | ||
| let block = block.unwrap_or_default(); | ||
|
|
||
| (fallback, block) | ||
| } | ||
|
|
||
| /// Returns the default fallback which is used when there is no explicit override via `#![never_type_options(...)]`. | ||
| fn default_fallback(tcx: TyCtxt<'_>) -> DivergingFallbackBehavior { | ||
| // Edition 2024: fallback to `!` | ||
| if tcx.sess.edition().at_least_rust_2024() { | ||
| return DivergingFallbackBehavior::ToNever; | ||
| } | ||
|
|
||
| // Otherwise: fallback to `()` | ||
| DivergingFallbackBehavior::ToUnit | ||
| } | ||
|
|
||
| fn parse_never_type_options_attr( | ||
| tcx: TyCtxt<'_>, | ||
| ) -> (Option<DivergingFallbackBehavior>, Option<DivergingBlockBehavior>) { | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.