Comments (2)
I believe this is working correctly. You can confirm using rustc that Rust syntax has attribute precedence that binds more tightly than the =
operator.
$ echo 'fn main() { #[someAttribute] a = b; }' | rustc -Zunpretty=ast-tree -
Stmt {
kind: Semi(
Expr {
kind: Assign(
Expr {
kind: Path(
None,
Path {
segments: [
PathSegment {
ident: "a",
args: None,
},
],
},
),
attrs: [
Attribute {
kind: Normal(
NormalAttr {
item: AttrItem {
path: Path {
segments: [
PathSegment {
ident: "someAttribute",
args: None,
},
],
},
args: Empty,
},
},
),
style: Outer,
},
],
},
Expr {
kind: Path(
None,
Path {
segments: [
PathSegment {
ident: "b",
args: None,
},
],
},
),
attrs: [],
},
),
attrs: [],
},
),
}
from syn.
Thank you for the reply. It seems that this is the problem of rust itself since in this case there is no way to give an attribute to an AssignExpr.
from syn.
Related Issues (20)
- syn::Path: Unknown literal value `()` HOT 2
- How to handle `AssignOp` from syn v1 to v2? HOT 1
- Custom punctuation containing `$` HOT 2
- Unsuccessful parsing of ExprRange consumes a token HOT 1
- Parse async closures trait bound syntax
- Parse mutable by-reference bindings syntax
- Parse postfix match syntax
- Parse for-await syntax
- Parse const trait bound syntax
- Stack overflow on a deeply nested chain of if-else expressions HOT 1
- Consider moving Visit, VisitMut, Fold traits to separate crate(s)
- Delete From impls of ast enums HOT 2
- Consider inserting invisible groups, rather than parens, when applying grouping for precedence
- Implement `Debug` for the AST nodes HOT 1
- parse_nested_meta don't work on attribute with multiple meta HOT 2
- Struct Literals in ExprLet HOT 1
- Parse `safe` items in extern blocks
- Parse precise capturing syntax HOT 1
- Scope when parsing delimited group content does not necessarily belong to the right Group token
- Parsing function using `parse` referencing enum fails HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from syn.