File tree 2 files changed +66
-0
lines changed
2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ module.exports = grammar({
109
109
[ $ . parameters , $ . tuple_struct_pattern ] ,
110
110
[ $ . array_expression ] ,
111
111
[ $ . visibility_modifier ] ,
112
+ [ $ . foreign_mod_item , $ . function_modifiers ] ,
112
113
[ $ . visibility_modifier , $ . scoped_identifier , $ . scoped_type_identifier ] ,
113
114
] ,
114
115
@@ -279,6 +280,7 @@ module.exports = grammar({
279
280
) ,
280
281
281
282
foreign_mod_item : $ => seq (
283
+ optional ( 'unsafe' ) ,
282
284
optional ( $ . visibility_modifier ) ,
283
285
$ . extern_modifier ,
284
286
choice (
@@ -404,6 +406,7 @@ module.exports = grammar({
404
406
405
407
static_item : $ => seq (
406
408
optional ( $ . visibility_modifier ) ,
409
+ optional ( choice ( 'unsafe' , 'safe' ) ) ,
407
410
'static' ,
408
411
409
412
// Not actual rust syntax, but made popular by the lazy_static crate.
@@ -461,6 +464,7 @@ module.exports = grammar({
461
464
'default' ,
462
465
'const' ,
463
466
'unsafe' ,
467
+ 'safe' ,
464
468
$ . extern_modifier ,
465
469
) ) ,
466
470
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]);
2584
2584
(array_type
2585
2585
(type_identifier)
2586
2586
(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