This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,11 @@ fn issue_10449() {
84
84
}
85
85
86
86
// Pointers cannot be cast to integers in const contexts
87
+ #[allow(ptr_to_integer_transmute_in_consts, reason = "This is tested in the compiler test suite")]
87
88
const fn issue_12402<P>(ptr: *const P) {
88
- unsafe { transmute::<*const i32, usize>(&42i32) };
89
- unsafe { transmute::<fn(*const P), usize>(issue_12402) };
90
- let _ = unsafe { transmute::<_, usize>(ptr) };
89
+ // This test exists even though the compiler lints against it
90
+ // to test that clippy's transmute lints do not trigger on this.
91
+ unsafe { std::mem::transmute::<*const i32, usize>(&42i32) };
92
+ unsafe { std::mem::transmute::<fn(*const P), usize>(issue_12402) };
93
+ let _ = unsafe { std::mem::transmute::<_, usize>(ptr) };
91
94
}
Original file line number Diff line number Diff line change @@ -84,8 +84,11 @@ fn issue_10449() {
84
84
}
85
85
86
86
// Pointers cannot be cast to integers in const contexts
87
+ #[ allow( ptr_to_integer_transmute_in_consts, reason = "This is tested in the compiler test suite" ) ]
87
88
const fn issue_12402 < P > ( ptr : * const P ) {
88
- unsafe { transmute :: < * const i32 , usize > ( & 42i32 ) } ;
89
- unsafe { transmute :: < fn ( * const P ) , usize > ( issue_12402) } ;
90
- let _ = unsafe { transmute :: < _ , usize > ( ptr) } ;
89
+ // This test exists even though the compiler lints against it
90
+ // to test that clippy's transmute lints do not trigger on this.
91
+ unsafe { std:: mem:: transmute :: < * const i32 , usize > ( & 42i32 ) } ;
92
+ unsafe { std:: mem:: transmute :: < fn ( * const P ) , usize > ( issue_12402) } ;
93
+ let _ = unsafe { std:: mem:: transmute :: < _ , usize > ( ptr) } ;
91
94
}
You can’t perform that action at this time.
0 commit comments