Add cast to type for constants to avoid mis-typing.

This commit is contained in:
Stephen Chung
2020-09-13 22:36:24 +08:00
committed by J Henry Waugh
parent 848bdf3f01
commit 6dc5a81d53
3 changed files with 6 additions and 5 deletions

View File

@@ -140,12 +140,13 @@ impl Parse for Module {
ref expr,
ident,
attrs,
ty,
..
}) => {
// #[cfg] attributes are not allowed on const declarations
crate::attrs::deny_cfg_attr(&attrs)?;
if let syn::Visibility::Public(_) = vis {
consts.push((ident.to_string(), expr.as_ref().clone()));
consts.push((ident.to_string(), ty.clone(), expr.as_ref().clone()));
}
}
_ => {}