Skip to content

attr: Register needs_allocator#4696

Open
nsvke wants to merge 1 commit into
Rust-GCC:masterfrom
nsvke:add-needs-allocator
Open

attr: Register needs_allocator#4696
nsvke wants to merge 1 commit into
Rust-GCC:masterfrom
nsvke:add-needs-allocator

Conversation

@nsvke

@nsvke nsvke commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This patch registers the 'needs_allocator' attribute, which is required for compiling the 'alloc' crate.

Currently, it is implemented as a stub that emits a compiler warning when encountered. The reoson for this temporary stub is that full handling of 'needs_allocator' strictly depends on the 'global_allocator' infrastructure and the 'core::alloc::GlobalAlloc' trait. Since gccrs does not yet have full support for the 'core' crate, a complete implementation is deferred.

gcc/rust/ChangeLog:

* checks/errors/rust-builtin-attribute-checker.cc (check_inner_attribute): Add warning for needs_allocator.
* util/rust-attribute-values.h (class Attributes): Add NEEDS_ALLOCATOR constexpr.
* util/rust-attributes.cc (__definitions): Add BuiltinAttrDefinition for new attribute.

gcc/testsuite/ChangeLog:

* rust/compile/needs_allocator.rs: New test.

This patch registers the 'needs_allocator' attribute, which is required
for compiling the 'alloc' crate.

Currently, it is implemented as a stub that emits a compiler warning
when encountered. The reoson for this temporary stub is that full
handling of 'needs_allocator' strictly depends on the 'global_allocator'
infrastructure and the 'core::alloc::GlobalAlloc' trait. Since gccrs
does not yet have full support for the 'core' crate, a complete
implementation is deferred.

gcc/rust/ChangeLog:

	* checks/errors/rust-builtin-attribute-checker.cc
	(check_inner_attribute): Add warning for needs_allocator.
	* util/rust-attribute-values.h (class Attributes): Add
	NEEDS_ALLOCATOR constexpr.
	* util/rust-attributes.cc (__definitions): Add
	BuiltinAttrDefinition for new attribute.

gcc/testsuite/ChangeLog:

	* rust/compile/needs_allocator.rs: New test.

Signed-off-by: Enes Cevik <enes@nsvke.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant