From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../source/configs/spaces_around_ranges/false.rs | 34 ++++++++++++++++++++++ .../source/configs/spaces_around_ranges/true.rs | 34 ++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 src/tools/rustfmt/tests/source/configs/spaces_around_ranges/false.rs create mode 100644 src/tools/rustfmt/tests/source/configs/spaces_around_ranges/true.rs (limited to 'src/tools/rustfmt/tests/source/configs/spaces_around_ranges') diff --git a/src/tools/rustfmt/tests/source/configs/spaces_around_ranges/false.rs b/src/tools/rustfmt/tests/source/configs/spaces_around_ranges/false.rs new file mode 100644 index 000000000..1878c68a5 --- /dev/null +++ b/src/tools/rustfmt/tests/source/configs/spaces_around_ranges/false.rs @@ -0,0 +1,34 @@ +// rustfmt-spaces_around_ranges: false +// Spaces around ranges + +fn main() { + let lorem = 0 .. 10; + let ipsum = 0 ..= 10; + + match lorem { + 1 .. 5 => foo(), + _ => bar, + } + + match lorem { + 1 ..= 5 => foo(), + _ => bar, + } + + match lorem { + 1 ... 5 => foo(), + _ => bar, + } +} + +fn half_open() { + match [5 .. 4, 99 .. 105, 43 .. 44] { + [_, 99 .., _] => {} + [_, .. 105, _] => {} + _ => {} + }; + + if let ..= 5 = 0 {} + if let .. 5 = 0 {} + if let 5 .. = 0 {} +} diff --git a/src/tools/rustfmt/tests/source/configs/spaces_around_ranges/true.rs b/src/tools/rustfmt/tests/source/configs/spaces_around_ranges/true.rs new file mode 100644 index 000000000..0eadfb285 --- /dev/null +++ b/src/tools/rustfmt/tests/source/configs/spaces_around_ranges/true.rs @@ -0,0 +1,34 @@ +// rustfmt-spaces_around_ranges: true +// Spaces around ranges + +fn main() { + let lorem = 0..10; + let ipsum = 0..=10; + + match lorem { + 1..5 => foo(), + _ => bar, + } + + match lorem { + 1..=5 => foo(), + _ => bar, + } + + match lorem { + 1...5 => foo(), + _ => bar, + } +} + +fn half_open() { + match [5..4, 99..105, 43..44] { + [_, 99.., _] => {} + [_, ..105, _] => {} + _ => {} + }; + + if let ..=5 = 0 {} + if let ..5 = 0 {} + if let 5.. = 0 {} +} -- cgit v1.2.3