Closed
Description
Code
use futures::lock::Mutex;
use std::sync::Arc;
use tokio::sync::mpsc::channel;
async fn _increase_id(increament_id: Arc<Mutex<u64>>) -> anyhow::Result<()> {
let (_tx, mut rx) = channel(32);
let read_increament_id = increament_id.clone();
tokio::spawn(async move {
while let Some(i) = rx.recv().await {
read_increament_id.lock().await = i;
}
});
Ok(())
}
The compiler doesn't seem to crash on Beta nor on Nightly. However, I was thinking I should report it anyways, wasn't sure if you "accidentally" fixed it or was aware of the issue from another bug report and fixed it. I suppose the suggestion could also be improved. To make the code work I need to do the following: *read_increament_id.lock().await = i;
which I suppose could have been suggested by the compiler?
Meta
rustc --version --verbose
:
rustc 1.58.1 (db9d1b20b 2022-01-20)
binary: rustc
commit-hash: db9d1b20bba1968c1ec1fc49616d4742c1725b4b
commit-date: 2022-01-20
host: x86_64-unknown-linux-gnu
release: 1.58.1
LLVM version: 13.0.0
Error output
error: internal compiler error[[E0070]](https://doc.rust-lang.org/stable/error-index.html#E0070): invalid left-hand side of assignment
[--> src/lib.rs:13:45
](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021#) |
13 | read_increament_id.lock().await = i;
| ------------------------------- ^
| |
| cannot assign to this expression
|
help: you might have meant to use pattern destructuring
|
12 | while let let Some(i) = rx.recv().await {
| +++
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1188:13
note: [run with `RUST_BACKTRACE=1` environment variable to display a backtrace](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021#)
error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md
note: rustc 1.58.1 (db9d1b20b 2022-01-20) running on x86_64-unknown-linux-gnu
note: compiler flags: -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack