@@ -11,11 +11,6 @@ use core::{
1111use pinned_init:: * ;
1212use std:: sync:: Arc ;
1313
14- #[ expect( unused_attributes) ]
15- #[ path = "../examples/mutex.rs" ]
16- mod mutex;
17- use mutex:: * ;
18-
1914#[ expect( unused_attributes) ]
2015#[ path = "../examples/error.rs" ]
2116mod error;
@@ -244,6 +239,7 @@ fn with_failing_inner() {
244239 assert_eq ! ( buf. as_mut( ) . pop( ) , None ) ;
245240}
246241
242+ #[ cfg_attr( miri, allow( dead_code) ) ]
247243#[ derive( Debug ) ]
248244struct BigStruct {
249245 buf : [ u8 ; 1024 * 1024 ] ,
@@ -268,6 +264,11 @@ fn big_struct() {
268264#[ cfg( all( any( feature = "std" , feature = "alloc" ) , not( miri) ) ) ]
269265#[ test]
270266fn with_big_struct ( ) {
267+ #[ expect( unused_attributes) ]
268+ #[ path = "../examples/mutex.rs" ]
269+ mod mutex;
270+ use mutex:: * ;
271+
271272 let buf = Arc :: pin_init ( CMutex :: new ( RingBuffer :: < BigStruct , 64 > :: new ( ) ) ) . unwrap ( ) ;
272273 let mut buf = buf. lock ( ) ;
273274 for _ in 0 ..63 {
@@ -290,3 +291,25 @@ fn with_big_struct() {
290291 assert ! ( buf. as_mut( ) . pop_no_stack( ) . is_some( ) ) ;
291292 }
292293}
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