Debian Codegraph @

gcc/rust/checks/errors/rust-unsafe-checker.cc

raw
1 // Copyright (C) 2020-2025 Free Software Foundation, Inc.
2
3 // This file is part of GCC.
4
5 // GCC is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation; either version 3, or (at your option) any later
8 // version.
9
10 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 // for more details.
14
15 // You should have received a copy of the GNU General Public License
16 // along with GCC; see the file COPYING3. If not see
17 // <http://www.gnu.org/licenses/>.
18
19 #include "rust-unsafe-checker.h"
20 #include "rust-hir.h"
21 #include "rust-hir-expr.h"
22 #include "rust-hir-stmt.h"
23 #include "rust-hir-item.h"
24 #include "rust-attribute-values.h"
25 #include "rust-system.h"
26 #include "rust-immutable-name-resolution-context.h"
27
28 // for flag_name_resolution_2_0
29 #include "options.h"
30
31 namespace Rust {
32 namespace HIR {
33
34 UnsafeChecker::UnsafeChecker ()
35 : context (*Resolver::TypeCheckContext::get ()),
36 resolver (*Resolver::Resolver::get ()),
37 mappings (Analysis::Mappings::get ())
38 {}
39
40 void
41 UnsafeChecker::go (HIR::Crate &crate)
42 {
43 for (auto &item : crate.get_items ())
44 item->accept_vis (*this);
45 }
46
47 static void
48 check_static_mut (HIR::Item *maybe_static, location_t locus)
49 {
50 if (maybe_static->get_hir_kind () == Node::BaseKind::VIS_ITEM)
51 {
52 auto item = static_cast<Item *> (maybe_static);
53 if (item->get_item_kind () == Item::ItemKind::Static)
54 {
55 auto static_item = static_cast<StaticItem *> (item);
56 if (static_item->is_mut ())
57 rust_error_at (
58 locus, "use of mutable static requires unsafe function or block");
59 }
60 }
61 }
62
63 static void
64 check_extern_static (HIR::ExternalItem *maybe_static, location_t locus)
65 {
66 if (maybe_static->get_extern_kind () == ExternalItem::ExternKind::Static)
67 rust_error_at (locus,
68 "use of extern static requires unsafe function or block");
69 }
70
71 void
72 UnsafeChecker::check_use_of_static (HirId node_id, location_t locus)
73 {
74 if (unsafe_context.is_in_context ())
75 return;
76
77 if (auto maybe_static_mut = mappings.lookup_hir_item (node_id))
78 check_static_mut (*maybe_static_mut, locus);
79
80 if (auto maybe_extern_static = mappings.lookup_hir_extern_item (node_id))
81 check_extern_static (static_cast<ExternalItem *> (
82 maybe_extern_static->first),
83 locus);
84 }
85
86 static void
87 check_unsafe_call (HIR::Function *fn, location_t locus, const std::string &kind)
88 {
89 if (fn->get_qualifiers ().is_unsafe ())
90 rust_error_at (locus, ErrorCode::E0133,
91 "call to unsafe %s requires unsafe function or block",
92 kind.c_str ());
93 }
94
95 static bool
96 is_safe_intrinsic (const std::string &fn_name)
97 {
98 static const std::unordered_set<std::string> safe_intrinsics = {
99 "abort",
100 "size_of",
101 "min_align_of",
102 "needs_drop",
103 "caller_location",
104 "add_with_overflow",
105 "sub_with_overflow",
106 "mul_with_overflow",
107 "wrapping_add",
108 "wrapping_sub",
109 "wrapping_mul",
110 "saturating_add",
111 "saturating_sub",
112 "rotate_left",
113 "rotate_right",
114 "ctpop",
115 "ctlz",
116 "cttz",
117 "bswap",
118 "bitreverse",
119 "discriminant_value",
120 "type_id",
121 "likely",
122 "unlikely",
123 "ptr_guaranteed_eq",
124 "ptr_guaranteed_ne",
125 "minnumf32",
126 "minnumf64",
127 "maxnumf32",
128 "rustc_peek",
129 "maxnumf64",
130 "type_name",
131 "forget",
132 "black_box",
133 "variant_count",
134 };
135
136 return safe_intrinsics.find (fn_name) != safe_intrinsics.end ();
137 }
138
139 static void
140 check_extern_call (HIR::ExternalItem *maybe_fn, HIR::ExternBlock *parent_block,
141 location_t locus)
142 {
143 // We have multiple operations to perform here
144 // 1. Is the item an actual function we're calling
145 // 2. Is the block it's defined in an FFI block or an `extern crate` block
146 //
147 // It is not unsafe to call into other crates, so items defined in an `extern
148 // crate` must be callable without being in an unsafe context. On the other
149 // hand, any function defined in a block with a specific ABI (even `extern
150 // "Rust"` blocks) is unsafe to call
151
152 if (maybe_fn->get_extern_kind () != ExternalItem::ExternKind::Function)
153 return;
154
155 // Some intrinsics are safe to call
156 if (parent_block->get_abi () == Rust::ABI::INTRINSIC
157 && is_safe_intrinsic (maybe_fn->get_item_name ().as_string ()))
158 return;
159
160 rust_error_at (locus,
161 "call to extern function requires unsafe function or block");
162 }
163
164 void
165 UnsafeChecker::check_function_call (HirId node_id, location_t locus)
166 {
167 if (unsafe_context.is_in_context ())
168 return;
169
170 auto maybe_fn = mappings.lookup_hir_item (node_id);
171
172 if (maybe_fn
173 && maybe_fn.value ()->get_item_kind () == Item::ItemKind::Function)
174 check_unsafe_call (static_cast<Function *> (*maybe_fn), locus, "function");
175
176 if (auto maybe_extern = mappings.lookup_hir_extern_item (node_id))
177 check_extern_call (static_cast<ExternalItem *> (maybe_extern->first),
178 *mappings.lookup_hir_extern_block (maybe_extern->second),
179 locus);
180 }
181
182 static void
183 check_target_attr (HIR::Function *fn, location_t locus)
184 {
185 if (std::any_of (fn->get_outer_attrs ().begin (),
186 fn->get_outer_attrs ().end (),
187 [] (const AST::Attribute &attr) {
188 return attr.get_path ().as_string ()
189 == Values::Attributes::TARGET_FEATURE;
190 }))
191 rust_error_at (locus,
192 "call to function with %<#[target_feature]%> requires "
193 "unsafe function or block");
194 }
195
196 void
197 UnsafeChecker::check_function_attr (HirId node_id, location_t locus)
198 {
199 if (unsafe_context.is_in_context ())
200 return;
201
202 auto maybe_fn = mappings.lookup_hir_item (node_id);
203
204 if (maybe_fn
205 && maybe_fn.value ()->get_item_kind () == Item::ItemKind::Function)
206 check_target_attr (static_cast<Function *> (*maybe_fn), locus);
207 }
208
209 void
210 UnsafeChecker::visit (Lifetime &)
211 {}
212
213 void
214 UnsafeChecker::visit (LifetimeParam &)
215 {}
216
217 void
218 UnsafeChecker::visit (PathInExpression &path)
219 {
220 NodeId ast_node_id = path.get_mappings ().get_nodeid ();
221 NodeId ref_node_id;
222
223 if (flag_name_resolution_2_0)
224 {
225 auto &nr_ctx
226 = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
227
228 auto resolved = nr_ctx.lookup (ast_node_id);
229
230 if (!resolved.has_value ())
231 return;
232
233 ref_node_id = resolved.value ();
234 }
235 else
236 {
237 if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id))
238 return;
239 }
240
241 if (auto definition_id = mappings.lookup_node_to_hir (ref_node_id))
242 {
243 check_use_of_static (*definition_id, path.get_locus ());
244 }
245 else
246 {
247 rust_unreachable ();
248 }
249 }
250
251 void
252 UnsafeChecker::visit (TypePathSegment &)
253 {}
254
255 void
256 UnsafeChecker::visit (TypePathSegmentGeneric &)
257 {}
258
259 void
260 UnsafeChecker::visit (TypePathSegmentFunction &)
261 {}
262
263 void
264 UnsafeChecker::visit (TypePath &)
265 {}
266
267 void
268 UnsafeChecker::visit (QualifiedPathInExpression &)
269 {}
270
271 void
272 UnsafeChecker::visit (QualifiedPathInType &)
273 {}
274
275 void
276 UnsafeChecker::visit (LiteralExpr &)
277 {}
278
279 void
280 UnsafeChecker::visit (BorrowExpr &expr)
281 {
282 expr.get_expr ().accept_vis (*this);
283 }
284
285 void
286 UnsafeChecker::visit (DereferenceExpr &expr)
287 {
288 TyTy::BaseType *to_deref_type;
289 auto to_deref = expr.get_expr ().get_mappings ().get_hirid ();
290
291 rust_assert (context.lookup_type (to_deref, &to_deref_type));
292
293 if (to_deref_type->get_kind () == TyTy::TypeKind::POINTER
294 && !unsafe_context.is_in_context ())
295 rust_error_at (expr.get_locus (), "dereference of raw pointer requires "
296 "unsafe function or block");
297 }
298
299 void
300 UnsafeChecker::visit (ErrorPropagationExpr &expr)
301 {
302 expr.get_expr ().accept_vis (*this);
303 }
304
305 void
306 UnsafeChecker::visit (NegationExpr &expr)
307 {
308 expr.get_expr ().accept_vis (*this);
309 }
310
311 void
312 UnsafeChecker::visit (ArithmeticOrLogicalExpr &expr)
313 {
314 expr.get_lhs ().accept_vis (*this);
315 expr.get_rhs ().accept_vis (*this);
316 }
317
318 void
319 UnsafeChecker::visit (ComparisonExpr &expr)
320 {
321 expr.get_lhs ().accept_vis (*this);
322 expr.get_rhs ().accept_vis (*this);
323 }
324
325 void
326 UnsafeChecker::visit (LazyBooleanExpr &expr)
327 {
328 expr.get_lhs ().accept_vis (*this);
329 expr.get_rhs ().accept_vis (*this);
330 }
331
332 void
333 UnsafeChecker::visit (TypeCastExpr &expr)
334 {
335 expr.get_expr ().accept_vis (*this);
336 }
337
338 void
339 UnsafeChecker::visit (AssignmentExpr &expr)
340 {
341 expr.get_lhs ().accept_vis (*this);
342 expr.get_rhs ().accept_vis (*this);
343 }
344
345 void
346 UnsafeChecker::visit (CompoundAssignmentExpr &expr)
347 {
348 expr.get_lhs ().accept_vis (*this);
349 expr.get_rhs ().accept_vis (*this);
350 }
351
352 void
353 UnsafeChecker::visit (GroupedExpr &expr)
354 {
355 expr.get_expr_in_parens ().accept_vis (*this);
356 }
357
358 void
359 UnsafeChecker::visit (ArrayElemsValues &elems)
360 {
361 for (auto &elem : elems.get_values ())
362 elem->accept_vis (*this);
363 }
364
365 void
366 UnsafeChecker::visit (ArrayElemsCopied &elems)
367 {
368 elems.get_elem_to_copy ().accept_vis (*this);
369 }
370
371 void
372 UnsafeChecker::visit (ArrayExpr &expr)
373 {
374 expr.get_internal_elements ().accept_vis (*this);
375 }
376
377 void
378 UnsafeChecker::visit (ArrayIndexExpr &expr)
379 {
380 expr.get_array_expr ().accept_vis (*this);
381 expr.get_index_expr ().accept_vis (*this);
382 }
383
384 void
385 UnsafeChecker::visit (TupleExpr &expr)
386 {
387 for (auto &elem : expr.get_tuple_elems ())
388 elem->accept_vis (*this);
389 }
390
391 void
392 UnsafeChecker::visit (TupleIndexExpr &expr)
393 {
394 expr.get_tuple_expr ().accept_vis (*this);
395 }
396
397 void
398 UnsafeChecker::visit (StructExprStruct &)
399 {}
400
401 void
402 UnsafeChecker::visit (StructExprFieldIdentifier &)
403 {}
404
405 void
406 UnsafeChecker::visit (StructExprFieldIdentifierValue &field)
407 {
408 field.get_value ().accept_vis (*this);
409 }
410
411 void
412 UnsafeChecker::visit (StructExprFieldIndexValue &field)
413 {
414 field.get_value ().accept_vis (*this);
415 }
416
417 void
418 UnsafeChecker::visit (StructExprStructFields &expr)
419 {
420 for (auto &field : expr.get_fields ())
421 field->accept_vis (*this);
422 }
423
424 void
425 UnsafeChecker::visit (StructExprStructBase &)
426 {}
427
428 void
429 UnsafeChecker::visit (CallExpr &expr)
430 {
431 if (!expr.has_fnexpr ())
432 return;
433
434 NodeId ast_node_id = expr.get_fnexpr ().get_mappings ().get_nodeid ();
435 NodeId ref_node_id;
436
437 // There are no unsafe types, and functions are defined in the name resolver.
438 // If we can't find the name, then we're dealing with a type and should return
439 // early.
440 if (flag_name_resolution_2_0)
441 {
442 auto &nr_ctx
443 = Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
444
445 auto resolved = nr_ctx.lookup (ast_node_id);
446
447 if (!resolved.has_value ())
448 return;
449
450 ref_node_id = resolved.value ();
451 }
452 else
453 {
454 if (!resolver.lookup_resolved_name (ast_node_id, &ref_node_id))
455 return;
456 }
457
458 if (auto definition_id = mappings.lookup_node_to_hir (ref_node_id))
459 {
460 // At this point we have the function's HIR Id. There are three checks we
461 // must perform:
462 // 1. The function is an unsafe one
463 // 2. The function is an extern one
464 // 3. The function is marked with a target_feature attribute
465 check_function_call (*definition_id, expr.get_locus ());
466 check_function_attr (*definition_id, expr.get_locus ());
467
468 if (expr.has_params ())
469 for (auto &arg : expr.get_arguments ())
470 arg->accept_vis (*this);
471 }
472 else
473 {
474 rust_unreachable ();
475 }
476 }
477
478 void
479 UnsafeChecker::visit (MethodCallExpr &expr)
480 {
481 TyTy::BaseType *method_type;
482 context.lookup_type (expr.get_method_name ().get_mappings ().get_hirid (),
483 &method_type);
484
485 auto &fn = static_cast<TyTy::FnType &> (*method_type);
486
487 auto method = mappings.lookup_hir_implitem (fn.get_ref ());
488 if (!unsafe_context.is_in_context () && method)
489 check_unsafe_call (static_cast<Function *> (method->first),
490 expr.get_locus (), "method");
491
492 expr.get_receiver ().accept_vis (*this);
493
494 for (auto &arg : expr.get_arguments ())
495 arg->accept_vis (*this);
496 }
497
498 void
499 UnsafeChecker::visit (FieldAccessExpr &expr)
500 {
501 expr.get_receiver_expr ().accept_vis (*this);
502
503 if (unsafe_context.is_in_context ())
504 return;
505
506 TyTy::BaseType *receiver_ty;
507 auto ok = context.lookup_type (
508 expr.get_receiver_expr ().get_mappings ().get_hirid (), &receiver_ty);
509 rust_assert (ok);
510
511 if (receiver_ty->get_kind () == TyTy::TypeKind::ADT)
512 {
513 auto maybe_union = static_cast<TyTy::ADTType *> (receiver_ty);
514 if (maybe_union->is_union ())
515 rust_error_at (
516 expr.get_locus (),
517 "access to union field requires unsafe function or block");
518 }
519 }
520
521 void
522 UnsafeChecker::visit (ClosureExpr &expr)
523 {
524 expr.get_expr ().accept_vis (*this);
525 }
526
527 void
528 UnsafeChecker::visit (BlockExpr &expr)
529 {
530 for (auto &stmt : expr.get_statements ())
531 stmt->accept_vis (*this);
532
533 if (expr.has_expr ())
534 expr.get_final_expr ().accept_vis (*this);
535 }
536
537 void
538 UnsafeChecker::visit (ContinueExpr &)
539 {}
540
541 void
542 UnsafeChecker::visit (BreakExpr &expr)
543 {
544 if (expr.has_break_expr ())
545 expr.get_expr ().accept_vis (*this);
546 }
547
548 void
549 UnsafeChecker::visit (RangeFromToExpr &expr)
550 {
551 expr.get_from_expr ().accept_vis (*this);
552 expr.get_to_expr ().accept_vis (*this);
553 }
554
555 void
556 UnsafeChecker::visit (RangeFromExpr &expr)
557 {
558 expr.get_from_expr ().accept_vis (*this);
559 }
560
561 void
562 UnsafeChecker::visit (RangeToExpr &expr)
563 {
564 expr.get_to_expr ().accept_vis (*this);
565 }
566
567 void
568 UnsafeChecker::visit (RangeFullExpr &)
569 {}
570
571 void
572 UnsafeChecker::visit (RangeFromToInclExpr &expr)
573 {
574 expr.get_from_expr ().accept_vis (*this);
575 expr.get_to_expr ().accept_vis (*this);
576 }
577
578 void
579 UnsafeChecker::visit (RangeToInclExpr &expr)
580 {
581 expr.get_to_expr ().accept_vis (*this);
582 }
583
584 void
585 UnsafeChecker::visit (ReturnExpr &expr)
586 {
587 if (expr.has_return_expr ())
588 expr.get_expr ().accept_vis (*this);
589 }
590
591 void
592 UnsafeChecker::visit (UnsafeBlockExpr &expr)
593 {
594 unsafe_context.enter (expr.get_mappings ().get_hirid ());
595
596 expr.get_block_expr ().accept_vis (*this);
597
598 unsafe_context.exit ();
599 }
600
601 void
602 UnsafeChecker::visit (LoopExpr &expr)
603 {
604 expr.get_loop_block ().accept_vis (*this);
605 }
606
607 void
608 UnsafeChecker::visit (WhileLoopExpr &expr)
609 {
610 expr.get_predicate_expr ().accept_vis (*this);
611 expr.get_loop_block ().accept_vis (*this);
612 }
613
614 void
615 UnsafeChecker::visit (WhileLetLoopExpr &expr)
616 {
617 expr.get_cond ().accept_vis (*this);
618 expr.get_loop_block ().accept_vis (*this);
619 }
620
621 void
622 UnsafeChecker::visit (IfExpr &expr)
623 {
624 expr.get_if_condition ().accept_vis (*this);
625 expr.get_if_block ().accept_vis (*this);
626 }
627
628 void
629 UnsafeChecker::visit (IfExprConseqElse &expr)
630 {
631 expr.get_if_condition ().accept_vis (*this);
632 expr.get_if_block ().accept_vis (*this);
633 expr.get_else_block ().accept_vis (*this);
634 }
635
636 void
637 UnsafeChecker::visit (MatchExpr &expr)
638 {
639 expr.get_scrutinee_expr ().accept_vis (*this);
640
641 for (auto &match_arm : expr.get_match_cases ())
642 match_arm.get_expr ().accept_vis (*this);
643 }
644
645 void
646 UnsafeChecker::visit (AwaitExpr &)
647 {
648 // TODO: Visit expression
649 }
650
651 void
652 UnsafeChecker::visit (AsyncBlockExpr &)
653 {
654 // TODO: Visit block expression
655 }
656
657 void
658 UnsafeChecker::visit (InlineAsm &expr)
659 {
660 if (unsafe_context.is_in_context ())
661 return;
662
663 rust_error_at (
664 expr.get_locus (), ErrorCode::E0133,
665 "use of inline assembly is unsafe and requires unsafe function or block");
666 }
667
668 void
669 UnsafeChecker::visit (TypeParam &)
670 {}
671
672 void
673 UnsafeChecker::visit (ConstGenericParam &)
674 {}
675
676 void
677 UnsafeChecker::visit (LifetimeWhereClauseItem &)
678 {}
679
680 void
681 UnsafeChecker::visit (TypeBoundWhereClauseItem &)
682 {}
683
684 void
685 UnsafeChecker::visit (Module &module)
686 {
687 for (auto &item : module.get_items ())
688 item->accept_vis (*this);
689 }
690
691 void
692 UnsafeChecker::visit (ExternCrate &)
693 {}
694
695 void
696 UnsafeChecker::visit (UseTreeGlob &)
697 {}
698
699 void
700 UnsafeChecker::visit (UseTreeList &)
701 {}
702
703 void
704 UnsafeChecker::visit (UseTreeRebind &)
705 {}
706
707 void
708 UnsafeChecker::visit (UseDeclaration &)
709 {}
710
711 void
712 UnsafeChecker::visit (Function &function)
713 {
714 auto is_unsafe_fn = function.get_qualifiers ().is_unsafe ();
715
716 if (is_unsafe_fn)
717 unsafe_context.enter (function.get_mappings ().get_hirid ());
718
719 function.get_definition ().accept_vis (*this);
720
721 if (is_unsafe_fn)
722 unsafe_context.exit ();
723 }
724
725 void
726 UnsafeChecker::visit (TypeAlias &)
727 {
728 // FIXME: What do we need to do to handle type aliasing? Is it possible to
729 // have unsafe types? Type aliases on unsafe functions?
730 }
731
732 void
733 UnsafeChecker::visit (StructStruct &)
734 {}
735
736 void
737 UnsafeChecker::visit (TupleStruct &)
738 {}
739
740 void
741 UnsafeChecker::visit (EnumItem &)
742 {}
743
744 void
745 UnsafeChecker::visit (EnumItemTuple &)
746 {}
747
748 void
749 UnsafeChecker::visit (EnumItemStruct &)
750 {}
751
752 void
753 UnsafeChecker::visit (EnumItemDiscriminant &)
754 {}
755
756 void
757 UnsafeChecker::visit (Enum &)
758 {}
759
760 void
761 UnsafeChecker::visit (Union &)
762 {}
763
764 void
765 UnsafeChecker::visit (ConstantItem &const_item)
766 {
767 const_item.get_expr ().accept_vis (*this);
768 }
769
770 void
771 UnsafeChecker::visit (StaticItem &static_item)
772 {
773 static_item.get_expr ().accept_vis (*this);
774 }
775
776 void
777 UnsafeChecker::visit (TraitItemFunc &item)
778 {
779 if (item.has_definition ())
780 item.get_block_expr ().accept_vis (*this);
781 }
782
783 void
784 UnsafeChecker::visit (TraitItemConst &item)
785 {
786 if (item.has_expr ())
787 item.get_expr ().accept_vis (*this);
788 }
789
790 void
791 UnsafeChecker::visit (TraitItemType &)
792 {}
793
794 void
795 UnsafeChecker::visit (Trait &trait)
796 {
797 // FIXME: Handle unsafe traits
798 for (auto &item : trait.get_trait_items ())
799 item->accept_vis (*this);
800 }
801
802 void
803 UnsafeChecker::visit (ImplBlock &impl)
804 {
805 bool safe = !impl.is_unsafe ();
806 // Check for unsafe-only attributes on generics and lifetimes
807 if (safe)
808 for (auto &parm : impl.get_generic_params ())
809 {
810 for (auto o_attr : parm->get_outer_attrs ())
811 {
812 rust_assert (!o_attr.is_inner_attribute ());
813
814 Rust::AST::SimplePath path = o_attr.get_path ();
815 if (path == Values::Attributes::MAY_DANGLE)
816 rust_error_at (
817 o_attr.get_locus (), ErrorCode::E0569,
818 "use of %<may_dangle%> is unsafe and requires unsafe impl");
819 }
820 }
821
822 for (auto &item : impl.get_impl_items ())
823 item->accept_vis (*this);
824 }
825
826 void
827 UnsafeChecker::visit (ExternalStaticItem &)
828 {}
829
830 void
831 UnsafeChecker::visit (ExternalFunctionItem &)
832 {}
833
834 void
835 UnsafeChecker::visit (ExternalTypeItem &)
836 {}
837
838 void
839 UnsafeChecker::visit (ExternBlock &block)
840 {
841 // FIXME: Do we need to do this?
842 for (auto &item : block.get_extern_items ())
843 item->accept_vis (*this);
844 }
845
846 void
847 UnsafeChecker::visit (LiteralPattern &)
848 {}
849
850 void
851 UnsafeChecker::visit (IdentifierPattern &)
852 {}
853
854 void
855 UnsafeChecker::visit (WildcardPattern &)
856 {}
857
858 void
859 UnsafeChecker::visit (RangePatternBoundLiteral &)
860 {}
861
862 void
863 UnsafeChecker::visit (RangePatternBoundPath &)
864 {}
865
866 void
867 UnsafeChecker::visit (RangePatternBoundQualPath &)
868 {}
869
870 void
871 UnsafeChecker::visit (RangePattern &)
872 {}
873
874 void
875 UnsafeChecker::visit (ReferencePattern &)
876 {}
877
878 void
879 UnsafeChecker::visit (StructPatternFieldTuplePat &)
880 {}
881
882 void
883 UnsafeChecker::visit (StructPatternFieldIdentPat &)
884 {}
885
886 void
887 UnsafeChecker::visit (StructPatternFieldIdent &)
888 {}
889
890 void
891 UnsafeChecker::visit (StructPattern &)
892 {}
893
894 void
895 UnsafeChecker::visit (TupleStructItemsNoRange &)
896 {}
897
898 void
899 UnsafeChecker::visit (TupleStructItemsRange &)
900 {}
901
902 void
903 UnsafeChecker::visit (TupleStructPattern &)
904 {}
905
906 void
907 UnsafeChecker::visit (TuplePatternItemsMultiple &)
908 {}
909
910 void
911 UnsafeChecker::visit (TuplePatternItemsRanged &)
912 {}
913
914 void
915 UnsafeChecker::visit (TuplePattern &)
916 {}
917
918 void
919 UnsafeChecker::visit (SlicePattern &)
920 {}
921
922 void
923 UnsafeChecker::visit (AltPattern &)
924 {}
925
926 void
927 UnsafeChecker::visit (EmptyStmt &)
928 {}
929
930 void
931 UnsafeChecker::visit (LetStmt &stmt)
932 {
933 if (stmt.has_init_expr ())
934 stmt.get_init_expr ().accept_vis (*this);
935 }
936
937 void
938 UnsafeChecker::visit (ExprStmt &stmt)
939 {
940 stmt.get_expr ().accept_vis (*this);
941 }
942
943 void
944 UnsafeChecker::visit (TraitBound &)
945 {}
946
947 void
948 UnsafeChecker::visit (ImplTraitType &)
949 {}
950
951 void
952 UnsafeChecker::visit (TraitObjectType &)
953 {}
954
955 void
956 UnsafeChecker::visit (ParenthesisedType &)
957 {}
958
959 void
960 UnsafeChecker::visit (TupleType &)
961 {}
962
963 void
964 UnsafeChecker::visit (NeverType &)
965 {}
966
967 void
968 UnsafeChecker::visit (RawPointerType &)
969 {}
970
971 void
972 UnsafeChecker::visit (ReferenceType &)
973 {}
974
975 void
976 UnsafeChecker::visit (ArrayType &)
977 {}
978
979 void
980 UnsafeChecker::visit (SliceType &)
981 {}
982
983 void
984 UnsafeChecker::visit (InferredType &)
985 {}
986
987 void
988 UnsafeChecker::visit (BareFunctionType &)
989 {}
990
991 } // namespace HIR
992 } // namespace Rust