respect the tcx's recursion limit when peeling
This commit is contained in:
parent
923d95cc9f
commit
977c9ab7a2
4 changed files with 68 additions and 11 deletions
23
tests/ui/pattern/deref-patterns/recursion-limit.rs
Normal file
23
tests/ui/pattern/deref-patterns/recursion-limit.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
//! Test that implicit deref patterns respect the recursion limit
|
||||
#![feature(deref_patterns)]
|
||||
#![allow(incomplete_features)]
|
||||
#![recursion_limit = "8"]
|
||||
|
||||
use std::ops::Deref;
|
||||
|
||||
struct Cyclic;
|
||||
impl Deref for Cyclic {
|
||||
type Target = Cyclic;
|
||||
fn deref(&self) -> &Cyclic {
|
||||
&Cyclic
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match &Box::new(Cyclic) {
|
||||
() => {}
|
||||
//~^ ERROR: reached the recursion limit while auto-dereferencing `Cyclic`
|
||||
//~| ERROR: the trait bound `Cyclic: DerefPure` is not satisfied
|
||||
_ => {}
|
||||
}
|
||||
}
|
18
tests/ui/pattern/deref-patterns/recursion-limit.stderr
Normal file
18
tests/ui/pattern/deref-patterns/recursion-limit.stderr
Normal file
|
@ -0,0 +1,18 @@
|
|||
error[E0055]: reached the recursion limit while auto-dereferencing `Cyclic`
|
||||
--> $DIR/recursion-limit.rs:18:9
|
||||
|
|
||||
LL | () => {}
|
||||
| ^^ deref recursion limit reached
|
||||
|
|
||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "16"]` attribute to your crate (`recursion_limit`)
|
||||
|
||||
error[E0277]: the trait bound `Cyclic: DerefPure` is not satisfied
|
||||
--> $DIR/recursion-limit.rs:18:9
|
||||
|
|
||||
LL | () => {}
|
||||
| ^^ the trait `DerefPure` is not implemented for `Cyclic`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0055, E0277.
|
||||
For more information about an error, try `rustc --explain E0055`.
|
Loading…
Add table
Add a link
Reference in a new issue