summary refs log tree commit diff
path: root/src/test/ui/consts/const-eval/promoted_errors.rs
blob: 142ce75eebc80837d564c86a7b526caa1a8d162b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// revisions: noopt opt opt_with_overflow_checks
//[noopt]compile-flags: -C opt-level=0
//[opt]compile-flags: -O
//[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O

// build-pass
// ignore-pass (test emits codegen-time warnings and verifies that they are not errors)

#![warn(const_err, arithmetic_overflow, unconditional_panic)]

fn main() {
    println!("{}", 0u32 - 1);
    //[opt_with_overflow_checks,noopt]~^ WARN [arithmetic_overflow]
    let _x = 0u32 - 1;
    //~^ WARN [arithmetic_overflow]
    println!("{}", 1 / (1 - 1));
    //~^ WARN [unconditional_panic]
    //~| WARN panic or abort [const_err]
    //~| WARN erroneous constant used [const_err]
    let _x = 1 / (1 - 1);
    //~^ WARN [unconditional_panic]
    println!("{}", 1 / (false as u32));
    //~^ WARN [unconditional_panic]
    //~| WARN panic or abort [const_err]
    //~| WARN erroneous constant used [const_err]
    let _x = 1 / (false as u32);
    //~^ WARN [unconditional_panic]
}