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