- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Closed
Labels
A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)Area: Declarative macros 2.0 (#39412)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Following up on #38356 (comment).
Right now, the prelude is in scope at the definition site (unless the proc-macro crate is
#![no_implicit_prelude]) and this is an accident (in some sense) due to the phase 0 vs phase 1 distinction as you point out.However, I think that phase 1 should implicitly contain
stdat the proc-macro root (so that you can alwaysquote!(use std::...);) and the prelude for convenience/ergonomics and since these are already implicit in phase 0. There will be a PR to addstdat the root in phase 1 soon.
The following procedural macro invocation should compile and print None.
#![feature(proc_macro)]
extern crate proc_macro;
use proc_macro::{quote, TokenStream};
#[proc_macro]
pub fn none(input: TokenStream) -> TokenStream {
    quote! {
        // Works currently, because `None` is in the prelude.
        //None::<$input>
        // Does not work, but should.
        std::option::Option::None::<$input>
    }
}#![feature(proc_macro)]
extern crate mac;
fn main() {
    println!("{:?}", mac::none!(u8));
}Metadata
Metadata
Assignees
Labels
A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)Area: Declarative macros 2.0 (#39412)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.