4 #![allow(incomplete_features)]
5 #![feature(unsized_locals, unsized_fn_params)]
10 // Check to make sure that we can deduce the `readonly` attribute from function bodies for
11 // parameters passed indirectly.
13 pub struct BigStruct {
17 pub struct BigCellContainer {
18 blah: [Cell<i32>; 1024],
21 // The by-value parameter for this big struct can be marked readonly.
23 // CHECK: @use_big_struct_immutably({{.*}} readonly {{.*}} %big_struct)
25 pub fn use_big_struct_immutably(big_struct: BigStruct) {
26 hint::black_box(&big_struct);
29 // The by-value parameter for this big struct can't be marked readonly, because we mutate it.
31 // CHECK-NOT: @use_big_struct_mutably({{.*}} readonly {{.*}} %big_struct)
33 pub fn use_big_struct_mutably(mut big_struct: BigStruct) {
34 big_struct.blah[987] = 654;
35 hint::black_box(&big_struct);
38 // The by-value parameter for this big struct can't be marked readonly, because it contains
41 // CHECK-NOT: @use_big_cell_container({{.*}} readonly {{.*}} %big_cell_container)
43 pub fn use_big_cell_container(big_cell_container: BigCellContainer) {
44 hint::black_box(&big_cell_container);
47 // Make sure that we don't mistakenly mark a big struct as `readonly` when passed through a generic
48 // type parameter if it contains UnsafeCell.
50 // CHECK-NOT: @use_something({{.*}} readonly {{.*}} %something)
53 pub fn use_something<T>(something: T) {
54 hint::black_box(&something);
58 pub fn forward_big_cell_container(big_cell_container: BigCellContainer) {
59 use_something(big_cell_container)