rust/library
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
..
alloc Add invariant to VecDeque::pop_* that len < cap if pop successful 2024-04-08 12:12:13 +02:00
backtrace@6fa4b85b99 Use rust-lang/backtrace-rs@6fa4b85 2024-03-14 12:37:43 -07:00
core Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors 2024-04-08 16:25:23 +00:00
panic_abort Cleanup windows abort_internal 2024-03-02 18:22:15 +00:00
panic_unwind SeqCst->Relaxed in panic_unwind/emcc. 2024-03-19 15:27:11 +01:00
portable-simd rename `expose_addr` to `expose_provenance` 2024-04-03 16:00:38 +02:00
proc_macro Stabilize `Literal::c_string` 2024-04-04 05:04:27 +08:00
profiler_builtins Update version of cc crate 2024-03-14 16:42:15 +00:00
rtstartup library: Fix warnings in rtstartup 2024-01-06 01:32:03 +03:00
rustc-std-workspace-alloc Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
rustc-std-workspace-core
rustc-std-workspace-std
std Auto merge of #120131 - oli-obk:pattern_types_syntax, r=compiler-errors 2024-04-08 16:25:23 +00:00
stdarch@967e7afd87 Update stdarch submodule 2024-03-22 12:16:16 -07:00
sysroot Expose `compiler-builtins-weak-intrinsics` feature for `-Zbuild-std` 2023-06-23 11:15:34 +01:00
test Drop panic hook after running tests 2024-04-06 18:56:22 +03:00
unwind Rollup merge of #121419 - agg23:xrOS-pr, r=davidtwco 2024-04-05 22:33:25 +02:00