Closed
Description
Given the following code:
fn main() {
let mut x: Vec<()> = vec![()];
x.last_mut().unwrap() = ();
}
The current output is:
error[E0070]: invalid left-hand side of assignment
--> src/main.rs:3:27
|
3 | x.last_mut().unwrap() = ();
| --------------------- ^
| |
| cannot assign to this expression
For more information about this error, try `rustc --explain E0070`.
Ideally the output should look like:
error[E0070]: invalid left-hand side of assignment
--> src/main.rs:3:27
|
3 | x.last_mut().unwrap() = ();
| --------------------- ^
| |
| cannot assign to this expression
Note: consider dereferencing the left-hand side
3 | *x.last_mut().unwrap() = ();
+
For more information about this error, try `rustc --explain E0070`.
The root cause seems to be the coersion error being suppressed, since there is already logic that suggest dereferencing the LHS of an assignment operator. In fact, this diagnostic code path is being hit, but somewhere along the way the diagnostic is being canceled (hence the fact that we only see this "invalid left-hand side of assignment" error being emitted and not an error about not being able to relate &mut ()
and ()
.)