You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have read all the tree-sitter docs if it relates to using the parser
I have searched the existing issues of tree-sitter-rust
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
tree-sitter 0.23.0
Describe the bug
The grammar does not attach attributes to the syntactic elements they annotate. Instead, attributes are treated as siblings of the elements they annotate. For instance, when parsing the following example
mod tests {#[cfg(feature = "tracing")]pubfnexecute(){}}
Both #[cfg(feature = "tracing")] and pub fn execute() {} are direct children of the module body, whereas I would expect them to be gathered in a node representing the function declaration.
Another symptom of this problem is that the grammar successfully parses the following code:
mod tests {pubfnexecute(){}#[cfg(feature = "tracing")]}
This code is incorrect because #[cfg(feature = "tracing")] is an outer attribute, which needs to be followed by the element it is applied to. This is indeed rejected by rustc:
error: expected item after attributes
--> test.rs:3:5
|
3 | #[cfg(feature = "tracing")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error
Did you check existing issues?
Tree-Sitter CLI Version, if relevant (output of
tree-sitter --version
)tree-sitter 0.23.0
Describe the bug
The grammar does not attach attributes to the syntactic elements they annotate. Instead, attributes are treated as siblings of the elements they annotate. For instance, when parsing the following example
Both
#[cfg(feature = "tracing")]
andpub fn execute() {}
are direct children of the module body, whereas I would expect them to be gathered in a node representing the function declaration.Another symptom of this problem is that the grammar successfully parses the following code:
This code is incorrect because
#[cfg(feature = "tracing")]
is an outer attribute, which needs to be followed by the element it is applied to. This is indeed rejected by rustc:Steps To Reproduce/Bad Parse Tree
Parsing the first sample above:
Expected Behavior/Parse Tree
Correctly bundling outer attributes with the syntactic element they apply to:
Repro
The text was updated successfully, but these errors were encountered: