avoid an ICE in ptr_as_ptr when getting the def_id of a local
This commit is contained in:
parent
2b30a5924e
commit
e575f05a8b
4 changed files with 34 additions and 1 deletions
7
tests/ui/crashes/ice-12616.fixed
Normal file
7
tests/ui/crashes/ice-12616.fixed
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![warn(clippy::ptr_as_ptr)]
|
||||
#![allow(clippy::unnecessary_operation, clippy::unnecessary_cast)]
|
||||
|
||||
fn main() {
|
||||
let s = std::ptr::null::<()>;
|
||||
s().cast::<()>();
|
||||
}
|
||||
7
tests/ui/crashes/ice-12616.rs
Normal file
7
tests/ui/crashes/ice-12616.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#![warn(clippy::ptr_as_ptr)]
|
||||
#![allow(clippy::unnecessary_operation, clippy::unnecessary_cast)]
|
||||
|
||||
fn main() {
|
||||
let s = std::ptr::null::<()>;
|
||||
s() as *const ();
|
||||
}
|
||||
19
tests/ui/crashes/ice-12616.stderr
Normal file
19
tests/ui/crashes/ice-12616.stderr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/crashes/ice-12616.rs:6:5
|
||||
|
|
||||
LL | s() as *const ();
|
||||
| ^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `s().cast::<()>()`
|
||||
|
|
||||
= note: `-D clippy::ptr-as-ptr` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::ptr_as_ptr)]`
|
||||
|
||||
error: `as` casting between raw pointers without changing its mutability
|
||||
--> tests/ui/crashes/ice-12616.rs:6:5
|
||||
|
|
||||
LL | s() as *const ();
|
||||
| ^^^^^^^^^^^^^^^^ help: try `pointer::cast`, a safer alternative: `s().cast::<()>()`
|
||||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue