about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCaleb Cartwright <caleb.cartwright@outlook.com>2024-07-19 18:23:16 -0500
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>2024-07-28 19:37:36 -0500
commite04e4118529461f3d97b0cf3d102925cbab69f74 (patch)
tree4a94742d95b877a2e1c2d80d21cf5e668bedd95d
parentb6c89fc657f7bcfe973d50bfcaf8a73dac3a119b (diff)
downloadrust-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.
-rw-r--r--tests/target/configs/indent_style/block_trailing_comma_call/one.rs2
-rw-r--r--tests/target/configs/indent_style/block_trailing_comma_call/two.rs2
-rw-r--r--tests/target/configs/version/mapped.rs9
-rw-r--r--tests/target/style_edition/default.rs10
-rw-r--r--tests/target/style_edition/follows_edition.rs14
-rw-r--r--tests/target/style_edition/overrides_edition_when_set.rs14
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
+) {
+}