resolve: Introduce two sub-namespaces in macro namespace
This commit is contained in:
parent
994cdd9185
commit
beb3b5d22c
10 changed files with 64 additions and 35 deletions
|
|
@ -0,0 +1,2 @@
|
|||
#[macro_export]
|
||||
macro_rules! my_attr { () => () }
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// no-prefer-dynamic
|
||||
|
||||
#![crate_type = "proc-macro"]
|
||||
|
||||
extern crate proc_macro;
|
||||
use proc_macro::*;
|
||||
|
||||
#[proc_macro_derive(MyTrait, attributes(my_attr))]
|
||||
pub fn foo(_: TokenStream) -> TokenStream {
|
||||
TokenStream::new()
|
||||
}
|
||||
16
src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs
Normal file
16
src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// compile-pass
|
||||
// aux-build:derive-helper-shadowed.rs
|
||||
// aux-build:derive-helper-shadowed-2.rs
|
||||
|
||||
#[macro_use]
|
||||
extern crate derive_helper_shadowed;
|
||||
#[macro_use(my_attr)]
|
||||
extern crate derive_helper_shadowed_2;
|
||||
|
||||
macro_rules! my_attr { () => () }
|
||||
|
||||
#[derive(MyTrait)]
|
||||
#[my_attr] // OK
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -9,5 +9,5 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
concat!(test!()); //~ ERROR `test` can only be used in attributes
|
||||
concat!(test!()); //~ ERROR cannot find macro `test!` in this scope
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
error: `test` can only be used in attributes
|
||||
error: cannot find macro `test!` in this scope
|
||||
--> $DIR/issue-11692-2.rs:12:13
|
||||
|
|
||||
LL | concat!(test!()); //~ ERROR `test` can only be used in attributes
|
||||
LL | concat!(test!()); //~ ERROR cannot find macro `test!` in this scope
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
|
|||
|
|
@ -1,16 +1,3 @@
|
|||
// 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.
|
||||
|
||||
#[derive(inline)] //~ ERROR cannot find derive macro `inline` in this scope
|
||||
struct S;
|
||||
|
||||
fn main() {
|
||||
inline!(); //~ ERROR cannot find macro `inline!` in this scope
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
error: cannot find derive macro `inline` in this scope
|
||||
--> $DIR/macro-path-prelude-fail-3.rs:11:10
|
||||
|
|
||||
LL | #[derive(inline)] //~ ERROR cannot find derive macro `inline` in this scope
|
||||
| ^^^^^^
|
||||
|
||||
error: cannot find macro `inline!` in this scope
|
||||
--> $DIR/macro-path-prelude-fail-3.rs:15:5
|
||||
--> $DIR/macro-path-prelude-fail-3.rs:2:5
|
||||
|
|
||||
LL | inline!(); //~ ERROR cannot find macro `inline!` in this scope
|
||||
| ^^^^^^ help: you could try the macro: `line`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
|||
4
src/test/ui/macros/macro-path-prelude-fail-4.rs
Normal file
4
src/test/ui/macros/macro-path-prelude-fail-4.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#[derive(inline)] //~ ERROR expected a macro, found built-in attribute
|
||||
struct S;
|
||||
|
||||
fn main() {}
|
||||
8
src/test/ui/macros/macro-path-prelude-fail-4.stderr
Normal file
8
src/test/ui/macros/macro-path-prelude-fail-4.stderr
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
error: expected a macro, found built-in attribute
|
||||
--> $DIR/macro-path-prelude-fail-4.rs:1:10
|
||||
|
|
||||
LL | #[derive(inline)] //~ ERROR expected a macro, found built-in attribute
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue