Skip to content

bug: Missing parsing of safe/unsafe externs #250

Open
@SKyletoft

Description

@SKyletoft

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions