Closed
Description
I tried this code:
const SZ: usize = 64_000_000;
type BigDrop = [String; SZ];
fn f(from_fn: BigDrop) {}
fn f2(_moveme: BigDrop) -> String {
let [a, ..] = _moveme;
a
}
fn main() {
f(std::array::from_fn(|_| String::new()));
f2(std::array::from_fn(|_| String::new()));
}
I expected to see this happen: explanation
Instead, this happened: explanation
Meta
rustc --version --verbose
:
rustc 1.71.0-nightly (b628260df 2023-04-22)
binary: rustc
commit-hash: b628260df0587ae559253d8640ecb8738d3de613
commit-date: 2023-04-22
host: x86_64-unknown-linux-gnu
release: 1.71.0-nightly
LLVM version: 16.0.2
If you compile this you will get very interesting output
warning: unused variable: `from_fn`
--> B3A5F4060827522A3328FC59CAE6348272F5F8B0627152DED589D0B44CBBDBB5.rs:6:6
|
6 | fn f(from_fn: BigDrop) {}
| ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_from_fn`
|
= note: `#[warn(unused_variables)]` on by default
80/9216000120 (0.00%) spills, 9216000040/9216000120 (100.00%) variables
80/9216000120 (0.00%) spills, 9216000040/9216000120 (100.00%) variables
warning: 1 warning emitted
I could not find any traces of this inside the rust source code, it seems to be coming from llvm directly?! Some leftover debug print maybe?
(llvm git: llvm/lib/CodeGen/PrologEpilogInserter.cpp:316: dbgs() << formatv("{0}/{1} ({3:P}) spills, {2}/{1} ({4:P}) variables",
)