diff options
author | Dylan Reid <dgreid@chromium.org> | 2020-01-28 12:31:15 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-06 05:28:15 +0000 |
commit | 672559f91ae54664fc1f76326c0ecc4008da4c09 (patch) | |
tree | 05a1d14081aefbc91dcc3a3c4e3988688f1b84ee /bit_field/bit_field_derive/bit_field_derive.rs | |
parent | 3eb7927bcd1aeb5578aab3109b9fb90c7a641af5 (diff) | |
download | crosvm-672559f91ae54664fc1f76326c0ecc4008da4c09.tar crosvm-672559f91ae54664fc1f76326c0ecc4008da4c09.tar.gz crosvm-672559f91ae54664fc1f76326c0ecc4008da4c09.tar.bz2 crosvm-672559f91ae54664fc1f76326c0ecc4008da4c09.tar.lz crosvm-672559f91ae54664fc1f76326c0ecc4008da4c09.tar.xz crosvm-672559f91ae54664fc1f76326c0ecc4008da4c09.tar.zst crosvm-672559f91ae54664fc1f76326c0ecc4008da4c09.zip |
Update syn, quote, and proc-macro past 1.0
These were pinned at pre-1.0 versions. Update to the stable API to allow new features to be used in the future. Cq-Depend: chromium:2026764 Change-Id: Id2d979525e5210436cbb1cfa61e2b05fafb288f3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2025907 Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'bit_field/bit_field_derive/bit_field_derive.rs')
-rw-r--r-- | bit_field/bit_field_derive/bit_field_derive.rs | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/bit_field/bit_field_derive/bit_field_derive.rs b/bit_field/bit_field_derive/bit_field_derive.rs index 7084e22..92fea94 100644 --- a/bit_field/bit_field_derive/bit_field_derive.rs +++ b/bit_field/bit_field_derive/bit_field_derive.rs @@ -75,14 +75,14 @@ fn bitfield_tuple_struct_impl(ast: &DeriveInput, fields: &FieldsUnnamed) -> Resu let ident = &ast.ident; - if width.value() > 64 { + if width > 64 { return Err(Error::new( Span::call_site(), "max width of bitfield field is 64", )); } - let bits = width.value() as u8; + let bits = width as u8; if fields.unnamed.len() != 1 { return Err(Error::new( @@ -91,7 +91,7 @@ fn bitfield_tuple_struct_impl(ast: &DeriveInput, fields: &FieldsUnnamed) -> Resu )); } - let field_type = match &fields.unnamed.first().unwrap().value().ty { + let field_type = match &fields.unnamed.first().unwrap().ty { Type::Path(t) => t, _ => { return Err(Error::new( @@ -100,14 +100,7 @@ fn bitfield_tuple_struct_impl(ast: &DeriveInput, fields: &FieldsUnnamed) -> Resu )); } }; - let span = field_type - .path - .segments - .first() - .unwrap() - .value() - .ident - .span(); + let span = field_type.path.segments.first().unwrap().ident.span(); let from_u64 = quote_spanned! { span => val as #field_type @@ -145,22 +138,22 @@ fn bitfield_enum_impl(ast: &DeriveInput, data: &DataEnum) -> Result<TokenStream> let width = parse_remove_bits_attr(&mut ast)?; match width { None => bitfield_enum_without_width_impl(&ast, data), - Some(width) => bitfield_enum_with_width_impl(&ast, data, &width), + Some(width) => bitfield_enum_with_width_impl(&ast, data, width), } } fn bitfield_enum_with_width_impl( ast: &DeriveInput, data: &DataEnum, - width: &LitInt, + width: u64, ) -> Result<TokenStream> { - if width.value() > 64 { + if width > 64 { return Err(Error::new( Span::call_site(), "max width of bitfield enum is 64", )); } - let bits = width.value() as u8; + let bits = width as u8; let declare_discriminants = get_declare_discriminants_for_enum(bits, ast, data); let ident = &ast.ident; @@ -409,14 +402,14 @@ fn try_parse_bits_attr(attr: &Attribute) -> Result<Option<LitInt>> { Ok(None) } -fn parse_remove_bits_attr(ast: &mut DeriveInput) -> Result<Option<LitInt>> { +fn parse_remove_bits_attr(ast: &mut DeriveInput) -> Result<Option<u64>> { let mut width = None; let mut bits_idx = 0; for (i, attr) in ast.attrs.iter().enumerate() { if let Some(w) = try_parse_bits_attr(attr)? { bits_idx = i; - width = Some(w); + width = Some(w.base10_parse()?); } } |