about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-08-08 19:37:35 +0000
committerMichael Goulet <michael@errs.io>2023-08-28 01:05:34 +0000
commit32a9565223c05e6f7e60d783ad25e1864cd51d70 (patch)
treee5ee7e4e58241194c0b86958733a5900f8f65a34
parent13d3e57237eefd92a518d99367b6f8e04110e847 (diff)
downloadrust-32a9565223c05e6f7e60d783ad25e1864cd51d70.tar.gz
rust-32a9565223c05e6f7e60d783ad25e1864cd51d70.zip
Bless tests
-rw-r--r--tests/ui/impl-trait/in-trait/object-safety.rs1
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr (renamed from tests/ui/impl-trait/in-trait/signature-mismatch.stderr)2
-rw-r--r--tests/ui/impl-trait/in-trait/signature-mismatch.rs38
3 files changed, 32 insertions, 9 deletions
diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs
index dd35b9a2d8a..6e02934363d 100644
--- a/tests/ui/impl-trait/in-trait/object-safety.rs
+++ b/tests/ui/impl-trait/in-trait/object-safety.rs
@@ -19,4 +19,5 @@ fn main() {
     //~| ERROR the trait `Foo` cannot be made into an object
     let s = i.baz();
     //~^ ERROR the trait `Foo` cannot be made into an object
+    //~| ERROR the trait bound `dyn Foo: Foo`
 }
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr
index 05b5d3f1148..186580f5756 100644
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.stderr
+++ b/tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr
@@ -1,5 +1,5 @@
 error[E0623]: lifetime mismatch
-  --> $DIR/signature-mismatch.rs:56:10
+  --> $DIR/signature-mismatch.rs:77:10
    |
 LL |         &'a self,
    |         -------- this parameter and the return type are declared with different lifetimes...
diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.rs b/tests/ui/impl-trait/in-trait/signature-mismatch.rs
index 1d63a6f3ce2..c84a3b8f46b 100644
--- a/tests/ui/impl-trait/in-trait/signature-mismatch.rs
+++ b/tests/ui/impl-trait/in-trait/signature-mismatch.rs
@@ -1,4 +1,6 @@
 // edition:2021
+// revisions: success failure
+//[success] check-pass
 
 #![feature(return_position_impl_trait_in_trait)]
 #![allow(incomplete_features)]
@@ -11,16 +13,25 @@ impl<T> Captures<'_> for T {}
 trait Captures2<'a, 'b> {}
 impl<T> Captures2<'_, '_> for T {}
 
-pub trait AsyncTrait {
+trait AsyncTrait {
+    #[cfg(success)]
     fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
+
+    #[cfg(success)]
     fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
+
+    #[cfg(success)]
     fn async_fn_multiple<'a>(&'a self, buff: &[u8])
-        -> impl Future<Output = Vec<u8>> + Captures<'a>;
+    -> impl Future<Output = Vec<u8>> + Captures<'a>;
+
+    #[cfg(failure)]
     fn async_fn_reduce_outlive<'a, T>(
         &'a self,
         buff: &[u8],
         t: T,
     ) -> impl Future<Output = Vec<u8>> + 'a;
+
+    #[cfg(success)]
     fn async_fn_reduce<'a, T>(
         &'a self,
         buff: &[u8],
@@ -31,38 +42,49 @@ pub trait AsyncTrait {
 pub struct Struct;
 
 impl AsyncTrait for Struct {
+    // Does not capture more lifetimes that trait def'n, since trait def'n
+    // implicitly captures all in-scope lifetimes.
+    #[cfg(success)]
     fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
-        //~^ ERROR return type captures more lifetimes than trait definition
         async move { buff.to_vec() }
     }
 
+    // Does not capture more lifetimes that trait def'n, since trait def'n
+    // implicitly captures all in-scope lifetimes.
+    #[cfg(success)]
     fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
-        //~^ ERROR return type captures more lifetimes than trait definition
         async move { buff.to_vec() }
     }
 
+    // Does not capture more lifetimes that trait def'n, since trait def'n
+    // implicitly captures all in-scope lifetimes.
+    #[cfg(success)]
     fn async_fn_multiple<'a, 'b>(
         &'a self,
         buff: &'b [u8],
     ) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
-        //~^ ERROR return type captures more lifetimes than trait definition
         async move { buff.to_vec() }
     }
 
+    // This error message is awkward, but `impl Future<Output = Vec<u8>>`
+    // cannot outlive `'a` (from the trait signature) because it captures
+    // both `T` and `'b`.
+    #[cfg(failure)]
     fn async_fn_reduce_outlive<'a, 'b, T>(
         &'a self,
         buff: &'b [u8],
         t: T,
     ) -> impl Future<Output = Vec<u8>> {
-        //~^ ERROR the parameter type `T` may not live long enough
+        //[failure]~^ ERROR lifetime mismatch
         async move {
             let _t = t;
             vec![]
         }
     }
 
-    // OK: We remove the `Captures<'a>`, providing a guarantee that we don't capture `'a`,
-    // but we still fulfill the `Captures<'a>` trait bound.
+    // Does not capture fewer lifetimes that trait def'n (not that it matters),
+    // since impl also captures all in-scope lifetimes.
+    #[cfg(success)]
     fn async_fn_reduce<'a, 'b, T>(&'a self, buff: &'b [u8], t: T) -> impl Future<Output = Vec<u8>> {
         async move {
             let _t = t;