summary refs log tree commit diff
path: root/src/test/ui/consts/const-eval/promoted_errors.rs
blob: fa8859cbb3bb652282ed7d1ac8cd4182420a62cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// compile-flags: -O

#![deny(const_err)]

fn main() {
    println!("{}", 0u32 - 1);
    let _x = 0u32 - 1;
    //~^ ERROR this expression will panic at runtime [const_err]
    println!("{}", 1/(1-1));
    //~^ ERROR this expression will panic at runtime [const_err]
    //~| ERROR attempt to divide by zero [const_err]
    //~| ERROR reaching this expression at runtime will panic or abort [const_err]
    let _x = 1/(1-1);
    //~^ ERROR const_err
    //~| ERROR const_err
    println!("{}", 1/(false as u32));
    //~^ ERROR this expression will panic at runtime [const_err]
    //~| ERROR attempt to divide by zero [const_err]
    //~| ERROR reaching this expression at runtime will panic or abort [const_err]
    let _x = 1/(false as u32);
    //~^ ERROR const_err
    //~| ERROR const_err
}