Skip to content

Commit b0ab37e

Browse files
Additional wf test
1 parent a14285c commit b0ab37e

File tree

3 files changed

+51
-10
lines changed

3 files changed

+51
-10
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
2-
--> $DIR/wf-bounds.rs:13:22
2+
--> $DIR/wf-bounds.rs:17:22
33
|
44
LL | fn nya() -> impl Wf<Vec<[u8]>>;
55
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -9,14 +9,14 @@ note: required by a bound in `Vec`
99
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
1010

1111
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
12-
--> $DIR/wf-bounds.rs:16:23
12+
--> $DIR/wf-bounds.rs:20:23
1313
|
1414
LL | fn nya2() -> impl Wf<[u8]>;
1515
| ^^^^^^^^ doesn't have a size known at compile-time
1616
|
1717
= help: the trait `Sized` is not implemented for `[u8]`
1818
note: required by a bound in `Wf`
19-
--> $DIR/wf-bounds.rs:8:10
19+
--> $DIR/wf-bounds.rs:10:10
2020
|
2121
LL | trait Wf<T> {
2222
| ^ required by this bound in `Wf`
@@ -26,7 +26,7 @@ LL | trait Wf<T: ?Sized> {
2626
| ++++++++
2727

2828
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
29-
--> $DIR/wf-bounds.rs:19:44
29+
--> $DIR/wf-bounds.rs:23:44
3030
|
3131
LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
3232
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -35,6 +35,23 @@ LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
3535
note: required by a bound in `Vec`
3636
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
3737

38-
error: aborting due to 3 previous errors
38+
error[E0277]: `T` doesn't implement `std::fmt::Display`
39+
--> $DIR/wf-bounds.rs:26:26
40+
|
41+
LL | fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
42+
| ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
43+
|
44+
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
45+
note: required by a bound in `NeedsDisplay`
46+
--> $DIR/wf-bounds.rs:14:24
47+
|
48+
LL | struct NeedsDisplay<T: Display>(T);
49+
| ^^^^^^^ required by this bound in `NeedsDisplay`
50+
help: consider restricting type parameter `T`
51+
|
52+
LL | fn nya4<T: std::fmt::Display>() -> impl Wf<NeedsDisplay<T>>;
53+
| +++++++++++++++++++
54+
55+
error: aborting due to 4 previous errors
3956

4057
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
2-
--> $DIR/wf-bounds.rs:13:22
2+
--> $DIR/wf-bounds.rs:17:22
33
|
44
LL | fn nya() -> impl Wf<Vec<[u8]>>;
55
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -9,14 +9,14 @@ note: required by a bound in `Vec`
99
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
1010

1111
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
12-
--> $DIR/wf-bounds.rs:16:23
12+
--> $DIR/wf-bounds.rs:20:23
1313
|
1414
LL | fn nya2() -> impl Wf<[u8]>;
1515
| ^^^^^^^^ doesn't have a size known at compile-time
1616
|
1717
= help: the trait `Sized` is not implemented for `[u8]`
1818
note: required by a bound in `Wf`
19-
--> $DIR/wf-bounds.rs:8:10
19+
--> $DIR/wf-bounds.rs:10:10
2020
|
2121
LL | trait Wf<T> {
2222
| ^ required by this bound in `Wf`
@@ -26,7 +26,7 @@ LL | trait Wf<T: ?Sized> {
2626
| ++++++++
2727

2828
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
29-
--> $DIR/wf-bounds.rs:19:44
29+
--> $DIR/wf-bounds.rs:23:44
3030
|
3131
LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
3232
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
@@ -35,6 +35,23 @@ LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
3535
note: required by a bound in `Vec`
3636
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
3737

38-
error: aborting due to 3 previous errors
38+
error[E0277]: `T` doesn't implement `std::fmt::Display`
39+
--> $DIR/wf-bounds.rs:26:26
40+
|
41+
LL | fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
42+
| ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter
43+
|
44+
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
45+
note: required by a bound in `NeedsDisplay`
46+
--> $DIR/wf-bounds.rs:14:24
47+
|
48+
LL | struct NeedsDisplay<T: Display>(T);
49+
| ^^^^^^^ required by this bound in `NeedsDisplay`
50+
help: consider restricting type parameter `T`
51+
|
52+
LL | fn nya4<T: std::fmt::Display>() -> impl Wf<NeedsDisplay<T>>;
53+
| +++++++++++++++++++
54+
55+
error: aborting due to 4 previous errors
3956

4057
For more information about this error, try `rustc --explain E0277`.

tests/ui/impl-trait/in-trait/wf-bounds.rs

+7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
#![feature(return_position_impl_trait_in_trait)]
66
#![allow(incomplete_features)]
77

8+
use std::fmt::Display;
9+
810
trait Wf<T> {
911
type Output;
1012
}
1113

14+
struct NeedsDisplay<T: Display>(T);
15+
1216
trait Uwu {
1317
fn nya() -> impl Wf<Vec<[u8]>>;
1418
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
@@ -18,6 +22,9 @@ trait Uwu {
1822

1923
fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>;
2024
//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time
25+
26+
fn nya4<T>() -> impl Wf<NeedsDisplay<T>>;
27+
//~^ ERROR `T` doesn't implement `std::fmt::Display`
2128
}
2229

2330
fn main() {}

0 commit comments

Comments
 (0)