]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/literals.rs
Add `zero_prefixed_literal` lint
[rust.git] / tests / compile-fail / literals.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3 #![deny(mixed_case_hex_literals)]
4 #![deny(unseparated_literal_suffix)]
5 #![deny(zero_prefixed_literal)]
6 #![allow(dead_code)]
7
8 fn main() {
9     let ok1 = 0xABCD;
10     let ok3 = 0xab_cd;
11     let ok4 = 0xab_cd_i32;
12     let ok5 = 0xAB_CD_u32;
13     let ok5 = 0xAB_CD_isize;
14     let fail1 = 0xabCD;       //~ERROR inconsistent casing in hexadecimal literal
15     let fail2 = 0xabCD_u32;   //~ERROR inconsistent casing in hexadecimal literal
16     let fail2 = 0xabCD_isize; //~ERROR inconsistent casing in hexadecimal literal
17
18     let ok6 = 1234_i32;
19     let ok7 = 1234_f32;
20     let ok8 = 1234_isize;
21     let fail3 = 1234i32;      //~ERROR integer type suffix should be separated
22     let fail4 = 1234u32;      //~ERROR integer type suffix should be separated
23     let fail5 = 1234isize;    //~ERROR integer type suffix should be separated
24     let fail6 = 1234usize;    //~ERROR integer type suffix should be separated
25     let fail7 = 1.5f32;       //~ERROR float type suffix should be separated
26
27     let ok9 = 0;
28     let ok10 = 0_i64;
29     let fail8 = 0123;
30     //~^ERROR decimal constant
31     //~|HELP remove the `0`
32     //~|SUGGESTION = 123;
33     //~|HELP use `0o`
34     //~|SUGGESTION = 0o123;
35 }