Skip to content

Commit

Permalink
Auto merge of rust-lang#4956 - JohnTitor:decimal-lit-suffix, r=llogiq
Browse files Browse the repository at this point in the history
Do not drop suffixes on `decimal_literal_representation`

Fixes rust-lang#4763

changelog: Do not drop type suffixes on `decimal_literal_representation`
  • Loading branch information
bors committed Dec 25, 2019
2 parents 87e628f + b68e65b commit b0c4744
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clippy_lints/src/literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ impl DecimalLiteralRepresentation {
if val >= u128::from(self.threshold);
then {
let hex = format!("{:#X}", val);
let num_lit = NumericLiteral::new(&hex, None, false);
let num_lit = NumericLiteral::new(&hex, num_lit.suffix, false);
let _ = Self::do_lint(num_lit.integer).map_err(|warning_type| {
warning_type.display(num_lit.format(), cx, lit.span)
});
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/decimal_literal_representation.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ fn main() {
0x7FFF_FFFF, // 0x7FFF_FFFF
#[allow(overflowing_literals)]
0xF0F0_F0F0, // 0xF0F0_F0F0
0x8005_usize, // 0x8005_usize
0x7F0F_F00F_isize, // 0x7F0F_F00F_isize
);
}
2 changes: 2 additions & 0 deletions tests/ui/decimal_literal_representation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ fn main() {
2_147_483_647, // 0x7FFF_FFFF
#[allow(overflowing_literals)]
4_042_322_160, // 0xF0F0_F0F0
32_773usize, // 0x8005_usize
2_131_750_927isize, // 0x7F0F_F00F_isize
);
}
14 changes: 13 additions & 1 deletion tests/ui/decimal_literal_representation.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,17 @@ error: integer literal has a better hexadecimal representation
LL | 4_042_322_160, // 0xF0F0_F0F0
| ^^^^^^^^^^^^^ help: consider: `0xF0F0_F0F0`

error: aborting due to 5 previous errors
error: integer literal has a better hexadecimal representation
--> $DIR/decimal_literal_representation.rs:24:9
|
LL | 32_773usize, // 0x8005_usize
| ^^^^^^^^^^^ help: consider: `0x8005_usize`

error: integer literal has a better hexadecimal representation
--> $DIR/decimal_literal_representation.rs:25:9
|
LL | 2_131_750_927isize, // 0x7F0F_F00F_isize
| ^^^^^^^^^^^^^^^^^^ help: consider: `0x7F0F_F00F_isize`

error: aborting due to 7 previous errors

0 comments on commit b0c4744

Please sign in to comment.