Skip to content

Commit 0332a7b

Browse files
committed
Auto merge of #87337 - jyn514:lint-error, r=oli-obk,flip1995
Don't abort compilation after giving a lint error The only reason to use `abort_if_errors` is when the program is so broken that either: 1. later passes get confused and ICE 2. any diagnostics from later passes would be noise This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints. So it can continue to lint and compile even if there are lint errors. Closes rust-lang/rust#82761. This is a WIP because I have a feeling it will exit with 0 even if there were lint errors; I don't have a computer that can build rustc locally at the moment.
2 parents 6536c58 + ac9dd36 commit 0332a7b

30 files changed

+123
-102
lines changed

tests/ui-toml/lint_decimal_readability/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::excessive_precision)]
12
#[deny(clippy::unreadable_literal)]
23

34
fn allow_inconsistent_digit_grouping() {

tests/ui-toml/lint_decimal_readability/test.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: digits grouped inconsistently by underscores
2-
--> $DIR/test.rs:18:18
2+
--> $DIR/test.rs:19:18
33
|
44
LL | let _fail1 = 100_200_300.123456789;
55
| ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789`

tests/ui/deref_addrof.fixed

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ macro_rules! m_mut {
5252
};
5353
}
5454

55+
#[derive(Copy, Clone)]
5556
pub struct S;
5657
impl S {
5758
pub fn f(&self) -> &Self {
5859
m!(self)
5960
}
60-
pub fn f_mut(&self) -> &Self {
61+
#[allow(unused_mut)] // mut will be unused, once the macro is fixed
62+
pub fn f_mut(mut self) -> Self {
6163
m_mut!(self)
6264
}
6365
}

tests/ui/deref_addrof.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ macro_rules! m_mut {
5252
};
5353
}
5454

55+
#[derive(Copy, Clone)]
5556
pub struct S;
5657
impl S {
5758
pub fn f(&self) -> &Self {
5859
m!(self)
5960
}
60-
pub fn f_mut(&self) -> &Self {
61+
#[allow(unused_mut)] // mut will be unused, once the macro is fixed
62+
pub fn f_mut(mut self) -> Self {
6163
m_mut!(self)
6264
}
6365
}

tests/ui/double_neg.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#[warn(clippy::double_neg)]
2+
#[allow(clippy::no_effect)]
23
fn main() {
34
let x = 1;
45
-x;

tests/ui/double_neg.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
2-
--> $DIR/double_neg.rs:6:5
2+
--> $DIR/double_neg.rs:7:5
33
|
44
LL | --x;
55
| ^^^

tests/ui/fn_params_excessive_bools.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![warn(clippy::fn_params_excessive_bools)]
2+
#![allow(clippy::too_many_arguments)]
23

34
extern "C" {
45
fn f(_: bool, _: bool, _: bool, _: bool);

tests/ui/fn_params_excessive_bools.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: more than 3 bools in function parameters
2-
--> $DIR/fn_params_excessive_bools.rs:17:1
2+
--> $DIR/fn_params_excessive_bools.rs:18:1
33
|
44
LL | fn g(_: bool, _: bool, _: bool, _: bool) {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,31 +8,31 @@ LL | fn g(_: bool, _: bool, _: bool, _: bool) {}
88
= help: consider refactoring bools into two-variant enums
99

1010
error: more than 3 bools in function parameters
11-
--> $DIR/fn_params_excessive_bools.rs:20:1
11+
--> $DIR/fn_params_excessive_bools.rs:21:1
1212
|
1313
LL | fn t(_: S, _: S, _: Box<S>, _: Vec<u32>, _: bool, _: bool, _: bool, _: bool) {}
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
|
1616
= help: consider refactoring bools into two-variant enums
1717

1818
error: more than 3 bools in function parameters
19-
--> $DIR/fn_params_excessive_bools.rs:24:5
19+
--> $DIR/fn_params_excessive_bools.rs:25:5
2020
|
2121
LL | fn f(_: bool, _: bool, _: bool, _: bool);
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
2424
= help: consider refactoring bools into two-variant enums
2525

2626
error: more than 3 bools in function parameters
27-
--> $DIR/fn_params_excessive_bools.rs:29:5
27+
--> $DIR/fn_params_excessive_bools.rs:30:5
2828
|
2929
LL | fn f(&self, _: bool, _: bool, _: bool, _: bool) {}
3030
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3131
|
3232
= help: consider refactoring bools into two-variant enums
3333

3434
error: more than 3 bools in function parameters
35-
--> $DIR/fn_params_excessive_bools.rs:41:5
35+
--> $DIR/fn_params_excessive_bools.rs:42:5
3636
|
3737
LL | / fn n(_: bool, _: u32, _: bool, _: Box<u32>, _: bool, _: bool) {
3838
LL | | fn nn(_: bool, _: bool, _: bool, _: bool) {}
@@ -42,7 +42,7 @@ LL | | }
4242
= help: consider refactoring bools into two-variant enums
4343

4444
error: more than 3 bools in function parameters
45-
--> $DIR/fn_params_excessive_bools.rs:42:9
45+
--> $DIR/fn_params_excessive_bools.rs:43:9
4646
|
4747
LL | fn nn(_: bool, _: bool, _: bool, _: bool) {}
4848
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/ui/formatting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(unused_assignments)]
44
#![allow(clippy::if_same_then_else)]
55
#![allow(clippy::deref_addrof)]
6+
#![allow(clippy::nonminimal_bool)]
67

78
fn foo() -> bool {
89
true

tests/ui/formatting.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
2-
--> $DIR/formatting.rs:15:6
2+
--> $DIR/formatting.rs:16:6
33
|
44
LL | a =- 35;
55
| ^^^^
@@ -8,23 +8,23 @@ LL | a =- 35;
88
= note: to remove this lint, use either `-=` or `= -`
99

1010
error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)`
11-
--> $DIR/formatting.rs:16:6
11+
--> $DIR/formatting.rs:17:6
1212
|
1313
LL | a =* &191;
1414
| ^^^^
1515
|
1616
= note: to remove this lint, use either `*=` or `= *`
1717

1818
error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)`
19-
--> $DIR/formatting.rs:19:6
19+
--> $DIR/formatting.rs:20:6
2020
|
2121
LL | b =! false;
2222
| ^^^^
2323
|
2424
= note: to remove this lint, use either `!=` or `= !`
2525

2626
error: possibly missing a comma here
27-
--> $DIR/formatting.rs:28:19
27+
--> $DIR/formatting.rs:29:19
2828
|
2929
LL | -1, -2, -3 // <= no comma here
3030
| ^
@@ -33,15 +33,15 @@ LL | -1, -2, -3 // <= no comma here
3333
= note: to remove this lint, add a comma or write the expr in a single line
3434

3535
error: possibly missing a comma here
36-
--> $DIR/formatting.rs:32:19
36+
--> $DIR/formatting.rs:33:19
3737
|
3838
LL | -1, -2, -3 // <= no comma here
3939
| ^
4040
|
4141
= note: to remove this lint, add a comma or write the expr in a single line
4242

4343
error: possibly missing a comma here
44-
--> $DIR/formatting.rs:69:11
44+
--> $DIR/formatting.rs:70:11
4545
|
4646
LL | -1
4747
| ^

tests/ui/literals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![warn(clippy::zero_prefixed_literal)]
55
#![warn(clippy::unseparated_literal_suffix)]
66
#![warn(clippy::separated_literal_suffix)]
7-
#![allow(dead_code)]
7+
#![allow(dead_code, overflowing_literals)]
88

99
fn main() {
1010
let ok1 = 0xABCD;

tests/ui/many_single_char_names.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::too_many_arguments, clippy::diverging_sub_expression)]
12
#![warn(clippy::many_single_char_names)]
23

34
fn bla() {

tests/ui/many_single_char_names.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: 5 bindings with single-character names in scope
2-
--> $DIR/many_single_char_names.rs:4:9
2+
--> $DIR/many_single_char_names.rs:5:9
33
|
44
LL | let a: i32;
55
| ^
@@ -12,7 +12,7 @@ LL | let e: i32;
1212
= note: `-D clippy::many-single-char-names` implied by `-D warnings`
1313

1414
error: 6 bindings with single-character names in scope
15-
--> $DIR/many_single_char_names.rs:4:9
15+
--> $DIR/many_single_char_names.rs:5:9
1616
|
1717
LL | let a: i32;
1818
| ^
@@ -25,7 +25,7 @@ LL | let f: i32;
2525
| ^
2626

2727
error: 5 bindings with single-character names in scope
28-
--> $DIR/many_single_char_names.rs:4:9
28+
--> $DIR/many_single_char_names.rs:5:9
2929
|
3030
LL | let a: i32;
3131
| ^
@@ -36,13 +36,13 @@ LL | e => panic!(),
3636
| ^
3737

3838
error: 8 bindings with single-character names in scope
39-
--> $DIR/many_single_char_names.rs:29:13
39+
--> $DIR/many_single_char_names.rs:30:13
4040
|
4141
LL | fn bindings(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32, g: i32, h: i32) {}
4242
| ^ ^ ^ ^ ^ ^ ^ ^
4343

4444
error: 8 bindings with single-character names in scope
45-
--> $DIR/many_single_char_names.rs:32:10
45+
--> $DIR/many_single_char_names.rs:33:10
4646
|
4747
LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!();
4848
| ^ ^ ^ ^ ^ ^ ^ ^

tests/ui/mistyped_literal_suffix.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(
44
dead_code,
55
unused_variables,
6+
overflowing_literals,
67
clippy::excessive_precision,
78
clippy::inconsistent_digit_grouping
89
)]
@@ -21,7 +22,6 @@ fn main() {
2122
let fail25 = 1E2_f32;
2223
let fail26 = 43E7_f64;
2324
let fail27 = 243E17_f32;
24-
#[allow(overflowing_literals)]
2525
let fail28 = 241_251_235E723_f64;
2626
let ok29 = 42279.911_32;
2727

tests/ui/mistyped_literal_suffix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![allow(
44
dead_code,
55
unused_variables,
6+
overflowing_literals,
67
clippy::excessive_precision,
78
clippy::inconsistent_digit_grouping
89
)]
@@ -21,7 +22,6 @@ fn main() {
2122
let fail25 = 1E2_32;
2223
let fail26 = 43E7_64;
2324
let fail27 = 243E17_32;
24-
#[allow(overflowing_literals)]
2525
let fail28 = 241251235E723_64;
2626
let ok29 = 42279.911_32;
2727

tests/ui/mistyped_literal_suffix.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
error: mistyped literal suffix
2-
--> $DIR/mistyped_literal_suffix.rs:11:18
2+
--> $DIR/mistyped_literal_suffix.rs:12:18
33
|
44
LL | let fail14 = 2_32;
55
| ^^^^ help: did you mean to write: `2_i32`
66
|
77
= note: `#[deny(clippy::mistyped_literal_suffixes)]` on by default
88

