Skip to content

Commit 8277932

Browse files
authored
Rollup merge of #165729 - hardikxk:tests/infinite-comp, r=adwinwhite
tests: Add regression test for infinite recursive dereference Add a test for a case that results in a recursive loop that runs until it runs out of memory or gets killed. closes #67064
2 parents 0400592 + a7280a9 commit 8277932

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: -Zwrite-long-types-to-disk=yes
2+
3+
// Regression test for: https://github.com/rust-lang/rust/issues/67064
4+
// This used to take a long time to compile because dereferencing led to
5+
// recursive expansion of the type of the struct.
6+
7+
struct S<T>(T);
8+
9+
impl<T> std::ops::Deref for S<T> {
10+
type Target = S<(T, T)>;
11+
fn deref(&self) -> &Self::Target {
12+
self.thing()
13+
//~^ ERROR: reached the recursion limit while auto-dereferencing
14+
//~| ERROR: no method named `thing` found for reference
15+
}
16+
}
17+
18+
fn main() {}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0055]: reached the recursion limit while auto-dereferencing `S<(((((((((((((_, _), _), _), _), _), _), _), _), _), _), _), _), _)>`
2+
--> $DIR/infinite-dereference-recursion-issue-67064.rs:12:14
3+
|
4+
LL | self.thing()
5+
| ^^^^^ deref recursion limit reached
6+
|
7+
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`infinite_dereference_recursion_issue_67064`)
8+
= note: the full name for the type has been written to '$TEST_BUILD_DIR/infinite-dereference-recursion-issue-67064.long-type-$LONG_TYPE_HASH.txt'
9+
= note: consider using `--verbose` to print the full type name to the console
10+
11+
error[E0599]: no method named `thing` found for reference `&S<T>` in the current scope
12+
--> $DIR/infinite-dereference-recursion-issue-67064.rs:12:14
13+
|
14+
LL | self.thing()
15+
| ^^^^^ method not found in `&S<T>`
16+
17+
error: aborting due to 2 previous errors
18+
19+
Some errors have detailed explanations: E0055, E0599.
20+
For more information about an error, try `rustc --explain E0055`.

0 commit comments

Comments
 (0)