|
| 1 | +error[E0373]: closure may outlive the current function, but it borrows `self.start.line`, which is owned by the current function |
| 2 | + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:38 |
| 3 | + | |
| 4 | +LL | lines.enumerate().filter_map(|(i, line)| { |
| 5 | + | ^^^^^^^^^^^ may outlive borrowed value `self.start.line` |
| 6 | +... |
| 7 | +LL | if self.start.line as usize <= i && i <= self.end.line as usize { |
| 8 | + | --------------- `self.start.line` is borrowed here |
| 9 | + | |
| 10 | +note: function requires argument type to outlive `'static` |
| 11 | + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:9 |
| 12 | + | |
| 13 | +LL | / lines.enumerate().filter_map(|(i, line)| { |
| 14 | +LL | | |
| 15 | +LL | | |
| 16 | +LL | | if self.start.line as usize <= i && i <= self.end.line as usize { |
| 17 | +... | |
| 18 | +LL | | }) |
| 19 | + | |__________^ |
| 20 | +help: to force the closure to take ownership of `self.start.line` (and any other referenced variables), use the `move` keyword |
| 21 | + | |
| 22 | +LL | lines.enumerate().filter_map(move |(i, line)| { |
| 23 | + | ++++ |
| 24 | + |
| 25 | +error[E0373]: closure may outlive the current function, but it borrows `self.end.line`, which is owned by the current function |
| 26 | + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:38 |
| 27 | + | |
| 28 | +LL | lines.enumerate().filter_map(|(i, line)| { |
| 29 | + | ^^^^^^^^^^^ may outlive borrowed value `self.end.line` |
| 30 | +... |
| 31 | +LL | if self.start.line as usize <= i && i <= self.end.line as usize { |
| 32 | + | ------------- `self.end.line` is borrowed here |
| 33 | + | |
| 34 | +note: function requires argument type to outlive `'static` |
| 35 | + --> $DIR/confusing-lifetime-error-issue-79033.rs:24:9 |
| 36 | + | |
| 37 | +LL | / lines.enumerate().filter_map(|(i, line)| { |
| 38 | +LL | | |
| 39 | +LL | | |
| 40 | +LL | | if self.start.line as usize <= i && i <= self.end.line as usize { |
| 41 | +... | |
| 42 | +LL | | }) |
| 43 | + | |__________^ |
| 44 | +help: to force the closure to take ownership of `self.end.line` (and any other referenced variables), use the `move` keyword |
| 45 | + | |
| 46 | +LL | lines.enumerate().filter_map(move |(i, line)| { |
| 47 | + | ++++ |
| 48 | + |
| 49 | +error: aborting due to 2 previous errors |
| 50 | + |
| 51 | +For more information about this error, try `rustc --explain E0373`. |
0 commit comments