diff options
| author | Caleb Cartwright <caleb.cartwright@outlook.com> | 2024-07-19 18:23:16 -0500 |
|---|---|---|
| committer | Caleb Cartwright <calebcartwright@users.noreply.github.com> | 2024-07-28 19:37:36 -0500 |
| commit | e04e4118529461f3d97b0cf3d102925cbab69f74 (patch) | |
| tree | 4a94742d95b877a2e1c2d80d21cf5e668bedd95d | |
| parent | b6c89fc657f7bcfe973d50bfcaf8a73dac3a119b (diff) | |
| download | rust-e04e4118529461f3d97b0cf3d102925cbab69f74.tar.gz rust-e04e4118529461f3d97b0cf3d102925cbab69f74.zip | |
tests: validate style_edition derivation
Adds a few tests that validate the various scenarios of precendence, overrides, and defaults to ensure the correct 'style_edition' value is selected even when other options like 'edition' and/or 'version' are included.
6 files changed, 49 insertions, 2 deletions
diff --git a/tests/target/configs/indent_style/block_trailing_comma_call/one.rs b/tests/target/configs/indent_style/block_trailing_comma_call/one.rs index 6b9489bef55..204dce6d655 100644 --- a/tests/target/configs/indent_style/block_trailing_comma_call/one.rs +++ b/tests/target/configs/indent_style/block_trailing_comma_call/one.rs @@ -1,4 +1,4 @@ -// rustfmt-version: One +// rustfmt-style_edition: 2015 // rustfmt-error_on_line_overflow: false // rustfmt-indent_style: Block diff --git a/tests/target/configs/indent_style/block_trailing_comma_call/two.rs b/tests/target/configs/indent_style/block_trailing_comma_call/two.rs index 4f4292e5f48..887e8328ccc 100644 --- a/tests/target/configs/indent_style/block_trailing_comma_call/two.rs +++ b/tests/target/configs/indent_style/block_trailing_comma_call/two.rs @@ -1,4 +1,4 @@ -// rustfmt-version: Two +// rustfmt-style_edition: 2024 // rustfmt-error_on_line_overflow: false // rustfmt-indent_style: Block diff --git a/tests/target/configs/version/mapped.rs b/tests/target/configs/version/mapped.rs new file mode 100644 index 00000000000..296dc559a93 --- /dev/null +++ b/tests/target/configs/version/mapped.rs @@ -0,0 +1,9 @@ +// rustfmt-version: Two +fn main() { + let [ + aaaaaaaaaaaaaaaaaaaaaaaaaa, + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, + cccccccccccccccccccccccccc, + ddddddddddddddddddddddddd, + ] = panic!(); +} diff --git a/tests/target/style_edition/default.rs b/tests/target/style_edition/default.rs new file mode 100644 index 00000000000..17442df6c49 --- /dev/null +++ b/tests/target/style_edition/default.rs @@ -0,0 +1,10 @@ +fn build_sorted_static_get_entry_names( + mut entries: Vec<(u8, &'static str)>, +) -> (impl Fn( + AlphabeticalTraversal, + Box<dyn dirents_sink::Sink<AlphabeticalTraversal>>, +) -> BoxFuture<'static, Result<Box<dyn dirents_sink::Sealed>, Status>> + + Send + + Sync + + 'static) { +} diff --git a/tests/target/style_edition/follows_edition.rs b/tests/target/style_edition/follows_edition.rs new file mode 100644 index 00000000000..c36a993d842 --- /dev/null +++ b/tests/target/style_edition/follows_edition.rs @@ -0,0 +1,14 @@ +// rustfmt-edition: 2024 + +fn build_sorted_static_get_entry_names( + mut entries: Vec<(u8, &'static str)>, +) -> ( + impl Fn( + AlphabeticalTraversal, + Box<dyn dirents_sink::Sink<AlphabeticalTraversal>>, + ) -> BoxFuture<'static, Result<Box<dyn dirents_sink::Sealed>, Status>> + + Send + + Sync + + 'static +) { +} diff --git a/tests/target/style_edition/overrides_edition_when_set.rs b/tests/target/style_edition/overrides_edition_when_set.rs new file mode 100644 index 00000000000..6d0eaac8970 --- /dev/null +++ b/tests/target/style_edition/overrides_edition_when_set.rs @@ -0,0 +1,14 @@ +// rustfmt-edition: 2018 +// rustfmt-style_edition: 2024 +fn build_sorted_static_get_entry_names( + mut entries: Vec<(u8, &'static str)>, +) -> ( + impl Fn( + AlphabeticalTraversal, + Box<dyn dirents_sink::Sink<AlphabeticalTraversal>>, + ) -> BoxFuture<'static, Result<Box<dyn dirents_sink::Sealed>, Status>> + + Send + + Sync + + 'static +) { +} |
