Closed
Description
I tried this code:
find(line.to_string(), &cap[0]).iter().for_each(|x| {
#[allow(clippy::cast_possible_truncation)]
coordinates.push((*x as u16, i as u16));
})
*line = replace;
I expected to see this error happen: Missing semicolon at the end of statement
Instead, these two errors happened:
error[E0070]: invalid left-hand side of assignment
error[E0369]: cannot multiply `&mut String` to `()`
Meta
I ran this on both stable and nightly. Here are the versions
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
rustc 1.50.0-nightly (fe982319a 2020-11-19)
binary: rustc
commit-hash: fe982319aa0aa5bbfc2795791a753832292bd2ba
commit-date: 2020-11-19
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
Complete error
error[E0070]: invalid left-hand side of assignment
--> src/search.rs:150:19
|
145 | / find(line.to_string(), &cap[0]).iter().for_each(|x| {
146 | | #[allow(clippy::cast_possible_truncation)]
147 | | coordinates.push((*x as u16, i as u16));
148 | | })
149 | |
150 | | *line = replace;
| | - ^
| |_________________|
| cannot assign to this expression
error[E0369]: cannot multiply `&mut String` to `()`
--> src/search.rs:150:13
|
145 | / find(line.to_string(), &cap[0]).iter().for_each(|x| {
146 | | #[allow(clippy::cast_possible_truncation)]
147 | | coordinates.push((*x as u16, i as u16));
148 | | })
| |______________- ()
149 |
150 | *line = replace;
| ^---- &mut String