Skip to content

Commit 8f69a82

Browse files
add test for proc-macro re-export
1 parent f05b744 commit 8f69a82

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// no-prefer-dynamic
12+
13+
#![crate_type="proc-macro"]
14+
#![crate_name="some_macros"]
15+
16+
extern crate proc_macro;
17+
18+
use proc_macro::TokenStream;
19+
20+
/// a proc-macro that swallows its input and does nothing.
21+
#[proc_macro]
22+
pub fn some_proc_macro(_input: TokenStream) -> TokenStream {
23+
TokenStream::new()
24+
}
25+
26+
/// a proc-macro attribute that passes its item through verbatim.
27+
#[proc_macro_attribute]
28+
pub fn some_proc_attr(_attr: TokenStream, item: TokenStream) -> TokenStream {
29+
item
30+
}
31+
32+
/// a derive attribute that adds nothing to its input.
33+
#[proc_macro_derive(SomeDerive)]
34+
pub fn some_derive(_item: TokenStream) -> TokenStream {
35+
TokenStream::new()
36+
}
37+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// ignore-stage1
12+
// aux-build:proc_macro.rs
13+
// build-aux-docs
14+
15+
// FIXME: if/when proc-macros start exporting their doc attributes across crates, we can turn on
16+
// cross-crate inlining for them
17+
18+
extern crate some_macros;
19+
20+
// @has proc_macro/index.html
21+
// @has - '//a/@href' '../some_macros/macro.some_proc_macro.html'
22+
// @has - '//a/@href' '../some_macros/attr.some_proc_attr.html'
23+
// @has - '//a/@href' '../some_macros/derive.SomeDerive.html'
24+
// @!has proc_macro/macro.some_proc_macro.html
25+
// @!has proc_macro/attr.some_proc_attr.html
26+
// @!has proc_macro/derive.SomeDerive.html
27+
pub use some_macros::{some_proc_macro, some_proc_attr, SomeDerive};

0 commit comments

Comments
 (0)