Auto merge of #52328 - petrochenkov:pmroot, r=alexcrichton

proc_macro: Fix crate root detection

Fixes https://github.com/rust-lang/rust/issues/52270
This commit is contained in:
bors 2018-07-14 04:19:44 +00:00
commit ccade97544
3 changed files with 39 additions and 10 deletions

View file

@ -0,0 +1,25 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// no-prefer-dynamic
#![feature(proc_macro)]
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::*;
fn foo(arg: TokenStream) -> TokenStream {
#[proc_macro]
pub fn foo(arg: TokenStream) -> TokenStream { arg }
//~^ ERROR functions tagged with `#[proc_macro]` must currently reside in the root of the crate
arg
}

View file

@ -0,0 +1,8 @@
error: functions tagged with `#[proc_macro]` must currently reside in the root of the crate
--> $DIR/non-root.rs:21:5
|
LL | pub fn foo(arg: TokenStream) -> TokenStream { arg }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error