diff options
| author | Remy Rakic <remy.rakic@gmail.com> | 2019-01-25 19:35:35 +0100 |
|---|---|---|
| committer | Rémy Rakic <remy.rakic@gmail.com> | 2019-01-27 10:52:43 +0100 |
| commit | f5a74d40d9ceef0d27d8d60e1b867e6cbf3f6883 (patch) | |
| tree | 3a06cd23ba3f0d34682df8b00dbcda400b21ae26 | |
| parent | a79f135be616588e83d18b4694d97470e986497a (diff) | |
| download | rust-f5a74d40d9ceef0d27d8d60e1b867e6cbf3f6883.tar.gz rust-f5a74d40d9ceef0d27d8d60e1b867e6cbf3f6883.zip | |
Test new placeholder error messages in previously untested combinations
| -rwxr-xr-x | src/test/ui/issues/issue-57362.rs | 41 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-57362.stderr | 20 |
2 files changed, 61 insertions, 0 deletions
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<T> 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 = <fn (&())>::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 = <fn (&())>::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 + |
