Skip to content

Commit 0d38030

Browse files
Merge pull request #566 from eddyb/wf-projection-stress-65510
Add wf-projection-stress-65510 benchmark.
2 parents bb53d92 + db505be commit 0d38030

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

collector/benchmarks/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,6 @@ programs.
9090
behavior](https://github.com/rust-lang/rust/pull/32062) in the past.
9191
- **unused-warnings**: Contains many unused imports, which caused [quadratic
9292
behavior](https://github.com/rust-lang/rust/issues/43572) in the past.
93+
- **wf-projection-stress-65510**: A stress test which showcases [quadratic
94+
behavior](https://github.com/rust-lang/rust/issues/65510) (in the number of
95+
associated type bounds).

collector/benchmarks/wf-projection-stress-65510/Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[package]
2+
name = "wf-projection-stress-65510"
3+
version = "0.1.0"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
macro_rules! stress {
2+
(type $name:ident: $($i:expr,)*) => {
3+
type $name: $(From<[(); $i]> + Into<[(); $i]> +)*;
4+
};
5+
(fn $($underscore:tt)*) => {
6+
const _: () = {
7+
$({fn _f<T: Trait>() {
8+
#[derive(Copy, Clone)]
9+
struct Foo<X>(X);
10+
let $underscore = Foo(T::X::default()).clone();
11+
}})*
12+
};
13+
};
14+
}
15+
16+
trait Trait {
17+
type X: Copy + Default;
18+
19+
// The bounds would normally be on many separate
20+
// associated types, but that makes no difference.
21+
stress!(type _Unused:
22+
00, 01, 02, 03, 04, 05, 06, 07, 08, 09,
23+
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
24+
25+
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
26+
30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
27+
28+
40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
29+
50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
30+
31+
60, 61, 62, 63, 64, 65, 66, 67, 68, 69,
32+
70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
33+
);
34+
}
35+
36+
stress!(fn _ _ _ _ _ _ _ _ _ _);

0 commit comments

Comments
 (0)