deny_public_fields/
lib.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use std::str::FromStr;
6
7use synstructure::{self, decl_derive};
8
9decl_derive!([DenyPublicFields] => deny_public_fields_derive);
10
11fn deny_public_fields_derive(s: synstructure::Structure) -> proc_macro::TokenStream {
12    s.each(|binding| {
13        if binding.ast().vis != syn::Visibility::Inherited {
14            panic!(
15                "Field `{}` should not be public",
16                binding.ast().ident.as_ref().unwrap_or(&binding.binding)
17            );
18        }
19
20        "".to_owned()
21    });
22
23    proc_macro::TokenStream::from_str("").unwrap()
24}