Skip to content

Commit

Permalink
Rollup merge of rust-lang#5419 - dtolnay:unreadable, r=flip1995
Browse files Browse the repository at this point in the history
Downgrade unreadable_literal to pedantic

As motivated by rust-lang#5418. This is the top most commonly suppressed Clippy style lint, which indicates that the community has decided they don't share Clippy's opinion on the best style of this.

I've left the lint in as pedantic, though it could be that "restriction" would be better -- I can see this lint being useful as an opt-in restriction in some codebases.

changelog: Remove unreadable_literal from default set of enabled lints
  • Loading branch information
flip1995 authored Apr 7, 2020
2 parents 858bfd4 + be34bc4 commit 642d743
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
3 changes: 1 addition & 2 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&items_after_statements::ITEMS_AFTER_STATEMENTS),
LintId::of(&large_stack_arrays::LARGE_STACK_ARRAYS),
LintId::of(&literal_representation::LARGE_DIGIT_GROUPS),
LintId::of(&literal_representation::UNREADABLE_LITERAL),
LintId::of(&loops::EXPLICIT_INTO_ITER_LOOP),
LintId::of(&loops::EXPLICIT_ITER_LOOP),
LintId::of(&macro_use::MACRO_USE_IMPORTS),
Expand Down Expand Up @@ -1229,7 +1230,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&lifetimes::NEEDLESS_LIFETIMES),
LintId::of(&literal_representation::INCONSISTENT_DIGIT_GROUPING),
LintId::of(&literal_representation::MISTYPED_LITERAL_SUFFIXES),
LintId::of(&literal_representation::UNREADABLE_LITERAL),
LintId::of(&loops::EMPTY_LOOP),
LintId::of(&loops::EXPLICIT_COUNTER_LOOP),
LintId::of(&loops::FOR_KV_MAP),
Expand Down Expand Up @@ -1436,7 +1436,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&len_zero::LEN_ZERO),
LintId::of(&let_if_seq::USELESS_LET_IF_SEQ),
LintId::of(&literal_representation::INCONSISTENT_DIGIT_GROUPING),
LintId::of(&literal_representation::UNREADABLE_LITERAL),
LintId::of(&loops::EMPTY_LOOP),
LintId::of(&loops::FOR_KV_MAP),
LintId::of(&loops::NEEDLESS_RANGE_LOOP),
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare_clippy_lint! {
/// let x: u64 = 61864918973511;
/// ```
pub UNREADABLE_LITERAL,
style,
pedantic,
"long integer literal without underscores"
}

Expand Down
2 changes: 1 addition & 1 deletion src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2301,7 +2301,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
},
Lint {
name: "unreadable_literal",
group: "style",
group: "pedantic",
desc: "long integer literal without underscores",
deprecation: None,
module: "literal_representation",
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/approx_const.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[warn(clippy::approx_constant)]
#[allow(unused, clippy::shadow_unrelated, clippy::similar_names, clippy::unreadable_literal)]
#[allow(unused, clippy::shadow_unrelated, clippy::similar_names)]
fn main() {
let my_e = 2.7182;
let almost_e = 2.718;
Expand Down
1 change: 1 addition & 0 deletions tests/ui/inconsistent_digit_grouping.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#[warn(clippy::inconsistent_digit_grouping)]
#[deny(clippy::unreadable_literal)]
#[allow(unused_variables, clippy::excessive_precision)]
fn main() {
macro_rules! mac1 {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/inconsistent_digit_grouping.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-rustfix
#[warn(clippy::inconsistent_digit_grouping)]
#[deny(clippy::unreadable_literal)]
#[allow(unused_variables, clippy::excessive_precision)]
fn main() {
macro_rules! mac1 {
Expand Down
26 changes: 15 additions & 11 deletions tests/ui/inconsistent_digit_grouping.stderr
Original file line number Diff line number Diff line change
@@ -1,63 +1,67 @@
error: digits grouped inconsistently by underscores
--> $DIR/inconsistent_digit_grouping.rs:25:16
--> $DIR/inconsistent_digit_grouping.rs:26:16
|
LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32);
| ^^^^^^^^ help: consider: `123_456`
|
= note: `-D clippy::inconsistent-digit-grouping` implied by `-D warnings`

error: digits grouped inconsistently by underscores
--> $DIR/inconsistent_digit_grouping.rs:25:26
--> $DIR/inconsistent_digit_grouping.rs:26:26
|
LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32);
| ^^^^^^^^^^ help: consider: `12_345_678`

error: digits grouped inconsistently by underscores
--> $DIR/inconsistent_digit_grouping.rs:25:38
--> $DIR/inconsistent_digit_grouping.rs:26:38
|
LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32);
| ^^^^^^^^ help: consider: `1_234_567`

error: digits grouped inconsistently by underscores
--> $DIR/inconsistent_digit_grouping.rs:25:48
--> $DIR/inconsistent_digit_grouping.rs:26:48
|
LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32);
| ^^^^^^^^^^^^^^ help: consider: `1_234.567_8_f32`

error: digits grouped inconsistently by underscores
--> $DIR/inconsistent_digit_grouping.rs:25:64
--> $DIR/inconsistent_digit_grouping.rs:26:64
|
LL | let bad = (1_23_456, 1_234_5678, 1234_567, 1_234.5678_f32, 1.234_5678_f32);
| ^^^^^^^^^^^^^^ help: consider: `1.234_567_8_f32`

error: long literal lacking separators
--> $DIR/inconsistent_digit_grouping.rs:28:13
--> $DIR/inconsistent_digit_grouping.rs:29:13
|
LL | let _ = 0x100000;
| ^^^^^^^^ help: consider: `0x0010_0000`
|
= note: `-D clippy::unreadable-literal` implied by `-D warnings`
note: the lint level is defined here
--> $DIR/inconsistent_digit_grouping.rs:3:8
|
LL | #[deny(clippy::unreadable_literal)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^

error: long literal lacking separators
--> $DIR/inconsistent_digit_grouping.rs:29:13
--> $DIR/inconsistent_digit_grouping.rs:30:13
|
LL | let _ = 0x1000000;
| ^^^^^^^^^ help: consider: `0x0100_0000`

error: long literal lacking separators
--> $DIR/inconsistent_digit_grouping.rs:30:13
--> $DIR/inconsistent_digit_grouping.rs:31:13
|
LL | let _ = 0x10000000;
| ^^^^^^^^^^ help: consider: `0x1000_0000`

error: long literal lacking separators
--> $DIR/inconsistent_digit_grouping.rs:31:13
--> $DIR/inconsistent_digit_grouping.rs:32:13
|
LL | let _ = 0x100000000_u64;
| ^^^^^^^^^^^^^^^ help: consider: `0x0001_0000_0000_u64`

error: digits grouped inconsistently by underscores
--> $DIR/inconsistent_digit_grouping.rs:34:18
--> $DIR/inconsistent_digit_grouping.rs:35:18
|
LL | let _: f32 = 1_23_456.;
| ^^^^^^^^^ help: consider: `123_456.`
Expand Down

0 comments on commit 642d743

Please sign in to comment.