rust/tests/ui/literals.rs

45 lines
1.0 KiB
Rust
Raw Normal View History

#![warn(mixed_case_hex_literals)]
#![warn(unseparated_literal_suffix)]
#![warn(zero_prefixed_literal)]
#![allow(dead_code)]
fn main() {
let ok1 = 0xABCD;
let ok3 = 0xab_cd;
let ok4 = 0xab_cd_i32;
let ok5 = 0xAB_CD_u32;
let ok5 = 0xAB_CD_isize;
2017-02-08 14:58:07 +01:00
let fail1 = 0xabCD;
let fail2 = 0xabCD_u32;
let fail2 = 0xabCD_isize;
2017-07-20 01:56:32 +02:00
let fail_multi_zero = 000_123usize;
let ok6 = 1234_i32;
let ok7 = 1234_f32;
let ok8 = 1234_isize;
2017-02-08 14:58:07 +01:00
let fail3 = 1234i32;
let fail4 = 1234u32;
let fail5 = 1234isize;
let fail6 = 1234usize;
let fail7 = 1.5f32;
2016-08-20 18:11:15 +02:00
let ok9 = 0;
let ok10 = 0_i64;
let fail8 = 0123;
2017-02-08 14:58:07 +01:00
let ok11 = 0o123;
2017-07-20 01:56:32 +02:00
let ok12 = 0b10_1010;
2018-05-28 14:12:20 +02:00
let ok13 = 0xab_abcd;
let ok14 = 0xBAFE_BAFE;
let ok15 = 0xab_cabc_abca_bcab_cabc;
let ok16 = 0xFE_BAFE_ABAB_ABCD;
let ok17 = 0x123_4567_8901_usize;
let fail9 = 0xabcdef;
let fail10 = 0xBAFEBAFE;
let fail11 = 0xabcdeff;
2018-05-28 14:12:20 +02:00
let fail12 = 0xabcabcabcabcabcabc;
let fail13 = 0x1_23456_78901_usize;
}