Skip to content

Commit

Permalink
Auto merge of rust-lang#87337 - jyn514:lint-error, r=oli-obk,flip1995
Browse files Browse the repository at this point in the history
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#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.
  • Loading branch information
bors committed Nov 9, 2021
2 parents 6536c58 + ac9dd36 commit 0332a7b
Show file tree
Hide file tree
Showing 30 changed files with 123 additions and 102 deletions.
1 change: 1 addition & 0 deletions tests/ui-toml/lint_decimal_readability/test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::excessive_precision)]
#[deny(clippy::unreadable_literal)]

fn allow_inconsistent_digit_grouping() {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-toml/lint_decimal_readability/test.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: digits grouped inconsistently by underscores
--> $DIR/test.rs:18:18
--> $DIR/test.rs:19:18
|
LL | let _fail1 = 100_200_300.123456789;
| ^^^^^^^^^^^^^^^^^^^^^ help: consider: `100_200_300.123_456_789`
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/deref_addrof.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ macro_rules! m_mut {
};
}

#[derive(Copy, Clone)]
pub struct S;
impl S {
pub fn f(&self) -> &Self {
m!(self)
}
pub fn f_mut(&self) -> &Self {
#[allow(unused_mut)] // mut will be unused, once the macro is fixed
pub fn f_mut(mut self) -> Self {
m_mut!(self)
}
}
4 changes: 3 additions & 1 deletion tests/ui/deref_addrof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ macro_rules! m_mut {
};
}

