Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Missing parsing of safe/unsafe externs #250

Open
2 tasks done
SKyletoft opened this issue Feb 4, 2025 · 0 comments · May be fixed by #256
Open
2 tasks done

bug: Missing parsing of safe/unsafe externs #250

SKyletoft opened this issue Feb 4, 2025 · 0 comments · May be fixed by #256
Labels

Comments

@SKyletoft
Copy link

Did you check existing issues?

  • 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)

0.24.6, via nixpkgs

Describe the bug

As a poorly documented part of the rust language, there is apparently a safe keyword that can be used in extern blocks. This is valid Rust:

unsafe extern "C" {
	safe static some_constant_external_value: [u32; 128];
	safe fn some_external_function_i_promise_is_safe();
}

This is not listed in the keywords list but is described here.

Steps To Reproduce/Bad Parse Tree

(source_file
(ERROR unsafe
(extern_modifier extern
(string_literal " (string_content) ")))
(expression_statement
(block {
(ERROR (identifier)
(static_item static name: (identifier) :
type: (array_type [ element: (primitive_type) ; length: (integer_literal) ])
;)
(identifier))
(function_signature_item fn name: (identifier)
parameters: (parameters ( ))
;)
})))

Expected Behavior/Parse Tree

As far as I can tell, there is no safe token in the grammar currently. (Or I'm just blind)

Repro

unsafe extern "C" {
	safe static some_constant_external_value: [u32; 128];
	safe fn some_external_function_i_promise_is_safe();
}
@SKyletoft SKyletoft added the bug label Feb 4, 2025
@m4rch3n1ng m4rch3n1ng linked a pull request Feb 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant