syn icon indicating copy to clipboard operation
syn copied to clipboard

Parser for Rust source code

Results 117 syn issues
Sort by recently updated
recently updated
newest added

I think https://docs.rs/syn/1.0.76/syn/index.html is a landing page for proc macro docs. As such, it would be useful to include copy-passable example of attribute and function like macros. Strictly speaking, it’s...

docs

I have a `Path` for an enum variant like `my_mod::MyType::MyVariant`, and I can remove the `MyVariant` part with `path.segments.pop()`, however that gives me a path like `my_mod::MyType::` which is syntatically...

While developing certain proc macros using `syn` I found getters that return the attribute slice for a generic `syn::Item` to be missing. The implementation is straight forward and simple, however,...

The signature of these procedural macros is `fn cool_fn_macro(attr: TokenStream, item: TokenStream) -> TokenStream` and they usually start with `let mut function = parse_macro_input!(item as ItemFn);`. The `attr` argument that...

docs

I am trying to write some code which parses patterns like an `if let` expression does, and I discovered that it cannot parse `|`-patterns. This appear's to be because most...

Depending on the outcome of https://github.com/rust-lang/rust/pull/80080. This would be a valid Expr: `::Assoc::Variant {}` The current parse error is: ```console error: expected `;` --> dev/main.rs:5:45 | 5 | let _...

syntax

LitStr::parse currently puts the entire input string's span on every output token. It would be better to try producing smaller spans using [Literal::subspan](https://docs.rs/proc-macro2/1.0.4/proc_macro2/struct.Literal.html#method.subspan).

enhancement
help wanted

Purely out of curiosity, I recently attempted parsing Objective-C message syntax inline in Rust using `syn`: [receiver-expr no-arg-selector] [receiver-expr selector-piece:arg-expr selector-piece:second-arg-expr...] ```rust impl Parse for MessageSend { fn parse(input: ParseStream)...

The documentation of parsing an attribute feels incomplete, and rather confusing. I specifically want to inject a new attribute constructed with `quote!` into the vector of attributes I have already...

docs

When parsing identifiers, `accept_as_ident` is used to reject those strings which are keywords. This does not include Rust 2018 keywords such as `async` and `try`. Additionally, the linked resource for...