fix(middle): emit error rather than delay bug when reaching limit
This commit is contained in:
parent
a93bcdc307
commit
d8a4e7cf51
6 changed files with 26 additions and 81 deletions
|
|
@ -1,52 +0,0 @@
|
|||
// 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.
|
||||
// compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![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
|
||||
//~| ERROR reached the recursion limit while auto-dereferencing `J`
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0055]: reached the recursion limit while auto-dereferencing `J`
|
||||
--> $DIR/issue-38940.rs:49:22
|
||||
|
|
||||
LL | let x: &Bottom = &t;
|
||||
| ^^ deref recursion limit reached
|
||||
|
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`issue_38940`)
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-38940.rs:49:22
|
||||
|
|
||||
LL | let x: &Bottom = &t;
|
||||
| ------- ^^ expected `&Bottom`, found `&Top`
|
||||
| |
|
||||
| expected due to this
|
||||
|
|
||||
= note: expected reference `&Bottom`
|
||||
found reference `&Top`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0055, E0308.
|
||||
For more information about an error, try `rustc --explain E0055`.
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
error: reached the recursion limit finding the struct tail for `Bottom`
|
||||
|
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]`
|
||||
|
||||
error[E0055]: reached the recursion limit while auto-dereferencing `J`
|
||||
--> $DIR/recursion_limit_deref.rs:51:22
|
||||
|
|
||||
|
|
@ -17,7 +21,7 @@ LL | let x: &Bottom = &t;
|
|||
= note: expected reference `&Bottom`
|
||||
found reference `&Top`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0055, E0308.
|
||||
For more information about an error, try `rustc --explain E0055`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue