Closed
Description
Code
fn main() {
let a: usize;
let b: usize;
(a, b) = (123, &mut 123);
}
Current output
error[E0308]: mismatched types
--> src/main.rs:17:9
|
15 | let b: usize;
| ----- expected due to this type
16 |
17 | (a, b) = (123, &mut 123);
| ^ expected `usize`, found `&mut {integer}`
|
help: consider dereferencing the borrow
|
17 | (a, *b) = (123, &mut 123);
| +
Desired output
error[E0308]: mismatched types
--> src/main.rs:17:9
|
15 | let b: usize;
| ----- expected due to this type
16 |
17 | (a, b) = (123, &mut 123);
| ^ expected `usize`, found `&mut {integer}`
|
help: consider dereferencing the borrow
|
17 | (a, b) = (123, *&mut 123);
| +
Although this cannot be always applied, e.g. consider:
fn main() {
let a: usize;
let b: usize;
(a, b) = foo();
}
fn foo() -> (usize, &'static mut usize) {
todo!()
}
Rationale and extra context
No response
Other cases
No response
Anything else?
No response