Skip to content

Commit 1b45679

Browse files
Stabilize hex_literal_case (#6935)
1 parent 87c8f21 commit 1b45679

13 files changed

Lines changed: 56 additions & 27 deletions

Configurations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ Control the case of the letters in hexadecimal literal values
12571257

12581258
- **Default value**: `Preserve`
12591259
- **Possible values**: `Preserve`, `Upper`, `Lower`
1260-
- **Stable**: No (tracking issue: [#5081](https://github.com/rust-lang/rustfmt/issues/5081))
1260+
- **Stable**: Yes
12611261

12621262
## `float_literal_trailing_zero`
12631263

src/config/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ create_config! {
7878
"Format the bodies of declarative macro definitions";
7979
skip_macro_invocations: SkipMacroInvocations, false,
8080
"Skip formatting the bodies of macros invoked with the following names.";
81-
hex_literal_case: HexLiteralCaseConfig, false, "Format hexadecimal integer literals";
81+
hex_literal_case: HexLiteralCaseConfig, true, "Format hexadecimal integer literals";
8282
float_literal_trailing_zero: FloatLiteralTrailingZeroConfig, false,
8383
"Add or remove trailing zero in floating-point literals";
8484

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-hex_literal_case: Lower
2+
fn main() {
3+
let h1 = 0xCAFE_5EA7;
4+
let h2 = 0xCAFE_F00Du32;
5+
let h3 = -0xCAFE_5EA7;
6+
let h4 = -0xCAFE_F00Di32;
7+
let h5 = 0xABcD07_i32;
8+
let h6 = -0xABcD07_i32;
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-hex_literal_case: Preserve
2+
fn main() {
3+
let h1 = 0xcAfE_5Ea7;
4+
let h2 = 0xCaFe_F00du32;
5+
let h3 = -0xcAfE_5Ea7;
6+
let h4 = -0xCaFe_F00di32;
7+
let h5 = 0xAbcd07_i32;
8+
let h6 = -0xAbcd07_i32;
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-hex_literal_case: Upper
2+
fn main() {
3+
let h1 = 0xCaFE_5ea7;
4+
let h2 = 0xCAFE_F00Du32;
5+
let h3 = -0xCaFE_5ea7;
6+
let h4 = -0xCAFE_F00Di32;
7+
let h5 = 0xAbcd07_i32;
8+
let h6 = -0xAbcd07_i32;
9+
}

tests/source/hex_literal_lower.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/source/hex_literal_upper.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-hex_literal_case: Lower
2+
fn main() {
3+
let h1 = 0xcafe_5ea7;
4+
let h2 = 0xcafe_f00du32;
5+
let h3 = -0xcafe_5ea7;
6+
let h4 = -0xcafe_f00di32;
7+
let h5 = 0xabcd07_i32;
8+
let h6 = -0xabcd07_i32;
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-hex_literal_case: Preserve
2+
fn main() {
3+
let h1 = 0xcAfE_5Ea7;
4+
let h2 = 0xCaFe_F00du32;
5+
let h3 = -0xcAfE_5Ea7;
6+
let h4 = -0xCaFe_F00di32;
7+
let h5 = 0xAbcd07_i32;
8+
let h6 = -0xAbcd07_i32;
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// rustfmt-hex_literal_case: Upper
2+
fn main() {
3+
let h1 = 0xCAFE_5EA7;
4+
let h2 = 0xCAFE_F00Du32;
5+
let h3 = -0xCAFE_5EA7;
6+
let h4 = -0xCAFE_F00Di32;
7+
let h5 = 0xABCD07_i32;
8+
let h6 = -0xABCD07_i32;
9+
}

0 commit comments

Comments
 (0)