Skip to content

Commit e5c8b85

Browse files
authored
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
2 parents a18fbd0 + 43bf016 commit e5c8b85

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

core/src/borrow.rs

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ pub trait Borrow<Borrowed: ?Sized> {
184184
/// an underlying type by providing a mutable reference. See [`Borrow<T>`]
185185
/// for more information on borrowing as another type.
186186
#[stable(feature = "rust1", since = "1.0.0")]
187+
#[rustc_diagnostic_item = "BorrowMut"]
187188
pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
188189
/// Mutably borrows from an owned value.
189190
///

0 commit comments

Comments
 (0)