deny_public_fields: display field identifier in help message

Use a binding's field identifier to produce more descriptive output.
Fall back to a binding's identifier if a field identifier is not
available.

Additionally, make the privatize.rs compiletest more specific and
wrap the identifier in backticks to aid readability.
This commit is contained in:
Harvey Hunt 2017-06-24 00:21:52 +01:00
parent 946c9aede1
commit 6081241962
2 changed files with 3 additions and 1 deletions

View file

@ -17,7 +17,8 @@ fn expand_string(input: &str) -> String {
let style = synstructure::BindStyle::Ref.into();
synstructure::each_field(&type_, &style, |binding| {
if binding.field.vis != syn::Visibility::Inherited {
panic!("Field {} should not be public", binding.ident);
panic!("Field `{}` should not be public",
binding.field.ident.as_ref().unwrap_or(&binding.ident));
}
"".to_owned()
});