diff --git a/Configurations.md b/Configurations.md index 1df79daf798..0f4320853fe 100644 --- a/Configurations.md +++ b/Configurations.md @@ -1257,7 +1257,7 @@ Control the case of the letters in hexadecimal literal values - **Default value**: `Preserve` - **Possible values**: `Preserve`, `Upper`, `Lower` -- **Stable**: No (tracking issue: [#5081](https://github.com/rust-lang/rustfmt/issues/5081)) +- **Stable**: Yes ## `float_literal_trailing_zero` diff --git a/src/config/mod.rs b/src/config/mod.rs index 8abb7439257..8c4ed07c3d7 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -78,7 +78,7 @@ create_config! { "Format the bodies of declarative macro definitions"; skip_macro_invocations: SkipMacroInvocations, false, "Skip formatting the bodies of macros invoked with the following names."; - hex_literal_case: HexLiteralCaseConfig, false, "Format hexadecimal integer literals"; + hex_literal_case: HexLiteralCaseConfig, true, "Format hexadecimal integer literals"; float_literal_trailing_zero: FloatLiteralTrailingZeroConfig, false, "Add or remove trailing zero in floating-point literals"; diff --git a/tests/source/configs/hex_literal_case/hex_literal_lower.rs b/tests/source/configs/hex_literal_case/hex_literal_lower.rs new file mode 100644 index 00000000000..de2c9f9d9dc --- /dev/null +++ b/tests/source/configs/hex_literal_case/hex_literal_lower.rs @@ -0,0 +1,9 @@ +// rustfmt-hex_literal_case: Lower +fn main() { + let h1 = 0xCAFE_5EA7; + let h2 = 0xCAFE_F00Du32; + let h3 = -0xCAFE_5EA7; + let h4 = -0xCAFE_F00Di32; + let h5 = 0xABcD07_i32; + let h6 = -0xABcD07_i32; +} diff --git a/tests/source/configs/hex_literal_case/hex_literal_preserve.rs b/tests/source/configs/hex_literal_case/hex_literal_preserve.rs new file mode 100644 index 00000000000..876592a4f64 --- /dev/null +++ b/tests/source/configs/hex_literal_case/hex_literal_preserve.rs @@ -0,0 +1,9 @@ +// rustfmt-hex_literal_case: Preserve +fn main() { + let h1 = 0xcAfE_5Ea7; + let h2 = 0xCaFe_F00du32; + let h3 = -0xcAfE_5Ea7; + let h4 = -0xCaFe_F00di32; + let h5 = 0xAbcd07_i32; + let h6 = -0xAbcd07_i32; +} diff --git a/tests/source/configs/hex_literal_case/hex_literal_upper.rs b/tests/source/configs/hex_literal_case/hex_literal_upper.rs new file mode 100644 index 00000000000..d3fbe367185 --- /dev/null +++ b/tests/source/configs/hex_literal_case/hex_literal_upper.rs @@ -0,0 +1,9 @@ +// rustfmt-hex_literal_case: Upper +fn main() { + let h1 = 0xCaFE_5ea7; + let h2 = 0xCAFE_F00Du32; + let h3 = -0xCaFE_5ea7; + let h4 = -0xCAFE_F00Di32; + let h5 = 0xAbcd07_i32; + let h6 = -0xAbcd07_i32; +} diff --git a/tests/source/hex_literal_lower.rs b/tests/source/hex_literal_lower.rs deleted file mode 100644 index ce307b3aa52..00000000000 --- a/tests/source/hex_literal_lower.rs +++ /dev/null @@ -1,5 +0,0 @@ -// rustfmt-hex_literal_case: Lower -fn main() { - let h1 = 0xCAFE_5EA7; - let h2 = 0xCAFE_F00Du32; -} diff --git a/tests/source/hex_literal_upper.rs b/tests/source/hex_literal_upper.rs deleted file mode 100644 index b1092ad71ba..00000000000 --- a/tests/source/hex_literal_upper.rs +++ /dev/null @@ -1,5 +0,0 @@ -// rustfmt-hex_literal_case: Upper -fn main() { - let h1 = 0xCaFE_5ea7; - let h2 = 0xCAFE_F00Du32; -} diff --git a/tests/target/configs/hex_literal_case/hex_literal_lower.rs b/tests/target/configs/hex_literal_case/hex_literal_lower.rs new file mode 100644 index 00000000000..d1d284c6df0 --- /dev/null +++ b/tests/target/configs/hex_literal_case/hex_literal_lower.rs @@ -0,0 +1,9 @@ +// rustfmt-hex_literal_case: Lower +fn main() { + let h1 = 0xcafe_5ea7; + let h2 = 0xcafe_f00du32; + let h3 = -0xcafe_5ea7; + let h4 = -0xcafe_f00di32; + let h5 = 0xabcd07_i32; + let h6 = -0xabcd07_i32; +} diff --git a/tests/target/configs/hex_literal_case/hex_literal_preserve.rs b/tests/target/configs/hex_literal_case/hex_literal_preserve.rs new file mode 100644 index 00000000000..876592a4f64 --- /dev/null +++ b/tests/target/configs/hex_literal_case/hex_literal_preserve.rs @@ -0,0 +1,9 @@ +// rustfmt-hex_literal_case: Preserve +fn main() { + let h1 = 0xcAfE_5Ea7; + let h2 = 0xCaFe_F00du32; + let h3 = -0xcAfE_5Ea7; + let h4 = -0xCaFe_F00di32; + let h5 = 0xAbcd07_i32; + let h6 = -0xAbcd07_i32; +} diff --git a/tests/target/configs/hex_literal_case/hex_literal_upper.rs b/tests/target/configs/hex_literal_case/hex_literal_upper.rs new file mode 100644 index 00000000000..4336453abae --- /dev/null +++ b/tests/target/configs/hex_literal_case/hex_literal_upper.rs @@ -0,0 +1,9 @@ +// rustfmt-hex_literal_case: Upper +fn main() { + let h1 = 0xCAFE_5EA7; + let h2 = 0xCAFE_F00Du32; + let h3 = -0xCAFE_5EA7; + let h4 = -0xCAFE_F00Di32; + let h5 = 0xABCD07_i32; + let h6 = -0xABCD07_i32; +} diff --git a/tests/target/hex_literal_lower.rs b/tests/target/hex_literal_lower.rs deleted file mode 100644 index 5c27fded167..00000000000 --- a/tests/target/hex_literal_lower.rs +++ /dev/null @@ -1,5 +0,0 @@ -// rustfmt-hex_literal_case: Lower -fn main() { - let h1 = 0xcafe_5ea7; - let h2 = 0xcafe_f00du32; -} diff --git a/tests/target/hex_literal_preserve.rs b/tests/target/hex_literal_preserve.rs deleted file mode 100644 index e8774d0bb24..00000000000 --- a/tests/target/hex_literal_preserve.rs +++ /dev/null @@ -1,5 +0,0 @@ -// rustfmt-hex_literal_case: Preserve -fn main() { - let h1 = 0xcAfE_5Ea7; - let h2 = 0xCaFe_F00du32; -} diff --git a/tests/target/hex_literal_upper.rs b/tests/target/hex_literal_upper.rs deleted file mode 100644 index 48bb93d2c1c..00000000000 --- a/tests/target/hex_literal_upper.rs +++ /dev/null @@ -1,5 +0,0 @@ -// rustfmt-hex_literal_case: Upper -fn main() { - let h1 = 0xCAFE_5EA7; - let h2 = 0xCAFE_F00Du32; -}