Skip to content

Commit

Permalink
Merge pull request #732 from Emilgardis/bump-syn
Browse files Browse the repository at this point in the history
update to syn2
  • Loading branch information
burrbull authored Jun 6, 2023
2 parents 615f093 + 4da1837 commit ef56dd1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
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

0 comments on commit ef56dd1

Please sign in to comment.