Skip to content

Commit ac52f3c

Browse files
committed
Add more regression tests
1 parent cea7d9d commit ac52f3c

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

clippy_lints/src/misc_early.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,6 @@ impl EarlyLintPass for MiscEarlyLints {
390390

391391
impl MiscEarlyLints {
392392
fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) {
393-
if in_external_macro(cx.sess(), lit.span) {
394-
return;
395-
}
396-
397393
if let LitKind::Int(value, lit_int_type) = lit.node {
398394
if let Some(src) = snippet_opt(cx, lit.span) {
399395
let suffix = match lit_int_type {

tests/ui/unseparated_prefix_literals.fixed

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#![warn(clippy::unseparated_literal_suffix)]
44
#![allow(dead_code)]
55

6+
macro_rules! lit_from_macro {
7+
() => {42_usize};
8+
}
9+
610
fn main() {
711
let _ok1 = 1234_i32;
812
let _ok2 = 1234_isize;

tests/ui/unseparated_prefix_literals.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#![warn(clippy::unseparated_literal_suffix)]
44
#![allow(dead_code)]
55

6+
macro_rules! lit_from_macro {
7+
() => {42usize};
8+
}
9+
610
fn main() {
711
let _ok1 = 1234_i32;
812
let _ok2 = 1234_isize;
@@ -17,4 +21,8 @@ fn main() {
1721
let _okf2 = 1_f32;
1822
let _failf1 = 1.5f32;
1923
let _failf2 = 1f32;
24+
25+
// Counter example
26+
let _ = line!();
27+
let _ = lit_from_macro!();
2028
}

tests/ui/unseparated_prefix_literals.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
error: integer type suffix should be separated by an underscore
2-
--> $DIR/unseparated_prefix_literals.rs:10:18
2+
--> $DIR/unseparated_prefix_literals.rs:14:18
33
|
44
LL | let _fail1 = 1234i32;
55
| ^^^^^^^ help: add an underscore: `1234_i32`
66
|
77
= note: `-D clippy::unseparated-literal-suffix` implied by `-D warnings`
88

99
error: integer type suffix should be separated by an underscore
10-
--> $DIR/unseparated_prefix_literals.rs:11:18
10+
--> $DIR/unseparated_prefix_literals.rs:15:18
1111
|
1212
LL | let _fail2 = 1234u32;
1313
| ^^^^^^^ help: add an underscore: `1234_u32`
1414

1515
error: integer type suffix should be separated by an underscore
16-
--> $DIR/unseparated_prefix_literals.rs:12:18
16+
--> $DIR/unseparated_prefix_literals.rs:16:18
1717
|
1818
LL | let _fail3 = 1234isize;
1919
| ^^^^^^^^^ help: add an underscore: `1234_isize`
2020

2121
error: integer type suffix should be separated by an underscore
22-
--> $DIR/unseparated_prefix_literals.rs:13:18
22+
--> $DIR/unseparated_prefix_literals.rs:17:18
2323
|
2424
LL | let _fail4 = 1234usize;
2525
| ^^^^^^^^^ help: add an underscore: `1234_usize`
2626

2727
error: integer type suffix should be separated by an underscore
28-
--> $DIR/unseparated_prefix_literals.rs:14:18
28+
--> $DIR/unseparated_prefix_literals.rs:18:18
2929
|
3030
LL | let _fail5 = 0x123isize;
3131
| ^^^^^^^^^^ help: add an underscore: `0x123_isize`
3232

3333
error: float type suffix should be separated by an underscore
34-
--> $DIR/unseparated_prefix_literals.rs:18:19
34+
--> $DIR/unseparated_prefix_literals.rs:22:19
3535
|
3636
LL | let _failf1 = 1.5f32;
3737
| ^^^^^^ help: add an underscore: `1.5_f32`
3838

3939
error: float type suffix should be separated by an underscore
40-
--> $DIR/unseparated_prefix_literals.rs:19:19
40+
--> $DIR/unseparated_prefix_literals.rs:23:19
4141
|
4242
LL | let _failf2 = 1f32;
4343
| ^^^^ help: add an underscore: `1_f32`

0 commit comments

Comments
 (0)