99
error: mistyped literal suffix
10-
--> $DIR/mistyped_literal_suffix.rs:12:18
10+
--> $DIR/mistyped_literal_suffix.rs:13:18
1111
|
1212
LL | let fail15 = 4_64;
1313
| ^^^^ help: did you mean to write: `4_i64`
1414

1515
error: mistyped literal suffix
16-
--> $DIR/mistyped_literal_suffix.rs:13:18
16+
--> $DIR/mistyped_literal_suffix.rs:14:18
1717
|
1818
LL | let fail16 = 7_8; //
1919
| ^^^ help: did you mean to write: `7_i8`
2020

2121
error: mistyped literal suffix
22-
--> $DIR/mistyped_literal_suffix.rs:14:18
22+
--> $DIR/mistyped_literal_suffix.rs:15:18
2323
|
2424
LL | let fail17 = 23_16; //
2525
| ^^^^^ help: did you mean to write: `23_i16`
2626

2727
error: mistyped literal suffix
28-
--> $DIR/mistyped_literal_suffix.rs:17:18
28+
--> $DIR/mistyped_literal_suffix.rs:18:18
2929
|
3030
LL | let fail20 = 2__8; //
3131
| ^^^^ help: did you mean to write: `2_i8`
3232

3333
error: mistyped literal suffix
34-
--> $DIR/mistyped_literal_suffix.rs:18:18
34+
--> $DIR/mistyped_literal_suffix.rs:19:18
3535
|
3636
LL | let fail21 = 4___16; //
3737
| ^^^^^^ help: did you mean to write: `4_i16`
3838

3939
error: mistyped literal suffix
40-
--> $DIR/mistyped_literal_suffix.rs:21:18
40+
--> $DIR/mistyped_literal_suffix.rs:22:18
4141
|
4242
LL | let fail25 = 1E2_32;
4343
| ^^^^^^ help: did you mean to write: `1E2_f32`
4444

4545
error: mistyped literal suffix
46-
--> $DIR/mistyped_literal_suffix.rs:22:18
46+
--> $DIR/mistyped_literal_suffix.rs:23:18
4747
|
4848
LL | let fail26 = 43E7_64;
4949
| ^^^^^^^ help: did you mean to write: `43E7_f64`
5050

5151
error: mistyped literal suffix
52-
--> $DIR/mistyped_literal_suffix.rs:23:18
52+
--> $DIR/mistyped_literal_suffix.rs:24:18
5353
|
5454
LL | let fail27 = 243E17_32;
5555
| ^^^^^^^^^ help: did you mean to write: `243E17_f32`

tests/ui/needless_arbitrary_self_type_unfixable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ mod issue_6089 {
3838
// fn call_with_mut_self<'life0>(self: &'life0 mut Self) {}
3939
#[rename_my_lifetimes]
4040
impl T2 for S2 {
41+
#[allow(clippy::needless_lifetimes)]
4142
fn call_with_mut_self(self: &mut Self) {}
4243
}
4344
}

tests/ui/needless_arbitrary_self_type_unfixable.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: the type of the `self` parameter does not need to be arbitrary
2-
--> $DIR/needless_arbitrary_self_type_unfixable.rs:41:31
2+
--> $DIR/needless_arbitrary_self_type_unfixable.rs:42:31
33
|
44
LL | fn call_with_mut_self(self: &mut Self) {}
55
| ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'_ mut self`

tests/ui/needless_continue.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ macro_rules! nonzero {
1212
};
1313
}
1414

15+
#[allow(clippy::nonminimal_bool)]
1516
fn main() {
1617
let mut i = 1;
1718
while i < 10 {

0 commit comments

Comments
 (0)