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 @@ -2559,3 +2559,65 @@ pub struct Loaf<T: Sized, const N: usize = 1>([T; N]);
25592559 (array_type
25602560 (type_identifier)
25612561 (identifier)))))
2562+
2563+ ================================================================================
2564+ Unsafe extern blocks
2565+ ================================================================================
2566+
2567+ unsafe extern "C" {
2568+ pub safe fn sqrt(x: f64) -> f64;
2569+ pub unsafe fn strlen(p: *const std::ffi::c_char) -> usize;
2570+ pub fn free(p: *mut core::ffi::c_void);
2571+ pub safe static IMPORTANT_BYTES: [u8; 256];
2572+ }
2573+
2574+ --------------------------------------------------------------------------------
2575+
2576+ (source_file
2577+ (foreign_mod_item
2578+ (extern_modifier
2579+ (string_literal
2580+ (string_content)))
2581+ (declaration_list
2582+ (function_signature_item
2583+ (visibility_modifier)
2584+ (function_modifiers)
2585+ (identifier)
2586+ (parameters
2587+ (parameter
2588+ (identifier)
2589+ (primitive_type)))
2590+ (primitive_type))
2591+ (function_signature_item
2592+ (visibility_modifier)
2593+ (function_modifiers)
2594+ (identifier)
2595+ (parameters
2596+ (parameter
2597+ (identifier)
2598+ (pointer_type
2599+ (scoped_type_identifier
2600+ (scoped_identifier
2601+ (identifier)
2602+ (identifier))
2603+ (type_identifier)))))
2604+ (primitive_type))
2605+ (function_signature_item
2606+ (visibility_modifier)
2607+ (identifier)
2608+ (parameters
2609+ (parameter
2610+ (identifier)
2611+ (pointer_type
2612+ (mutable_specifier)
2613+ (scoped_type_identifier
2614+ (scoped_identifier
2615+ (identifier)
2616+ (identifier))
2617+ (type_identifier))))))
2618+ (static_item
2619+ (visibility_modifier)
2620+ (identifier)
2621+ (array_type
2622+ (primitive_type)
2623+ (integer_literal))))))
You can’t perform that action at this time.
0 commit comments