Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
300901b70509a0af2d971aa6f6104300da24212c
rust/tests/ui/proc-macro/auxiliary/derive-b-rpass.rs

18 lines
413 B
Rust
Raw Normal View History

tests: use `force-host` and `no-prefer-dynamic` in all proc_macro tests.
2018-11-24 15:34:13 +02:00
// force-host
Allow proc_macro functions to whitelist specific attributes By using a second attribute `attributes(Bar)` on proc_macro_derive, whitelist any attributes with the name `Bar` in the deriving item. This allows a proc_macro function to use custom attribtues without a custom attribute error or unused attribute lint.
2016-11-08 21:45:02 +10:30
// no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro_derive(B, attributes(B, C))]
pub fn derive(input: TokenStream) -> TokenStream {
let input = input.to_string();
expand: Stop using nonterminals for passing tokens to attribute and derive macros
2020-06-14 14:30:42 +03:00
assert!(input.contains("#[B [arbitrary tokens]]"));
Allow proc_macro functions to whitelist specific attributes By using a second attribute `attributes(Bar)` on proc_macro_derive, whitelist any attributes with the name `Bar` in the deriving item. This allows a proc_macro function to use custom attribtues without a custom attribute error or unused attribute lint.
2016-11-08 21:45:02 +10:30
assert!(input.contains("struct B {"));
assert!(input.contains("#[C]"));
"".parse().unwrap()
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 3235ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API