]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/iter-fold-closure-no-dupes.rs
Suggest defining type parameter when appropriate
[rust.git] / src / test / codegen / iter-fold-closure-no-dupes.rs
1 //! Check that fold closures aren't duplicated for each iterator type.
2 // compile-flags: -C opt-level=0
3
4 fn main() {
5     (0i32..10).by_ref().count();
6     (0i32..=10).by_ref().count();
7 }
8
9 // `count` calls `fold`, which calls `try_fold` -- find the `fold` closure:
10 // CHECK: {{^define.*Iterator::fold::.*closure}}
11 //
12 // Only one closure is needed for both `count` calls, even from different
13 // monomorphized iterator types, as it's only generic over the item type.
14 // CHECK-NOT: {{^define.*Iterator::fold::.*closure}}