Skip to content

Commit d43378e

Browse files
wanda-phimeithecatte
authored andcommitted
Update syn to v2
This requires bumping MSRV to 1.56.
1 parent c898257 commit d43378e

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ readme = "README.md"
99
keywords = ["enum", "bitflag", "flag", "bitflags"]
1010
documentation = "https://docs.rs/enumflags2"
1111
edition = "2018"
12-
rust-version = "1.41.1"
12+
rust-version = "1.56"
1313

1414
[dependencies.enumflags2_derive]
1515
version = "=0.7.4"

enumflags_derive/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ license = "MIT OR Apache-2.0"
77
repository = "https://github.com/NieDzejkob/enumflags2"
88
keywords = ["enum", "bitflag", "flag", "bitflags"]
99
edition = "2018"
10-
rust-version = "1.41.1"
10+
rust-version = "1.56"
1111

1212
[lib]
1313
proc-macro = true
1414

1515
[dependencies]
16-
syn = { version = "^1.0", features = ["full"] }
16+
syn = { version = "^2.0", features = ["full"] }
1717
quote = "^1.0"
1818
proc-macro2 = "^1.0"

enumflags_derive/src/lib.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,18 @@ fn infer_values(flags: &mut [Flag], type_name: &Ident, repr: &Ident) {
171171
/// Given a list of attributes, find the `repr`, if any, and return the integer
172172
/// type specified.
173173
fn extract_repr(attrs: &[syn::Attribute]) -> Result<Option<Ident>, syn::Error> {
174-
use syn::{Meta, NestedMeta};
175-
attrs
176-
.iter()
177-
.find_map(|attr| match attr.parse_meta() {
178-
Err(why) => Some(Err(syn::Error::new_spanned(
179-
attr,
180-
format!("Couldn't parse attribute: {}", why),
181-
))),
182-
Ok(Meta::List(ref meta)) if meta.path.is_ident("repr") => {
183-
meta.nested.iter().find_map(|mi| match mi {
184-
NestedMeta::Meta(Meta::Path(path)) => path.get_ident().cloned().map(Ok),
185-
_ => None,
186-
})
187-
}
188-
Ok(_) => None,
189-
})
190-
.transpose()
174+
let mut res = None;
175+
for attr in attrs {
176+
if attr.path().is_ident("repr") {
177+
attr.parse_nested_meta(|meta| {
178+
if let Some(ident) = meta.path.get_ident() {
179+
res = Some(ident.clone());
180+
}
181+
Ok(())
182+
})?;
183+
}
184+
}
185+
Ok(res)
191186
}
192187

193188
/// Check the repr and return the number of bits available

0 commit comments

Comments
 (0)