Closed
Description
In this code:
let mut value = 0;
async {
value = 1;
yield_now().await;
value = 2;
}
.now_or_never();
assert_eq!(value, 1);
The 1
assigned to the value
variable is later read. However, Rust incorrectly generates a warning:
warning: value assigned to `value` is never read
--> src/main.rs:6:9
|
6 | value = 1;
| ^^^^^
|
= note: `#[warn(unused_assignments)]` on by default
= help: maybe it is overwritten before being read?
Meta
Occurs on both stable 1.51.0 and Nightly 2021-04-17.
rustc --version --verbose
:
rustc 1.53.0-nightly (392ba2ba1 2021-04-17)
binary: rustc
commit-hash: 392ba2ba1a7d6c542d2459fb8133bebf62a4a423
commit-date: 2021-04-17
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
This issue has been assigned to @tmiasko via this comment.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done