Integrate suggestions from code review

This commit is contained in:
cgm616
2020-10-25 11:31:24 -04:00
parent e7e4b35bdf
commit 312bbff696
8 changed files with 19 additions and 19 deletions
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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,
@@ -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),
@@ -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),
+7 -7
View File
@@ -96,7 +96,7 @@
/// 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"
}
@@ -144,7 +144,7 @@ enum WarningType {
LargeDigitGroups,
DecimalRepresentation,
MistypedLiteralSuffix,
UnusualByteGrouping,
UnusualByteGroupings,
}
impl WarningType {
@@ -195,9 +195,9 @@ fn display(&self, suggested_format: String, cx: &EarlyContext<'_>, span: rustc_s
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",
@@ -213,7 +213,7 @@ fn display(&self, suggested_format: String, cx: &EarlyContext<'_>, span: rustc_s
INCONSISTENT_DIGIT_GROUPING,
LARGE_DIGIT_GROUPS,
MISTYPED_LITERAL_SUFFIXES,
UNUSUAL_BYTE_GROUPING,
UNUSUAL_BYTE_GROUPINGS,
]);
impl EarlyLintPass for LiteralDigitGrouping {
@@ -268,7 +268,7 @@ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit) {
let should_warn = match warning_type {
| WarningType::UnreadableLiteral
| WarningType::InconsistentDigitGrouping
| WarningType::UnusualByteGrouping
| WarningType::UnusualByteGroupings
| WarningType::LargeDigitGroups => {
!in_macro(lit.span)
}
@@ -369,7 +369,7 @@ fn get_group_size<'a>(groups: impl Iterator<Item = &'a str>, radix: Radix) -> Re
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() {
+1 -1
View File
@@ -2644,7 +2644,7 @@
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,
+1 -1
View File
@@ -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
+4 -4
View File
@@ -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;
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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