rust/compiler
bors 537aab7a2e Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors
Implement minimal, internal-only pattern types in the type system

rebase of https://github.com/rust-lang/rust/pull/107606

You can create pattern types with `std::pat::pattern_type!(ty is pat)`. The feature is incomplete and will panic on you if you use any pattern other than integral range patterns. The only way to create or deconstruct a pattern type is via `transmute`.

This PR's implementation differs from the MCP's text. Specifically

> This means you could implement different traits for different pattern types with the same base type. Thus, we just forbid implementing any traits for pattern types.

is violated in this PR. The reason is that we do need impls after all in order to make them usable as fields. constants of type `std::time::Nanoseconds` struct are used in patterns, so the type must be structural-eq, which it only can be if you derive several traits on it. It doesn't need to be structural-eq recursively, so we can just manually implement the relevant traits on the pattern type and use the pattern type as a private field.

Waiting on:

* [x] move all unrelated commits into their own PRs.
* [x] fix niche computation (see 2db07f94f44f078daffe5823680d07d4fded883f)
* [x] add lots more tests
* [x] T-types MCP https://github.com/rust-lang/types-team/issues/126 to finish
* [x] some commit cleanup
* [x] full self-review
* [x] remove 61bd325da19a918cc3e02bbbdce97281a389c648, it's not necessary anymore I think.
* [ ] ~~make sure we never accidentally leak pattern types to user code (add stability checks or feature gate checks and appopriate tests)~~ we don't even do this for the new float primitives
* [x] get approval that [the scope expansion to trait impls](https://rust-lang.zulipchat.com/#narrow/stream/326866-t-types.2Fnominated/topic/Pattern.20types.20types-team.23126/near/427670099) is ok

r? `@BoxyUwU`
2024-04-08 16:25:23 +00:00
..
rustc
rustc_abi Use the Align type when parsing alignment attributes 2024-04-01 03:05:55 +01:00
rustc_arena rename ptr::invalid -> ptr::without_provenance 2024-02-21 20:15:52 +01:00
rustc_ast Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_ast_ir Fix typo in VisitorResult 2024-03-08 23:20:29 -05:00
rustc_ast_lowering Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_ast_passes Add pattern types to parser 2024-04-08 11:57:17 +00:00
rustc_ast_pretty Add pattern types to ast 2024-04-08 11:54:22 +00:00
rustc_attr Use the Align type when parsing alignment attributes 2024-04-01 03:05:55 +01:00
rustc_baked_icu_data
rustc_borrowck Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_builtin_macros Add pattern types to parser 2024-04-08 11:57:17 +00:00
rustc_codegen_cranelift Auto merge of #123221 - pacak:cache_emit, r=fmease,jieyouxu 2024-04-07 10:46:50 +00:00
rustc_codegen_gcc Save/restore more items in cache with incremental compilation 2024-04-06 10:59:24 -04:00
rustc_codegen_llvm Save/restore more items in cache with incremental compilation 2024-04-06 10:59:24 -04:00
rustc_codegen_ssa Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_const_eval Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_data_structures rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
rustc_driver
rustc_driver_impl Rollup merge of #122807 - danielhuang:fix-1, r=davidtwco 2024-04-08 14:31:10 +02:00
rustc_error_codes Auto merge of #122055 - compiler-errors:stabilize-atb, r=oli-obk 2024-03-19 00:04:09 +00:00
rustc_error_messages Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_errors Rollup merge of #123401 - Zalathar:assert-size-aarch64, r=fmease 2024-04-03 20:17:06 -04:00
rustc_expand Check x86_64 size assertions on aarch64, too 2024-04-03 16:53:03 +11:00
rustc_feature Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors 2024-04-08 16:25:23 +00:00
rustc_fluent_macro Rename SubdiagnosticMessage as SubdiagMessage. 2024-03-05 12:14:49 +11:00
rustc_fs_util Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_graphviz Invert diagnostic lints. 2024-02-06 13:12:33 +11:00
rustc_hir Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_hir_analysis Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_hir_pretty Thread pattern types through the HIR 2024-04-08 12:00:07 +00:00
rustc_hir_typeck Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors 2024-04-08 16:25:23 +00:00
rustc_incremental Auto merge of #122070 - Zoxc:dep-edges-from-previous, r=cjgillot 2024-04-05 11:11:17 +00:00
rustc_index Check x86_64 size assertions on aarch64, too 2024-04-03 16:53:03 +11:00
rustc_index_macros rustc_index: Add a ZERO constant to index types 2024-04-03 19:06:22 +03:00
rustc_infer Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_interface Put checks that detect UB under their own flag below debug_assertions 2024-04-06 11:21:47 -04:00
rustc_lexer Silence redundant error on char literal that was meant to be a string in 2021 edition 2024-03-17 23:35:19 +00:00
rustc_lint Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors 2024-04-08 16:25:23 +00:00
rustc_lint_defs Rollup merge of #120144 - petrochenkov:unty, r=davidtwco 2024-04-08 14:31:10 +02:00
rustc_llvm Rollup merge of #122807 - danielhuang:fix-1, r=davidtwco 2024-04-08 14:31:10 +02:00
rustc_log bump tracing-tree to 0.3 2024-03-30 17:39:43 +03:00
rustc_macros Rename diagnostic derive things. 2024-03-11 10:06:34 +11:00
rustc_metadata Replace RemapFileNameExt::for_codegen with explicit calls 2024-03-28 18:47:26 +01:00
rustc_middle Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_mir_build Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_mir_dataflow Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_mir_transform Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_monomorphize Only allow upstream calls to LLVM intrinsics, not any link_name function 2024-04-01 20:31:19 -04:00
rustc_next_trait_solver Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_parse Rollup merge of #123401 - Zalathar:assert-size-aarch64, r=fmease 2024-04-03 20:17:06 -04:00
rustc_parse_format Check x86_64 size assertions on aarch64, too 2024-04-03 16:53:03 +11:00
rustc_passes Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_pattern_analysis Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_privacy Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_query_impl Verify that query keys result in unique dep nodes 2024-03-12 05:31:41 +01:00
rustc_query_system Remove sharding for VecCache 2024-04-06 10:49:31 -04:00
rustc_resolve Rollup merge of #123307 - tgross35:f16-f128-feature-gate-fix, r=petrochenkov 2024-04-03 20:17:05 -04:00
rustc_serialize Stabilize associated type bounds 2024-03-08 20:56:25 +00:00
rustc_session Put checks that detect UB under their own flag below debug_assertions 2024-04-06 11:21:47 -04:00
rustc_smir Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_span Add pattern types to parser 2024-04-08 11:57:17 +00:00
rustc_symbol_mangling Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_target Rollup merge of #123446 - crazytonyli:fix-watchos-llvm-target, r=estebank 2024-04-07 09:17:15 +02:00
rustc_trait_selection Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_traits Merge check_mod_impl_wf and check_mod_type_wf 2024-03-07 06:27:09 +00:00
rustc_transmute Remove unnecessary Partial/Ord derive 2024-03-27 14:02:15 +00:00
rustc_ty_utils Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
rustc_type_ir Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00
stable_mir Actually create ranged int types in the type system. 2024-04-08 12:02:19 +00:00