-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Point to definition when modifying field of immutable variable #40767
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
It'd be nice to avoid the phrasing "immutable field" since it's not really the field that's immutable, but more the binding of the struct. I'm not sure I can come up with anything better than "immutable binding," though, which isn't great either. The help message does alleviate most of the potential pain from this, so while nice to improve, certainly not necessary. |
0f8c678
to
289772f
Compare
Given a file ```rust struct S { x: i32, } fn foo() { let s = S { x: 42 }; s.x += 1; } fn bar(s: S) { s.x += 1; } ``` Provide the following output: ```rust error: cannot assign to immutable field `s.x` --> $DIR/issue-35937.rs:16:5 | 5 | let s = S { x: 42 }; | - consider changing this to `mut s` 6 | s.x += 1; | ^^^^^^^^ cannot mutably borrow immutable field error: cannot assign to immutable field `s.x` --> $DIR/issue-35937.rs:20:5 | 8 | fn bar(s: S) { | - consider changing this to `mut s` 9 | s.x += 1; | ^^^^^^^^ cannot mutably borrow immutable field ``` Follow up to rust-lang#40445. Fix rust-lang#35937.
@bors r+ |
📌 Commit 289772f has been approved by |
⌛ Testing commit 289772f with merge 83d832d... |
💔 Test failed - status-travis |
@bors retry |
⌛ Testing commit 289772f with merge d1023ae... |
💔 Test failed - status-travis |
@bors: retry
* network error
…On Sun, Apr 2, 2017 at 12:06 PM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/217835654>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#40767 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95IYapgdutfh1OLNNGqyDfVQyFaSCks5rr-OPgaJpZM4MnLU7>
.
|
⌛ Testing commit 289772f with merge 7f2ec26... |
💔 Test failed - status-travis |
@bors retry |
⌛ Testing commit 289772f with merge cd0a4f3... |
💔 Test failed - status-travis |
… On Mon, Apr 3, 2017 at 12:52 PM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/rust/builds/218183568>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40767 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95MV5yw_Q3VTl2iQ_uY3N9xvjHpvWks5rsT_agaJpZM4MnLU7>
.
|
⌛ Testing commit 289772f with merge ceaaebc... |
💔 Test failed - status-travis |
@bors retry |
@bors: r- I think that's a legitimate error unfortunately:
|
@alexcrichton it seems like #40841 supersedes this PR. |
Given a file
Provide the following output:
Follow up to #40445. Fix #35937.