#![warn(clippy::manual_div_ceil)]
#![feature(int_roundings)]

fn main() {
    let x = 7_i32;
    let y = 4_i32;
    let z = 3_i32;
    let z_u: u32 = 11;

    // Lint.
    let _ = x.div_ceil(y);
    //~^ manual_div_ceil
    let _ = x.div_ceil(y);
    //~^ manual_div_ceil
    let _ = x.div_ceil(y);
    //~^ manual_div_ceil

    let _ = 7_i32.div_ceil(4);
    //~^ manual_div_ceil
    let _ = (7_i32 as u32).div_ceil(4);
    //~^ manual_div_ceil
    let _ = (7_u32 as i32).div_ceil(4);
    //~^ manual_div_ceil
    let _ = z_u.div_ceil(4);
    //~^ manual_div_ceil

    // No lint.
    let _ = (x + (y - 2)) / y;
    let _ = (x + (y + 1)) / y;

    let _ = (x + (y - 1)) / z;
}

fn issue_13843() {
    let x = 3usize;
    let _ = 2048_usize.div_ceil(x);
    //~^ manual_div_ceil

    let x = 5usize;
    let _ = 2048usize.div_ceil(x);
    //~^ manual_div_ceil

    let x = 5usize;
    let _ = 2048_usize.div_ceil(x);
    //~^ manual_div_ceil

    let x = 2048usize;
    let _ = x.div_ceil(4);
    //~^ manual_div_ceil

    let _ = 2048_i32.div_ceil(4);
    //~^ manual_div_ceil

    let _: u32 = 2048_u32.div_ceil(6);
    //~^ manual_div_ceil
    let _: usize = 2048_usize.div_ceil(6);
    //~^ manual_div_ceil
    let _: u32 = 0x2048_u32.div_ceil(0x6);
    //~^ manual_div_ceil

    let _ = 2048_u32.div_ceil(6u32);
    //~^ manual_div_ceil

    let x = -2;
    let _ = (-2048_i32).div_ceil(x);
    //~^ manual_div_ceil

    let _ = 1_000_000_u32.div_ceil(6u32);
    //~^ manual_div_ceil
}

fn issue_13950() {
    let x = 33u32;
    let _ = x.div_ceil(8);
    //~^ manual_div_ceil
    let _ = x.div_ceil(8);
    //~^ manual_div_ceil

    let y = -33i32;
    let _ = y.div_ceil(-7);
    //~^ manual_div_ceil
    let _ = y.div_ceil(-7);
    //~^ manual_div_ceil
    let _ = y.div_ceil(-7);
    //~^ manual_div_ceil
}
