Suggest borrowing on fn argument that is impl AsRef
· model-checking/verify-rust-std@43bf016 (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 43bf016
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
Lines changed: 1 addition & 0 deletions
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 | /// |