Skip to content

Commit 32a9565

Browse files
Bless tests
1 parent 13d3e57 commit 32a9565

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

tests/ui/impl-trait/in-trait/object-safety.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ fn main() {
1919
//~| ERROR the trait `Foo` cannot be made into an object
2020
let s = i.baz();
2121
//~^ ERROR the trait `Foo` cannot be made into an object
22+
//~| ERROR the trait bound `dyn Foo: Foo`
2223
}

tests/ui/impl-trait/in-trait/signature-mismatch.stderr renamed to tests/ui/impl-trait/in-trait/signature-mismatch.failure.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0623]: lifetime mismatch
2-
--> $DIR/signature-mismatch.rs:56:10
2+
--> $DIR/signature-mismatch.rs:77:10
33
|
44
LL | &'a self,
55
| -------- this parameter and the return type are declared with different lifetimes...

tests/ui/impl-trait/in-trait/signature-mismatch.rs

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// edition:2021
2+
// revisions: success failure
3+
//[success] check-pass
24

35
#![feature(return_position_impl_trait_in_trait)]
46
#![allow(incomplete_features)]
@@ -11,16 +13,25 @@ impl<T> Captures<'_> for T {}
1113
trait Captures2<'a, 'b> {}
1214
impl<T> Captures2<'_, '_> for T {}
1315

14-
pub trait AsyncTrait {
16+
trait AsyncTrait {
17+
#[cfg(success)]
1518
fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
19+
20+
#[cfg(success)]
1621
fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>>;
22+
23+
#[cfg(success)]
1724
fn async_fn_multiple<'a>(&'a self, buff: &[u8])
18-
-> impl Future<Output = Vec<u8>> + Captures<'a>;
25+
-> impl Future<Output = Vec<u8>> + Captures<'a>;
26+
27+
#[cfg(failure)]
1928
fn async_fn_reduce_outlive<'a, T>(
2029
&'a self,
2130
buff: &[u8],
2231
t: T,
2332
) -> impl Future<Output = Vec<u8>> + 'a;
33+
34+
#[cfg(success)]
2435
fn async_fn_reduce<'a, T>(
2536
&'a self,
2637
buff: &[u8],
@@ -31,38 +42,49 @@ pub trait AsyncTrait {
3142
pub struct Struct;
3243

3344
impl AsyncTrait for Struct {
45+
// Does not capture more lifetimes that trait def'n, since trait def'n
46+
// implicitly captures all in-scope lifetimes.
47+
#[cfg(success)]
3448
fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
35-
//~^ ERROR return type captures more lifetimes than trait definition
3649
async move { buff.to_vec() }
3750
}
3851

52+
// Does not capture more lifetimes that trait def'n, since trait def'n
53+
// implicitly captures all in-scope lifetimes.
54+
#[cfg(success)]
3955
fn async_fn_early<'a: 'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
40-
//~^ ERROR return type captures more lifetimes than trait definition
4156
async move { buff.to_vec() }
4257
}
4358

59+
// Does not capture more lifetimes that trait def'n, since trait def'n
60+
// implicitly captures all in-scope lifetimes.
61+
#[cfg(success)]
4462
fn async_fn_multiple<'a, 'b>(
4563
&'a self,
4664
buff: &'b [u8],
4765
) -> impl Future<Output = Vec<u8>> + Captures2<'a, 'b> {
48-
//~^ ERROR return type captures more lifetimes than trait definition
4966
async move { buff.to_vec() }
5067
}
5168

69+
// This error message is awkward, but `impl Future<Output = Vec<u8>>`
70+
// cannot outlive `'a` (from the trait signature) because it captures
71+
// both `T` and `'b`.
72+
#[cfg(failure)]
5273
fn async_fn_reduce_outlive<'a, 'b, T>(
5374
&'a self,
5475
buff: &'b [u8],
5576
t: T,
5677
) -> impl Future<Output = Vec<u8>> {
57-
//~^ ERROR the parameter type `T` may not live long enough
78+
//[failure]~^ ERROR lifetime mismatch
5879
async move {
5980
let _t = t;
6081
vec![]
6182
}
6283
}
6384

64-
// OK: We remove the `Captures<'a>`, providing a guarantee that we don't capture `'a`,
65-
// but we still fulfill the `Captures<'a>` trait bound.
85+
// Does not capture fewer lifetimes that trait def'n (not that it matters),
86+
// since impl also captures all in-scope lifetimes.
87+
#[cfg(success)]
6688
fn async_fn_reduce<'a, 'b, T>(&'a self, buff: &'b [u8], t: T) -> impl Future<Output = Vec<u8>> {
6789
async move {
6890
let _t = t;

0 commit comments

Comments
 (0)