From d341b177ae47305d2204efe6e16654e4f45892c3 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Thu, 20 Sep 2018 21:14:05 -0400 Subject: [PATCH 1/2] Add test for deref recursion limit printing twice --- src/test/ui/issues/issue-38940.rs | 51 +++++++++++++++++++++++++++ src/test/ui/issues/issue-38940.stderr | 21 +++++++++++ 2 files changed, 72 insertions(+) create mode 100644 src/test/ui/issues/issue-38940.rs create mode 100644 src/test/ui/issues/issue-38940.stderr diff --git a/src/test/ui/issues/issue-38940.rs b/src/test/ui/issues/issue-38940.rs new file mode 100644 index 0000000000000..22d7d1cd916f6 --- /dev/null +++ b/src/test/ui/issues/issue-38940.rs @@ -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 +} diff --git a/src/test/ui/issues/issue-38940.stderr b/src/test/ui/issues/issue-38940.stderr new file mode 100644 index 0000000000000..2d3cfda9a5f72 --- /dev/null +++ b/src/test/ui/issues/issue-38940.stderr @@ -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`. From 70da203259360b12d871c043d9eab327034785d6 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Thu, 20 Sep 2018 22:07:57 -0400 Subject: [PATCH 2/2] Remove incidental notes --- src/test/ui/issues/issue-38940.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/test/ui/issues/issue-38940.rs b/src/test/ui/issues/issue-38940.rs index 22d7d1cd916f6..7f9b141e02e3c 100644 --- a/src/test/ui/issues/issue-38940.rs +++ b/src/test/ui/issues/issue-38940.rs @@ -42,10 +42,5 @@ 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 }