@@ -7,19 +7,16 @@ LL | a::foo::<fn() -> dyn A>();
7
7
= help: within `fn() -> dyn A`, the trait `Sized` is not implemented for `dyn A`
8
8
= note: required because it appears within the type `fn() -> dyn A`
9
9
10
- error[E0277 ]: the size for values of type `dyn A` cannot be known at compilation time
10
+ error[E0746 ]: return type cannot have an unboxed trait object
11
11
--> $DIR/closure-return-type-must-be-sized.rs:55:14
12
12
|
13
13
LL | a::bar::<fn() -> dyn A, _>();
14
14
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
15
15
|
16
- = help: within `fn() -> dyn A`, the trait `Sized` is not implemented for `dyn A`
17
- = note: required because it appears within the type `fn() -> dyn A`
18
- note: required by a bound in `a::bar`
19
- --> $DIR/closure-return-type-must-be-sized.rs:14:19
16
+ help: box the return type, and wrap all of the returned values in `Box::new`
20
17
|
21
- LL | pub fn bar<F: FnOnce () -> R, R: ?Sized >() {}
22
- | ^^^^^^^^^^^^^ required by this bound in `bar`
18
+ LL | a:: bar::<Box<fn () -> dyn A>, _ >();
19
+ | ++++ +
23
20
24
21
error[E0277]: the size for values of type `dyn A` cannot be known at compilation time
25
22
--> $DIR/closure-return-type-must-be-sized.rs:56:5
@@ -39,19 +36,16 @@ LL | b::foo::<fn() -> dyn A>();
39
36
= help: within `fn() -> dyn A`, the trait `Sized` is not implemented for `dyn A`
40
37
= note: required because it appears within the type `fn() -> dyn A`
41
38
42
- error[E0277 ]: the size for values of type `dyn A` cannot be known at compilation time
39
+ error[E0746 ]: return type cannot have an unboxed trait object
43
40
--> $DIR/closure-return-type-must-be-sized.rs:62:14
44
41
|
45
42
LL | b::bar::<fn() -> dyn A, _>();
46
43
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
47
44
|
48
- = help: within `fn() -> dyn A`, the trait `Sized` is not implemented for `dyn A`
49
- = note: required because it appears within the type `fn() -> dyn A`
50
- note: required by a bound in `b::bar`
51
- --> $DIR/closure-return-type-must-be-sized.rs:28:19
45
+ help: box the return type, and wrap all of the returned values in `Box::new`
52
46
|
53
- LL | pub fn bar<F: Fn () -> R, R: ?Sized >() {}
54
- | ^^^^^^^^^ required by this bound in `bar`
47
+ LL | b:: bar::<Box<fn () -> dyn A>, _ >();
48
+ | ++++ +
55
49
56
50
error[E0277]: the size for values of type `dyn A` cannot be known at compilation time
57
51
--> $DIR/closure-return-type-must-be-sized.rs:63:5
@@ -71,19 +65,16 @@ LL | c::foo::<fn() -> dyn A>();
71
65
= help: within `fn() -> dyn A`, the trait `Sized` is not implemented for `dyn A`
72
66
= note: required because it appears within the type `fn() -> dyn A`
73
67
74
- error[E0277 ]: the size for values of type `dyn A` cannot be known at compilation time
68
+ error[E0746 ]: return type cannot have an unboxed trait object
75
69
--> $DIR/closure-return-type-must-be-sized.rs:69:14
76
70
|
77
71
LL | c::bar::<fn() -> dyn A, _>();
78
72
| ^^^^^^^^^^^^^ doesn't have a size known at compile-time
79
73
|
80
- = help: within `fn() -> dyn A`, the trait `Sized` is not implemented for `dyn A`
81
- = note: required because it appears within the type `fn() -> dyn A`
82
- note: required by a bound in `c::bar`
83
- --> $DIR/closure-return-type-must-be-sized.rs:42:19
74
+ help: box the return type, and wrap all of the returned values in `Box::new`
84
75
|
85
- LL | pub fn bar<F: FnMut () -> R, R: ?Sized >() {}
86
- | ^^^^^^^^^^^^ required by this bound in `bar`
76
+ LL | c:: bar::<Box<fn () -> dyn A>, _ >();
77
+ | ++++ +
87
78
88
79
error[E0277]: the size for values of type `dyn A` cannot be known at compilation time
89
80
--> $DIR/closure-return-type-must-be-sized.rs:70:5
@@ -96,4 +87,5 @@ LL | c::baz::<fn() -> dyn A>();
96
87
97
88
error: aborting due to 9 previous errors
98
89
99
- For more information about this error, try `rustc --explain E0277`.
90
+ Some errors have detailed explanations: E0277, E0746.
91
+ For more information about an error, try `rustc --explain E0277`.
0 commit comments