Skip to content

Commit

Permalink
large_assignments: Add test for -Zinline-mir
Browse files Browse the repository at this point in the history
  • Loading branch information
Enselic committed Feb 27, 2024
1 parent 21033f6 commit 812ebca
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/ui/lint/large_assignments/inline-mir.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#![feature(large_assignments)]
#![deny(large_assignments)]
#![move_size_limit = "1000"]

//! Tests that with `-Zinline-mir`, we do NOT get an error that points to the
//! implementation of `UnsafeCell` since that is not actionable by the user:
//!
//! ```text
//! error: moving 9999 bytes
//! --> /rustc/FAKE_PREFIX/library/core/src/cell.rs:2054:9
//! |
//! = note: value moved from here
//! ```
//!
//! We want the diagnostics to point to the relevant user code.

//@ build-fail
//@ compile-flags: -Zmir-opt-level=1 -Zinline-mir

pub fn main() {
let data = [10u8; 9999];
let cell = std::cell::UnsafeCell::new(data); //~ ERROR large_assignments
std::hint::black_box(cell);
}
15 changes: 15 additions & 0 deletions tests/ui/lint/large_assignments/inline-mir.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: moving 9999 bytes
--> $DIR/inline-mir.rs:22:43
|
LL | let cell = std::cell::UnsafeCell::new(data);
| ^^^^ value moved from here
|
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
note: the lint level is defined here
--> $DIR/inline-mir.rs:2:9
|
LL | #![deny(large_assignments)]
| ^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

0 comments on commit 812ebca

Please sign in to comment.