tree-sitter / tree-sitter-rust

Rust grammar for tree-sitter
MIT License
338 stars 96 forks source link

bug: error on impl trait for dyn trait #227

Open matthiaskrgr opened 2 months ago

matthiaskrgr commented 2 months ago

Did you check existing issues?

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

No response

Describe the bug

FP error as rustc accepts this code (although with a warning)

Steps To Reproduce/Bad Parse Tree

(source_file (trait_item (visibility_modifier) name: (type_identifier) body: (declaration_list)) (impl_item trait: (type_identifier) (ERROR) type: (bounded_type (tuple_type (scoped_type_identifier path: (scoped_identifier path: (scoped_identifier name: (identifier)) name: (identifier)) name: (type_identifier))) (type_identifier)) body: (declaration_list)))

source_file [0, 0] - [5, 0] trait_item [0, 0] - [0, 25] visibility_modifier [0, 0] - [0, 3] name: type_identifier [0, 17] - [0, 22] body: declaration_list [0, 23] - [0, 25] impl_item [2, 0] - [2, 54] trait: type_identifier [2, 12] - [2, 17] ERROR [2, 22] - [2, 25] type: bounded_type [2, 26] - [2, 50] tuple_type [2, 26] - [2, 43] scoped_type_identifier [2, 27] - [2, 42] path: scoped_identifier [2, 27] - [2, 37] path: scoped_identifier [2, 27] - [2, 32] name: identifier [2, 29] - [2, 32] name: identifier [2, 34] - [2, 37] name: type_identifier [2, 39] - [2, 42] type_identifier [2, 46] - [2, 50] body: declaration_list [2, 51] - [2, 54]

Expected Behavior/Parse Tree

looks like ts does not know about impl .. for dyn yet. I guess the `dyn' should just be part of the bounded type?

Repro

pub unsafe trait Trait {}

unsafe impl Trait for dyn (::std::any::Any) + Send { }