Closed
Description
Code
#[derive(Clone)]
struct Cloneable;
fn f() -> Result<(), Cloneable> {
let thing = &(Ok::<(), Cloneable>(()),);
thing.0?;
Ok(())
}
Current output
error[E0507]: cannot move out of `thing.0` which is behind a shared reference
--> src/lib.rs:5:5
|
5 | thing.0?;
| ^^^^^^^-
| |
| `thing.0` moved due to this method call
| move occurs because `thing.0` has type `Result<(), Cloneable>`, which does not implement the `Copy` trait
|
note: `branch` takes ownership of the receiver `self`, which moves `thing.0`
--> /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/try_trait.rs:218:15
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
5 | clone().thing.0?;
| ++++++++
For more information about this error, try `rustc --explain E0507`.
error: could not compile `playground` due to previous error
Desired output
error[E0507]: cannot move out of `thing.0` which is behind a shared reference
--> src/lib.rs:5:5
|
5 | thing.0?;
| ^^^^^^^-
| |
| `thing.0` moved due to this method call
| move occurs because `thing.0` has type `Result<(), Cloneable>`, which does not implement the `Copy` trait
|
note: `branch` takes ownership of the receiver `self`, which moves `thing.0`
--> /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/core/src/ops/try_trait.rs:218:15
help: you can `clone` the value and consume it, but this might not be your desired behavior
|
5 | thing.0.clone()?;
| ++++++++
For more information about this error, try `rustc --explain E0507`.
error: could not compile `playground` due to previous error
Rationale and extra context
The .clone()
call is being prepended to the expression instead of appended
Other cases
No response
Anything else?
No response