mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
Silence non_upper_case_globals warnings in macros
The enumn and bitfield macros generate global constants based on names that are typically in CamelCase, but the new on-by-default warning non_upper_case_globals complains about them. Fixes warnings of the form: warning: associated constant `...` should have an upper case name when using enumn or bitfield. BUG=None TEST=`cargo build` without warnings Change-Id: Id908df1dcdf58288c2cbdff574cb70be2026bde6 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1536558 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
This commit is contained in:
parent
48ff4165d2
commit
7154c1d8ae
3 changed files with 4 additions and 0 deletions
|
@ -319,6 +319,7 @@ fn get_declare_discriminants_for_enum(
|
|||
};
|
||||
|
||||
quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
const #variant: u64 = {
|
||||
const IS_IN_BOUNDS: bool = (#ident::#variant as u64) < #upper_bound;
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@ fn testable_derive(input: DeriveInput) -> proc_macro2::TokenStream {
|
|||
});
|
||||
|
||||
quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
impl #ident {
|
||||
pub #signature -> Option<Self> {
|
||||
struct discriminant;
|
||||
|
|
|
@ -17,6 +17,7 @@ fn test_repr() {
|
|||
};
|
||||
let actual = crate::testable_derive(input);
|
||||
let expected = quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
impl E {
|
||||
pub fn n(value: u8) -> Option<Self> {
|
||||
struct discriminant;
|
||||
|
@ -48,6 +49,7 @@ fn test_no_repr() {
|
|||
};
|
||||
let actual = crate::testable_derive(input);
|
||||
let expected = quote! {
|
||||
#[allow(non_upper_case_globals)]
|
||||
impl E {
|
||||
pub fn n<REPR: Into<i64>>(value: REPR) -> Option<Self> {
|
||||
struct discriminant;
|
||||
|
|
Loading…
Reference in a new issue