Skip to content

strange scoping issue when trying to use alloc::vec![]  #61699

Description

@alex

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=74f146f90570f0e4bb9e2b957532290a

#![no_std]

extern crate alloc;

use alloc::vec::Vec;

pub fn f() -> Vec<u8> {
    let x = alloc::vec![
        0,
    ].into_boxed_slice();
    return x.to_vec();
}
   Compiling playground v0.0.1 (/playground)
error: cannot find macro `vec!` in this scope
  --> src/lib.rs:8:13
   |
8  |       let x = alloc::vec![
   |  _____________^
9  | |         0,
10 | |     ].into_boxed_slice();
   | |_____^
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

error: Could not compile `playground`.

If I change the invocation to alloc::vec![] it has no trouble finding the invocation. I have no idea what to make of this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions