Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Globally upgrade to syn 2.x and latest quote and proc_macro2 1x versi…
Browse files Browse the repository at this point in the history
…ons (#13846)

* globally upgrade quote to latest 1.0.x (1.0.26)

* globally upgrade syn to final 1.0.x version (1.0.109)

* globally upgrade proc-macro2 to 1.0.56

* upgrade to syn v2.0.13 and fix everything except NestedMeta

* fix parse nested metadata code in decl_runtime_apis.rs

* Port more stuff to syn 2.0

* Make the rest compile

* Ignore error

* update to syn 2.0.14

---------

Co-authored-by: Bastian Köcher <info@kchr.de>
  • Loading branch information
sam0x17 and bkchr authored Apr 12, 2023
1 parent b4f857e commit f0d3bbb
Show file tree
Hide file tree
Showing 62 changed files with 409 additions and 485 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

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

5 changes: 3 additions & 2 deletions bin/node/cli/tests/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ async fn telemetry_works() {
}
},

Event::TextFrame { .. } =>
panic!("Got a TextFrame over the socket, this is a bug"),
Event::TextFrame { .. } => {
panic!("Got a TextFrame over the socket, this is a bug")
},

// Connection has been closed.
Event::ConnectionError { .. } => {},
Expand Down
6 changes: 3 additions & 3 deletions client/chain-spec/derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ proc-macro = true

[dependencies]
proc-macro-crate = "1.1.3"
proc-macro2 = "1.0.37"
quote = "1.0.10"
syn = "1.0.98"
proc-macro2 = "1.0.56"
quote = "1.0.26"
syn = "2.0.14"
2 changes: 1 addition & 1 deletion client/chain-spec/derive/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn extension_derive(ast: &DeriveInput) -> proc_macro::TokenStream {
.named
.iter()
.find_map(|f| {
if f.attrs.iter().any(|attr| attr.path.is_ident(ATTRIBUTE_NAME)) {
if f.attrs.iter().any(|attr| attr.path().is_ident(ATTRIBUTE_NAME)) {
let typ = &f.ty;
Some(quote! { #typ })
} else {
Expand Down
5 changes: 3 additions & 2 deletions client/consensus/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,9 @@ fn aux_storage_cleanup<C: HeaderMetadata<Block> + HeaderBackend<Block>, Block: B
Ok(meta) => {
hashes.insert(meta.parent);
},
Err(err) =>
warn!(target: LOG_TARGET, "Failed to lookup metadata for block `{:?}`: {}", first, err,),
Err(err) => {
warn!(target: LOG_TARGET, "Failed to lookup metadata for block `{:?}`: {}", first, err,)
},
}

// Cleans data for finalized block's ancestors
Expand Down
5 changes: 3 additions & 2 deletions client/db/src/pinned_blocks_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ impl<Block: BlockT> PinnedBlocksCache<Block> {
self.cache.len()
);
},
None =>
log::warn!(target: LOG_TARGET, "Unable to bump reference count. hash = {}", hash),
None => {
log::warn!(target: LOG_TARGET, "Unable to bump reference count. hash = {}", hash)
},
};
}

Expand Down
5 changes: 3 additions & 2 deletions client/service/test/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ fn finality_notification_check(
assert_eq!(notif.hash, *finalized.last().unwrap());
assert_eq!(stale_heads, stale_heads_expected);
},
Err(TryRecvError::Closed) =>
panic!("unexpected notification result, client send channel was closed"),
Err(TryRecvError::Closed) => {
panic!("unexpected notification result, client send channel was closed")
},
Err(TryRecvError::Empty) => assert!(finalized.is_empty()),
}
}
Expand Down
10 changes: 6 additions & 4 deletions client/state-db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ impl fmt::Debug for StateDbError {
"Incompatible pruning modes [stored: {:?}; requested: {:?}]",
stored, requested
),
Self::TooManySiblingBlocks { number } =>
write!(f, "Too many sibling blocks at #{number} inserted"),
Self::TooManySiblingBlocks { number } => {
write!(f, "Too many sibling blocks at #{number} inserted")
},
Self::BlockAlreadyExists => write!(f, "Block already exists"),
Self::Metadata(message) => write!(f, "Invalid metadata: {}", message),
Self::BlockUnavailable =>
write!(f, "Trying to get a block record from db while it is not commit to db yet"),
Self::BlockUnavailable => {
write!(f, "Trying to get a block record from db while it is not commit to db yet")
},
Self::BlockMissing => write!(f, "Block record is missing from the pruning window"),
}
}
Expand Down
6 changes: 3 additions & 3 deletions client/tracing/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ proc-macro = true

[dependencies]
proc-macro-crate = "1.1.3"
proc-macro2 = "1.0.37"
quote = { version = "1.0.10", features = ["proc-macro"] }
syn = { version = "1.0.98", features = ["proc-macro", "full", "extra-traits", "parsing"] }
proc-macro2 = "1.0.56"
quote = { version = "1.0.26", features = ["proc-macro"] }
syn = { version = "2.0.14", features = ["proc-macro", "full", "extra-traits", "parsing"] }
6 changes: 3 additions & 3 deletions frame/contracts/proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ targets = ["x86_64-unknown-linux-gnu"]
proc-macro = true

[dependencies]
proc-macro2 = "1"
quote = "1"
syn = { version = "1.0.98", features = ["full"] }
proc-macro2 = "1.0.56"
quote = "1.0.26"
syn = { version = "2.0.14", features = ["full"] }

[dev-dependencies]

Expand Down
10 changes: 5 additions & 5 deletions frame/contracts/proc-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ impl HostFn {
"only #[version(<u8>)], #[unstable], #[prefixed_alias] and #[deprecated] attributes are allowed.";
let span = item.span();
let mut attrs = item.attrs.clone();
attrs.retain(|a| !a.path.is_ident("doc"));
attrs.retain(|a| !a.path().is_ident("doc"));
let mut maybe_version = None;
let mut is_stable = true;
let mut alias_to = None;
let mut not_deprecated = true;
while let Some(attr) = attrs.pop() {
let ident = attr.path.get_ident().ok_or(err(span, msg))?.to_string();
let ident = attr.path().get_ident().ok_or(err(span, msg))?.to_string();
match ident.as_str() {
"version" => {
if maybe_version.is_some() {
Expand Down Expand Up @@ -377,7 +377,7 @@ impl EnvDef {
_ => None,
};

let selector = |a: &syn::Attribute| a.path.is_ident("prefixed_alias");
let selector = |a: &syn::Attribute| a.path().is_ident("prefixed_alias");

let aliases = items
.iter()
Expand All @@ -401,7 +401,7 @@ impl EnvDef {
}

fn is_valid_special_arg(idx: usize, arg: &FnArg) -> bool {
let pat = if let FnArg::Typed(pat) = arg { pat } else { return false };
let FnArg::Typed(pat) = arg else { return false };
let ident = if let syn::Pat::Ident(ref ident) = *pat.pat { &ident.ident } else { return false };
let name_ok = match idx {
0 => ident == "ctx" || ident == "_ctx",
Expand Down Expand Up @@ -434,7 +434,7 @@ fn expand_func_doc(func: &HostFn) -> TokenStream2 {
);
quote! { #[doc = #alias_doc] }
} else {
let docs = func.item.attrs.iter().filter(|a| a.path.is_ident("doc")).map(|d| {
let docs = func.item.attrs.iter().filter(|a| a.path().is_ident("doc")).map(|d| {
let docs = d.to_token_stream();
quote! { #docs }
});
Expand Down
6 changes: 3 additions & 3 deletions frame/election-provider-support/solution-type/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ targets = ["x86_64-unknown-linux-gnu"]
proc-macro = true

[dependencies]
syn = { version = "1.0.98", features = ["full", "visit"] }
quote = "1.0"
proc-macro2 = "1.0.37"
syn = { version = "2.0.14", features = ["full", "visit"] }
quote = "1.0.26"
proc-macro2 = "1.0.56"
proc-macro-crate = "1.1.3"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions frame/election-provider-support/solution-type/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ fn check_attributes(input: ParseStream) -> syn::Result<bool> {
return Ok(false)
}
let attr = attrs.pop().expect("attributes vec with len 1 can be popped.");
if attr.path.is_ident("compact") {
if attr.path().is_ident("compact") {
Ok(true)
} else {
Err(syn::Error::new_spanned(attr, "compact solution can accept only #[compact]"))
Expand Down Expand Up @@ -200,7 +200,7 @@ impl Parse for SolutionDef {
format!("Expected binding: `{} = ...`", expected),
))
},
syn::GenericArgument::Binding(syn::Binding { ident, ty, .. }) => {
syn::GenericArgument::AssocType(syn::AssocType { ident, ty, .. }) => {
// check that we have the right keyword for this position in the argument list
if ident == expected {
Ok(ty.clone())
Expand Down
6 changes: 5 additions & 1 deletion frame/nfts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,11 @@ fn claim_swap_should_work() {
Balances::make_free_balance_be(&user_1, initial_balance);
Balances::make_free_balance_be(&user_2, initial_balance);

assert_ok!(Nfts::force_create(RuntimeOrigin::root(), user_1.clone(), default_collection_config()));
assert_ok!(Nfts::force_create(
RuntimeOrigin::root(),
user_1.clone(),
default_collection_config()
));

assert_ok!(Nfts::mint(
RuntimeOrigin::signed(user_1.clone()),
Expand Down
10 changes: 6 additions & 4 deletions frame/scheduler/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,9 @@ pub mod v4 {
target: TARGET,
"Did not clean up any agendas. v4::CleanupAgendas can be removed."
),
Some(n) =>
log::info!(target: TARGET, "Cleaned up {} agendas, now {}", n, new_agendas),
Some(n) => {
log::info!(target: TARGET, "Cleaned up {} agendas, now {}", n, new_agendas)
},
None => unreachable!(
"Number of agendas cannot increase, old {} new {}",
old_agendas, new_agendas
Expand Down Expand Up @@ -560,8 +561,9 @@ mod test {
"Agenda {} should be removed",
i
),
Some(new) =>
assert_eq!(Agenda::<Test>::get(i as u64), new, "Agenda wrong {}", i),
Some(new) => {
assert_eq!(Agenda::<Test>::get(i as u64), new, "Agenda wrong {}", i)
},
}
}
});
Expand Down
6 changes: 3 additions & 3 deletions frame/staking/reward-curve/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ proc-macro = true

[dependencies]
proc-macro-crate = "1.1.3"
proc-macro2 = "1.0.37"
quote = "1.0.10"
syn = { version = "1.0.98", features = ["full", "visit"] }
proc-macro2 = "1.0.56"
quote = "1.0.26"
syn = { version = "2.0.14", features = ["full", "visit"] }

[dev-dependencies]
sp-runtime = { version = "7.0.0", path = "../../../primitives/runtime" }
Loading

0 comments on commit f0d3bbb

Please sign in to comment.