Rollup merge of #124599 - estebank:issue-41708, r=wesleywiser · model-checking/verify-rust-std@e5c8b85 (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Commit e5c8b85

Rollup merge of rust-lang#124599 - estebank:issue-41708, r=wesleywiser

Suggest borrowing on fn argument that is `impl AsRef` When encountering a move conflict, on an expression that is `!Copy` passed as an argument to an `fn` that is `impl AsRef`, suggest borrowing the expression. ``` error[E0382]: use of moved value: `bar` --> f204.rs:14:15 | 12 | let bar = Bar; | --- move occurs because `bar` has type `Bar`, which does not implement the `Copy` trait 13 | foo(bar); | --- value moved here 14 | let baa = bar; | ^^^ value used here after move | help: borrow the value to avoid moving it | 13 | foo(&bar); | + ```Fix rust-lang#41708

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -184,6 +184,7 @@ pub trait Borrow<Borrowed: ?Sized> {
184 184 /// an underlying type by providing a mutable reference. See [`Borrow`]
185 185 /// for more information on borrowing as another type.
186 186 #[stable(feature = "rust1", since = "1.0.0")]
187 +#[rustc_diagnostic_item = "BorrowMut"]
187 188 pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
188 189 /// Mutably borrows from an owned value.
189 190 ///