-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Give a better error message for shared borrow treated as unique for purposes of lifetimes #76630
Comments
|
@jonas-schievink But it doesn't mutably borrow "more than once at a time" right? The mutable borrow gets dropped before the end of each iteration. |
The returned |
Hmm that doesn't make sense to me. How is |
@jyn514 Thank you! I didn't realize that the lifetime of the mutable borrow was being extended to the same lifetime as the immutable borrows. I guess that makes sense, because locally inside of I still think it would be nice if this was more clear from the compiler's error message. Maybe even if there were a tool that could desugar the code for me so I could see the explicit lifetimes. |
…idtwco Added better error message for shared borrow treated as unique for purposes of lifetimes Part of Issue rust-lang#76630 r? `@jyn514`
…twco Added better error message for shared borrow treated as unique for purposes of lifetimes Part of Issue rust-lang#76630 r? `@jyn514`
I tried this code:
I expected to see this happen:
The error should say something like, "cannot borrow
foo
as mutable while it is already borrowed as immutable."Instead, this happened:
Meta
Playground link:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=a6450c7200878a52ff8bf4466cb09f5f
The text was updated successfully, but these errors were encountered: