]> git.proxmox.com Git - rustc.git/blame - src/test/ui/consts/const-eval/const-eval-overflow2.rs
New upstream version 1.51.0+dfsg1
[rustc.git] / src / test / ui / consts / const-eval / const-eval-overflow2.rs
CommitLineData
0531ce1d
XL
1#![allow(unused_imports)]
2
3// Note: the relevant lint pass here runs before some of the constant
0731742a 4// evaluation below (e.g., that performed by codegen and llvm), so if you
0531ce1d
XL
5// change this warn to a deny, then the compiler will exit before
6// those errors are detected.
7
8#![deny(const_err)]
9
10use std::fmt;
0531ce1d 11
532ac7d7 12const VALS_I8: (i8,) =
0531ce1d
XL
13 (
14 i8::MIN - 1,
0531ce1d 15 );
532ac7d7 16 //~^^ ERROR any use of this value will cause an error
5869c6ff 17 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d 18
532ac7d7 19const VALS_I16: (i16,) =
0531ce1d
XL
20 (
21 i16::MIN - 1,
0531ce1d 22 );
532ac7d7 23 //~^^ ERROR any use of this value will cause an error
5869c6ff 24 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d 25
532ac7d7 26const VALS_I32: (i32,) =
0531ce1d
XL
27 (
28 i32::MIN - 1,
0531ce1d 29 );
532ac7d7 30 //~^^ ERROR any use of this value will cause an error
5869c6ff 31 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d 32
532ac7d7 33const VALS_I64: (i64,) =
0531ce1d
XL
34 (
35 i64::MIN - 1,
0531ce1d 36 );
532ac7d7 37 //~^^ ERROR any use of this value will cause an error
5869c6ff 38 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d 39
532ac7d7 40const VALS_U8: (u8,) =
0531ce1d
XL
41 (
42 u8::MIN - 1,
0531ce1d 43 );
532ac7d7 44 //~^^ ERROR any use of this value will cause an error
5869c6ff 45 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d 46
532ac7d7 47const VALS_U16: (u16,) = (
0531ce1d 48 u16::MIN - 1,
0531ce1d 49 );
532ac7d7 50 //~^^ ERROR any use of this value will cause an error
5869c6ff 51 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d 52
532ac7d7 53const VALS_U32: (u32,) = (
0531ce1d 54 u32::MIN - 1,
0531ce1d 55 );
532ac7d7 56 //~^^ ERROR any use of this value will cause an error
5869c6ff 57 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d 58
532ac7d7 59const VALS_U64: (u64,) =
0531ce1d
XL
60 (
61 u64::MIN - 1,
0531ce1d 62 );
532ac7d7 63 //~^^ ERROR any use of this value will cause an error
5869c6ff 64 //~| WARN this was previously accepted by the compiler but is being phased out
0531ce1d
XL
65
66fn main() {
67 foo(VALS_I8);
68 foo(VALS_I16);
69 foo(VALS_I32);
70 foo(VALS_I64);
71
72 foo(VALS_U8);
73 foo(VALS_U16);
74 foo(VALS_U32);
75 foo(VALS_U64);
76}
77
78fn foo<T>(_: T) {
79}