summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/source/configs/chain_width
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/tools/rustfmt/tests/source/configs/chain_width
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/rustfmt/tests/source/configs/chain_width')
-rw-r--r--src/tools/rustfmt/tests/source/configs/chain_width/always.rs23
-rw-r--r--src/tools/rustfmt/tests/source/configs/chain_width/small.rs23
-rw-r--r--src/tools/rustfmt/tests/source/configs/chain_width/tiny.rs21
3 files changed, 67 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/source/configs/chain_width/always.rs b/src/tools/rustfmt/tests/source/configs/chain_width/always.rs
new file mode 100644
index 000000000..2d16d66ae
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/configs/chain_width/always.rs
@@ -0,0 +1,23 @@
+// rustfmt-chain_width: 1
+// setting an unachievable chain_width to always get chains
+// on separate lines
+
+struct Fluent {}
+
+impl Fluent {
+ fn blorp(&self) -> &Self {
+ self
+ }
+}
+
+fn main() {
+ let test = Fluent {};
+
+ // should be left alone
+ test.blorp();
+
+ // should be wrapped
+ test.blorp().blorp();
+ test.blorp().blorp().blorp();
+ test.blorp().blorp().blorp().blorp();
+}
diff --git a/src/tools/rustfmt/tests/source/configs/chain_width/small.rs b/src/tools/rustfmt/tests/source/configs/chain_width/small.rs
new file mode 100644
index 000000000..26f935453
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/configs/chain_width/small.rs
@@ -0,0 +1,23 @@
+// rustfmt-chain_width: 40
+
+struct Fluent {}
+
+impl Fluent {
+ fn blorp(&self) -> &Self {
+ self
+ }
+}
+
+fn main() {
+ let test = Fluent {};
+
+ // should not be wrapped
+ test.blorp();
+ test.blorp().blorp();
+ test.blorp().blorp().blorp();
+ test.blorp().blorp().blorp().blorp();
+
+ // should be wrapped
+ test.blorp().blorp().blorp().blorp().blorp();
+ test.blorp().blorp().blorp().blorp().blorp().blorp();
+}
diff --git a/src/tools/rustfmt/tests/source/configs/chain_width/tiny.rs b/src/tools/rustfmt/tests/source/configs/chain_width/tiny.rs
new file mode 100644
index 000000000..fffc81dd5
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/configs/chain_width/tiny.rs
@@ -0,0 +1,21 @@
+// rustfmt-chain_width: 20
+
+struct Fluent {}
+
+impl Fluent {
+ fn blorp(&self) -> &Self {
+ self
+ }
+}
+
+fn main() {
+ let test = Fluent {};
+
+ // should not be wrapped
+ test.blorp();
+ test.blorp().blorp();
+
+ // should be wrapped
+ test.blorp().blorp().blorp();
+ test.blorp().blorp().blorp().blorp();
+}