]> git.lizzy.rs Git - rust.git/commit
Auto merge of #51242 - ytausky:mut-ref, r=estebank
authorbors <bors@rust-lang.org>
Tue, 5 Jun 2018 01:47:13 +0000 (01:47 +0000)
committerbors <bors@rust-lang.org>
Tue, 5 Jun 2018 01:47:13 +0000 (01:47 +0000)
commitf9157f5b869fdb14308eaf6778d01ee3d0e1268a
treedd3773889cae79721fa3cee93c982712543b8680
parentc610be92e2925ab8e789efc835c88247e46c6cbf
parent3303e6847b4e8b413ec65a166337e5f9f8325f28
Auto merge of #51242 - ytausky:mut-ref, r=estebank

Suggest not mutably borrowing a mutable reference

This PR would (hopefully) solve #45392. I deviated a bit from @estebank's instructions since the error span only included the borrowed expression (e.g. the `b` in `&mut b`). I also didn't check the mutability of the local binding, since this whole case is concerned with an immutable local.

I can see two outstanding questions:
1. `note_immutability_blame` is called in two places, but I only have one test case. I think it covers the call in `report_bckerror`, but I'm not sure how to trigger the call from `report_aliasability_violation`.
2. There is one failing test, where the local binding is `self: &mut Self`. I'm not entirely sure what the correct output should be, but I think the new message should also apply. Unfortunately, since this parameter is parsed differently, its `let_span` covers both the pattern and the type, leading to a wrong suggestion text. I'm not sure how to correctly identify this case.