forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
large_assignments: Add test for -Zinline-mir
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|