Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add codegen tests for the genericity of fold closures
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}} |