Skip to content

Commit 9211bee

Browse files
committed
Use E0308 instead of E0495 for checking the error message improvement
because previous test does not cause the expected error message when `-Z borrowck=mir`.
1 parent 7b9ddbd commit 9211bee

File tree

2 files changed

+19
-47
lines changed

2 files changed

+19
-47
lines changed

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

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
trait T {
2-
type U;
3-
fn f(&self) -> Self::U;
4-
}
1+
trait T0 {}
2+
trait T1: T0 {}
53

6-
struct X<'a>(&'a mut i32);
4+
trait T2 {}
75

8-
impl<'a> T for X<'a> {
9-
type U = &'a i32;
10-
fn f(&self) -> Self::U {
11-
self.0
12-
}
13-
//~^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'a`
14-
//
15-
// Return type of `f` has lifetime `'a` but it tries to return `self.0` which
16-
// has lifetime `'_`.
17-
}
6+
impl<'a> T0 for &'a (dyn T2 + 'static) {}
7+
8+
impl T1 for &dyn T2 {}
9+
//~^ ERROR mismatched types
1810

1911
fn main() {}

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

+12-32
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,18 @@
1-
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
2-
--> $DIR/issue-65230.rs:10:28
3-
|
4-
LL | fn f(&self) -> Self::U {
5-
| ____________________________^
6-
LL | | self.0
7-
LL | | }
8-
| |_____^
9-
|
10-
note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 10:10...
11-
--> $DIR/issue-65230.rs:10:10
12-
|
13-
LL | fn f(&self) -> Self::U {
14-
| ^^^^^
15-
note: ...so that reference does not outlive borrowed content
16-
--> $DIR/issue-65230.rs:11:9
17-
|
18-
LL | self.0
19-
| ^^^^^^
20-
note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 8:6...
1+
error[E0308]: mismatched types
212
--> $DIR/issue-65230.rs:8:6
223
|
23-
LL | impl<'a> T for X<'a> {
24-
| ^^
25-
note: ...so that the types are compatible
26-
--> $DIR/issue-65230.rs:10:28
4+
LL | impl T1 for &dyn T2 {}
5+
| ^^ lifetime mismatch
6+
|
7+
= note: expected trait `<&dyn T2 as T0>`
8+
found trait `<&(dyn T2 + 'static) as T0>`
9+
note: the lifetime `'_` as defined on the impl at 8:13...
10+
--> $DIR/issue-65230.rs:8:13
2711
|
28-
LL | fn f(&self) -> Self::U {
29-
| ____________________________^
30-
LL | | self.0
31-
LL | | }
32-
| |_____^
33-
= note: expected `<X<'a> as T>`
34-
found `<X<'_> as T>`
12+
LL | impl T1 for &dyn T2 {}
13+
| ^
14+
= note: ...does not necessarily outlive the static lifetime
3515

3616
error: aborting due to previous error
3717

38-
For more information about this error, try `rustc --explain E0495`.
18+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)