Skip to content

Commit 0bf52b3

Browse files
authored
Rollup merge of #54413 - memoryruins:deref-error-twice, r=estebank
Add UI test for deref recursion limit printing twice Closes #38940 Does ``NOTE`` in the test need to be changed to ``HELP`` if its in the stderr? ``help: consider adding a `#![recursion_limit="20"]` attribute to your crate`` It doesn't appear to complaining locally that the line isn't set to ``HELP`` in the test, and the guide says > HELP and SUGGESTION* > * Note: SUGGESTION must follow immediately after HELP. yet there's no concrete suggestion emitted. r? @estebank
2 parents 394d687 + 70da203 commit 0bf52b3

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/test/ui/issues/issue-38940.rs

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// issue-38940: error printed twice for deref recursion limit exceeded
2+
// Test that the recursion limit can be changed. In this case, we have
3+
// deeply nested types that will fail the `Send` check by overflow
4+
// when the recursion limit is set very low.
5+
#![allow(dead_code)]
6+
#![recursion_limit="10"]
7+
macro_rules! link {
8+
($outer:ident, $inner:ident) => {
9+
struct $outer($inner);
10+
impl $outer {
11+
fn new() -> $outer {
12+
$outer($inner::new())
13+
}
14+
}
15+
impl std::ops::Deref for $outer {
16+
type Target = $inner;
17+
fn deref(&self) -> &$inner {
18+
&self.0
19+
}
20+
}
21+
}
22+
}
23+
struct Bottom;
24+
impl Bottom {
25+
fn new() -> Bottom {
26+
Bottom
27+
}
28+
}
29+
link!(Top, A);
30+
link!(A, B);
31+
link!(B, C);
32+
link!(C, D);
33+
link!(D, E);
34+
link!(E, F);
35+
link!(F, G);
36+
link!(G, H);
37+
link!(H, I);
38+
link!(I, J);
39+
link!(J, K);
40+
link!(K, Bottom);
41+
fn main() {
42+
let t = Top::new();
43+
let x: &Bottom = &t;
44+
//~^ ERROR mismatched types
45+
//~| ERROR reached the recursion limit while auto-dereferencing I
46+
}

src/test/ui/issues/issue-38940.stderr

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0055]: reached the recursion limit while auto-dereferencing I
2+
--> $DIR/issue-38940.rs:43:22
3+
|
4+
LL | let x: &Bottom = &t;
5+
| ^^ deref recursion limit reached
6+
|
7+
= help: consider adding a `#![recursion_limit="20"]` attribute to your crate
8+
9+
error[E0308]: mismatched types
10+
--> $DIR/issue-38940.rs:43:22
11+
|
12+
LL | let x: &Bottom = &t;
13+
| ^^ expected struct `Bottom`, found struct `Top`
14+
|
15+
= note: expected type `&Bottom`
16+
found type `&Top`
17+
18+
error: aborting due to 2 previous errors
19+
20+
Some errors occurred: E0055, E0308.
21+
For more information about an error, try `rustc --explain E0055`.

0 commit comments

Comments
 (0)