From f5a74d40d9ceef0d27d8d60e1b867e6cbf3f6883 Mon Sep 17 00:00:00 2001 From: Remy Rakic Date: Fri, 25 Jan 2019 19:35:35 +0100 Subject: Test new placeholder error messages in previously untested combinations --- src/test/ui/issues/issue-57362.rs | 41 +++++++++++++++++++++++++++++++++++ src/test/ui/issues/issue-57362.stderr | 20 +++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 src/test/ui/issues/issue-57362.rs create mode 100644 src/test/ui/issues/issue-57362.stderr (limited to 'src/test/ui/issues') diff --git a/src/test/ui/issues/issue-57362.rs b/src/test/ui/issues/issue-57362.rs new file mode 100755 index 00000000000..d5b506f3c2c --- /dev/null +++ b/src/test/ui/issues/issue-57362.rs @@ -0,0 +1,41 @@ +// Test for issue #57362, ensuring that the self ty is shown in cases of higher-ranked lifetimes +// conflicts: the `expected` and `found` trait refs would otherwise be printed the same, leading +// to confusing notes such as: +// = note: expected type `Trait` +// found type `Trait` + +// from issue #57362 +trait Trait { + fn f(self); +} + +impl Trait for fn(&T) { + fn f(self) { + println!("f"); + } +} + +fn f() { + let a: fn(_) = |_: &u8| {}; + a.f(); //~ ERROR not general enough +} + +// extracted from a similar issue: #57642 +trait X { + type G; + fn make_g() -> Self::G; +} + +impl<'a> X for fn(&'a ()) { + type G = &'a (); + + fn make_g() -> Self::G { + &() + } +} + +fn g() { + let x = ::make_g(); //~ ERROR not general enough +} + +fn main() {} \ No newline at end of file diff --git a/src/test/ui/issues/issue-57362.stderr b/src/test/ui/issues/issue-57362.stderr new file mode 100644 index 00000000000..d7886e5af27 --- /dev/null +++ b/src/test/ui/issues/issue-57362.stderr @@ -0,0 +1,20 @@ +error: implementation of `Trait` is not general enough + --> $DIR/issue-57362.rs:20:7 + | +LL | a.f(); //~ ERROR not general enough + | ^ + | + = note: `Trait` would have to be implemented for the type `fn(&u8)` + = note: but `Trait` is actually implemented for the type `for<'r> fn(&'r u8)` + +error: implementation of `X` is not general enough + --> $DIR/issue-57362.rs:38:13 + | +LL | let x = ::make_g(); //~ ERROR not general enough + | ^^^^^^^^^^^^^^^^^^ + | + = note: `X` would have to be implemented for the type `for<'r> fn(&'r ())` + = note: but `X` is actually implemented for the type `fn(&'0 ())`, for the specific lifetime `'0` + +error: aborting due to 2 previous errors + -- cgit 1.4.1-3-g733a5