Skip to content

Commit 2e58d05

Browse files
committed
Add test from rust-lang#124901.
Issue rust-lang#124901 was an OOM caused by a query cycle. It was fixed by a complex change in PR rust-lang#138672, but that PR did not add the test case. Let's add it now, because it's the only known reproducer of the OOM.
1 parent 4c2e447 commit 2e58d05

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//~ ERROR: cycle detected when looking up span for `Default`
2+
trait Default {
3+
type Id;
4+
5+
fn intu(&self) -> &Self::Id;
6+
}
7+
8+
impl<T: Default<Id = U>, U: Copy> Default for U {
9+
default type Id = T;
10+
fn intu(&self) -> &Self::Id {
11+
self
12+
}
13+
}
14+
15+
fn specialization<T>(t: T) -> U {
16+
*t.intu()
17+
}
18+
19+
use std::num::NonZero;
20+
21+
fn main() {
22+
let assert_eq = NonZero::<u8, Option<NonZero<u8>>>(0);
23+
assert_eq!(specialization, None);
24+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0391]: cycle detected when looking up span for `Default`
2+
|
3+
= note: ...which immediately requires looking up span for `Default` again
4+
= note: cycle used when perform lints prior to AST lowering
5+
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0391`.

0 commit comments

Comments
 (0)