Skip to content

Commit

Permalink
Update to syn 2 (#140)
Browse files Browse the repository at this point in the history
* Update to syn 2.

* Update changelog.
  • Loading branch information
futursolo authored Sep 17, 2023
1 parent 3d0addb commit a8f2f4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### v0.13.0

- Increase MSRV to 1.64.0.
- Update syn to v2.

### v0.12.1

Expand Down
2 changes: 1 addition & 1 deletion packages/stylist-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ proc-macro-error = "1.0.4"
proc-macro2 = "1.0.47"
quote = "1.0.21"
nom = "7.1.1"
syn = { version = "1.0.105", features = ["full", "extra-traits"] }
syn = { version = "2", features = ["full", "extra-traits"] }
itertools = "0.11.0"
log = "0.4.17"

Expand Down
11 changes: 6 additions & 5 deletions packages/stylist-macros/src/inline/css_ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use syn::ext::IdentExt;
use syn::parse::{Parse, ParseBuffer, Result as ParseResult};
use syn::{token, Ident};

syn::custom_punctuation!(DoubleSub, --);
syn::custom_punctuation!(DoubleMinus, --);

#[derive(Debug, Clone)]
pub enum IdentPart {
Expand All @@ -20,7 +20,8 @@ pub struct CssIdent {

impl IdentPart {
pub fn peek(lookahead: &ParseBuffer, accept_dash: bool, accept_ident: bool) -> bool {
let peek_dash = accept_dash && (lookahead.peek(token::Sub) || lookahead.peek(DoubleSub));
let peek_dash =
accept_dash && (lookahead.peek(token::Minus) || lookahead.peek(DoubleMinus));
let peek_ident = accept_ident && lookahead.peek(Ident::peek_any);
peek_dash || peek_ident
}
Expand All @@ -35,9 +36,9 @@ impl Display for CssIdent {

impl CssIdent {
pub fn peek(lookahead: &ParseBuffer) -> bool {
if lookahead.peek(token::Sub) {
if lookahead.peek(token::Minus) {
// A single dash is not an identifier
lookahead.peek2(token::Sub) || lookahead.peek2(Ident::peek_any)
lookahead.peek2(token::Minus) || lookahead.peek2(Ident::peek_any)
} else {
IdentPart::peek(lookahead, true, true)
}
Expand All @@ -62,7 +63,7 @@ impl IdentPart {
) -> ParseResult<IdentPart> {
debug_assert!(accept_dash || accept_ident);
let lookahead = input.lookahead1();
if accept_dash && (lookahead.peek(token::Sub) || lookahead.peek(DoubleSub)) {
if accept_dash && (lookahead.peek(token::Minus) || lookahead.peek(DoubleMinus)) {
let dash = input.parse::<Punct>()?;
debug_assert!(dash.as_char() == '-', "expected a - character");
Ok(IdentPart::Dash(dash))
Expand Down

0 comments on commit a8f2f4f

Please sign in to comment.