summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorNicholas Nethercote <nnethercote@mozilla.com>2020-05-14 09:39:50 +1000
committerNicholas Nethercote <nnethercote@mozilla.com>2020-05-18 05:41:59 +1000
commit4b7c3d88c6488d552214738cfb4dc0a05549a103 (patch)
tree23c081447f15d1cc890156b97cef2b514bb0005c /src/test/codegen
parent34cce58d81f006a5406fcae918db4492e6cf2784 (diff)
downloadrust-4b7c3d88c6488d552214738cfb4dc0a05549a103.tar.gz
rust-4b7c3d88c6488d552214738cfb4dc0a05549a103.zip
Make `fold` standalone.
`fold` is currently implemented via `try_fold`, but implementing it
directly results in slightly less LLVM IR being generated, speeding up
compilation of some benchmarks.

(And likewise for `rfold`.)

The commit adds `fold` implementations to all the iterators that lack
one but do have a `try_fold` implementation. Most of these just call the
`try_fold` implementation directly.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/iter-fold-closure-no-dupes.rs14
-rw-r--r--src/test/codegen/iter-fold-closure-no-iterator.rs10
2 files changed, 0 insertions, 24 deletions
diff --git a/src/test/codegen/iter-fold-closure-no-dupes.rs b/src/test/codegen/iter-fold-closure-no-dupes.rs
deleted file mode 100644
index ec58f7068ab..00000000000
--- a/src/test/codegen/iter-fold-closure-no-dupes.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-//! 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
deleted file mode 100644
index fbeafd5f395..00000000000
--- a/src/test/codegen/iter-fold-closure-no-iterator.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//! 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}}