Skip to main content

rustidy_ast/item/
macro_.rs

1//! Macro
2
3// Imports
4use {
5	crate::{
6		attr::TokenTree,
7		path::SimplePath,
8		token,
9		util::{Braced, Bracketed, Parenthesized},
10	},
11	rustidy_ast_util::delimited,
12	rustidy_format::{Format, Formattable, WhitespaceFormat},
13	rustidy_parse::Parse,
14	rustidy_print::Print,
15	rustidy_util::Whitespace,
16};
17
18/// `MacroInvocationSemi`
19#[derive(PartialEq, Eq, Clone, Debug)]
20#[derive(serde::Serialize, serde::Deserialize)]
21#[derive(Parse, Formattable, Format, Print)]
22pub enum MacroInvocationSemi {
23	Parens(MacroInvocationSemiParens),
24	Brackets(MacroInvocationSemiBrackets),
25	Braces(MacroInvocationSemiBraces),
26}
27
28#[derive(PartialEq, Eq, Clone, Debug)]
29#[derive(serde::Serialize, serde::Deserialize)]
30#[derive(Parse, Formattable, Format, Print)]
31pub struct MacroInvocationSemiParens {
32	pub path:   SimplePath,
33	#[format(prefix_ws = Whitespace::REMOVE)]
34	pub not:    token::Not,
35	#[format(prefix_ws = Whitespace::REMOVE)]
36	#[format(args = delimited::fmt_preserve())]
37	pub tokens: Parenthesized<MacroInvocationSemiTokens>,
38	#[format(prefix_ws = Whitespace::REMOVE)]
39	pub semi:   token::Semi,
40}
41
42#[derive(PartialEq, Eq, Clone, Debug)]
43#[derive(serde::Serialize, serde::Deserialize)]
44#[derive(Parse, Formattable, Format, Print)]
45pub struct MacroInvocationSemiBrackets {
46	pub path:   SimplePath,
47	#[format(prefix_ws = Whitespace::REMOVE)]
48	pub not:    token::Not,
49	#[format(prefix_ws = Whitespace::REMOVE)]
50	#[format(args = delimited::fmt_preserve())]
51	pub tokens: Bracketed<MacroInvocationSemiTokens>,
52	#[format(prefix_ws = Whitespace::REMOVE)]
53	pub semi:   token::Semi,
54}
55
56#[derive(PartialEq, Eq, Clone, Debug)]
57#[derive(serde::Serialize, serde::Deserialize)]
58#[derive(Parse, Formattable, Format, Print)]
59pub struct MacroInvocationSemiBraces {
60	pub path:   SimplePath,
61	#[format(prefix_ws = Whitespace::REMOVE)]
62	pub not:    token::Not,
63	#[format(prefix_ws = Whitespace::SINGLE)]
64	#[format(args = delimited::fmt_preserve())]
65	pub tokens: Braced<MacroInvocationSemiTokens>,
66}
67
68#[derive(PartialEq, Eq, Clone, Debug)]
69#[derive(serde::Serialize, serde::Deserialize)]
70#[derive(Parse, Formattable, Format, Print)]
71pub struct MacroInvocationSemiTokens(
72	#[format(args = rustidy_format::vec::args_prefix_ws(Whitespace::PRESERVE))]
73	Vec<TokenTree>,
74);