rust/src/libsyntax_ext
bors d21ec9b4ef Auto merge of #43582 - ivanbakel:unused_mut_ref, r=arielb1
Fixed mutable vars being marked used when they weren't

#### NB : bootstrapping is slow on my machine, even with `keep-stage` - fixes for occurances in the current codebase are <s>in the pipeline</s> done. This PR is being put up for review of the fix of the issue.

Fixes #43526, Fixes #30280, Fixes #25049

### Issue
Whenever the compiler detected a mutable deref being used mutably, it marked an associated value as being used mutably as well. In the case of derefencing local variables which were mutable references, this incorrectly marked the reference itself being used mutably, instead of its contents - with the consequence of making the following code emit no warnings
```
fn do_thing<T>(mut arg : &mut T) {
    ... // don't touch arg - just deref it to access the T
}
```

### Fix
Make dereferences not be counted as a mutable use, but only when they're on borrows on local variables.
#### Why not on things other than local variables?
  * Whenever you capture a variable in a closure, it gets turned into a hidden reference - when you use it in the closure, it gets dereferenced. If the closure uses the variable mutably, that is actually a mutable use of the thing being dereffed to, so it has to be counted.
  * If you deref a mutable `Box` to access the contents mutably, you are using the `Box` mutably - so it has to be counted.
2017-08-10 08:53:22 +00:00
..
deriving Rollup merge of #43501 - topecongiro:span-to-whereclause, r=nrc 2017-07-29 18:03:52 -06:00
asm.rs
Cargo.toml
cfg.rs
compile_error.rs Stabilize the compile_error_macro feature 2017-07-25 07:09:31 -07:00
concat_idents.rs Simplify hygiene::Mark application, and 2017-06-26 02:05:45 +00:00
concat.rs
env.rs Hygienize lifetimes. 2017-05-25 05:52:09 +00:00
format_foreign.rs
format.rs Fixed extra cases found in better checking. 2017-08-01 23:01:24 +01:00
global_asm.rs syntax: Add tokens: Option<TokenStream> to Item 2017-07-28 07:58:20 -07:00
lib.rs Add a feature gate 2017-08-10 02:43:31 +02:00
log_syntax.rs
proc_macro_impl.rs Simplify hygiene::Mark application, and 2017-06-26 02:05:45 +00:00
proc_macro_registrar.rs
trace_macros.rs