Line data Source code
1 : // Copyright (C) 2021-2026 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-expr.h"
20 : #include "rust-hir-full-decls.h"
21 : #include "rust-hir-visitor.h"
22 : #include "rust-hir-full.h"
23 : #include "rust-system.h"
24 :
25 : namespace Rust {
26 : namespace HIR {
27 :
28 : void
29 5855 : DefaultHIRVisitor::walk (Lifetime &)
30 5855 : {}
31 :
32 : void
33 173 : DefaultHIRVisitor::walk (LifetimeParam &lifetime_param)
34 : {
35 173 : visit_outer_attrs (lifetime_param);
36 173 : lifetime_param.get_lifetime ().accept_vis (*this);
37 173 : for (Lifetime &lifetime_bound : lifetime_param.get_lifetime_bounds ())
38 0 : lifetime_bound.accept_vis (*this);
39 173 : }
40 :
41 : void
42 2307 : DefaultHIRVisitor::visit_generic_args (GenericArgs &generic_args)
43 : {
44 2333 : for (auto &lifetime : generic_args.get_lifetime_args ())
45 26 : lifetime.accept_vis (*this);
46 4688 : for (auto &type : generic_args.get_type_args ())
47 2381 : type->accept_vis (*this);
48 2372 : for (auto &binding : generic_args.get_binding_args ())
49 65 : binding.get_type ().accept_vis (*this);
50 2343 : for (auto &const_arg : generic_args.get_const_args ())
51 36 : const_arg.get_expression ()->accept_vis (*this);
52 2307 : }
53 :
54 : void
55 20 : DefaultHIRVisitor::walk (PathInExpression &path_in_expr)
56 : {
57 20 : visit_outer_attrs (path_in_expr);
58 20 : if (!path_in_expr.is_lang_item ())
59 40 : for (auto &segment : path_in_expr.get_segments ())
60 20 : visit_path_expr_segment (segment);
61 20 : }
62 :
63 : void
64 44946 : DefaultHIRVisitor::walk (TypePathSegment &)
65 44946 : {}
66 :
67 : void
68 27 : DefaultHIRVisitor::walk (TypePathSegmentFunction &segment_function)
69 : {
70 27 : TypePathFunction &function_path = segment_function.get_function_path ();
71 27 : if (function_path.has_inputs ())
72 56 : for (auto ¶m : function_path.get_params ())
73 29 : param->accept_vis (*this);
74 27 : if (function_path.has_return_type ())
75 27 : function_path.get_return_type ().accept_vis (*this);
76 27 : }
77 :
78 : void
79 2307 : DefaultHIRVisitor::walk (TypePathSegmentGeneric &segment_generic)
80 : {
81 2307 : if (segment_generic.has_generic_args ())
82 2307 : visit_generic_args (segment_generic.get_generic_args ());
83 2307 : }
84 :
85 : void
86 45301 : DefaultHIRVisitor::walk (TypePath &type_path)
87 : {
88 92382 : for (auto &segment : type_path.get_segments ())
89 47081 : segment->accept_vis (*this);
90 45301 : }
91 :
92 : void
93 271 : DefaultHIRVisitor::visit_qualified_path_type (QualifiedPathType &path)
94 : {
95 271 : path.get_type ().accept_vis (*this);
96 271 : if (path.has_as_clause ())
97 239 : path.get_trait ().accept_vis (*this);
98 271 : }
99 :
100 : // TODO: Implement visit_path_expr_segment
101 : void
102 1422 : DefaultHIRVisitor::visit_path_expr_segment (PathExprSegment &segment)
103 : {
104 1422 : if (segment.has_generic_args ())
105 0 : visit_generic_args (segment.get_generic_args ());
106 1422 : }
107 :
108 : void
109 72 : DefaultHIRVisitor::walk (QualifiedPathInExpression &path_in_expr)
110 : {
111 72 : visit_outer_attrs (path_in_expr);
112 72 : visit_qualified_path_type (path_in_expr.get_path_type ());
113 144 : for (auto &segment : path_in_expr.get_segments ())
114 72 : visit_path_expr_segment (segment);
115 72 : }
116 :
117 : void
118 199 : DefaultHIRVisitor::walk (QualifiedPathInType &path_in_type)
119 : {
120 199 : visit_qualified_path_type (path_in_type.get_path_type ());
121 199 : path_in_type.get_associated_segment ().accept_vis (*this);
122 199 : for (auto &segment : path_in_type.get_segments ())
123 0 : segment->accept_vis (*this);
124 199 : }
125 :
126 : void
127 23 : DefaultHIRVisitor::walk (LiteralExpr &expr)
128 : {
129 23 : visit_outer_attrs (expr);
130 23 : }
131 :
132 : void
133 1202 : DefaultHIRVisitor::walk (BorrowExpr &expr)
134 : {
135 1202 : visit_outer_attrs (expr);
136 1202 : expr.get_expr ().accept_vis (*this);
137 1202 : }
138 :
139 : void
140 0 : DefaultHIRVisitor::walk (DereferenceExpr &expr)
141 : {
142 0 : visit_outer_attrs (expr);
143 0 : expr.get_expr ().accept_vis (*this);
144 0 : }
145 :
146 : void
147 0 : DefaultHIRVisitor::walk (ErrorPropagationExpr &expr)
148 : {
149 0 : visit_outer_attrs (expr);
150 0 : expr.get_expr ().accept_vis (*this);
151 0 : }
152 :
153 : void
154 324 : DefaultHIRVisitor::walk (NegationExpr &expr)
155 : {
156 324 : visit_outer_attrs (expr);
157 324 : expr.get_expr ().accept_vis (*this);
158 324 : }
159 :
160 : void
161 2155 : DefaultHIRVisitor::walk (ArithmeticOrLogicalExpr &expr)
162 : {
163 2155 : visit_outer_attrs (expr);
164 2155 : expr.get_lhs ().accept_vis (*this);
165 2155 : expr.get_rhs ().accept_vis (*this);
166 2155 : }
167 :
168 : void
169 2557 : DefaultHIRVisitor::walk (ComparisonExpr &expr)
170 : {
171 2557 : visit_outer_attrs (expr);
172 2557 : expr.get_lhs ().accept_vis (*this);
173 2557 : expr.get_rhs ().accept_vis (*this);
174 2557 : }
175 :
176 : void
177 335 : DefaultHIRVisitor::walk (LazyBooleanExpr &expr)
178 : {
179 335 : visit_outer_attrs (expr);
180 335 : expr.get_lhs ().accept_vis (*this);
181 335 : expr.get_rhs ().accept_vis (*this);
182 335 : }
183 :
184 : void
185 1960 : DefaultHIRVisitor::walk (TypeCastExpr &expr)
186 : {
187 1960 : visit_outer_attrs (expr);
188 1960 : expr.get_expr ().accept_vis (*this);
189 1960 : expr.get_type_to_convert_to ().accept_vis (*this);
190 1960 : }
191 :
192 : void
193 0 : DefaultHIRVisitor::walk (AssignmentExpr &expr)
194 : {
195 0 : visit_outer_attrs (expr);
196 0 : expr.get_lhs ().accept_vis (*this);
197 0 : expr.get_rhs ().accept_vis (*this);
198 0 : }
199 :
200 : void
201 652 : DefaultHIRVisitor::walk (CompoundAssignmentExpr &expr)
202 : {
203 652 : visit_outer_attrs (expr);
204 652 : expr.get_lhs ().accept_vis (*this);
205 652 : expr.get_rhs ().accept_vis (*this);
206 652 : }
207 :
208 : void
209 182 : DefaultHIRVisitor::walk (GroupedExpr &expr)
210 : {
211 182 : visit_outer_attrs (expr);
212 182 : visit_inner_attrs (expr);
213 182 : expr.get_expr_in_parens ().accept_vis (*this);
214 182 : }
215 :
216 : void
217 37 : DefaultHIRVisitor::walk (ArrayElemsValues &elems)
218 : {
219 246 : for (auto &elem : elems.get_values ())
220 209 : elem->accept_vis (*this);
221 37 : }
222 :
223 : void
224 37 : DefaultHIRVisitor::walk (ArrayElemsCopied &elems)
225 : {
226 37 : elems.get_elem_to_copy ().accept_vis (*this);
227 37 : elems.get_num_copies_expr ().accept_vis (*this);
228 37 : }
229 :
230 : void
231 74 : DefaultHIRVisitor::walk (ArrayExpr &expr)
232 : {
233 74 : visit_outer_attrs (expr);
234 74 : visit_inner_attrs (expr);
235 74 : expr.get_internal_elements ().accept_vis (*this);
236 74 : }
237 :
238 : void
239 0 : DefaultHIRVisitor::walk (ArrayIndexExpr &expr)
240 : {
241 0 : visit_outer_attrs (expr);
242 0 : expr.get_array_expr ().accept_vis (*this);
243 0 : expr.get_index_expr ().accept_vis (*this);
244 0 : }
245 :
246 : void
247 2 : DefaultHIRVisitor::walk (TupleExpr &expr)
248 : {
249 2 : visit_outer_attrs (expr);
250 2 : visit_inner_attrs (expr);
251 6 : for (auto &elem : expr.get_tuple_elems ())
252 4 : elem->accept_vis (*this);
253 2 : }
254 :
255 : void
256 0 : DefaultHIRVisitor::walk (TupleIndexExpr &expr)
257 : {
258 0 : visit_outer_attrs (expr);
259 0 : expr.get_tuple_expr ().accept_vis (*this);
260 0 : }
261 :
262 : void
263 13 : DefaultHIRVisitor::walk (StructExprStruct &expr)
264 : {
265 13 : visit_outer_attrs (expr);
266 13 : visit_inner_attrs (expr);
267 13 : expr.get_struct_name ().accept_vis (*this);
268 13 : }
269 :
270 : void
271 86 : DefaultHIRVisitor::walk (StructExprFieldIdentifier &)
272 86 : {}
273 :
274 : void
275 288 : DefaultHIRVisitor::walk (StructExprFieldIdentifierValue &field)
276 : {
277 288 : field.get_value ().accept_vis (*this);
278 288 : }
279 :
280 : void
281 0 : DefaultHIRVisitor::walk (StructExprFieldIndexValue &field)
282 : {
283 0 : field.get_value ().accept_vis (*this);
284 0 : }
285 :
286 : void
287 190 : DefaultHIRVisitor::walk (StructExprStructFields &expr)
288 : {
289 190 : visit_outer_attrs (expr);
290 190 : visit_inner_attrs (expr);
291 190 : expr.get_struct_name ().accept_vis (*this);
292 190 : if (expr.has_struct_base ())
293 : {
294 0 : StructBase &base = expr.get_struct_base ();
295 0 : base.get_base ().accept_vis (*this);
296 : }
297 564 : for (auto &field : expr.get_fields ())
298 374 : field->accept_vis (*this);
299 190 : }
300 :
301 : void
302 0 : DefaultHIRVisitor::walk (StructExprStructBase &expr)
303 : {
304 0 : visit_outer_attrs (expr);
305 0 : visit_inner_attrs (expr);
306 0 : expr.get_struct_name ().accept_vis (*this);
307 0 : StructBase &base = expr.get_struct_base ();
308 0 : base.get_base ().accept_vis (*this);
309 0 : }
310 :
311 : void
312 7642 : DefaultHIRVisitor::walk (CallExpr &expr)
313 : {
314 7642 : visit_outer_attrs (expr);
315 7642 : expr.get_fnexpr ().accept_vis (*this);
316 16942 : for (auto &arg : expr.get_arguments ())
317 9300 : arg->accept_vis (*this);
318 7642 : }
319 :
320 : void
321 1330 : DefaultHIRVisitor::walk (MethodCallExpr &expr)
322 : {
323 1330 : visit_outer_attrs (expr);
324 1330 : expr.get_receiver ().accept_vis (*this);
325 1330 : visit_path_expr_segment (expr.get_method_name ());
326 2196 : for (auto &arg : expr.get_arguments ())
327 866 : arg->accept_vis (*this);
328 1330 : }
329 :
330 : void
331 0 : DefaultHIRVisitor::walk (FieldAccessExpr &expr)
332 : {
333 0 : visit_outer_attrs (expr);
334 0 : expr.get_receiver_expr ().accept_vis (*this);
335 0 : }
336 :
337 : void
338 0 : DefaultHIRVisitor::visit_closure_param (ClosureParam ¶m)
339 : {
340 0 : visit_outer_attrs (param);
341 0 : param.get_pattern ().accept_vis (*this);
342 0 : if (param.has_type_given ())
343 : {
344 0 : param.get_type ().accept_vis (*this);
345 : }
346 0 : }
347 :
348 : void
349 7 : DefaultHIRVisitor::walk (ClosureExpr &expr)
350 : {
351 7 : visit_outer_attrs (expr);
352 7 : for (auto ¶m : expr.get_params ())
353 0 : visit_closure_param (param);
354 7 : if (expr.has_return_type ())
355 0 : expr.get_return_type ().accept_vis (*this);
356 7 : expr.get_expr ().accept_vis (*this);
357 7 : }
358 :
359 : void
360 20436 : DefaultHIRVisitor::walk (BlockExpr &expr)
361 : {
362 20436 : visit_outer_attrs (expr);
363 20436 : visit_inner_attrs (expr);
364 41934 : for (auto &stmt : expr.get_statements ())
365 21498 : stmt->accept_vis (*this);
366 20436 : if (expr.has_expr ())
367 14953 : expr.get_final_expr ().accept_vis (*this);
368 20436 : }
369 :
370 : void
371 477 : DefaultHIRVisitor::walk (AnonConst &expr)
372 : {
373 477 : if (!expr.is_deferred ())
374 477 : expr.get_inner_expr ().accept_vis (*this);
375 477 : }
376 :
377 : void
378 7 : DefaultHIRVisitor::walk (ConstBlock &expr)
379 : {
380 7 : expr.get_const_expr ().accept_vis (*this);
381 7 : }
382 :
383 : void
384 9 : DefaultHIRVisitor::walk (ContinueExpr &expr)
385 : {
386 9 : visit_outer_attrs (expr);
387 9 : if (expr.has_label ())
388 4 : expr.get_label ().accept_vis (*this);
389 9 : }
390 :
391 : void
392 52 : DefaultHIRVisitor::walk (BreakExpr &expr)
393 : {
394 52 : visit_outer_attrs (expr);
395 52 : if (expr.has_label ())
396 19 : expr.get_label ().accept_vis (*this);
397 :
398 52 : if (expr.has_break_expr ())
399 0 : expr.get_expr ().accept_vis (*this);
400 52 : }
401 :
402 : void
403 0 : DefaultHIRVisitor::walk (RangeFromToExpr &expr)
404 : {
405 0 : expr.get_from_expr ().accept_vis (*this);
406 0 : expr.get_to_expr ().accept_vis (*this);
407 0 : }
408 :
409 : void
410 0 : DefaultHIRVisitor::walk (RangeFromExpr &expr)
411 : {
412 0 : expr.get_from_expr ().accept_vis (*this);
413 0 : }
414 :
415 : void
416 0 : DefaultHIRVisitor::walk (RangeToExpr &expr)
417 : {
418 0 : expr.get_to_expr ().accept_vis (*this);
419 0 : }
420 :
421 : void
422 0 : DefaultHIRVisitor::walk (RangeFullExpr &)
423 0 : {}
424 :
425 : void
426 0 : DefaultHIRVisitor::walk (RangeFromToInclExpr &expr)
427 : {
428 0 : expr.get_from_expr ().accept_vis (*this);
429 0 : expr.get_to_expr ().accept_vis (*this);
430 0 : }
431 :
432 : void
433 0 : DefaultHIRVisitor::walk (RangeToInclExpr &expr)
434 : {
435 0 : expr.get_to_expr ().accept_vis (*this);
436 0 : }
437 :
438 : void
439 496 : DefaultHIRVisitor::walk (ReturnExpr &expr)
440 : {
441 496 : visit_outer_attrs (expr);
442 496 : if (expr.has_return_expr ())
443 467 : expr.get_expr ().accept_vis (*this);
444 496 : }
445 :
446 : void
447 3082 : DefaultHIRVisitor::walk (UnsafeBlockExpr &expr)
448 : {
449 3082 : visit_outer_attrs (expr);
450 3082 : expr.get_block_expr ().accept_vis (*this);
451 3082 : }
452 :
453 : void
454 39 : DefaultHIRVisitor::visit_loop_label (LoopLabel &label)
455 : {
456 39 : label.get_lifetime ().accept_vis (*this);
457 39 : }
458 :
459 : void
460 91 : DefaultHIRVisitor::walk (LoopExpr &expr)
461 : {
462 91 : visit_outer_attrs (expr);
463 91 : if (expr.has_loop_label ())
464 42 : visit_loop_label (expr.get_loop_label ());
465 91 : expr.get_loop_block ().accept_vis (*this);
466 91 : }
467 :
468 : void
469 72 : DefaultHIRVisitor::walk (WhileLoopExpr &expr)
470 : {
471 72 : visit_outer_attrs (expr);
472 72 : if (expr.has_loop_label ())
473 1 : visit_loop_label (expr.get_loop_label ());
474 72 : expr.get_predicate_expr ().accept_vis (*this);
475 72 : expr.get_loop_block ().accept_vis (*this);
476 72 : }
477 :
478 : void
479 0 : DefaultHIRVisitor::walk (WhileLetLoopExpr &expr)
480 : {
481 0 : visit_outer_attrs (expr);
482 0 : expr.get_pattern ()->accept_vis (*this);
483 0 : if (expr.has_loop_label ())
484 0 : visit_loop_label (expr.get_loop_label ());
485 0 : expr.get_cond ().accept_vis (*this);
486 0 : expr.get_loop_block ().accept_vis (*this);
487 0 : }
488 :
489 : void
490 1589 : DefaultHIRVisitor::walk (IfExpr &expr)
491 : {
492 1589 : visit_outer_attrs (expr);
493 1589 : expr.get_if_condition ().accept_vis (*this);
494 1589 : expr.get_if_block ().accept_vis (*this);
495 1589 : }
496 :
497 : void
498 1143 : DefaultHIRVisitor::walk (IfExprConseqElse &expr)
499 : {
500 1143 : expr.IfExpr::accept_vis (*this);
501 1143 : expr.get_else_block ().accept_vis (*this);
502 1143 : }
503 :
504 : void
505 2332 : DefaultHIRVisitor::visit_match_arm (MatchArm &arm)
506 : {
507 : // visit_outer_attrs (arm);
508 2332 : arm.get_pattern ()->accept_vis (*this);
509 2332 : if (arm.has_match_arm_guard ())
510 1 : arm.get_guard_expr ().accept_vis (*this);
511 2332 : }
512 :
513 : void
514 2332 : DefaultHIRVisitor::visit_match_case (MatchCase &arm)
515 : {
516 2332 : visit_match_arm (arm.get_arm ());
517 2332 : arm.get_expr ().accept_vis (*this);
518 2332 : }
519 :
520 : void
521 990 : DefaultHIRVisitor::walk (MatchExpr &expr)
522 : {
523 990 : visit_outer_attrs (expr);
524 990 : visit_inner_attrs (expr);
525 990 : expr.get_scrutinee_expr ().accept_vis (*this);
526 3322 : for (auto &arm : expr.get_match_cases ())
527 2332 : visit_match_case (arm);
528 990 : }
529 :
530 : void
531 0 : DefaultHIRVisitor::walk (AwaitExpr &expr)
532 : {
533 0 : visit_outer_attrs (expr);
534 0 : expr.get_awaited_expr ().accept_vis (*this);
535 0 : }
536 :
537 : void
538 0 : DefaultHIRVisitor::walk (AsyncBlockExpr &expr)
539 : {
540 0 : visit_outer_attrs (expr);
541 0 : expr.get_block_expr ().accept_vis (*this);
542 0 : }
543 :
544 : void
545 24 : DefaultHIRVisitor::walk (InlineAsm &expr)
546 : {
547 24 : visit_outer_attrs (expr);
548 24 : auto &operands = expr.get_operands ();
549 24 : using RegisterType = AST::InlineAsmOperand::RegisterType;
550 53 : for (auto &operand : operands)
551 : {
552 29 : switch (operand.get_register_type ())
553 : {
554 10 : case RegisterType::In:
555 10 : {
556 10 : operand.get_in ().expr->accept_vis (*this);
557 10 : break;
558 : }
559 17 : case RegisterType::Out:
560 17 : {
561 17 : operand.get_out ().expr->accept_vis (*this);
562 17 : break;
563 : }
564 0 : case RegisterType::InOut:
565 0 : {
566 0 : operand.get_in_out ().expr->accept_vis (*this);
567 0 : break;
568 : }
569 2 : case RegisterType::SplitInOut:
570 2 : {
571 2 : operand.get_split_in_out ().in_expr->accept_vis (*this);
572 2 : operand.get_split_in_out ().out_expr->accept_vis (*this);
573 2 : break;
574 : }
575 0 : case RegisterType::Const:
576 0 : {
577 0 : operand.get_const ().anon_const.get_inner_expr ().accept_vis (
578 : *this);
579 0 : break;
580 : }
581 0 : case RegisterType::Sym:
582 0 : {
583 0 : operand.get_sym ().expr->accept_vis (*this);
584 0 : break;
585 : }
586 0 : case RegisterType::Label:
587 0 : {
588 0 : operand.get_label ().expr->accept_vis (*this);
589 0 : break;
590 : }
591 : }
592 : }
593 24 : }
594 :
595 : void
596 2 : DefaultHIRVisitor::walk (LlvmInlineAsm &expr)
597 : {
598 2 : for (auto &output : expr.outputs)
599 0 : output.expr->accept_vis (*this);
600 4 : for (auto &input : expr.inputs)
601 2 : input.expr->accept_vis (*this);
602 2 : }
603 :
604 : void
605 0 : DefaultHIRVisitor::walk (OffsetOf &expr)
606 : {
607 0 : expr.get_type ().accept_vis (*this);
608 0 : }
609 :
610 : void
611 7727 : DefaultHIRVisitor::walk (TypeParam ¶m)
612 : {
613 7727 : visit_outer_attrs (param);
614 8526 : for (auto &bounds : param.get_type_param_bounds ())
615 799 : bounds->accept_vis (*this);
616 7727 : if (param.has_type ())
617 346 : param.get_type ().accept_vis (*this);
618 7727 : }
619 :
620 : void
621 0 : DefaultHIRVisitor::walk (ConstGenericParam &const_param)
622 : {
623 0 : visit_outer_attrs (const_param);
624 0 : const_param.get_type ().accept_vis (*this);
625 0 : if (const_param.has_default_expression ())
626 0 : const_param.get_default_expression ().accept_vis (*this);
627 0 : }
628 :
629 : void
630 0 : DefaultHIRVisitor::walk (LifetimeWhereClauseItem &item)
631 : {
632 0 : item.get_lifetime ().accept_vis (*this);
633 0 : for (auto &bound : item.get_lifetime_bounds ())
634 0 : bound.accept_vis (*this);
635 0 : }
636 :
637 : void
638 139 : DefaultHIRVisitor::walk (TypeBoundWhereClauseItem &item)
639 : {
640 146 : for (auto &lifetime : item.get_for_lifetimes ())
641 7 : lifetime.accept_vis (*this);
642 139 : item.get_bound_type ().accept_vis (*this);
643 278 : for (auto ¶m : item.get_type_param_bounds ())
644 139 : param->accept_vis (*this);
645 139 : }
646 :
647 : void
648 1154 : DefaultHIRVisitor::walk (Module &module)
649 : {
650 1154 : visit_outer_attrs (module);
651 1154 : visit_inner_attrs (module);
652 4832 : for (auto &item : module.get_items ())
653 3678 : item->accept_vis (*this);
654 1154 : }
655 :
656 : void
657 0 : DefaultHIRVisitor::walk (ExternCrate &crate)
658 : {
659 0 : visit_outer_attrs (crate);
660 0 : }
661 :
662 : void
663 0 : DefaultHIRVisitor::walk (UseTreeGlob &)
664 0 : {}
665 :
666 : void
667 0 : DefaultHIRVisitor::walk (UseTreeList &)
668 0 : {}
669 :
670 : void
671 0 : DefaultHIRVisitor::walk (UseTreeRebind &)
672 0 : {}
673 :
674 : void
675 0 : DefaultHIRVisitor::walk (UseDeclaration &)
676 0 : {}
677 :
678 : void
679 7734 : DefaultHIRVisitor::visit_function_param (FunctionParam ¶m)
680 : {
681 7734 : param.get_param_name ().accept_vis (*this);
682 7734 : param.get_type ().accept_vis (*this);
683 7734 : }
684 :
685 : void
686 12626 : DefaultHIRVisitor::walk (Function &function)
687 : {
688 12626 : visit_outer_attrs (function);
689 13365 : for (auto &generic : function.get_generic_params ())
690 739 : generic->accept_vis (*this);
691 18759 : for (auto ¶m : function.get_function_params ())
692 6133 : visit_function_param (param);
693 12626 : if (function.has_return_type ())
694 9283 : function.get_return_type ().accept_vis (*this);
695 12626 : if (function.has_where_clause ())
696 27 : visit_where_clause (function.get_where_clause ());
697 12626 : function.get_definition ().accept_vis (*this);
698 12626 : }
699 :
700 : void
701 1212 : DefaultHIRVisitor::walk (TypeAlias &type_alias)
702 : {
703 1212 : visit_outer_attrs (type_alias);
704 1226 : for (auto &generic : type_alias.get_generic_params ())
705 14 : generic->accept_vis (*this);
706 1212 : if (type_alias.has_where_clause ())
707 0 : visit_where_clause (type_alias.get_where_clause ());
708 1212 : type_alias.get_type_aliased ().accept_vis (*this);
709 1212 : }
710 :
711 : void
712 2018 : DefaultHIRVisitor::visit_struct_field (StructField &field)
713 : {
714 2018 : field.get_field_type ().accept_vis (*this);
715 2018 : }
716 :
717 : void
718 1409 : DefaultHIRVisitor::walk (StructStruct &struct_item)
719 : {
720 1409 : visit_outer_attrs (struct_item);
721 1887 : for (auto &generic : struct_item.get_generic_params ())
722 478 : generic->accept_vis (*this);
723 1409 : if (struct_item.has_where_clause ())
724 2 : visit_where_clause (struct_item.get_where_clause ());
725 3142 : for (auto &field : struct_item.get_fields ())
726 1733 : visit_struct_field (field);
727 1409 : }
728 :
729 : void
730 927 : DefaultHIRVisitor::walk (TupleStruct &tuple_struct)
731 : {
732 927 : visit_outer_attrs (tuple_struct);
733 1271 : for (auto &generic : tuple_struct.get_generic_params ())
734 344 : generic->accept_vis (*this);
735 927 : if (tuple_struct.has_where_clause ())
736 0 : visit_where_clause (tuple_struct.get_where_clause ());
737 2500 : for (auto &field : tuple_struct.get_fields ())
738 1573 : field.get_field_type ().accept_vis (*this);
739 927 : }
740 :
741 : void
742 1139 : DefaultHIRVisitor::walk (EnumItem &item)
743 : {
744 1139 : visit_outer_attrs (item);
745 1139 : }
746 :
747 : void
748 388 : DefaultHIRVisitor::walk (EnumItemTuple &item_tuple)
749 : {
750 388 : item_tuple.EnumItem::accept_vis (*this);
751 799 : for (auto &field : item_tuple.get_tuple_fields ())
752 411 : field.get_field_type ().accept_vis (*this);
753 388 : }
754 :
755 : void
756 79 : DefaultHIRVisitor::walk (EnumItemStruct &item_struct)
757 : {
758 79 : item_struct.EnumItem::accept_vis (*this);
759 209 : for (auto &field : item_struct.get_struct_fields ())
760 130 : field.get_field_type ().accept_vis (*this);
761 79 : }
762 :
763 : void
764 268 : DefaultHIRVisitor::walk (EnumItemDiscriminant &item)
765 : {
766 268 : item.EnumItem::accept_vis (*this);
767 268 : item.get_discriminant_expression ().accept_vis (*this);
768 268 : }
769 :
770 : void
771 480 : DefaultHIRVisitor::walk (Enum &enum_item)
772 : {
773 480 : visit_outer_attrs (enum_item);
774 747 : for (auto &generic : enum_item.get_generic_params ())
775 267 : generic->accept_vis (*this);
776 480 : if (enum_item.has_where_clause ())
777 0 : visit_where_clause (enum_item.get_where_clause ());
778 1619 : for (auto &item : enum_item.get_variants ())
779 1139 : item->accept_vis (*this);
780 480 : }
781 :
782 : void
783 96 : DefaultHIRVisitor::walk (Union &union_item)
784 : {
785 96 : visit_outer_attrs (union_item);
786 169 : for (auto &generic : union_item.get_generic_params ())
787 73 : generic->accept_vis (*this);
788 96 : if (union_item.has_where_clause ())
789 0 : visit_where_clause (union_item.get_where_clause ());
790 381 : for (auto &variant : union_item.get_variants ())
791 285 : visit_struct_field (variant);
792 96 : }
793 :
794 : void
795 496 : DefaultHIRVisitor::walk (ConstantItem &const_item)
796 : {
797 496 : visit_outer_attrs (const_item);
798 496 : const_item.get_type ().accept_vis (*this);
799 496 : const_item.get_expr ().accept_vis (*this);
800 496 : }
801 :
802 : void
803 50 : DefaultHIRVisitor::walk (StaticItem &static_item)
804 : {
805 50 : visit_outer_attrs (static_item);
806 50 : static_item.get_type ().accept_vis (*this);
807 50 : static_item.get_expr ().accept_vis (*this);
808 50 : }
809 :
810 : void
811 2166 : DefaultHIRVisitor::visit_self_param (SelfParam &self_param)
812 : {
813 2166 : if (self_param.has_lifetime ())
814 : {
815 1614 : Lifetime lifetime = self_param.get_lifetime ();
816 1614 : lifetime.accept_vis (*this);
817 1614 : }
818 2166 : if (self_param.has_type ())
819 0 : self_param.get_type ().accept_vis (*this);
820 2166 : }
821 :
822 : void
823 2458 : DefaultHIRVisitor::walk (TraitItemFunc &item)
824 : {
825 2458 : visit_outer_attrs (item);
826 2458 : TraitFunctionDecl &decl = item.get_decl ();
827 2474 : for (auto &generic : decl.get_generic_params ())
828 16 : generic->accept_vis (*this);
829 2458 : if (decl.get_self ().has_value ())
830 2166 : visit_self_param (decl.get_self ().value ());
831 4059 : for (auto ¶m : decl.get_function_params ())
832 1601 : visit_function_param (param);
833 2458 : if (decl.has_return_type ())
834 2058 : decl.get_return_type ().accept_vis (*this);
835 2458 : if (decl.has_where_clause ())
836 0 : visit_where_clause (decl.get_where_clause ());
837 2458 : if (item.has_definition ())
838 840 : item.get_block_expr ().accept_vis (*this);
839 2458 : }
840 :
841 : void
842 30 : DefaultHIRVisitor::walk (TraitItemConst &item)
843 : {
844 30 : visit_outer_attrs (item);
845 30 : item.get_type ().accept_vis (*this);
846 30 : if (item.has_expr ())
847 7 : item.get_expr ().accept_vis (*this);
848 30 : }
849 :
850 : void
851 709 : DefaultHIRVisitor::walk (TraitItemType &item)
852 : {
853 709 : visit_outer_attrs (item);
854 751 : for (auto &bound : item.get_type_param_bounds ())
855 42 : bound->accept_vis (*this);
856 709 : }
857 :
858 : void
859 0 : DefaultHIRVisitor::visit_where_clause (const WhereClause &where_clause)
860 : {
861 0 : for (auto &item : where_clause.get_items ())
862 0 : item->accept_vis (*this);
863 0 : }
864 :
865 : void
866 119 : DefaultHIRVisitor::visit_where_clause (WhereClause &where_clause)
867 : {
868 258 : for (auto &item : where_clause.get_items ())
869 : {
870 139 : item->accept_vis (*this);
871 : }
872 119 : }
873 :
874 : void
875 0 : DefaultHIRVisitor::walk (WhereClauseItem &node)
876 0 : {}
877 :
878 : void
879 3494 : DefaultHIRVisitor::walk (Trait &trait)
880 : {
881 3494 : visit_outer_attrs (trait);
882 7614 : for (auto &generic : trait.get_generic_params ())
883 4120 : generic->accept_vis (*this);
884 3494 : if (trait.has_where_clause ())
885 7 : visit_where_clause (trait.get_where_clause ());
886 4072 : for (auto &bound : trait.get_type_param_bounds ())
887 578 : bound->accept_vis (*this);
888 6691 : for (auto &item : trait.get_trait_items ())
889 3197 : item->accept_vis (*this);
890 3494 : }
891 :
892 : void
893 5310 : DefaultHIRVisitor::walk (ImplBlock &impl)
894 : {
895 5310 : visit_outer_attrs (impl);
896 6366 : for (auto &generic : impl.get_generic_params ())
897 1056 : generic->accept_vis (*this);
898 5310 : if (impl.has_trait_ref ())
899 4401 : impl.get_trait_ref ().accept_vis (*this);
900 5310 : impl.get_type ().accept_vis (*this);
901 5310 : if (impl.has_where_clause ())
902 83 : visit_where_clause (impl.get_where_clause ());
903 5310 : visit_inner_attrs (impl);
904 13183 : for (auto &item : impl.get_impl_items ())
905 7873 : item->accept_vis (*this);
906 5310 : }
907 :
908 : void
909 0 : DefaultHIRVisitor::walk (ExternalStaticItem &item)
910 : {
911 0 : visit_outer_attrs (item);
912 0 : item.get_item_type ().accept_vis (*this);
913 0 : }
914 :
915 : void
916 2632 : DefaultHIRVisitor::visit_named_function_param (NamedFunctionParam ¶m)
917 : {
918 2632 : param.get_type ().accept_vis (*this);
919 2632 : }
920 :
921 : void
922 2158 : DefaultHIRVisitor::walk (ExternalFunctionItem &item)
923 : {
924 2158 : visit_outer_attrs (item);
925 3002 : for (auto &generic : item.get_generic_params ())
926 844 : generic->accept_vis (*this);
927 4790 : for (auto ¶m : item.get_function_params ())
928 2632 : visit_named_function_param (param);
929 2158 : if (item.has_return_type ())
930 990 : item.get_return_type ().accept_vis (*this);
931 2158 : if (item.has_where_clause ())
932 0 : visit_where_clause (item.get_where_clause ());
933 2158 : }
934 :
935 : void
936 0 : DefaultHIRVisitor::walk (ExternalTypeItem &item)
937 : {
938 0 : visit_outer_attrs (item);
939 0 : }
940 :
941 : void
942 1424 : DefaultHIRVisitor::walk (ExternBlock &block)
943 : {
944 1424 : visit_outer_attrs (block);
945 1424 : visit_inner_attrs (block);
946 3582 : for (auto &item : block.get_extern_items ())
947 2158 : item->accept_vis (*this);
948 1424 : }
949 :
950 : void
951 405 : DefaultHIRVisitor::walk (LiteralPattern &)
952 405 : {}
953 :
954 : void
955 8314 : DefaultHIRVisitor::walk (IdentifierPattern &pattern)
956 : {
957 8314 : if (pattern.has_subpattern ())
958 9 : pattern.get_subpattern ().accept_vis (*this);
959 8314 : }
960 :
961 : void
962 739 : DefaultHIRVisitor::walk (WildcardPattern &)
963 739 : {}
964 :
965 : void
966 53 : DefaultHIRVisitor::walk (RangePatternBoundLiteral &)
967 53 : {}
968 :
969 : void
970 21 : DefaultHIRVisitor::walk (RangePatternBoundPath &bound)
971 : {
972 21 : bound.get_path ().accept_vis (*this);
973 21 : }
974 :
975 : void
976 0 : DefaultHIRVisitor::walk (RangePatternBoundQualPath &bound)
977 : {
978 0 : bound.get_qualified_path ().accept_vis (*this);
979 0 : }
980 :
981 : void
982 37 : DefaultHIRVisitor::walk (RangePattern &pattern)
983 : {
984 37 : pattern.get_lower_bound ().accept_vis (*this);
985 37 : pattern.get_upper_bound ().accept_vis (*this);
986 37 : }
987 :
988 : void
989 173 : DefaultHIRVisitor::walk (ReferencePattern &pattern)
990 : {
991 173 : pattern.get_referenced_pattern ().accept_vis (*this);
992 173 : }
993 :
994 : void
995 18 : DefaultHIRVisitor::walk (StructPatternFieldTuplePat &field)
996 : {
997 18 : visit_outer_attrs (field);
998 18 : field.get_tuple_pattern ().accept_vis (*this);
999 18 : }
1000 :
1001 : void
1002 114 : DefaultHIRVisitor::walk (StructPatternFieldIdentPat &field)
1003 : {
1004 114 : visit_outer_attrs (field);
1005 114 : field.get_pattern ().accept_vis (*this);
1006 114 : }
1007 :
1008 : void
1009 93 : DefaultHIRVisitor::walk (StructPatternFieldIdent &field)
1010 : {
1011 93 : visit_outer_attrs (field);
1012 93 : }
1013 :
1014 : void
1015 134 : DefaultHIRVisitor::walk (StructPattern &pattern)
1016 : {
1017 134 : pattern.get_path ().accept_vis (*this);
1018 134 : StructPatternElements &elements = pattern.get_struct_pattern_elems ();
1019 361 : for (auto &field : elements.get_struct_pattern_fields ())
1020 227 : field->accept_vis (*this);
1021 134 : }
1022 :
1023 : void
1024 878 : DefaultHIRVisitor::walk (TupleStructItemsNoRest &tuple_items)
1025 : {
1026 1844 : for (auto &item : tuple_items.get_patterns ())
1027 966 : item->accept_vis (*this);
1028 878 : }
1029 :
1030 : void
1031 36 : DefaultHIRVisitor::walk (TupleStructItemsHasRest &tuple_items)
1032 : {
1033 65 : for (auto &lower : tuple_items.get_lower_patterns ())
1034 29 : lower->accept_vis (*this);
1035 50 : for (auto &upper : tuple_items.get_upper_patterns ())
1036 14 : upper->accept_vis (*this);
1037 36 : }
1038 :
1039 : void
1040 914 : DefaultHIRVisitor::walk (TupleStructPattern &pattern)
1041 : {
1042 914 : pattern.get_path ().accept_vis (*this);
1043 914 : pattern.get_items ().accept_vis (*this);
1044 914 : }
1045 :
1046 : void
1047 100 : DefaultHIRVisitor::walk (TuplePatternItemsNoRest &tuple_items)
1048 : {
1049 307 : for (auto &pattern : tuple_items.get_patterns ())
1050 207 : pattern->accept_vis (*this);
1051 100 : }
1052 :
1053 : void
1054 22 : DefaultHIRVisitor::walk (TuplePatternItemsHasRest &tuple_items)
1055 : {
1056 44 : for (auto &lower : tuple_items.get_lower_patterns ())
1057 22 : lower->accept_vis (*this);
1058 44 : for (auto &upper : tuple_items.get_upper_patterns ())
1059 22 : upper->accept_vis (*this);
1060 22 : }
1061 :
1062 : void
1063 122 : DefaultHIRVisitor::walk (TuplePattern &pattern)
1064 : {
1065 122 : pattern.get_items ().accept_vis (*this);
1066 122 : }
1067 :
1068 : void
1069 31 : DefaultHIRVisitor::walk (SlicePatternItemsNoRest &items)
1070 : {
1071 92 : for (auto &pattern : items.get_patterns ())
1072 61 : pattern->accept_vis (*this);
1073 31 : }
1074 :
1075 : void
1076 44 : DefaultHIRVisitor::walk (SlicePatternItemsHasRest &items)
1077 : {
1078 87 : for (auto &lower : items.get_lower_patterns ())
1079 43 : lower->accept_vis (*this);
1080 87 : for (auto &upper : items.get_upper_patterns ())
1081 43 : upper->accept_vis (*this);
1082 44 : }
1083 :
1084 : void
1085 75 : DefaultHIRVisitor::walk (SlicePattern &pattern)
1086 : {
1087 75 : pattern.get_items ().accept_vis (*this);
1088 75 : }
1089 :
1090 : void
1091 145 : DefaultHIRVisitor::walk (AltPattern &pattern)
1092 : {
1093 436 : for (auto &item : pattern.get_alts ())
1094 291 : item->accept_vis (*this);
1095 145 : }
1096 :
1097 : void
1098 46 : DefaultHIRVisitor::walk (EmptyStmt &stmt)
1099 46 : {}
1100 :
1101 : void
1102 12 : DefaultHIRVisitor::walk (LetStmt &stmt)
1103 : {
1104 12 : visit_outer_attrs (stmt);
1105 12 : stmt.get_pattern ().accept_vis (*this);
1106 12 : if (stmt.has_type ())
1107 0 : stmt.get_type ().accept_vis (*this);
1108 12 : if (stmt.has_init_expr ())
1109 12 : stmt.get_init_expr ().accept_vis (*this);
1110 12 : }
1111 :
1112 : void
1113 8908 : DefaultHIRVisitor::walk (ExprStmt &stmt)
1114 : {
1115 8908 : stmt.get_expr ().accept_vis (*this);
1116 8908 : }
1117 :
1118 : void
1119 1678 : DefaultHIRVisitor::walk (TraitBound &bound)
1120 : {
1121 1692 : for (auto &lifetime : bound.get_for_lifetimes ())
1122 14 : lifetime.accept_vis (*this);
1123 1678 : bound.get_path ().accept_vis (*this);
1124 1678 : }
1125 :
1126 : void
1127 28 : DefaultHIRVisitor::walk (ImplTraitType &type)
1128 : {
1129 56 : for (auto &bound : type.get_type_param_bounds ())
1130 28 : bound->accept_vis (*this);
1131 28 : }
1132 :
1133 : void
1134 91 : DefaultHIRVisitor::walk (TraitObjectType &type)
1135 : {
1136 194 : for (auto &bound : type.get_type_param_bounds ())
1137 103 : bound->accept_vis (*this);
1138 91 : }
1139 :
1140 : void
1141 4 : DefaultHIRVisitor::walk (ParenthesisedType &type)
1142 : {
1143 4 : type.get_type_in_parens ().accept_vis (*this);
1144 4 : }
1145 :
1146 : void
1147 312 : DefaultHIRVisitor::walk (TupleType &type)
1148 : {
1149 827 : for (auto &elem : type.get_elems ())
1150 515 : elem->accept_vis (*this);
1151 312 : }
1152 :
1153 : void
1154 44 : DefaultHIRVisitor::walk (NeverType &type)
1155 44 : {}
1156 :
1157 : void
1158 3914 : DefaultHIRVisitor::walk (RawPointerType &type)
1159 : {
1160 3914 : type.get_type ().accept_vis (*this);
1161 3914 : }
1162 :
1163 : void
1164 3969 : DefaultHIRVisitor::walk (ReferenceType &type)
1165 : {
1166 3969 : if (type.has_lifetime ())
1167 3969 : type.get_lifetime ().accept_vis (*this);
1168 3969 : type.get_base_type ().accept_vis (*this);
1169 3969 : }
1170 :
1171 : void
1172 470 : DefaultHIRVisitor::walk (ArrayType &type)
1173 : {
1174 470 : type.get_element_type ().accept_vis (*this);
1175 470 : type.get_size_expr ().accept_vis (*this);
1176 470 : }
1177 :
1178 : void
1179 819 : DefaultHIRVisitor::walk (SliceType &type)
1180 : {
1181 819 : type.get_element_type ().accept_vis (*this);
1182 819 : }
1183 :
1184 : void
1185 14 : DefaultHIRVisitor::walk (InferredType &type)
1186 14 : {}
1187 :
1188 : void
1189 33 : DefaultHIRVisitor::walk (BareFunctionType &type)
1190 : {
1191 33 : for (auto &lifetime : type.get_for_lifetimes ())
1192 0 : lifetime.accept_vis (*this);
1193 54 : for (auto ¶m : type.get_function_params ())
1194 21 : param.get_type ().accept_vis (*this);
1195 33 : if (type.has_return_type ())
1196 23 : type.get_return_type ().accept_vis (*this);
1197 33 : }
1198 :
1199 : } // namespace HIR
1200 : } // namespace Rust
|