large_assignments
: Unactionable diagnostics with -Zinline-mir
· Issue #121672 · rust-lang/rust (original) (raw)
Tracking issue #83518.
Doing cargo build --release
will activate -Zinline-mir
under the hood (through -Copt-level=3
). But it makes large_assignments
diagnostics unhelpful, because it can make diagnostics point to library code that the user can't change.
How to reproduce
src/main.rs
#![feature(large_assignments)] #![deny(large_assignments)] #![move_size_limit = "1000"]
pub fn main() { let data = [10u8; 9999]; let cell = std::cell::UnsafeCell::new(data); std::hint::black_box(cell); }
One of:
cargo +nightly build --release cargo +nightly rustc -- -Zmir-opt-level=1 -Zinline-mir
Actual
Compiling minimal v0.1.0 (/home/martin/src/bin) error: moving 9999 bytes --> /home/martin/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/cell.rs:2054:9 | 2054 | UnsafeCell { value } | ^^^^^^^^^^^^^^^^^^^^ value moved from here |
Expected
Compiling minimal v0.1.0 (/home/martin/src/bin) error: moving 9999 bytes --> src/main.rs:7:43 | 7 | let cell = std::cell::UnsafeCell::new(data); | ^^^^ value moved from here |
Remarks
The expected diagnostics is given with these commands. Note how -Zinline-mir
is deactivated in both cases:
One of:
cargo +nightly build cargo +nightly rustc -- -Zmir-opt-level=1
The above test case is ui-testified here.
CC E-mentor @oli-obk who maybe have an idea on how to fix this? (I currently don't.)