Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smallvec macro in no_std code #197

Closed
debris opened this issue Jan 27, 2020 · 4 comments · Fixed by #198
Closed

smallvec macro in no_std code #197

debris opened this issue Jan 27, 2020 · 4 comments · Fixed by #198

Comments

@debris
Copy link

debris commented Jan 27, 2020

hey! I'm trying to use smallvec! macro in no_std library. Is it possible?

code:

smallvec![a];

fails with:

error: cannot find macro `vec` in this scope
  --> example.rs:2:1
   |
2  | smallvec![a]

I already imported extern crate alloc

@pshaughn
Copy link
Member

I haven't actually done this so forgive me if it's not on the right track: It looks like you need to macro_use extern crate std, since that's where vec! is defined.

@jdm
Copy link
Member

jdm commented Jan 27, 2020

@debris According to https://stackoverflow.com/questions/51516773/how-to-use-vec-macro-in-a-no-std-library you need to add a #[macro_use] to your extern crate alloc.

mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this issue Jan 27, 2020
@mbrubeck
Copy link
Collaborator

Submitted a fix in #198.

bors-servo pushed a commit that referenced this issue Jan 28, 2020
Use full path to vec! in smallvec! macro

Fixes #197
@mbrubeck
Copy link
Collaborator

Version 1.2.0 has been released with the fix included.

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 a pull request may close this issue.

4 participants