fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

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