Skip to content

Commit

Permalink
Integrate suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
cgm616 committed Oct 25, 2020
1 parent e7e4b35 commit 312bbff
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2017,7 +2017,7 @@ Released 2018-09-13
[`unused_label`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_label
[`unused_self`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_self
[`unused_unit`]: https://rust-lang.github.io/rust-clippy/master/index.html#unused_unit
[`unusual_byte_grouping`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_grouping
[`unusual_byte_groupings`]: https://rust-lang.github.io/rust-clippy/master/index.html#unusual_byte_groupings
[`unwrap_in_result`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_in_result
[`unwrap_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used
[`use_debug`]: https://rust-lang.github.io/rust-clippy/master/index.html#use_debug
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&literal_representation::LARGE_DIGIT_GROUPS,
&literal_representation::MISTYPED_LITERAL_SUFFIXES,
&literal_representation::UNREADABLE_LITERAL,
&literal_representation::UNUSUAL_BYTE_GROUPING,
&literal_representation::UNUSUAL_BYTE_GROUPINGS,
&loops::EMPTY_LOOP,
&loops::EXPLICIT_COUNTER_LOOP,
&loops::EXPLICIT_INTO_ITER_LOOP,
Expand Down Expand Up @@ -1366,7 +1366,7 @@ 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::UNUSUAL_BYTE_GROUPING),
LintId::of(&literal_representation::UNUSUAL_BYTE_GROUPINGS),
LintId::of(&loops::EMPTY_LOOP),
LintId::of(&loops::EXPLICIT_COUNTER_LOOP),
LintId::of(&loops::FOR_KV_MAP),
Expand Down Expand Up @@ -1589,7 +1589,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&len_zero::LEN_WITHOUT_IS_EMPTY),
LintId::of(&len_zero::LEN_ZERO),
LintId::of(&literal_representation::INCONSISTENT_DIGIT_GROUPING),
LintId::of(&literal_representation::UNUSUAL_BYTE_GROUPING),
LintId::of(&literal_representation::UNUSUAL_BYTE_GROUPINGS),
LintId::of(&loops::EMPTY_LOOP),
LintId::of(&loops::FOR_KV_MAP),
LintId::of(&loops::NEEDLESS_RANGE_LOOP),
Expand Down
14 changes: 7 additions & 7 deletions clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ declare_clippy_lint! {
/// let x: u32 = 0xFFF_FFF;
/// let y: u8 = 0b01_011_101;
/// ```
pub UNUSUAL_BYTE_GROUPING,
pub UNUSUAL_BYTE_GROUPINGS,
style,
"binary or hex literals that aren't grouped by four"
}
Expand Down Expand Up @@ -144,7 +144,7 @@ enum WarningType {
LargeDigitGroups,
DecimalRepresentation,
MistypedLiteralSuffix,
UnusualByteGrouping,
UnusualByteGroupings,
}

impl WarningType {
Expand Down Expand Up @@ -195,9 +195,9 @@ impl WarningType {
suggested_format,
Applicability::MachineApplicable,
),
Self::UnusualByteGrouping => span_lint_and_sugg(
Self::UnusualByteGroupings => span_lint_and_sugg(
cx,
UNUSUAL_BYTE_GROUPING,
UNUSUAL_BYTE_GROUPINGS,
span,
"digits of hex or binary literal not grouped by four",
"consider",
Expand All @@ -213,7 +213,7 @@ declare_lint_pass!(LiteralDigitGrouping => [
INCONSISTENT_DIGIT_GROUPING,
LARGE_DIGIT_GROUPS,
MISTYPED_LITERAL_SUFFIXES,
UNUSUAL_BYTE_GROUPING,
UNUSUAL_BYTE_GROUPINGS,
]);

impl EarlyLintPass for LiteralDigitGrouping {
Expand Down Expand Up @@ -268,7 +268,7 @@ impl LiteralDigitGrouping {
let should_warn = match warning_type {
| WarningType::UnreadableLiteral
| WarningType::InconsistentDigitGrouping
| WarningType::UnusualByteGrouping
| WarningType::UnusualByteGroupings
| WarningType::LargeDigitGroups => {
!in_macro(lit.span)
}
Expand Down Expand Up @@ -369,7 +369,7 @@ impl LiteralDigitGrouping {
let first = groups.next().expect("At least one group");

if (radix == Radix::Binary || radix == Radix::Hexadecimal) && groups.any(|i| i != 4 && i != 2) {
return Err(WarningType::UnusualByteGrouping);
return Err(WarningType::UnusualByteGroupings);
}

if let Some(second) = groups.next() {
Expand Down
2 changes: 1 addition & 1 deletion src/lintlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@ vec![
module: "unused_unit",
},
Lint {
name: "unusual_byte_grouping",
name: "unusual_byte_groupings",
group: "style",
desc: "binary or hex literals that aren\'t grouped by four",
deprecation: None,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/large_digit_groups.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: digits of hex or binary literal not grouped by four
LL | 0x1_234_567,
| ^^^^^^^^^^^ help: consider: `0x0123_4567`
|
= note: `-D clippy::unusual-byte-grouping` implied by `-D warnings`
= note: `-D clippy::unusual-byte-groupings` implied by `-D warnings`

error: digits of hex or binary literal not grouped by four
--> $DIR/large_digit_groups.rs:22:9
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/literals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

fn main() {
let ok1 = 0xABCD;
let ok3 = 0xabcd;
let ok4 = 0xabcd_i32;
let ok5 = 0xABCD_u32;
let ok5 = 0xABCD_isize;
let ok3 = 0xab_cd;
let ok4 = 0xab_cd_i32;
let ok5 = 0xAB_CD_u32;
let ok5 = 0xAB_CD_isize;
let fail1 = 0xabCD;
let fail2 = 0xabCD_u32;
let fail2 = 0xabCD_isize;
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/literals.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ error: digits of hex or binary literal not grouped by four
LL | let fail24 = 0xAB_ABC_AB;
| ^^^^^^^^^^^ help: consider: `0x0ABA_BCAB`
|
= note: `-D clippy::unusual-byte-grouping` implied by `-D warnings`
= note: `-D clippy::unusual-byte-groupings` implied by `-D warnings`

error: digits of hex or binary literal not grouped by four
--> $DIR/literals.rs:38:18
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/unreadable_literal.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: digits of hex or binary literal not grouped by four
LL | 0x1_234_567,
| ^^^^^^^^^^^ help: consider: `0x0123_4567`
|
= note: `-D clippy::unusual-byte-grouping` implied by `-D warnings`
= note: `-D clippy::unusual-byte-groupings` implied by `-D warnings`

error: long literal lacking separators
--> $DIR/unreadable_literal.rs:25:17
Expand Down

0 comments on commit 312bbff

Please sign in to comment.