Skip to content

Commit e868020

Browse files
authored
Unrolled build for #144573
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
2 parents cb6785f + 2b11851 commit e868020

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compiler/rustc_middle/src/thir.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,8 @@ pub enum PatKind<'tcx> {
838838
/// * integer, bool, char or float (represented as a valtree), which will be handled by
839839
/// exhaustiveness to cover exactly its own value, similar to `&str`, but these values are
840840
/// much simpler.
841+
/// * raw pointers derived from integers, other raw pointers will have already resulted in an
842+
// error.
841843
/// * `String`, if `string_deref_patterns` is enabled.
842844
Constant {
843845
value: mir::Const<'tcx>,

0 commit comments

Comments
 (0)