Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for deref recursion limit printing twice
- Loading branch information
1 parent
20dc0c5
commit d341b17
Showing
2 changed files
with
72 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,51 @@ | ||
// issue-38940: error printed twice for deref recursion limit exceeded | ||
// Test that the recursion limit can be changed. In this case, we have | ||
// deeply nested types that will fail the `Send` check by overflow | ||
// when the recursion limit is set very low. | ||
#![allow(dead_code)] | ||
#![recursion_limit="10"] | ||
macro_rules! link { | ||
($outer:ident, $inner:ident) => { | ||
struct $outer($inner); | ||
impl $outer { | ||
fn new() -> $outer { | ||
$outer($inner::new()) | ||
} | ||
} | ||
impl std::ops::Deref for $outer { | ||
type Target = $inner; | ||
fn deref(&self) -> &$inner { | ||
&self.0 | ||
} | ||
} | ||
} | ||
} | ||
struct Bottom; | ||
impl Bottom { | ||
fn new() -> Bottom { | ||
Bottom | ||
} | ||
} | ||
link!(Top, A); | ||
link!(A, B); | ||
link!(B, C); | ||
link!(C, D); | ||
link!(D, E); | ||
link!(E, F); | ||
link!(F, G); | ||
link!(G, H); | ||
link!(H, I); | ||
link!(I, J); | ||
link!(J, K); | ||
link!(K, Bottom); | ||
fn main() { | ||
let t = Top::new(); | ||
let x: &Bottom = &t; | ||
//~^ ERROR mismatched types | ||
//~| NOTE expected type `&Bottom` | ||
//~| NOTE found type `&Top` | ||
//~| NOTE expected struct `Bottom`, found struct `Top` | ||
//~| ERROR reached the recursion limit while auto-dereferencing I | ||
//~| NOTE deref recursion limit reached | ||
//~| NOTE consider adding a `#![recursion_limit="20"]` attribute to your crate | ||
} |
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,21 @@ | ||
error[E0055]: reached the recursion limit while auto-dereferencing I | ||
--> $DIR/issue-38940.rs:43:22 | ||
| | ||
LL | let x: &Bottom = &t; | ||
| ^^ deref recursion limit reached | ||
| | ||
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/issue-38940.rs:43:22 | ||
| | ||
LL | let x: &Bottom = &t; | ||
| ^^ expected struct `Bottom`, found struct `Top` | ||
| | ||
= note: expected type `&Bottom` | ||
found type `&Top` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors occurred: E0055, E0308. | ||
For more information about an error, try `rustc --explain E0055`. |