mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
2763a0541c
When encountering a E0382 borrow error involving an `Option` or `Result` provide a suggestion to use `.as_ref()` on the prior move location to avoid the move. Fix #84165.
14 lines
223 B
Rust
14 lines
223 B
Rust
// run-rustfix
|
|
|
|
struct Struct;
|
|
|
|
fn bar(_: &Struct) -> Struct {
|
|
Struct
|
|
}
|
|
|
|
fn main() {
|
|
let foo = Some(Struct);
|
|
let _x: Option<Struct> = foo.map(|s| bar(&s));
|
|
let _y = foo; //~ERROR use of moved value: `foo`
|
|
}
|