From 6081241962476ccb7f85dfa251977ecf88f047d7 Mon Sep 17 00:00:00 2001 From: Harvey Hunt Date: Sat, 24 Jun 2017 00:21:52 +0100 Subject: 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. --- components/deny_public_fields/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'components/deny_public_fields') diff --git a/components/deny_public_fields/lib.rs b/components/deny_public_fields/lib.rs index a43db51e4af..e9b8b7938a2 100644 --- a/components/deny_public_fields/lib.rs +++ b/components/deny_public_fields/lib.rs @@ -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() }); -- cgit v1.2.3