File tree 2 files changed +39
-0
lines changed
tests/ui/lint/large_assignments
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( large_assignments) ]
2
+ #![ deny( large_assignments) ]
3
+ #![ move_size_limit = "1000" ]
4
+
5
+ //! Tests that with `-Zinline-mir`, we do NOT get an error that points to the
6
+ //! implementation of `UnsafeCell` since that is not actionable by the user:
7
+ //!
8
+ //! ```text
9
+ //! error: moving 9999 bytes
10
+ //! --> /rustc/FAKE_PREFIX/library/core/src/cell.rs:2054:9
11
+ //! |
12
+ //! = note: value moved from here
13
+ //! ```
14
+ //!
15
+ //! We want the diagnostics to point to the relevant user code.
16
+
17
+ //@ build-fail
18
+ //@ compile-flags: -Zmir-opt-level=1 -Zinline-mir
19
+
20
+ pub fn main ( ) {
21
+ let data = [ 10u8 ; 9999 ] ;
22
+ let cell = std:: cell:: UnsafeCell :: new ( data) ; //~ ERROR large_assignments
23
+ std:: hint:: black_box ( cell) ;
24
+ }
Original file line number Diff line number Diff line change
1
+ error: moving 9999 bytes
2
+ --> $DIR/inline-mir.rs:22:43
3
+ |
4
+ LL | let cell = std::cell::UnsafeCell::new(data);
5
+ | ^^^^ value moved from here
6
+ |
7
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
8
+ note: the lint level is defined here
9
+ --> $DIR/inline-mir.rs:2:9
10
+ |
11
+ LL | #![deny(large_assignments)]
12
+ | ^^^^^^^^^^^^^^^^^
13
+
14
+ error: aborting due to 1 previous error
15
+
You can’t perform that action at this time.
0 commit comments