#[derive(Copy, Clone)]
pub struct S;
impl S {
pub fn f(&self) -> &Self {
m!(self)
}
pub fn f_mut(&self) -> &Self {
#[allow(unused_mut)] // mut will be unused, once the macro is fixed
pub fn f_mut(mut self) -> Self {
m_mut!(self)
}
}
1 change: 1 addition & 0 deletions tests/ui/double_neg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#[warn(clippy::double_neg)]
#[allow(clippy::no_effect)]
fn main() {
let x = 1;
-x;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/double_neg.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: `--x` could be misinterpreted as pre-decrement by C programmers, is usually a no-op
--> $DIR/double_neg.rs:6:5
--> $DIR/double_neg.rs:7:5
|
LL | --x;
| ^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/fn_params_excessive_bools.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![warn(clippy::fn_params_excessive_bools)]
#![allow(clippy::too_many_arguments)]

extern "C" {
fn f(_: bool, _: bool, _: bool, _: bool);
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/fn_params_excessive_bools.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: more than 3 bools in function parameters
--> $DIR/fn_params_excessive_bools.rs:17:1
--> $DIR/fn_params_excessive_bools.rs:18:1
|
LL | fn g(_: bool, _: bool, _: bool, _: bool) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -8,31 +8,31 @@ LL | fn g(_: bool, _: bool, _: bool, _: bool) {}
= help: consider refactoring bools into two-variant enums

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

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

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

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

error: more than 3 bools in function parameters
--> $DIR/fn_params_excessive_bools.rs:42:9
--> $DIR/fn_params_excessive_bools.rs:43:9
|
LL | fn nn(_: bool, _: bool, _: bool, _: bool) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions tests/ui/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![allow(unused_assignments)]
#![allow(clippy::if_same_then_else)]
#![allow(clippy::deref_addrof)]
#![allow(clippy::nonminimal_bool)]

fn foo() -> bool {
true
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/formatting.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
--> $DIR/formatting.rs:15:6
--> $DIR/formatting.rs:16:6
|
LL | a =- 35;
| ^^^^
Expand All @@ -8,23 +8,23 @@ LL | a =- 35;
= note: to remove this lint, use either `-=` or `= -`

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

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

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

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

error: possibly missing a comma here
--> $DIR/formatting.rs:69:11
--> $DIR/formatting.rs:70:11
|
LL | -1
| ^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#![warn(clippy::zero_prefixed_literal)]
#![warn(clippy::unseparated_literal_suffix)]
#![warn(clippy::separated_literal_suffix)]
#![allow(dead_code)]
#![allow(dead_code, overflowing_literals)]

fn main() {
let ok1 = 0xABCD;
Expand Down
1 change: 1 addition & 0 deletions tests/ui/many_single_char_names.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::too_many_arguments, clippy::diverging_sub_expression)]
#![warn(clippy::many_single_char_names)]

fn bla() {
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/many_single_char_names.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: 5 bindings with single-character names in scope
--> $DIR/many_single_char_names.rs:4:9
--> $DIR/many_single_char_names.rs:5:9
|
LL | let a: i32;
| ^
Expand All @@ -12,7 +12,7 @@ LL | let e: i32;
= note: `-D clippy::many-single-char-names` implied by `-D warnings`

error: 6 bindings with single-character names in scope
--> $DIR/many_single_char_names.rs:4:9
--> $DIR/many_single_char_names.rs:5:9
|
LL | let a: i32;
| ^
Expand All @@ -25,7 +25,7 @@ LL | let f: i32;
| ^

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

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

error: 8 bindings with single-character names in scope
--> $DIR/many_single_char_names.rs:32:10
--> $DIR/many_single_char_names.rs:33:10
|
LL | let (a, b, c, d, e, f, g, h): (bool, bool, bool, bool, bool, bool, bool, bool) = unimplemented!();
| ^ ^ ^ ^ ^ ^ ^ ^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/mistyped_literal_suffix.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![allow(
dead_code,
unused_variables,
overflowing_literals,
clippy::excessive_precision,
clippy::inconsistent_digit_grouping
)]
Expand All @@ -21,7 +22,6 @@ fn main() {
let fail25 = 1E2_f32;
let fail26 = 43E7_f64;
let fail27 = 243E17_f32;
#[allow(overflowing_literals)]
let fail28 = 241_251_235E723_f64;
let ok29 = 42279.911_32;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/mistyped_literal_suffix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#![allow(
dead_code,
unused_variables,
overflowing_literals,
clippy::excessive_precision,
clippy::inconsistent_digit_grouping
)]
Expand All @@ -21,7 +22,6 @@ fn main() {
let fail25 = 1E2_32;
let fail26 = 43E7_64;
let fail27 = 243E17_32;
#[allow(overflowing_literals)]
let fail28 = 241251235E723_64;
let ok29 = 42279.911_32;

Expand Down
18 changes: 9 additions & 9 deletions tests/ui/mistyped_literal_suffix.stderr
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:11:18
--> $DIR/mistyped_literal_suffix.rs:12: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:12:18
--> $DIR/mistyped_literal_suffix.rs:13:18
|
LL | let fail15 = 4_64;
| ^^^^ help: did you mean to write: `4_i64`

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

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

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

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

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

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

error: mistyped literal suffix
--> $DIR/mistyped_literal_suffix.rs:23:18
--> $DIR/mistyped_literal_suffix.rs:24:18
|
LL | let fail27 = 243E17_32;
| ^^^^^^^^^ help: did you mean to write: `243E17_f32`
Expand Down
1 change: 1 addition & 0 deletions tests/ui/needless_arbitrary_self_type_unfixable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mod issue_6089 {
// fn call_with_mut_self<'life0>(self: &'life0 mut Self) {}
#[rename_my_lifetimes]
impl T2 for S2 {
#[allow(clippy::needless_lifetimes)]
fn call_with_mut_self(self: &mut Self) {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/needless_arbitrary_self_type_unfixable.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: the type of the `self` parameter does not need to be arbitrary
--> $DIR/needless_arbitrary_self_type_unfixable.rs:41:31
--> $DIR/needless_arbitrary_self_type_unfixable.rs:42:31
|
LL | fn call_with_mut_self(self: &mut Self) {}
| ^^^^^^^^^^^^^^^ help: consider to change this parameter to: `&'_ mut self`
Expand Down
1 change: 1 addition & 0 deletions tests/ui/needless_continue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ macro_rules! nonzero {
};
}

#[allow(clippy::nonminimal_bool)]
fn main() {
let mut i = 1;
while i < 10 {
Expand Down
Loading

0 comments on commit 0332a7b

Please sign in to comment.