1- //@ compile-flags: -Copt-level=3
1+ //@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes
22
33#![ crate_type = "lib" ]
44#![ allow( internal_features) ]
@@ -28,7 +28,9 @@ pub fn use_big_struct_immutably(big_struct: BigStruct) {
2828
2929// The by-value parameter for this big struct can't be marked readonly, because we mutate it.
3030//
31- // CHECK-NOT: @use_big_struct_mutably({{.*}} readonly {{.*}} %big_struct)
31+ // CHECK: @use_big_struct_mutably(
32+ // CHECK-NOT: readonly
33+ // CHECK-SAME: %big_struct)
3234#[ no_mangle]
3335pub fn use_big_struct_mutably ( mut big_struct : BigStruct ) {
3436 big_struct. blah [ 987 ] = 654 ;
@@ -38,7 +40,9 @@ pub fn use_big_struct_mutably(mut big_struct: BigStruct) {
3840// The by-value parameter for this big struct can't be marked readonly, because it contains
3941// UnsafeCell.
4042//
41- // CHECK-NOT: @use_big_cell_container({{.*}} readonly {{.*}} %big_cell_container)
43+ // CHECK: @use_big_cell_container(
44+ // CHECK-NOT: readonly
45+ // CHECK-SAME: %big_cell_container)
4246#[ no_mangle]
4347pub fn use_big_cell_container ( big_cell_container : BigCellContainer ) {
4448 hint:: black_box ( & big_cell_container) ;
@@ -47,14 +51,34 @@ pub fn use_big_cell_container(big_cell_container: BigCellContainer) {
4751// Make sure that we don't mistakenly mark a big struct as `readonly` when passed through a generic
4852// type parameter if it contains UnsafeCell.
4953//
50- // CHECK-NOT: @use_something({{.*}} readonly {{.*}} %something)
54+ // CHECK: @use_something(
55+ // CHECK-NOT: readonly
56+ // CHECK-SAME: %something)
5157#[ no_mangle]
5258#[ inline( never) ]
5359pub fn use_something < T > ( something : T ) {
5460 hint:: black_box ( & something) ;
5561}
5662
63+ // Make sure that we still mark a big `Freeze` struct as `readonly` when passed through a generic
64+ // type parameter.
65+ //
66+ // CHECK: @use_something_freeze(
67+ // CHECK-SAME: readonly
68+ // CHECK-SAME: %x)
69+ #[ no_mangle]
70+ #[ inline( never) ]
71+ pub fn use_something_freeze < T > ( x : T ) {
72+ // `Drop` counts as a mutable use.
73+ std:: mem:: forget ( x)
74+ }
75+
5776#[ no_mangle]
5877pub fn forward_big_cell_container ( big_cell_container : BigCellContainer ) {
5978 use_something ( big_cell_container)
6079}
80+
81+ #[ no_mangle]
82+ pub fn forward_big_container ( big_struct : BigStruct ) {
83+ use_something_freeze ( big_struct)
84+ }
0 commit comments