forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregion-object-lifetime-in-coercion.stderr
52 lines (47 loc) · 2.06 KB
/
region-object-lifetime-in-coercion.stderr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
error[E0621]: explicit lifetime required in the type of `v`
--> $DIR/region-object-lifetime-in-coercion.rs:8:37
|
LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
| ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]`
LL | let x: Box<dyn Foo + 'static> = Box::new(v);
| ^^^^^^^^^^^ lifetime `'static` required
error[E0621]: explicit lifetime required in the type of `v`
--> $DIR/region-object-lifetime-in-coercion.rs:14:5
|
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
| ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]`
LL | Box::new(v)
| ^^^^^^^^^^^ lifetime `'static` required
error[E0621]: explicit lifetime required in the type of `v`
--> $DIR/region-object-lifetime-in-coercion.rs:21:5
|
LL | fn c(v: &[u8]) -> Box<dyn Foo> {
| ----- help: add explicit lifetime `'static` to the type of `v`: `&'static [u8]`
...
LL | Box::new(v)
| ^^^^^^^^^^^ lifetime `'static` required
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
--> $DIR/region-object-lifetime-in-coercion.rs:26:14
|
LL | Box::new(v)
| ^
|
note: first, the lifetime cannot outlive the lifetime 'a as defined on the function body at 25:6...
--> $DIR/region-object-lifetime-in-coercion.rs:25:6
|
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
| ^^
= note: ...so that the expression is assignable:
expected &[u8]
found &'a [u8]
note: but, the lifetime must be valid for the lifetime 'b as defined on the function body at 25:9...
--> $DIR/region-object-lifetime-in-coercion.rs:25:9
|
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
| ^^
= note: ...so that the expression is assignable:
expected std::boxed::Box<(dyn Foo + 'b)>
found std::boxed::Box<dyn Foo>
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0495, E0621.
For more information about an error, try `rustc --explain E0495`.