@@ -11,11 +11,6 @@ use core::{
11
11
use pinned_init:: * ;
12
12
use std:: sync:: Arc ;
13
13
14
- #[ expect( unused_attributes) ]
15
- #[ path = "../examples/mutex.rs" ]
16
- mod mutex;
17
- use mutex:: * ;
18
-
19
14
#[ expect( unused_attributes) ]
20
15
#[ path = "../examples/error.rs" ]
21
16
mod error;
@@ -244,6 +239,7 @@ fn with_failing_inner() {
244
239
assert_eq ! ( buf. as_mut( ) . pop( ) , None ) ;
245
240
}
246
241
242
+ #[ cfg_attr( miri, allow( dead_code) ) ]
247
243
#[ derive( Debug ) ]
248
244
struct BigStruct {
249
245
buf : [ u8 ; 1024 * 1024 ] ,
@@ -268,6 +264,11 @@ fn big_struct() {
268
264
#[ cfg( all( any( feature = "std" , feature = "alloc" ) , not( miri) ) ) ]
269
265
#[ test]
270
266
fn with_big_struct ( ) {
267
+ #[ expect( unused_attributes) ]
268
+ #[ path = "../examples/mutex.rs" ]
269
+ mod mutex;
270
+ use mutex:: * ;
271
+
271
272
let buf = Arc :: pin_init ( CMutex :: new ( RingBuffer :: < BigStruct , 64 > :: new ( ) ) ) . unwrap ( ) ;
272
273
let mut buf = buf. lock ( ) ;
273
274
for _ in 0 ..63 {
@@ -290,3 +291,25 @@ fn with_big_struct() {
290
291
assert ! ( buf. as_mut( ) . pop_no_stack( ) . is_some( ) ) ;
291
292
}
292
293
}
294
+
295
+ #[ cfg( all(
296
+ feature = "alloc" ,
297
+ not( miri) ,
298
+ not( NO_ALLOC_FAIL_TESTS ) ,
299
+ not( target_os = "macos" )
300
+ ) ) ]
301
+ #[ test]
302
+ fn too_big_pinned ( ) {
303
+ use core:: alloc:: AllocError ;
304
+
305
+ // should be too big with current hardware.
306
+ assert ! ( matches!(
307
+ Box :: pin_init( RingBuffer :: <u8 , { 1024 * 1024 * 1024 * 1024 } >:: new( ) ) ,
308
+ Err ( AllocError )
309
+ ) ) ;
310
+ // should be too big with current hardware.
311
+ assert ! ( matches!(
312
+ Arc :: pin_init( RingBuffer :: <u8 , { 1024 * 1024 * 1024 * 1024 } >:: new( ) ) ,
313
+ Err ( AllocError )
314
+ ) ) ;
315
+ }
0 commit comments