Skip to content

Commit f5a74d4

Browse files
committed
Test new placeholder error messages in previously untested combinations
1 parent a79f135 commit f5a74d4

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

src/test/ui/issues/issue-57362.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Test for issue #57362, ensuring that the self ty is shown in cases of higher-ranked lifetimes
2+
// conflicts: the `expected` and `found` trait refs would otherwise be printed the same, leading
3+
// to confusing notes such as:
4+
// = note: expected type `Trait`
5+
// found type `Trait`
6+
7+
// from issue #57362
8+
trait Trait {
9+
fn f(self);
10+
}
11+
12+
impl<T> Trait for fn(&T) {
13+
fn f(self) {
14+
println!("f");
15+
}
16+
}
17+
18+
fn f() {
19+
let a: fn(_) = |_: &u8| {};
20+
a.f(); //~ ERROR not general enough
21+
}
22+
23+
// extracted from a similar issue: #57642
24+
trait X {
25+
type G;
26+
fn make_g() -> Self::G;
27+
}
28+
29+
impl<'a> X for fn(&'a ()) {
30+
type G = &'a ();
31+
32+
fn make_g() -> Self::G {
33+
&()
34+
}
35+
}
36+
37+
fn g() {
38+
let x = <fn (&())>::make_g(); //~ ERROR not general enough
39+
}
40+
41+
fn main() {}

src/test/ui/issues/issue-57362.stderr

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: implementation of `Trait` is not general enough
2+
--> $DIR/issue-57362.rs:20:7
3+
|
4+
LL | a.f(); //~ ERROR not general enough
5+
| ^
6+
|
7+
= note: `Trait` would have to be implemented for the type `fn(&u8)`
8+
= note: but `Trait` is actually implemented for the type `for<'r> fn(&'r u8)`
9+
10+
error: implementation of `X` is not general enough
11+
--> $DIR/issue-57362.rs:38:13
12+
|
13+
LL | let x = <fn (&())>::make_g(); //~ ERROR not general enough
14+
| ^^^^^^^^^^^^^^^^^^
15+
|
16+
= note: `X` would have to be implemented for the type `for<'r> fn(&'r ())`
17+
= note: but `X` is actually implemented for the type `fn(&'0 ())`, for the specific lifetime `'0`
18+
19+
error: aborting due to 2 previous errors
20+

0 commit comments

Comments
 (0)