fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1error: lifetime may not live long enough 2 --> $DIR/suggest-lt-on-ty-alias-w-generics.rs:4:5 3 | 4LL | fn test(x: &i32) -> Lazy<i32> { 5 | - let's call the lifetime of this reference `'1` 6LL | / Box::new(|| { 7LL | | 8LL | | 9LL | | *x 10LL | | }) 11 | |______^ returning this value requires that `'1` must outlive `'static` 12 | 13help: to declare that the trait object captures data from argument `x`, you can add a lifetime parameter `'a` in the type alias 14 | 15LL | type Lazy<'a, T> = Box<dyn Fn() -> T + 'a>; 16 | +++ ~~ 17 18error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function 19 --> $DIR/suggest-lt-on-ty-alias-w-generics.rs:4:14 20 | 21LL | Box::new(|| { 22 | ^^ may outlive borrowed value `x` 23... 24LL | *x 25 | -- `x` is borrowed here 26 | 27note: closure is returned here 28 --> $DIR/suggest-lt-on-ty-alias-w-generics.rs:4:5 29 | 30LL | / Box::new(|| { 31LL | | 32LL | | 33LL | | *x 34LL | | }) 35 | |______^ 36help: to force the closure to take ownership of `x` (and any other referenced variables), use the `move` keyword 37 | 38LL | Box::new(move || { 39 | ++++ 40 41error: aborting due to 2 previous errors 42 43For more information about this error, try `rustc --explain E0373`.