summaryrefslogtreecommitdiffstats
path: root/tests/ui/inference/range-type-infer.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/inference/range-type-infer.rs
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/inference/range-type-infer.rs')
-rw-r--r--tests/ui/inference/range-type-infer.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/ui/inference/range-type-infer.rs b/tests/ui/inference/range-type-infer.rs
new file mode 100644
index 000000000..f07c04171
--- /dev/null
+++ b/tests/ui/inference/range-type-infer.rs
@@ -0,0 +1,22 @@
+// run-pass
+
+#![allow(unused_must_use)]
+// Make sure the type inference for the new range expression work as
+// good as the old one. Check out issue #21672, #21595 and #21649 for
+// more details.
+
+
+fn main() {
+ let xs = (0..8).map(|i| i == 1u64).collect::<Vec<_>>();
+ assert_eq!(xs[1], true);
+ let xs = (0..8).map(|i| 1u64 == i).collect::<Vec<_>>();
+ assert_eq!(xs[1], true);
+ let xs: Vec<u8> = (0..10).collect();
+ assert_eq!(xs.len(), 10);
+
+ for x in 0..10 { x % 2; }
+ for x in 0..100 { x as f32; }
+
+ let array = [true, false];
+ for i in 0..1 { array[i]; }
+}