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({
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 @@ -2559,3 +2559,65 @@ pub struct Loaf<T: Sized, const N: usize = 1>([T; N]);
2559
2559
(array_type
2560
2560
(type_identifier)
2561
2561
(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