You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
erroneous note: erroneous constant used emitted for non-compiling format_args! usage #110856
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)
letmut x = String::from("hello");let z = &x;let y = &mut x;println!("{y}{z}");
error[[E0502]](https://doc.rust-lang.org/nightly/error_codes/E0502.html): cannot borrow `x` as mutable because it is also borrowed as immutable
--> src/main.rs:4:13
|
3 | let z = &x;
| -- immutable borrow occurs here
4 | let y = &mut x;
| ^^^^^^ mutable borrow occurs here
5 | println!("{y}{z}");
| --- immutable borrow later used here
note: erroneous constant used
--> src/main.rs:5:14
|
5 | println!("{y}{z}");
| ^^^^^^^^
Intestingly, the same day also contained two format_args PRs but I have bisected this twice (with manual promt) and const prop lint really does seem to be the cause:
commit[0] 2023-04-20: Auto merge of #110616 - m-ou-se:fmt-lang-items, r=jyn514
commit[1] 2023-04-20: Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
Activity
Noratrieb commentedon Apr 26, 2023
It also applies to way simpler code like: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=aeadbb4b94770923ec61da515e15e45c
Noratrieb commentedon Apr 26, 2023
searched nightlies: from nightly-2023-04-01 to nightly-2023-04-26
regressed nightly: nightly-2023-04-22
searched commit range: 8bdcc62...fec9adc
regressed commit: fa4cc63
bisected with cargo-bisect-rustc v0.6.6
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
#110107 @cjgillot
Intestingly, the same day also contained two
format_argsPRs but I have bisected this twice (with manual promt) and const prop lint really does seem to be the cause:commit[0] 2023-04-20: Auto merge of #110616 - m-ou-se:fmt-lang-items, r=jyn514
commit[1] 2023-04-20: Auto merge of #109999 - m-ou-se:flatten-format-args, r=oli-obk
apiraino commentedon Apr 27, 2023
WG-prioritization assigning priority (Zulip discussion).
@rustbot label -I-prioritize +P-medium
Rollup merge of rust-lang#111038 - tmiasko:untainted-promoteds, r=com…