Skip to content

update to syn2 #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Updated syn to version 2 (#732)

## [v0.29.0] - 2023-06-05

- `FieldFpec` instead or `fty` generic (#722)
- print error on ci `curl` request fail (#725)
- removed `rty` generic in `FieldWriter` (#721)
- `bool` and `u8` as default generics for `BitReader/Writer` and `FieldReader/Writer` (#720)
- `bool` and `u8` as default generics for `BitReader/Writer` and `FieldReader/Writer` (#720)
- Bump MSRV to 1.65 (#711)
- Optimize case change/sanitize (#715)
- Fix dangling implicit derives (#703)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ features = ["serde"]
version = "0.14.1"

[dependencies.syn]
version = "1.0"
version = "2.0"
features = ["full","extra-traits"]
17 changes: 6 additions & 11 deletions src/generate/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use quote::{quote, ToTokens};
use syn::{punctuated::Punctuated, Token};

use crate::util::{
self, array_proxy_type, name_to_ty, new_syn_u32, path_segment, type_path, unsuffixed, Config,
FullName, ToSanitizedCase, BITS_PER_BYTE,
self, array_proxy_type, name_to_ty, path_segment, type_path, unsuffixed, Config, FullName,
ToSanitizedCase, BITS_PER_BYTE,
};
use anyhow::{anyhow, bail, Context, Result};

Expand Down Expand Up @@ -1393,21 +1393,16 @@ fn new_syn_field(ident: Ident, ty: syn::Type) -> syn::Field {
let span = Span::call_site();
syn::Field {
ident: Some(ident),
vis: syn::Visibility::Public(syn::VisPublic {
pub_token: Token![pub](span),
}),
vis: syn::Visibility::Public(Token![pub](span)),
attrs: vec![],
colon_token: Some(Token![:](span)),
ty,
mutability: syn::FieldMutability::None,
}
}

fn new_syn_array(ty: syn::Type, len: u32) -> syn::Type {
let span = Span::call_site();
syn::Type::Array(syn::TypeArray {
bracket_token: syn::token::Bracket { span },
elem: ty.into(),
semi_token: Token![;](span),
len: new_syn_u32(len, span),
})
let len = unsuffixed(len as _);
syn::parse_quote_spanned!( span => [#ty; #len] )
}
4 changes: 2 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};
use svd_rs::{MaybeArray, Peripheral, PeripheralInfo};

use syn::{
punctuated::Punctuated, token::Colon2, AngleBracketedGenericArguments, GenericArgument, Lit,
punctuated::Punctuated, token::PathSep, AngleBracketedGenericArguments, GenericArgument, Lit,
LitInt, PathArguments, PathSegment, Token, Type, TypePath,
};

Expand Down Expand Up @@ -473,7 +473,7 @@ pub fn ident_to_path(ident: Ident) -> TypePath {
type_path(segments)
}

pub fn type_path(segments: Punctuated<PathSegment, Colon2>) -> TypePath {
pub fn type_path(segments: Punctuated<PathSegment, PathSep>) -> TypePath {
TypePath {
qself: None,
path: syn::Path {
Expand Down