2021-07-04 06:06:23 -05:00
|
|
|
// aux-build:proc_macro_derive.rs
|
2022-09-19 11:08:28 -05:00
|
|
|
// run-rustfix
|
2021-07-04 06:06:23 -05:00
|
|
|
|
2021-07-03 00:14:32 -05:00
|
|
|
#![warn(clippy::nonstandard_macro_braces)]
|
2021-05-30 16:58:32 -05:00
|
|
|
|
2021-07-04 06:06:23 -05:00
|
|
|
extern crate proc_macro_derive;
|
2021-05-30 16:58:32 -05:00
|
|
|
extern crate quote;
|
|
|
|
|
|
|
|
use quote::quote;
|
|
|
|
|
2021-07-04 06:06:23 -05:00
|
|
|
#[derive(proc_macro_derive::DeriveSomething)]
|
|
|
|
pub struct S;
|
|
|
|
|
|
|
|
proc_macro_derive::foo_bar!();
|
|
|
|
|
2021-05-30 16:58:32 -05:00
|
|
|
#[rustfmt::skip]
|
|
|
|
macro_rules! test {
|
|
|
|
() => {
|
|
|
|
vec!{0, 0, 0}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[rustfmt::skip]
|
|
|
|
macro_rules! test2 {
|
|
|
|
($($arg:tt)*) => {
|
|
|
|
format_args!($($arg)*)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! type_pos {
|
|
|
|
($what:ty) => {
|
|
|
|
Vec<$what>
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-21 06:28:52 -05:00
|
|
|
macro_rules! printlnfoo {
|
|
|
|
($thing:expr) => {
|
2021-07-22 07:55:45 -05:00
|
|
|
println!("{}", $thing)
|
2021-07-21 06:28:52 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-05-30 16:58:32 -05:00
|
|
|
#[rustfmt::skip]
|
|
|
|
fn main() {
|
|
|
|
let _ = vec! {1, 2, 3};
|
|
|
|
let _ = format!["ugh {} stop being such a good compiler", "hello"];
|
2022-09-13 05:08:17 -05:00
|
|
|
let _ = matches!{{}, ()};
|
2021-05-30 16:58:32 -05:00
|
|
|
let _ = quote!(let x = 1;);
|
|
|
|
let _ = quote::quote!(match match match);
|
2021-07-24 06:03:52 -05:00
|
|
|
let _ = test!(); // trigger when macro def is inside our own crate
|
2021-05-30 16:58:32 -05:00
|
|
|
let _ = vec![1,2,3];
|
|
|
|
|
|
|
|
let _ = quote::quote! {true || false};
|
|
|
|
let _ = vec! [0 ,0 ,0];
|
|
|
|
let _ = format!("fds{}fds", 10);
|
|
|
|
let _ = test2!["{}{}{}", 1, 2, 3];
|
|
|
|
|
|
|
|
let _: type_pos!(usize) = vec![];
|
|
|
|
|
|
|
|
eprint!("test if user config overrides defaults");
|
2021-07-21 06:28:52 -05:00
|
|
|
|
2021-07-22 07:55:45 -05:00
|
|
|
printlnfoo!["test if printlnfoo is triggered by println"];
|
2021-05-30 16:58:32 -05:00
|
|
|
}
|