Skip to content

Commit b82d6a2

Browse files
committed
Run existing impl trait in traits tests using -Zlower-impl-trait-in-trait-to-assoc-ty
1 parent 07e018d commit b82d6a2

17 files changed

+91
-8
lines changed

tests/ui/impl-trait/in-trait/deep-match-works.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(return_position_impl_trait_in_trait)]
46
#![allow(incomplete_features)]
@@ -10,7 +12,9 @@ trait Foo {
1012
}
1113

1214
impl Foo for () {
13-
fn bar() -> Wrapper<i32> { Wrapper(0) }
15+
fn bar() -> Wrapper<i32> {
16+
Wrapper(0)
17+
}
1418
}
1519

1620
fn main() {}

tests/ui/impl-trait/in-trait/deep-match.stderr renamed to tests/ui/impl-trait/in-trait/deep-match.current.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0053]: method `bar` has an incompatible return type for trait
2-
--> $DIR/deep-match.rs:11:17
2+
--> $DIR/deep-match.rs:14:17
33
|
4-
LL | fn bar() -> i32 { 0 }
4+
LL | fn bar() -> i32 {
55
| ^^^
66
| |
77
| expected `Wrapper<_>`, found `i32`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0053]: method `bar` has an incompatible return type for trait
2+
--> $DIR/deep-match.rs:14:17
3+
|
4+
LL | fn bar() -> i32 {
5+
| ^^^
6+
| |
7+
| expected `Wrapper<_>`, found `i32`
8+
| return type in trait
9+
|
10+
= note: expected struct `Wrapper<_>`
11+
found type `i32`
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0053`.

tests/ui/impl-trait/in-trait/deep-match.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
2+
// revisions: current next
3+
14
#![feature(return_position_impl_trait_in_trait)]
25
#![allow(incomplete_features)]
36

@@ -8,8 +11,10 @@ trait Foo {
811
}
912

1013
impl Foo for () {
11-
fn bar() -> i32 { 0 }
12-
//~^ ERROR method `bar` has an incompatible return type for trait
14+
fn bar() -> i32 {
15+
//~^ ERROR method `bar` has an incompatible return type for trait
16+
0
17+
}
1318
}
1419

1520
fn main() {}

tests/ui/impl-trait/in-trait/default-method-binder-shifting.stderr renamed to tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2-
--> $DIR/default-method-binder-shifting.rs:3:12
2+
--> $DIR/default-method-binder-shifting.rs:5:12
33
|
44
LL | #![feature(return_position_impl_trait_in_trait)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes
2+
--> $DIR/default-method-binder-shifting.rs:5:12
3+
|
4+
LL | #![feature(return_position_impl_trait_in_trait)]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information
8+
= note: `#[warn(incomplete_features)]` on by default
9+
10+
warning: 1 warning emitted
11+

tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(return_position_impl_trait_in_trait)]
46
//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete

tests/ui/impl-trait/in-trait/encode.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// build-pass
22
// compile-flags: --crate-type=lib
3+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
4+
// revisions: current next
35

46
#![feature(return_position_impl_trait_in_trait)]
57
#![allow(incomplete_features)]

tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr renamed to tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/opaque-in-impl-is-opaque.rs:17:19
2+
--> $DIR/opaque-in-impl-is-opaque.rs:20:19
33
|
44
LL | fn bar(&self) -> impl Display {
55
| ------------ the found opaque type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/opaque-in-impl-is-opaque.rs:20:19
3+
|
4+
LL | fn bar(&self) -> impl Display {
5+
| ------------ the found opaque type
6+
...
7+
LL | let x: &str = ().bar();
8+
| ---- ^^^^^^^^ expected `&str`, found opaque type
9+
| |
10+
| expected due to this
11+
|
12+
= note: expected reference `&str`
13+
found opaque type `impl std::fmt::Display`
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.

tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
2+
// revisions: current next
3+
14
#![feature(return_position_impl_trait_in_trait)]
25
#![allow(incomplete_features)]
36

tests/ui/impl-trait/in-trait/reveal.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(return_position_impl_trait_in_trait)]
46
#![allow(incomplete_features)]

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: `impl` item signature doesn't match `trait` item signature
2-
--> $DIR/signature-mismatch.rs:15:5
2+
--> $DIR/signature-mismatch.rs:17:5
33
|
44
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
55
| ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: `impl` item signature doesn't match `trait` item signature
2+
--> $DIR/signature-mismatch.rs:17:5
3+
|
4+
LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>;
5+
| ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
6+
...
7+
LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a {
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
9+
|
10+
= note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3`
11+
found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2`
12+
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
13+
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
14+
15+
error: aborting due to previous error
16+

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// edition:2021
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(return_position_impl_trait_in_trait)]
46
#![allow(incomplete_features)]

tests/ui/impl-trait/in-trait/specialization-substs-remap.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(specialization)]
46
#![feature(return_position_impl_trait_in_trait)]

tests/ui/impl-trait/in-trait/success.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// check-pass
2+
// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty
3+
// revisions: current next
24

35
#![feature(return_position_impl_trait_in_trait)]
46
#![allow(incomplete_features)]

0 commit comments

Comments
 (0)