-
- Notifications
You must be signed in to change notification settings - Fork 14.2k
Add NonNull pattern types #142339
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
Add NonNull pattern types #142339
Conversation
| Some changes occurred to the CTFE machinery changes to the core type system Some changes occurred in src/tools/clippy cc @rust-lang/clippy HIR ty lowering was modified cc @fmease Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri The Miri subtree was changed cc @rust-lang/miri Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt changes to the core type system Some changes occurred in compiler/rustc_codegen_ssa |
This comment has been minimized.
This comment has been minimized.
02f19f4 to 57dc73a Compare This comment has been minimized.
This comment has been minimized.
57dc73a to 0adc902 Compare This comment has been minimized.
This comment has been minimized.
0adc902 to 9944787 Compare This comment has been minimized.
This comment has been minimized.
9944787 to 8c271d9 Compare compiler/rustc_trait_selection/src/traits/select/confirmation.rs Outdated Show resolved Hide resolved
8c271d9 to 50cab82 Compare | These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
| ☔ The latest upstream changes (presumably #143434) made this pull request unmergeable. Please resolve the merge conflicts. |
1c997f2 to 47869c2 Compare This comment has been minimized.
This comment has been minimized.
47869c2 to b20dd1d Compare This comment has been minimized.
This comment has been minimized.
b20dd1d to 96205ed Compare | ☔ The latest upstream changes (presumably #143582) made this pull request unmergeable. Please resolve the merge conflicts. |
96205ed to 66255f9 Compare | ☔ The latest upstream changes (presumably #143934) made this pull request unmergeable. Please resolve the merge conflicts. |
66255f9 to 962d6ac Compare 962d6ac to 8f23c36 Compare 2a3c83b to 9a953cf Compare This comment has been minimized.
This comment has been minimized.
9a953cf to 375899c Compare | @bors r=BoxyUwU |
Rollup of 7 pull requests Successful merges: - #141445 (Add `FromIterator` impls for `ascii::Char`s to `String`s) - #142339 (Add NonNull pattern types) - #147768 (Code refactoring on hir report_no_match_method_error) - #147788 (const Cell methods) - #147932 (Create UTF-8 version of `OsStr`/`OsString`) - #147933 (os_str: Make platform docs more consistent) - #147948 (PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang/rust#141445 (Add `FromIterator` impls for `ascii::Char`s to `String`s) - rust-lang/rust#142339 (Add NonNull pattern types) - rust-lang/rust#147768 (Code refactoring on hir report_no_match_method_error) - rust-lang/rust#147788 (const Cell methods) - rust-lang/rust#147932 (Create UTF-8 version of `OsStr`/`OsString`) - rust-lang/rust#147933 (os_str: Make platform docs more consistent) - rust-lang/rust#147948 (PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+) r? `@ghost` `@rustbot` modify labels: rollup
| | ||
| fn main() { | ||
| unsafe { | ||
| let _: NonNull<dyn Trait> = NonNull { pointer: transmute(&mut () as *mut dyn Trait) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oli-obk the unsizing here happens before pattern types are even involved, doesn't it? It happens during the &mut () as *mut dyn Trait. So I don't see how this tests anything about pattern type unsizing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not about unsizing pattern types, but just about the existence of unsized pattern types. I don't think unsizing pattern types works but I'll add some tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NonNull<dyn Trait> is a sized type, so I don't think there is an unsized pattern type in this example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No i mean we can't do NonNull<()> unsizing to NonNull<dyn Trait>. The pointer is obviously sized. Am I using the terminology wrong again? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just nitpicking about this part:
but just about the existence of unsized pattern types
This is more like, "pattern types for wide pointers" or so?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by this test -- it only covers is !null pattern types, but the name is much more general than that? Would be good to have a comment explaining the point of this. The commit message says something about "unsizing pattern types with pointer base"?
| @rust-timer build 375899c |
1 similar comment
| @rust-timer build 375899c |
| Doesn't look like it got added to the perf queue. |
| Yeah, the unrolling failed likely because GitHub was down, we can't do much about that now. |
Rollup of 7 pull requests Successful merges: - rust-lang/rust#141445 (Add `FromIterator` impls for `ascii::Char`s to `String`s) - rust-lang/rust#142339 (Add NonNull pattern types) - rust-lang/rust#147768 (Code refactoring on hir report_no_match_method_error) - rust-lang/rust#147788 (const Cell methods) - rust-lang/rust#147932 (Create UTF-8 version of `OsStr`/`OsString`) - rust-lang/rust#147933 (os_str: Make platform docs more consistent) - rust-lang/rust#147948 (PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang/rust#141445 (Add `FromIterator` impls for `ascii::Char`s to `String`s) - rust-lang/rust#142339 (Add NonNull pattern types) - rust-lang/rust#147768 (Code refactoring on hir report_no_match_method_error) - rust-lang/rust#147788 (const Cell methods) - rust-lang/rust#147932 (Create UTF-8 version of `OsStr`/`OsString`) - rust-lang/rust#147933 (os_str: Make platform docs more consistent) - rust-lang/rust#147948 (PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+) r? `@ghost` `@rustbot` modify labels: rollup
…BoxyUwU Add NonNull pattern types These are the final piece missing for * rust-lang#136006 We cannot use the previous scheme of using an integer range for raw pointers, as we're not just changing the layout of raw pointers anymore, but also the type representation. And we can't represent "any provenance or NonZero<usize>" natively as patterns. So I created a new `!null` pattern. Since this is all unstable representation stuff for replacing rustc_layout_scalar_range_start with pattern types, the divergence from normal patterns is fine, especially since T-lang seems interested in exploring general negation patterns r? `@BoxyUwU`
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#141445 (Add `FromIterator` impls for `ascii::Char`s to `String`s) - rust-lang#142339 (Add NonNull pattern types) - rust-lang#147768 (Code refactoring on hir report_no_match_method_error) - rust-lang#147788 (const Cell methods) - rust-lang#147932 (Create UTF-8 version of `OsStr`/`OsString`) - rust-lang#147933 (os_str: Make platform docs more consistent) - rust-lang#147948 (PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+) r? `@ghost` `@rustbot` modify labels: rollup
…BoxyUwU Add NonNull pattern types These are the final piece missing for * rust-lang#136006 We cannot use the previous scheme of using an integer range for raw pointers, as we're not just changing the layout of raw pointers anymore, but also the type representation. And we can't represent "any provenance or NonZero<usize>" natively as patterns. So I created a new `!null` pattern. Since this is all unstable representation stuff for replacing rustc_layout_scalar_range_start with pattern types, the divergence from normal patterns is fine, especially since T-lang seems interested in exploring general negation patterns r? `@BoxyUwU`
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#141445 (Add `FromIterator` impls for `ascii::Char`s to `String`s) - rust-lang#142339 (Add NonNull pattern types) - rust-lang#147768 (Code refactoring on hir report_no_match_method_error) - rust-lang#147788 (const Cell methods) - rust-lang#147932 (Create UTF-8 version of `OsStr`/`OsString`) - rust-lang#147933 (os_str: Make platform docs more consistent) - rust-lang#147948 (PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+) r? `@ghost` `@rustbot` modify labels: rollup
Rollup of 7 pull requests Successful merges: - rust-lang/rust#141445 (Add `FromIterator` impls for `ascii::Char`s to `String`s) - rust-lang/rust#142339 (Add NonNull pattern types) - rust-lang/rust#147768 (Code refactoring on hir report_no_match_method_error) - rust-lang/rust#147788 (const Cell methods) - rust-lang/rust#147932 (Create UTF-8 version of `OsStr`/`OsString`) - rust-lang/rust#147933 (os_str: Make platform docs more consistent) - rust-lang/rust#147948 (PassWrapper: Access GlobalValueSummaryInfo::SummaryList via getter for LLVM 22+) r? `@ghost` `@rustbot` modify labels: rollup
…BoxyUwU Add NonNull pattern types These are the final piece missing for * rust-lang#136006 We cannot use the previous scheme of using an integer range for raw pointers, as we're not just changing the layout of raw pointers anymore, but also the type representation. And we can't represent "any provenance or NonZero<usize>" natively as patterns. So I created a new `!null` pattern. Since this is all unstable representation stuff for replacing rustc_layout_scalar_range_start with pattern types, the divergence from normal patterns is fine, especially since T-lang seems interested in exploring general negation patterns r? `@BoxyUwU`
These are the final piece missing for
We cannot use the previous scheme of using an integer range for raw pointers, as we're not just changing the layout of raw pointers anymore, but also the type representation. And we can't represent "any provenance or NonZero" natively as patterns. So I created a new
!nullpattern. Since this is all unstable representation stuff for replacing rustc_layout_scalar_range_start with pattern types, the divergence from normal patterns is fine, especially since T-lang seems interested in exploring general negation patternsr? @BoxyUwU