Closed
Description
I tried this code:
format_args!("{:?}", { let [_a] = *(&[] as &[Vec<i32>]) else { return }; });
I expected to see this happen: an error about not being able to move out of a slice
Instead, this happened: the error and a bunch of note: erroneous constant used
error[E0508]: cannot move out of type `[Vec<i32>]`, a non-copy slice
--> src/main.rs:2:35
|
2 | format_args!("{:?}", { let [_a] = *(&[] as &[Vec<i32>]) else { return }; });
| -- ^^^^^^^^^^^^^^^^^^^^^ cannot move out of here
| |
| data moved here
| move occurs because `_a` has type `Vec<i32>`, which does not implement the `Copy` trait
|
help: consider borrowing the pattern binding
|
2 | format_args!("{:?}", { let [ref _a] = *(&[] as &[Vec<i32>]) else { return }; });
| +++
note: erroneous constant used
--> src/main.rs:2:14
|
2 | format_args!("{:?}", { let [_a] = *(&[] as &[Vec<i32>]) else { return }; });
| ^^^^^^
note: erroneous constant used
--> src/main.rs:2:37
|
2 | format_args!("{:?}", { let [_a] = *(&[] as &[Vec<i32>]) else { return }; });
| ^^^
note: erroneous constant used
--> src/main.rs:2:22
|
2 | format_args!("{:?}", { let [_a] = *(&[] as &[Vec<i32>]) else { return }; });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this note originates in the macro `format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
Meta
Fails on 1.71.0-nightly (2023-04-25 458d4dae845ec155b285)
, works fine on 1.70.0-beta.1 (2023-04-19 1b7dd2252b99671ce5d1)