Skip to content

Commit

Permalink
Update syn dependency (#172)
Browse files Browse the repository at this point in the history
* Update syn

* impl_trait_projections is now stable

* Update embassy rev.
  • Loading branch information
rmja authored Oct 17, 2023
1 parent 31a45fc commit d2175b4
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 58 deletions.
1 change: 0 additions & 1 deletion atat/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@
#![cfg_attr(all(not(test), not(feature = "std")), no_std)]
#![cfg_attr(feature = "async", allow(incomplete_features))]
#![cfg_attr(feature = "async", feature(async_fn_in_trait))]

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (thumbv6m-none-eabi, derive, log)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (thumbv6m-none-eabi)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (x86_64-unknown-linux-gnu)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (thumbv6m-none-eabi, derive)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

warning: the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable --> atat/src/lib.rs:221:40 | 221 | #![cfg_attr(feature = "async", feature(async_fn_in_trait))] | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(stable_features)]` on by default

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (x86_64-unknown-linux-gnu, derive, defmt)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (thumbv6m-none-eabi, derive, defmt)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (x86_64-unknown-linux-gnu, derive)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Build (x86_64-unknown-linux-gnu, derive, log)

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable

Check warning on line 221 in atat/src/lib.rs

View workflow job for this annotation

GitHub Actions / Test

the feature `async_fn_in_trait` has been stable since 1.75.0-nightly and no longer requires an attribute to enable
#![cfg_attr(feature = "async", feature(impl_trait_projections))]

// This mod MUST go first, so that the others see its macros.
pub(crate) mod fmt;
Expand Down
2 changes: 1 addition & 1 deletion atat_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["derive", "AT"]

[dependencies]
quote = "^1"
syn = { version = "^1", features = ["full"] }
syn = "2"
proc-macro2 = "^1"
serde_at = { path = "../serde_at", version = "^0.19.1" }

Expand Down
4 changes: 2 additions & 2 deletions atat_derive/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::parse::Variant;
use proc_macro2::{Literal, Span, TokenStream};
use quote::{format_ident, quote};
use syn::{parse_quote, GenericParam, Generics, Ident, Lifetime, LifetimeDef, TypeParamBound};
use syn::{parse_quote, GenericParam, Generics, Ident, Lifetime, LifetimeParam, TypeParamBound};

/// Adds a single lifetime symbol eg. <'a>
#[inline]
pub fn add_lifetime(generics: &mut Generics, lifetime_symbol: &str) {
generics
.params
.push(GenericParam::Lifetime(LifetimeDef::new(Lifetime::new(
.push(GenericParam::Lifetime(LifetimeParam::new(Lifetime::new(
lifetime_symbol,
Span::call_site(),
))));
Expand Down
100 changes: 50 additions & 50 deletions atat_derive/src/parse.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use proc_macro2::Span;
use syn::parse::{Error, Parse, ParseStream, Parser, Result};
use syn::parse::{Error, Parse, ParseStream, Result};
use syn::{
parenthesized, Attribute, Data, DataEnum, DataStruct, DeriveInput, Fields, Generics, Ident,
Attribute, Data, DataEnum, DataStruct, DeriveInput, Expr, ExprLit, Fields, Generics, Ident,
Lit, LitByteStr, Path, Type,
};

Expand Down Expand Up @@ -74,21 +74,11 @@ pub fn parse_field_attr(attributes: &[Attribute]) -> Result<FieldAttributes> {
at_arg: None,
};
for attr in attributes {
if attr.path.is_ident("at_arg") {
fn at_arg(input: ParseStream) -> Result<ArgAttributes> {
let content;
parenthesized!(content in input);
content.parse()
}
attrs.at_arg = Some(at_arg.parse2(attr.tokens.clone())?);
if attr.path().is_ident("at_arg") {
attrs.at_arg = Some(attr.parse_args()?);
}
if attr.path.is_ident("at_urc") {
fn at_urc(input: ParseStream) -> Result<UrcAttributes> {
let content;
parenthesized!(content in input);
content.parse()
}
attrs.at_urc = Some(at_urc.parse2(attr.tokens.clone())?);
if attr.path().is_ident("at_urc") {
attrs.at_urc = Some(attr.parse_args()?);
}
}
Ok(attrs)
Expand Down Expand Up @@ -176,8 +166,10 @@ impl Parse for ArgAttributes {
while {
match input.parse::<syn::Meta>()? {
syn::Meta::NameValue(name_value) if name_value.path.is_ident("value") => {
match name_value.lit.clone() {
Lit::Int(v) => attrs.value = Some(v.base10_parse().unwrap()),
match name_value.value.clone() {
Expr::Lit(ExprLit {
lit: Lit::Int(v), ..
}) => attrs.value = Some(v.base10_parse().unwrap()),
_ => {
return Err(Error::new(
Span::call_site(),
Expand All @@ -187,8 +179,10 @@ impl Parse for ArgAttributes {
}
}
syn::Meta::NameValue(name_value) if name_value.path.is_ident("position") => {
match name_value.lit.clone() {
Lit::Int(v) => attrs.position = Some(v.base10_parse().unwrap()),
match name_value.value.clone() {
Expr::Lit(ExprLit {
lit: Lit::Int(v), ..
}) => attrs.position = Some(v.base10_parse().unwrap()),
_ => {
return Err(Error::new(
Span::call_site(),
Expand All @@ -198,8 +192,10 @@ impl Parse for ArgAttributes {
}
}
syn::Meta::NameValue(name_value) if name_value.path.is_ident("len") => {
match name_value.lit.clone() {
Lit::Int(v) => attrs.len = Some(v.base10_parse().unwrap()),
match name_value.value.clone() {
Expr::Lit(ExprLit {
lit: Lit::Int(v), ..
}) => attrs.len = Some(v.base10_parse().unwrap()),
_ => {
return Err(Error::new(
Span::call_site(),
Expand Down Expand Up @@ -266,8 +262,10 @@ impl Parse for CmdAttributes {
while input.parse::<syn::token::Comma>().is_ok() {
let optional = input.parse::<syn::MetaNameValue>()?;
if optional.path.is_ident("timeout_ms") {
match optional.lit {
Lit::Int(v) => {
match optional.value {
Expr::Lit(ExprLit {
lit: Lit::Int(v), ..
}) => {
at_cmd.timeout_ms = Some(v.base10_parse().unwrap());
}
_ => {
Expand All @@ -278,8 +276,10 @@ impl Parse for CmdAttributes {
}
}
} else if optional.path.is_ident("attempts") {
match optional.lit {
Lit::Int(v) => {
match optional.value {
Expr::Lit(ExprLit {
lit: Lit::Int(v), ..
}) => {
at_cmd.attempts = Some(v.base10_parse().unwrap());
}
_ => {
Expand All @@ -290,22 +290,28 @@ impl Parse for CmdAttributes {
}
}
} else if optional.path.is_ident("abortable") {
match optional.lit {
Lit::Bool(v) => {
match optional.value {
Expr::Lit(ExprLit {
lit: Lit::Bool(v), ..
}) => {
at_cmd.abortable = Some(v.value);
}
_ => return Err(Error::new(call_site, "expected bool value for 'abortable'")),
}
} else if optional.path.is_ident("value_sep") {
match optional.lit {
Lit::Bool(v) => {
match optional.value {
Expr::Lit(ExprLit {
lit: Lit::Bool(v), ..
}) => {
at_cmd.value_sep = v.value;
}
_ => return Err(Error::new(call_site, "expected bool value for 'value_sep'")),
}
} else if optional.path.is_ident("cmd_prefix") {
match optional.lit {
Lit::Str(v) => {
match optional.value {
Expr::Lit(ExprLit {
lit: Lit::Str(v), ..
}) => {
at_cmd.cmd_prefix = v.value();
}
_ => {
Expand All @@ -316,8 +322,10 @@ impl Parse for CmdAttributes {
}
}
} else if optional.path.is_ident("termination") {
match optional.lit {
Lit::Str(v) => {
match optional.value {
Expr::Lit(ExprLit {
lit: Lit::Str(v), ..
}) => {
at_cmd.termination = v.value();
}
_ => {
Expand All @@ -328,8 +336,10 @@ impl Parse for CmdAttributes {
}
}
} else if optional.path.is_ident("quote_escape_strings") {
match optional.lit {
Lit::Bool(v) => {
match optional.value {
Expr::Lit(ExprLit {
lit: Lit::Bool(v), ..
}) => {
at_cmd.quote_escape_strings = v.value;
}
_ => {
Expand All @@ -355,21 +365,11 @@ impl Parse for ParseInput {

// Parse valid container attributes
for attr in derive_input.attrs {
if attr.path.is_ident("at_cmd") {
fn at_cmd_arg(input: ParseStream) -> Result<CmdAttributes> {
let content;
parenthesized!(content in input);
content.parse()
}
at_cmd = Some(at_cmd_arg.parse2(attr.tokens)?);
} else if attr.path.is_ident("at_enum") {
fn at_enum_arg(input: ParseStream) -> Result<Ident> {
let content;
parenthesized!(content in input);
content.parse()
}
if attr.path().is_ident("at_cmd") {
at_cmd = Some(attr.parse_args()?);
} else if attr.path().is_ident("at_enum") {
at_enum = Some(EnumAttributes {
repr: at_enum_arg.parse2(attr.tokens)?,
repr: attr.parse_args()?,
});
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ cortex-m = { version = "0.7.6", optional = true }
cortex-m-rt = { version = "0.7.3", optional = true }
defmt-rtt = { version = "0.4", optional = true }
panic-probe = { version = "0.3.0", features = ["print-defmt"], optional = true }
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "fcb77f3f96479b371e1279c9feed7eddf6b53083", features = [
embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "f0497039ed9a735dc5bc8cb05db98b35bc6b673a", features = [
"defmt",
"nightly",
"integrated-timers",
], optional = true }
embassy-time = { version = "0.1.0" }
embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "fcb77f3f96479b371e1279c9feed7eddf6b53083", features = [
embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "f0497039ed9a735dc5bc8cb05db98b35bc6b673a", features = [
"unstable-pac",
"nightly",
"time-driver",
Expand Down Expand Up @@ -71,5 +71,5 @@ std = [
"embassy-time/generic-queue",
"critical-section/std",
"embedded-io-adapters",
"embedded-io-adapters/tokio-1"
"embedded-io-adapters/tokio-1",
]
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly
nightly-2023-10-02

0 comments on commit d2175b4

Please sign in to comment.