@@ -5,9 +5,8 @@ pub mod lazy;
55
66pub use lazy:: { InstructionContext , MaybeAccount } ;
77
8- #[ cfg( not( feature = "alloc" ) ) ]
9- use core:: alloc:: { GlobalAlloc , Layout } ;
108use core:: {
9+ alloc:: { GlobalAlloc , Layout } ,
1110 cmp:: min,
1211 mem:: { size_of, MaybeUninit } ,
1312 ptr:: with_exposed_provenance_mut,
@@ -523,17 +522,6 @@ macro_rules! default_allocator {
523522 } ;
524523}
525524
526- /// A global allocator that does not allocate memory.
527- ///
528- /// Using this macro with the `"alloc"` feature enabled will result in a compile error.
529- #[ cfg( feature = "alloc" ) ]
530- #[ macro_export]
531- macro_rules! no_allocator {
532- ( ) => {
533- compile_error!( "Feature 'alloc' cannot be enabled." ) ;
534- } ;
535- }
536-
537525/// A global allocator that does not dynamically allocate memory.
538526///
539527/// This macro sets up a global allocator that denies all dynamic allocations, while allowing static
@@ -543,7 +531,6 @@ macro_rules! no_allocator {
543531/// The program will panic if it tries to dynamically allocate memory.
544532///
545533/// This is used when the `"alloc"` feature is disabled.
546- #[ cfg( not( feature = "alloc" ) ) ]
547534#[ macro_export]
548535macro_rules! no_allocator {
549536 ( ) => {
@@ -602,17 +589,15 @@ macro_rules! no_allocator {
602589 } ;
603590}
604591
605- #[ cfg( not( feature = "alloc" ) ) ]
606592/// An allocator that does not allocate memory.
607593#[ cfg_attr( feature = "copy" , derive( Copy ) ) ]
608594#[ derive( Clone , Debug ) ]
609595pub struct NoAllocator ;
610596
611- #[ cfg( not( feature = "alloc" ) ) ]
612597unsafe impl GlobalAlloc for NoAllocator {
613598 #[ inline]
614599 unsafe fn alloc ( & self , _: Layout ) -> * mut u8 {
615- panic ! ( "** NO ALLOCATOR **" ) ;
600+ panic ! ( "** NoAllocator::alloc() does not allocate memory **" ) ;
616601 }
617602
618603 #[ inline]
0 commit comments