File tree 4 files changed +63
-3
lines changed
tests/ui/lint/large_assignments
4 files changed +63
-3
lines changed Original file line number Diff line number Diff line change
1
+ #![ deny( large_assignments) ]
2
+ #![ feature( large_assignments) ]
3
+ #![ move_size_limit = "1000" ]
4
+ // build-fail
5
+ // only-x86_64
6
+
7
+ // edition:2018
8
+ // compile-flags: -Zmir-opt-level=1
9
+
10
+ use std:: { sync:: Arc , rc:: Rc } ;
11
+
12
+ fn main ( ) {
13
+ let data = [ 0 ; 9999 ] ;
14
+
15
+ // Looking at --emit mir, we can see that all parameters below are passed by
16
+ // copy. But it requires at least mir-opt-level=1.
17
+ let _ = Arc :: new ( data) ; // OK!
18
+ let _ = Box :: new ( data) ; // OK!
19
+ let _ = Rc :: new ( data) ; // OK!
20
+ let _ = NotBox :: new ( data) ; //~ ERROR large_assignments
21
+ }
22
+
23
+ struct NotBox {
24
+ data : [ u8 ; 9999 ] ,
25
+ }
26
+
27
+ impl NotBox {
28
+ fn new ( data : [ u8 ; 9999 ] ) -> Self {
29
+ Self { //~ ERROR large_assignments
30
+ data,
31
+ }
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ error: moving 9999 bytes
2
+ --> $DIR/copy_into_box_rc_arc.rs:20:25
3
+ |
4
+ LL | let _ = NotBox::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/copy_into_box_rc_arc.rs:1:9
10
+ |
11
+ LL | #![deny(large_assignments)]
12
+ | ^^^^^^^^^^^^^^^^^
13
+
14
+ error: moving 9999 bytes
15
+ --> $DIR/copy_into_box_rc_arc.rs:29:9
16
+ |
17
+ LL | / Self {
18
+ LL | | data,
19
+ LL | | }
20
+ | |_________^ value moved from here
21
+ |
22
+ = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
23
+
24
+ error: aborting due to 2 previous errors
25
+
Original file line number Diff line number Diff line change 10
10
use std:: { sync:: Arc , rc:: Rc } ;
11
11
12
12
fn main ( ) {
13
+ // Looking at --emit mir, we can see that all parameters below are passed
14
+ // with by move.
13
15
let _ = Arc :: new ( [ 0 ; 9999 ] ) ; // OK!
14
16
let _ = Box :: new ( [ 0 ; 9999 ] ) ; // OK!
15
17
let _ = Rc :: new ( [ 0 ; 9999 ] ) ; // OK!
Original file line number Diff line number Diff line change 1
1
error: moving 9999 bytes
2
- --> $DIR/box_rc_arc_allowed .rs:16 :25
2
+ --> $DIR/move_into_box_rc_arc .rs:18 :25
3
3
|
4
4
LL | let _ = NotBox::new([0; 9999]);
5
5
| ^^^^^^^^^ value moved from here
6
6
|
7
7
= note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]`
8
8
note: the lint level is defined here
9
- --> $DIR/box_rc_arc_allowed .rs:1:9
9
+ --> $DIR/move_into_box_rc_arc .rs:1:9
10
10
|
11
11
LL | #![deny(large_assignments)]
12
12
| ^^^^^^^^^^^^^^^^^
13
13
14
14
error: moving 9999 bytes
15
- --> $DIR/box_rc_arc_allowed .rs:26 :13
15
+ --> $DIR/move_into_box_rc_arc .rs:28 :13
16
16
|
17
17
LL | data,
18
18
| ^^^^ value moved from here
You can’t perform that action at this time.
0 commit comments