about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorBaoshan <pangbw@gmail.com>2019-08-29 09:29:23 -0700
committerGitHub <noreply@github.com>2019-08-29 09:29:23 -0700
commit043c19c69c0beac3696cb82d44476ba4298a6b07 (patch)
tree1813e5dd1e4efd5806f401968b4ed34b8c9c76ac /src/test/codegen
parentcae6d66d9989857e321e0963142b08b1517dc723 (diff)
parent76f17219c71973fd4a58f2f8020eec4d8f5dcd11 (diff)
downloadrust-043c19c69c0beac3696cb82d44476ba4298a6b07.tar.gz
rust-043c19c69c0beac3696cb82d44476ba4298a6b07.zip
Merge branch 'master' into bpang-runtest
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/issue-45222.rs3
-rw-r--r--src/test/codegen/iter-fold-closure-no-dupes.rs14
-rw-r--r--src/test/codegen/iter-fold-closure-no-iterator.rs10
3 files changed, 24 insertions, 3 deletions
diff --git a/src/test/codegen/issue-45222.rs b/src/test/codegen/issue-45222.rs
index 7f99ca724cf..7aadc8a0954 100644
--- a/src/test/codegen/issue-45222.rs
+++ b/src/test/codegen/issue-45222.rs
@@ -5,7 +5,6 @@
 
 // verify that LLVM recognizes a loop involving 0..=n and will const-fold it.
 
-//------------------------------------------------------------------------------
 // Example from original issue #45222
 
 fn foo2(n: u64) -> u64 {
@@ -25,7 +24,6 @@ pub fn check_foo2() -> u64 {
     foo2(100000)
 }
 
-//------------------------------------------------------------------------------
 // Simplified example of #45222
 
 fn triangle_inc(n: u64) -> u64 {
@@ -43,7 +41,6 @@ pub fn check_triangle_inc() -> u64 {
     triangle_inc(100000)
 }
 
-//------------------------------------------------------------------------------
 // Demo in #48012
 
 fn foo3r(n: u64) -> u64 {
diff --git a/src/test/codegen/iter-fold-closure-no-dupes.rs b/src/test/codegen/iter-fold-closure-no-dupes.rs
new file mode 100644
index 00000000000..ec58f7068ab
--- /dev/null
+++ b/src/test/codegen/iter-fold-closure-no-dupes.rs
@@ -0,0 +1,14 @@
+//! Check that fold closures aren't duplicated for each iterator type.
+// compile-flags: -C opt-level=0
+
+fn main() {
+    (0i32..10).by_ref().count();
+    (0i32..=10).by_ref().count();
+}
+
+// `count` calls `fold`, which calls `try_fold` -- find the `fold` closure:
+// CHECK: {{^define.*Iterator::fold::.*closure}}
+//
+// Only one closure is needed for both `count` calls, even from different
+// monomorphized iterator types, as it's only generic over the item type.
+// CHECK-NOT: {{^define.*Iterator::fold::.*closure}}
diff --git a/src/test/codegen/iter-fold-closure-no-iterator.rs b/src/test/codegen/iter-fold-closure-no-iterator.rs
new file mode 100644
index 00000000000..fbeafd5f395
--- /dev/null
+++ b/src/test/codegen/iter-fold-closure-no-iterator.rs
@@ -0,0 +1,10 @@
+//! Check that fold closures aren't generic in the iterator type.
+// compile-flags: -C opt-level=0
+
+fn main() {
+    (0i32..10).by_ref().count();
+}
+
+// `count` calls `fold`, which calls `try_fold` -- that `fold` closure should
+// not be generic in the iterator type, only in the item type.
+// CHECK-NOT: {{^define.*Iterator::fold::.*closure.*Range}}