Skip to content

Commit

Permalink
Version bump to 2.0 and fixes for syn (#6179)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfiedotwtf committed Sep 22, 2024
1 parent 805fc5f commit 5837851
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ slotmap = "1.0"
smallvec = "1.7"
strsim = "0.11"
strum = "0.26"
syn = "1.0"
syn = "2.0"
taplo = "0.13"
tar = "0.4"
tempfile = "3"
Expand Down
30 changes: 13 additions & 17 deletions sway-ir/sway-ir-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
quote::{format_ident, quote},
syn::{
parse_macro_input, Attribute, Data, DeriveInput, Fields, FieldsNamed, FieldsUnnamed, Ident,
Meta, NestedMeta, Variant,
Variant,
},
};

Expand Down Expand Up @@ -170,7 +170,7 @@ fn pass_through_context(field_name: &Ident, attrs: &[Attribute]) -> proc_macro2:
attrs
.iter()
.filter_map(|attr| {
let attr_name = attr.path.get_ident()?;
let attr_name = attr.path().get_ident()?;
if attr_name != "in_context" {
return None;
}
Expand Down Expand Up @@ -199,20 +199,16 @@ fn pass_through_context(field_name: &Ident, attrs: &[Attribute]) -> proc_macro2:
}

fn try_parse_context_field_from_attr(attr: &Attribute) -> Option<Ident> {
let meta = attr.parse_meta().ok()?;
let Meta::List(meta_list) = meta else {
return None;
};
if meta_list.nested.len() != 1 {
return None;
let mut context_fields = Vec::new();

let _ = attr.parse_nested_meta(|nested_meta| {
context_fields.push(nested_meta.path.get_ident().unwrap().clone());
Ok(())
});

if context_fields.len() != 1 {
None
} else {
context_fields.pop()
}
let nested_meta = meta_list.nested.first()?;
let NestedMeta::Meta(inner_meta) = nested_meta else {
return None;
};
let Meta::Path(path) = inner_meta else {
return None;
};
let context_field_name = path.get_ident()?.clone();
Some(context_field_name)
}
2 changes: 1 addition & 1 deletion sway-lsp/src/utils/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ impl KeywordDocs {
let name = ident.trim_end_matches("_keyword").to_owned();
let mut documentation = String::new();
keyword.attrs.iter().for_each(|attr| {
let tokens = attr.tokens.to_token_stream();
let tokens = attr.meta.clone().to_token_stream();
let lit = extract_lit(tokens);
writeln!(documentation, "{lit}").unwrap();
});
Expand Down

0 comments on commit 5837851

Please sign in to comment.