referrerpolicy=no-referrer-when-downgrade

frame_support_procedural/
dummy_part_checker.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18use crate::COUNTER;
19use proc_macro::TokenStream;
20
21pub fn generate_dummy_part_checker(input: TokenStream) -> TokenStream {
22	if !input.is_empty() {
23		return syn::Error::new(proc_macro2::Span::call_site(), "No arguments expected")
24			.to_compile_error()
25			.into()
26	}
27
28	let count = COUNTER.with(|counter| counter.borrow_mut().inc());
29
30	let no_op_macro_ident =
31		syn::Ident::new(&format!("__dummy_part_checker_{}", count), proc_macro2::Span::call_site());
32
33	quote::quote!(
34		#[macro_export]
35		#[doc(hidden)]
36		macro_rules! #no_op_macro_ident {
37			( $( $tt:tt )* ) => {};
38		}
39
40		#[doc(hidden)]
41		pub mod __substrate_genesis_config_check {
42			#[doc(hidden)]
43			pub use #no_op_macro_ident as is_genesis_config_defined;
44			#[doc(hidden)]
45			pub use #no_op_macro_ident as is_std_enabled_for_genesis;
46		}
47
48		#[doc(hidden)]
49		pub mod __substrate_event_check {
50			#[doc(hidden)]
51			pub use #no_op_macro_ident as is_event_part_defined;
52		}
53
54		#[doc(hidden)]
55		pub mod __substrate_inherent_check {
56			#[doc(hidden)]
57			pub use #no_op_macro_ident as is_inherent_part_defined;
58		}
59
60		#[doc(hidden)]
61		pub mod __substrate_validate_unsigned_check {
62			#[doc(hidden)]
63			pub use #no_op_macro_ident as is_validate_unsigned_part_defined;
64		}
65
66		#[doc(hidden)]
67		pub mod __substrate_call_check {
68			#[doc(hidden)]
69			pub use #no_op_macro_ident as is_call_part_defined;
70		}
71
72		#[doc(hidden)]
73		pub mod __substrate_origin_check {
74			#[doc(hidden)]
75			pub use #no_op_macro_ident as is_origin_part_defined;
76		}
77	)
78	.into()
79}