Add rustfix tests for mistyped_literal_suffix lint

This moves all `mistyped_literal_suffix` tests to their own file and
enables rustfix tests for them.

cc #3603, #2038

Based on #3887
This commit is contained in:
Philipp Hansch 2019-03-15 08:06:01 +01:00
parent 4e51c980bc
commit f1d0858a8f
No known key found for this signature in database
GPG key ID: B6FA06A6E0E2665B
5 changed files with 126 additions and 92 deletions

View file

@ -39,21 +39,7 @@ fn main() {
let fail13 = 0x1_23456_78901_usize;
let fail14 = 2_32;
let fail15 = 4_64;
let fail16 = 7_8;
let fail17 = 23_16;
let ok18 = 23_128;
let fail19 = 12_3456_21;
let fail20 = 2__8;
let fail21 = 4___16;
let fail22 = 3__4___23;
let fail23 = 3__16___23;
let fail24 = 12.34_64;
let fail25 = 1E2_32;
let fail26 = 43E7_64;
let fail27 = 243E17_32;
let fail28 = 241251235E723_64;
let fail29 = 42279.911_32;
}

View file

@ -94,99 +94,25 @@ LL | let fail13 = 0x1_23456_78901_usize;
|
= note: `-D clippy::large-digit-groups` implied by `-D warnings`
error: mistyped literal suffix
--> $DIR/literals.rs:42:18
|
LL | let fail14 = 2_32;
| ^^^^ help: did you mean to write: `2_i32`
|
= note: #[deny(clippy::mistyped_literal_suffixes)] on by default
error: mistyped literal suffix
--> $DIR/literals.rs:43:18
|
LL | let fail15 = 4_64;
| ^^^^ help: did you mean to write: `4_i64`
error: mistyped literal suffix
--> $DIR/literals.rs:44:18
|
LL | let fail16 = 7_8;
| ^^^ help: did you mean to write: `7_i8`
error: mistyped literal suffix
--> $DIR/literals.rs:45:18
|
LL | let fail17 = 23_16;
| ^^^^^ help: did you mean to write: `23_i16`
error: digits grouped inconsistently by underscores
--> $DIR/literals.rs:47:18
--> $DIR/literals.rs:42:18
|
LL | let fail19 = 12_3456_21;
| ^^^^^^^^^^ help: consider: `12_345_621`
|
= note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings`
error: mistyped literal suffix
--> $DIR/literals.rs:48:18
|
LL | let fail20 = 2__8;
| ^^^^ help: did you mean to write: `2_i8`
error: mistyped literal suffix
--> $DIR/literals.rs:49:18
|
LL | let fail21 = 4___16;
| ^^^^^^ help: did you mean to write: `4_i16`
error: digits grouped inconsistently by underscores
--> $DIR/literals.rs:50:18
--> $DIR/literals.rs:43:18
|
LL | let fail22 = 3__4___23;
| ^^^^^^^^^ help: consider: `3_423`
error: digits grouped inconsistently by underscores
--> $DIR/literals.rs:51:18
--> $DIR/literals.rs:44:18
|
LL | let fail23 = 3__16___23;
| ^^^^^^^^^^ help: consider: `31_623`
error: mistyped literal suffix
--> $DIR/literals.rs:53:18
|
LL | let fail24 = 12.34_64;
| ^^^^^^^^ help: did you mean to write: `12.34_f64`
error: mistyped literal suffix
--> $DIR/literals.rs:54:18
|
LL | let fail25 = 1E2_32;
| ^^^^^^ help: did you mean to write: `1E2_f32`
error: mistyped literal suffix
--> $DIR/literals.rs:55:18
|
LL | let fail26 = 43E7_64;
| ^^^^^^^ help: did you mean to write: `43E7_f64`
error: mistyped literal suffix
--> $DIR/literals.rs:56:18
|
LL | let fail27 = 243E17_32;
| ^^^^^^^^^ help: did you mean to write: `243E17_f32`
error: mistyped literal suffix
--> $DIR/literals.rs:57:18
|
LL | let fail28 = 241251235E723_64;
| ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64`
error: mistyped literal suffix
--> $DIR/literals.rs:58:18
|
LL | let fail29 = 42279.911_32;
| ^^^^^^^^^^^^ help: did you mean to write: `42_279.911_f32`
error: aborting due to 27 previous errors
error: aborting due to 15 previous errors

View file

@ -0,0 +1,23 @@
// run-rustfix
#![allow(dead_code, unused_variables, clippy::excessive_precision)]
fn main() {
let fail14 = 2_i32;
let fail15 = 4_i64;
let fail16 = 7_i8; //
let fail17 = 23_i16; //
let ok18 = 23_128;
let fail20 = 2_i8; //
let fail21 = 4_i16; //
let fail24 = 12.34_f64;
let fail25 = 1E2_f32;
let fail26 = 43E7_f64;
let fail27 = 243E17_f32;
#[allow(overflowing_literals)]
let fail28 = 241_251_235E723_f64;
let fail29 = 42_279.911_f32;
}

View file

@ -0,0 +1,23 @@
// run-rustfix
#![allow(dead_code, unused_variables, clippy::excessive_precision)]
fn main() {
let fail14 = 2_32;
let fail15 = 4_64;
let fail16 = 7_8; //
let fail17 = 23_16; //
let ok18 = 23_128;
let fail20 = 2__8; //
let fail21 = 4___16; //
let fail24 = 12.34_64;
let fail25 = 1E2_32;
let fail26 = 43E7_64;
let fail27 = 243E17_32;
#[allow(overflowing_literals)]
let fail28 = 241251235E723_64;
let fail29 = 42279.911_32;
}

View file

@ -0,0 +1,76 @@
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:7:18
|
LL | let fail14 = 2_32;
| ^^^^ help: did you mean to write: `2_i32`
|
= note: #[deny(clippy::mistyped_literal_suffixes)] on by default
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:8:18
|
LL | let fail15 = 4_64;
| ^^^^ help: did you mean to write: `4_i64`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:9:18
|
LL | let fail16 = 7_8; //
| ^^^ help: did you mean to write: `7_i8`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:10:18
|
LL | let fail17 = 23_16; //
| ^^^^^ help: did you mean to write: `23_i16`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:13:18
|
LL | let fail20 = 2__8; //
| ^^^^ help: did you mean to write: `2_i8`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:14:18
|
LL | let fail21 = 4___16; //
| ^^^^^^ help: did you mean to write: `4_i16`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:16:18
|
LL | let fail24 = 12.34_64;
| ^^^^^^^^ help: did you mean to write: `12.34_f64`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:17:18
|
LL | let fail25 = 1E2_32;
| ^^^^^^ help: did you mean to write: `1E2_f32`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:18:18
|
LL | let fail26 = 43E7_64;
| ^^^^^^^ help: did you mean to write: `43E7_f64`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:19:18
|
LL | let fail27 = 243E17_32;
| ^^^^^^^^^ help: did you mean to write: `243E17_f32`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:21:18
|
LL | let fail28 = 241251235E723_64;
| ^^^^^^^^^^^^^^^^ help: did you mean to write: `241_251_235E723_f64`
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:22:18
|
LL | let fail29 = 42279.911_32;
| ^^^^^^^^^^^^ help: did you mean to write: `42_279.911_f32`
error: aborting due to 12 previous errors