diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-07-29 16:16:44 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-29 16:16:44 +1000 |
| commit | fce74bacf3fc25b76cc0d021877f64184aacc4ad (patch) | |
| tree | c941a8674766837d0e68fe52fb367d8559140bb9 /compiler/rustc_middle/src | |
| parent | 0901e356c25c6543cbf61586ee17bfd1b294efb6 (diff) | |
| parent | 2b11851452364e07a3b0456a7a24424d944297fa (diff) | |
| download | rust-fce74bacf3fc25b76cc0d021877f64184aacc4ad.tar.gz rust-fce74bacf3fc25b76cc0d021877f64184aacc4ad.zip | |
Rollup merge of #144573 - BoxyUwU:patkind_constant_ptr_docs, r=lcnr
Raw Pointers are Constant PatKinds too
raw pointers can be matched on with a const pattern:
```rust
const FOO: *const u8 = core::ptr::null();
fn foo(a: *const u8) {
match a {
FOO => (),
_ => todo!(),
}
}
```
as far as I can tell this is represented with a `PatKind::Constant`: https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs#L333-L337
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/thir.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/thir.rs b/compiler/rustc_middle/src/thir.rs index 730c1147684..3dd6d2c8928 100644 --- a/compiler/rustc_middle/src/thir.rs +++ b/compiler/rustc_middle/src/thir.rs @@ -838,6 +838,8 @@ pub enum PatKind<'tcx> { /// * integer, bool, char or float (represented as a valtree), which will be handled by /// exhaustiveness to cover exactly its own value, similar to `&str`, but these values are /// much simpler. + /// * raw pointers derived from integers, other raw pointers will have already resulted in an + // error. /// * `String`, if `string_deref_patterns` is enabled. Constant { value: mir::Const<'tcx>, |
