Skip to content

No global memory allocator error when testing no_std crate that does link to std #54010

Closed
@IsaacWoods

Description

@IsaacWoods

I have a no_std crate that imports std when testing:

#![no_std]
#![feature(alloc)]

extern crate alloc;

#[cfg(test)]
#[macro_use]
extern crate std;

However, I get this error during testing:

error: no global memory allocator found but one is required; link to std or add #[global_allocator] t
o a static item that implements the GlobalAlloc trait.

Allocating on the heap during testing does appear to work, so I'm assuming this is just a case of the warning still being emitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions