With the latest nightly (rustc 1.27.0-nightly (66363b288 2018-04-29)) I get confusing compile warnings about unused mut keywords where there are no mut keywords present.
The warnings do not happen on the previous nightly (rustc 1.27.0-nightly (66363b288 2018-04-28)) - so this might be a regression.
For further inspection the project where I receive those warnings can be found here.
warning: variable does not need to be mutable
--> src/ast/visitor.rs:158:56
|
158 | fn visit_cond(&mut self, _cond: &expr::IfThenElse, _: VisitEvent) {}
| ^ help: remove this `mut`
|
= note: #[warn(unused_mut)] on by default
warning: variable does not need to be mutable
--> src/simplifier/simplifications/normalizer.rs:100:17
|
100 | .all(|(lhs, rhs)| {
| ------^^^^
| |
| help: remove this `mut`
Bizarre; this must be where all the missing "unused mut" warnings from #50321 are running off to!
A quick bisect run points at #48605 as the cause of this. cc @KiChjang @nikomatsakis
Just to confirm: this is specific to crates using nll, right?
This problem breaks our build. Some examples:
error: variable does not need to be mutable
--> src/utils/async_mutex.rs:154:35
|
154 | .map_err(|_| AsyncMutexError::AwakenerCanceled)?
| ^ help: remove this `mut`
...
error: variable does not need to be mutable
--> src/timer.rs:153:19
|
153 | .map(|_| tm.create_client())
| ^ help: remove this `mut`
|
note: lint level defined here
--> src/timer.rs:40:9
|
40 | #![deny(warnings)]
| ^^^^^^^^
@realcr Same question as Niko posted above -- does this only happen when you enable NLL?
In the case of my linked project nll is enabled but I cannot tell you if this bug is exclusive to nll enabled projects so I couldn't really answer niko's question.
@KiChjang @nikomatsakis as far as I can see this only happens with NLL (or at least, this snippet emits the warning only with NLL enabled):
```
fn main() {
vec![42].iter().map(|_| ()).count();
}
I guess that's a reduced test case?
@KiChjang : It's the first time I hear about NLL. It seems like my project does have NLL enabled.
$ ag "nll"
src/lib.rs
2:#![feature(nll)]
Interesting.
EDIT: I can't tell if this problem is unique to NLL, because if I remove it the project doesn't compile. Now I know what NLL does (:
error[E0597]: `**dur` does not live long enough
--> src/timer.rs:164:40
|
162 | .map(|client| client.take(u64::from(TICKS)).collect().and_then(|_| {
| --- capture occurs here
163 | let elapsed = start.elapsed();
164 | assert!(elapsed >= dur * TICKS * 2 / 3);
| ^^^ borrowed value does not live long enough
...
168 | .collect::<Vec<_>>();
| - borrowed value only lives until here
...
173 | }
| - borrowed value needs to live until here
Most helpful comment
Bizarre; this must be where all the missing "unused
mut" warnings from #50321 are running off to!