Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

gccrs#4696: Register needs_allocator

Link: Rust-GCC/gccrs#4696

Objective

This PR registers the #![needs_allocator] crate-level attribute.

Changes Made

Implemented as a temporary stub that emits a compiler warning. Full handling of needs_allocator requires the global allocator infrastructure and the core::alloc::GlobalAlloc trait. Since gccrs does not yet fully support the core crate, the complete implementation is deferred.

Why is this needed for alloc?

The alloc crate root defines #![needs_allocator] to signal to the compiler that the final binary needs a global allocator linked in. Registering the attribute is the first necessary step to prevent compilation failure when parsing the alloc crate.

Test Case

#![allow(unused)]
#![needs_allocator]
fn main() {
}