Edition 2024: Make ! fall back to ! - #123508
Conversation
|
Nominating for T-lang discussion. This PR changes never type fallback in the 2024 edition. I'm asking for approval, given that this is part of the following plan:
|
! fallback to !! fall back to !
|
Might worth add #66173 and #66757 as tests. fn test66173() {
let x = match true {
true => Default::default(),
false => panic!("..."),
};
// print `x` type
}
fn test66757() {
struct E;
impl From<!> for E {
fn from(_: !) -> E {
E
}
}
#[allow(unreachable_code)]
fn foo(never: !) {
<E as From<!>>::from(never); // Ok
<E as From<_>>::from(never); // Should the inference fail?
}
} |
|
@rfcbot merge This PR changes fallback to
These lints are valuable in all editions because they both address "suspicious" / error-prone code. They also catch the cases that could change behavior. Ideally we'll have them before we get to the new edition, if not, we'll want to revisit whether to proceed. |
|
Team member @nikomatsakis has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
@crlf0710 do those tests look good to you? |
|
I'm happy with doing this, contingent on having mitigations to avoid unsafe code changing behavior. @rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
779b684 to
e79aafc
Compare
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
|
This finished FCP 👍 sorry for taking so long to r+ @bors r+ rollup=never |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (9a7bf4a): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (primary -0.2%, secondary 2.3%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 1.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 676.102s -> 675.928s (-0.03%) |
… r=JonathanBrouwer stabilize never type ### This PR - stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!) - sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment))) - makes `Infallible` an alias to `!` - removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered) ### Cat <img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" /> ### Tracking - rust-lang#35121 - rust-lang#148922 ### FCPs - rust-lang#123508 (comment) (stabilization plan, T-lang) - rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang) - rust-lang#155924 (comment) (make `Infallible = !`, T-libs) ### Related changes - Lint bump: rust-lang#141937 - Rust 2024 edition change: - rust-lang#123748 - rust-lang#123508 - Various changes to lessen the effect of the breaking changes: - rust-lang#157820 - rust-lang#156047 - rust-lang#160705 - Never type documentation changes: rust-lang#158370 (blocked on this pr) ### Experiments - Fallback change and never type stabilization: - Run: rust-lang#155499 (comment) - Analysis: rust-lang#155499 (comment) - Status of backports: rust-lang#155499 (comment) - Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500 - Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501 - Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657 --- Closes rust-lang#35121 Closes rust-lang#148922
… r=JonathanBrouwer stabilize never type ### This PR - stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!) - sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment))) - makes `Infallible` an alias to `!` - removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered) ### Cat <img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" /> ### Tracking - rust-lang#35121 - rust-lang#148922 ### FCPs - rust-lang#123508 (comment) (stabilization plan, T-lang) - rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang) - rust-lang#155924 (comment) (make `Infallible = !`, T-libs) ### Related changes - Lint bump: rust-lang#141937 - Rust 2024 edition change: - rust-lang#123748 - rust-lang#123508 - Various changes to lessen the effect of the breaking changes: - rust-lang#157820 - rust-lang#156047 - rust-lang#160705 - Never type documentation changes: rust-lang#158370 (blocked on this pr) ### Experiments - Fallback change and never type stabilization: - Run: rust-lang#155499 (comment) - Analysis: rust-lang#155499 (comment) - Status of backports: rust-lang#155499 (comment) - Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500 - Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501 - Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657 --- Closes rust-lang#35121 Closes rust-lang#148922
… r=JonathanBrouwer stabilize never type ### This PR - stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!) - sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment))) - makes `Infallible` an alias to `!` - removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered) ### Cat <img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" /> ### Tracking - rust-lang#35121 - rust-lang#148922 ### FCPs - rust-lang#123508 (comment) (stabilization plan, T-lang) - rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang) - rust-lang#155924 (comment) (make `Infallible = !`, T-libs) ### Related changes - Lint bump: rust-lang#141937 - Rust 2024 edition change: - rust-lang#123748 - rust-lang#123508 - Various changes to lessen the effect of the breaking changes: - rust-lang#157820 - rust-lang#156047 - rust-lang#160705 - Never type documentation changes: rust-lang#158370 (blocked on this pr) ### Experiments - Fallback change and never type stabilization: - Run: rust-lang#155499 (comment) - Analysis: rust-lang#155499 (comment) - Status of backports: rust-lang#155499 (comment) - Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500 - Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501 - Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657 --- Closes rust-lang#35121 Closes rust-lang#148922
…Brouwer stabilize never type ### This PR - stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!) - sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](#155499 (comment)) and [refresher on never type fallback](#155499 (comment))) - makes `Infallible` an alias to `!` - removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered) ### Cat <img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" /> ### Tracking - #35121 - #148922 ### FCPs - #123508 (comment) (stabilization plan, T-lang) - #155499 (comment) (never type stabilization modulo bugs, T-lang) - #155924 (comment) (make `Infallible = !`, T-libs) ### Related changes - Lint bump: #141937 - Rust 2024 edition change: - #123748 - #123508 - Various changes to lessen the effect of the breaking changes: - #157820 - #156047 - #160705 - Never type documentation changes: #158370 (blocked on this pr) ### Experiments - Fallback change and never type stabilization: - Run: #155499 (comment) - Analysis: #155499 (comment) - Status of backports: #155499 (comment) - Fallback change, never type stabilization and making `Infallible = !`: #155500 - Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: #155501 - Never type stabilization and `Infallible = !` change, _without_ fallback change: #155657 --- Closes #35121 Closes #148922
… r=JonathanBrouwer stabilize never type ### This PR - stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!) - sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang#155499 (comment)) and [refresher on never type fallback](rust-lang#155499 (comment))) - makes `Infallible` an alias to `!` - removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered) ### Cat <img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" /> ### Tracking - rust-lang#35121 - rust-lang#148922 ### FCPs - rust-lang#123508 (comment) (stabilization plan, T-lang) - rust-lang#155499 (comment) (never type stabilization modulo bugs, T-lang) - rust-lang#155924 (comment) (make `Infallible = !`, T-libs) ### Related changes - Lint bump: rust-lang#141937 - Rust 2024 edition change: - rust-lang#123748 - rust-lang#123508 - Various changes to lessen the effect of the breaking changes: - rust-lang#157820 - rust-lang#156047 - rust-lang#160705 - Never type documentation changes: rust-lang#158370 (blocked on this pr) ### Experiments - Fallback change and never type stabilization: - Run: rust-lang#155499 (comment) - Analysis: rust-lang#155499 (comment) - Status of backports: rust-lang#155499 (comment) - Fallback change, never type stabilization and making `Infallible = !`: rust-lang#155500 - Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang#155501 - Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang#155657 --- Closes rust-lang#35121 Closes rust-lang#148922
…Brouwer stabilize never type ### This PR - stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!) - sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](#155499 (comment)) and [refresher on never type fallback](#155499 (comment))) - makes `Infallible` an alias to `!` - removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered) ### Cat <img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" /> ### Tracking - #35121 - #148922 ### FCPs - #123508 (comment) (stabilization plan, T-lang) - #155499 (comment) (never type stabilization modulo bugs, T-lang) - #155924 (comment) (make `Infallible = !`, T-libs) ### Related changes - Lint bump: #141937 - Rust 2024 edition change: - #123748 - #123508 - Various changes to lessen the effect of the breaking changes: - #157820 - #156047 - #160705 - Never type documentation changes: #158370 (blocked on this pr) ### Experiments - Fallback change and never type stabilization: - Run: #155499 (comment) - Analysis: #155499 (comment) - Status of backports: #155499 (comment) - Fallback change, never type stabilization and making `Infallible = !`: #155500 - Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: #155501 - Never type stabilization and `Infallible = !` change, _without_ fallback change: #155657 --- Closes #35121 Closes #148922
…Brouwer stabilize never type ### This PR - stabilizes the [never type](https://doc.rust-lang.org/stable/std/primitive.never.html) (aka `!`) (!!!) - sets the [never type fallback](https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html) to `!` on all editions (breaking change, see [crater report analysis](rust-lang/rust#155499 (comment)) and [refresher on never type fallback](rust-lang/rust#155499 (comment))) - makes `Infallible` an alias to `!` - removes `dependency_on_unit_never_type_fallback` lint (there is no more never type fallback to `()` so this lint can't be triggered) ### Cat <img width="1024" height="683" alt="52270233795_5979a3174d_b" src="https://github.com/user-attachments/assets/f6b4737e-32ef-4c33-86b2-76b81673cf20" /> ### Tracking - rust-lang/rust#35121 - rust-lang/rust#148922 ### FCPs - rust-lang/rust#123508 (comment) (stabilization plan, T-lang) - rust-lang/rust#155499 (comment) (never type stabilization modulo bugs, T-lang) - rust-lang/rust#155924 (comment) (make `Infallible = !`, T-libs) ### Related changes - Lint bump: rust-lang/rust#141937 - Rust 2024 edition change: - rust-lang/rust#123748 - rust-lang/rust#123508 - Various changes to lessen the effect of the breaking changes: - rust-lang/rust#157820 - rust-lang/rust#156047 - rust-lang/rust#160705 - Never type documentation changes: rust-lang/rust#158370 (blocked on this pr) ### Experiments - Fallback change and never type stabilization: - Run: rust-lang/rust#155499 (comment) - Analysis: rust-lang/rust#155499 (comment) - Status of backports: rust-lang/rust#155499 (comment) - Fallback change, never type stabilization and making `Infallible = !`: rust-lang/rust#155500 - Fallback change, never type stabilization, making `Infallible = !`, and removing reservation impl: rust-lang/rust#155501 - Never type stabilization and `Infallible = !` change, _without_ fallback change: rust-lang/rust#155657 --- Closes rust-lang/rust#35121 Closes rust-lang/rust#148922
This PR changes never type fallback to be
!(the never type itself) in the next, 2024, edition.This makes the never type's behavior more intuitive (in 2024 edition) and is the first step of the path to stabilize it.
r? @compiler-errors
Tracking:
!fall back to!#123748