Auto merge of #12403 - samueltardieu:issue-12402, r=blyxyas
Pointers cannot be converted to integers at compile time Fix #12402 changelog: [`transmutes_expressible_as_ptr_casts`]: do not suggest invalid const casts
This commit is contained in:
commit
c2dd413c79
4 changed files with 17 additions and 1 deletions
|
|
@ -82,3 +82,10 @@ fn issue_10449() {
|
|||
|
||||
let _x: u8 = unsafe { *(f as *const u8) };
|
||||
}
|
||||
|
||||
// Pointers cannot be cast to integers in const contexts
|
||||
const fn issue_12402<P>(ptr: *const P) {
|
||||
unsafe { transmute::<*const i32, usize>(&42i32) };
|
||||
unsafe { transmute::<fn(*const P), usize>(issue_12402) };
|
||||
let _ = unsafe { transmute::<_, usize>(ptr) };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,3 +82,10 @@ fn issue_10449() {
|
|||
|
||||
let _x: u8 = unsafe { *std::mem::transmute::<fn(), *const u8>(f) };
|
||||
}
|
||||
|
||||
// Pointers cannot be cast to integers in const contexts
|
||||
const fn issue_12402<P>(ptr: *const P) {
|
||||
unsafe { transmute::<*const i32, usize>(&42i32) };
|
||||
unsafe { transmute::<fn(*const P), usize>(issue_12402) };
|
||||
let _ = unsafe { transmute::<_, usize>(ptr) };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue