#![warn(clippy::manual_dangling_ptr)]
use std::mem;

pub fn foo(_const: *const f32, _mut: *mut i32) {}

fn main() {
    let _: *const u8 = std::ptr::dangling();
    //~^ manual_dangling_ptr
    let _ = std::ptr::dangling::<u32>();
    //~^ manual_dangling_ptr
    let _ = std::ptr::dangling_mut::<f32>();
    //~^ manual_dangling_ptr

    let _ = std::ptr::dangling::<u8>();
    //~^ manual_dangling_ptr
    let _ = std::ptr::dangling::<u32>();
    //~^ manual_dangling_ptr
    let _ = std::ptr::dangling::<usize>();
    //~^ manual_dangling_ptr

    foo(std::ptr::dangling(), std::ptr::dangling_mut());
    //~^ manual_dangling_ptr
    //~| manual_dangling_ptr
}

fn should_not_lint() {
    let _ = 0x10 as *mut i32;
    let _ = mem::align_of::<u32>() as *const u8;

    foo(0 as _, 0 as _);
}

#[clippy::msrv = "1.83"]
fn _msrv_1_83() {
    // `{core, std}::ptr::dangling` was stabilized in 1.84. Do not lint this
    foo(4 as *const _, 4 as *mut _);
}

#[clippy::msrv = "1.84"]
fn _msrv_1_84() {
    foo(std::ptr::dangling(), std::ptr::dangling_mut());
    //~^ manual_dangling_ptr
    //~| manual_dangling_ptr
}
