File tree 2 files changed +75
-2
lines changed
2 files changed +75
-2
lines changed Original file line number Diff line number Diff line change @@ -280,6 +280,7 @@ module.exports = grammar({
280
280
281
281
foreign_mod_item : $ => seq (
282
282
optional ( $ . visibility_modifier ) ,
283
+ optional ( $ . _item_modifiers ) ,
283
284
$ . extern_modifier ,
284
285
choice (
285
286
';' ,
@@ -404,6 +405,7 @@ module.exports = grammar({
404
405
405
406
static_item : $ => seq (
406
407
optional ( $ . visibility_modifier ) ,
408
+ optional ( choice ( 'unsafe' , 'safe' ) ) ,
407
409
'static' ,
408
410
409
411
// Not actual rust syntax, but made popular by the lazy_static crate.
@@ -456,12 +458,21 @@ module.exports = grammar({
456
458
';' ,
457
459
) ,
458
460
459
- function_modifiers : $ => repeat1 ( choice (
461
+ function_modifiers : $ => choice (
462
+ $ . _item_modifiers ,
463
+ $ . extern_modifier ,
464
+ seq (
465
+ $ . _item_modifiers ,
466
+ $ . extern_modifier ,
467
+ )
468
+ ) ,
469
+
470
+ _item_modifiers : _ => repeat1 ( choice (
460
471
'async' ,
461
472
'default' ,
462
473
'const' ,
463
474
'unsafe' ,
464
- $ . extern_modifier ,
475
+ 'safe' ,
465
476
) ) ,
466
477
467
478
where_clause : $ => prec . right ( seq (
Original file line number Diff line number Diff line change @@ -2613,3 +2613,65 @@ pub struct Loaf<T: Sized, const N: usize = 1>([T; N]);
2613
2613
(array_type
2614
2614
(type_identifier)
2615
2615
(identifier)))))
2616
+
2617
+ ================================================================================
2618
+ Unsafe extern blocks
2619
+ ================================================================================
2620
+
2621
+ unsafe extern "C" {
2622
+ pub safe fn sqrt(x: f64) -> f64;
2623
+ pub unsafe fn strlen(p: *const std::ffi::c_char) -> usize;
2624
+ pub fn free(p: *mut core::ffi::c_void);
2625
+ pub safe static IMPORTANT_BYTES: [u8; 256];
2626
+ }
2627
+
2628
+ --------------------------------------------------------------------------------
2629
+
2630
+ (source_file
2631
+ (foreign_mod_item
2632
+ (extern_modifier
2633
+ (string_literal
2634
+ (string_content)))
2635
+ (declaration_list
2636
+ (function_signature_item
2637
+ (visibility_modifier)
2638
+ (function_modifiers)
2639
+ (identifier)
2640
+ (parameters
2641
+ (parameter
2642
+ (identifier)
2643
+ (primitive_type)))
2644
+ (primitive_type))
2645
+ (function_signature_item
2646
+ (visibility_modifier)
2647
+ (function_modifiers)
2648
+ (identifier)
2649
+ (parameters
2650
+ (parameter
2651
+ (identifier)
2652
+ (pointer_type
2653
+ (scoped_type_identifier
2654
+ (scoped_identifier
2655
+ (identifier)
2656
+ (identifier))
2657
+ (type_identifier)))))
2658
+ (primitive_type))
2659
+ (function_signature_item
2660
+ (visibility_modifier)
2661
+ (identifier)
2662
+ (parameters
2663
+ (parameter
2664
+ (identifier)
2665
+ (pointer_type
2666
+ (mutable_specifier)
2667
+ (scoped_type_identifier
2668
+ (scoped_identifier
2669
+ (identifier)
2670
+ (identifier))
2671
+ (type_identifier))))))
2672
+ (static_item
2673
+ (visibility_modifier)
2674
+ (identifier)
2675
+ (array_type
2676
+ (primitive_type)
2677
+ (integer_literal))))))
You can’t perform that action at this time.
0 commit comments