File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ module.exports = grammar({
109109 [ $ . parameters , $ . tuple_struct_pattern ] ,
110110 [ $ . array_expression ] ,
111111 [ $ . visibility_modifier ] ,
112+ [ $ . foreign_mod_item , $ . function_modifiers ] ,
112113 [ $ . visibility_modifier , $ . scoped_identifier , $ . scoped_type_identifier ] ,
113114 ] ,
114115
@@ -279,6 +280,7 @@ module.exports = grammar({
279280 ) ,
280281
281282 foreign_mod_item : $ => seq (
283+ optional ( 'unsafe' ) ,
282284 optional ( $ . visibility_modifier ) ,
283285 $ . extern_modifier ,
284286 choice (
@@ -404,6 +406,7 @@ module.exports = grammar({
404406
405407 static_item : $ => seq (
406408 optional ( $ . visibility_modifier ) ,
409+ optional ( choice ( 'unsafe' , 'safe' ) ) ,
407410 'static' ,
408411
409412 // Not actual rust syntax, but made popular by the lazy_static crate.
@@ -461,6 +464,7 @@ module.exports = grammar({
461464 'default' ,
462465 'const' ,
463466 'unsafe' ,
467+ 'safe' ,
464468 $ . extern_modifier ,
465469 ) ) ,
466470
Original file line number Diff line number Diff line change @@ -2584,3 +2584,65 @@ pub struct Loaf<T: Sized, const N: usize = 1>([T; N]);
25842584 (array_type
25852585 (type_identifier)
25862586 (identifier)))))
2587+
2588+ ================================================================================
2589+ Unsafe extern blocks
2590+ ================================================================================
2591+
2592+ unsafe extern "C" {
2593+ pub safe fn sqrt(x: f64) -> f64;
2594+ pub unsafe fn strlen(p: *const std::ffi::c_char) -> usize;
2595+ pub fn free(p: *mut core::ffi::c_void);
2596+ pub safe static IMPORTANT_BYTES: [u8; 256];
2597+ }
2598+
2599+ --------------------------------------------------------------------------------
2600+
2601+ (source_file
2602+ (foreign_mod_item
2603+ (extern_modifier
2604+ (string_literal
2605+ (string_content)))
2606+ (declaration_list
2607+ (function_signature_item
2608+ (visibility_modifier)
2609+ (function_modifiers)
2610+ (identifier)
2611+ (parameters
2612+ (parameter
2613+ (identifier)
2614+ (primitive_type)))
2615+ (primitive_type))
2616+ (function_signature_item
2617+ (visibility_modifier)
2618+ (function_modifiers)
2619+ (identifier)
2620+ (parameters
2621+ (parameter
2622+ (identifier)
2623+ (pointer_type
2624+ (scoped_type_identifier
2625+ (scoped_identifier
2626+ (identifier)
2627+ (identifier))
2628+ (type_identifier)))))
2629+ (primitive_type))
2630+ (function_signature_item
2631+ (visibility_modifier)
2632+ (identifier)
2633+ (parameters
2634+ (parameter
2635+ (identifier)
2636+ (pointer_type
2637+ (mutable_specifier)
2638+ (scoped_type_identifier
2639+ (scoped_identifier
2640+ (identifier)
2641+ (identifier))
2642+ (type_identifier))))))
2643+ (static_item
2644+ (visibility_modifier)
2645+ (identifier)
2646+ (array_type
2647+ (primitive_type)
2648+ (integer_literal))))))
You can’t perform that action at this time.
0 commit comments