]> git.lizzy.rs Git - rust.git/commitdiff
Use E0308 instead of E0495 for checking the error message improvement
authorrhysd <lin90162@yahoo.co.jp>
Sat, 9 Oct 2021 15:23:35 +0000 (00:23 +0900)
committerrhysd <lin90162@yahoo.co.jp>
Sat, 9 Oct 2021 15:23:35 +0000 (00:23 +0900)
because previous test does not cause the expected error message when
`-Z borrowck=mir`.

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

index 10d9e8109969111b28cff683144c70549995bdf6..54141d2214cd9424041189865bf34d264136ff04 100644 (file)
@@ -1,19 +1,11 @@
-trait T {
-    type U;
-    fn f(&self) -> Self::U;
-}
+trait T0 {}
+trait T1: T0 {}
 
-struct X<'a>(&'a mut i32);
+trait T2 {}
 
-impl<'a> T for X<'a> {
-    type U = &'a i32;
-    fn f(&self) -> Self::U {
-        self.0
-    }
-    //~^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter `'a`
-    //
-    // Return type of `f` has lifetime `'a` but it tries to return `self.0` which
-    // has lifetime `'_`.
-}
+impl<'a> T0 for &'a (dyn T2 + 'static) {}
+
+impl T1 for &dyn T2 {}
+//~^ ERROR mismatched types
 
 fn main() {}
index 21e3f6b1ebb9c074aad77bee8c32d6184c016782..d75428f3d531dd7d1b5acae6fd2e604009c61453 100644 (file)
@@ -1,38 +1,18 @@
-error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
-  --> $DIR/issue-65230.rs:10:28
-   |
-LL |       fn f(&self) -> Self::U {
-   |  ____________________________^
-LL | |         self.0
-LL | |     }
-   | |_____^
-   |
-note: first, the lifetime cannot outlive the anonymous lifetime defined on the method body at 10:10...
-  --> $DIR/issue-65230.rs:10:10
-   |
-LL |     fn f(&self) -> Self::U {
-   |          ^^^^^
-note: ...so that reference does not outlive borrowed content
-  --> $DIR/issue-65230.rs:11:9
-   |
-LL |         self.0
-   |         ^^^^^^
-note: but, the lifetime must be valid for the lifetime `'a` as defined on the impl at 8:6...
+error[E0308]: mismatched types
   --> $DIR/issue-65230.rs:8:6
    |
-LL | impl<'a> T for X<'a> {
-   |      ^^
-note: ...so that the types are compatible
-  --> $DIR/issue-65230.rs:10:28
+LL | impl T1 for &dyn T2 {}
+   |      ^^ lifetime mismatch
+   |
+   = note: expected trait `<&dyn T2 as T0>`
+              found trait `<&(dyn T2 + 'static) as T0>`
+note: the lifetime `'_` as defined on the impl at 8:13...
+  --> $DIR/issue-65230.rs:8:13
    |
-LL |       fn f(&self) -> Self::U {
-   |  ____________________________^
-LL | |         self.0
-LL | |     }
-   | |_____^
-   = note: expected `<X<'a> as T>`
-              found `<X<'_> as T>`
+LL | impl T1 for &dyn T2 {}
+   |             ^
+   = note: ...does not necessarily outlive the static lifetime
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0495`.
+For more information about this error, try `rustc --explain E0308`.