Line data Source code
1 : // Copyright (C) 2020-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-ast-full.h"
20 : #include "rust-hir-expr.h"
21 : #include "rust-hir-full.h"
22 : #include "rust-hir-path.h"
23 : #include "rust-hir-visitor.h"
24 : #include "rust-diagnostics.h"
25 :
26 : /* Compilation unit used for various HIR-related functions that would make
27 : * the headers too long if they were defined inline and don't receive any
28 : * benefits from being defined inline because they are virtual. Also used
29 : * for various other stuff. */
30 :
31 : namespace Rust {
32 : namespace HIR {
33 :
34 : enum indent_mode
35 : {
36 : enter,
37 : out,
38 : stay
39 : };
40 :
41 : std::string
42 42 : indent_spaces (enum indent_mode mode)
43 : {
44 42 : static int indent = 0;
45 42 : std::string str = "";
46 42 : if (out == mode)
47 7 : indent--;
48 100 : for (int i = 0; i < indent; i++)
49 58 : str += " ";
50 42 : if (enter == mode)
51 7 : indent++;
52 :
53 42 : return str;
54 : }
55 :
56 : // Gets a string in a certain delim type.
57 : std::string
58 0 : get_string_in_delims (std::string str_input, AST::DelimType delim_type)
59 : {
60 0 : switch (delim_type)
61 : {
62 0 : case AST::DelimType::PARENS:
63 0 : return "(" + str_input + ")";
64 0 : case AST::DelimType::SQUARE:
65 0 : return "[" + str_input + "]";
66 0 : case AST::DelimType::CURLY:
67 0 : return "{" + str_input + "}";
68 0 : default:
69 0 : return "ERROR-MARK-STRING (delims)";
70 : }
71 : rust_unreachable ();
72 : }
73 :
74 4578 : Crate::Crate (std::vector<std::unique_ptr<Item>> items,
75 4578 : AST::AttrVec inner_attrs, Analysis::NodeMapping mappings)
76 4578 : : WithInnerAttrs (std::move (inner_attrs)), items (std::move (items)),
77 4578 : mappings (mappings)
78 4578 : {}
79 :
80 0 : Crate::Crate (Crate const &other)
81 0 : : WithInnerAttrs (other.inner_attrs), mappings (other.mappings)
82 : {
83 0 : items.reserve (other.items.size ());
84 0 : for (const auto &e : other.items)
85 0 : items.push_back (e->clone_item ());
86 0 : }
87 :
88 : Crate &
89 0 : Crate::operator= (Crate const &other)
90 : {
91 0 : inner_attrs = other.inner_attrs;
92 0 : mappings = other.mappings;
93 :
94 0 : items.reserve (other.items.size ());
95 0 : for (const auto &e : other.items)
96 0 : items.push_back (e->clone_item ());
97 :
98 0 : return *this;
99 : }
100 :
101 : std::string
102 0 : Crate::to_debug_string () const
103 : {
104 0 : std::string str ("HIR::Crate: ");
105 :
106 : // inner attributes
107 0 : str += "\n inner attributes: ";
108 0 : if (inner_attrs.empty ())
109 : {
110 0 : str += "none";
111 : }
112 : else
113 : {
114 : /* note that this does not print them with "inner attribute" syntax -
115 : * just the body */
116 0 : for (const auto &attr : inner_attrs)
117 : {
118 0 : str += "\n " + attr.as_string ();
119 : }
120 : }
121 :
122 : // items
123 0 : str += "\n items: ";
124 0 : if (items.empty ())
125 : {
126 0 : str += "none";
127 : }
128 : else
129 : {
130 0 : for (const auto &item : items)
131 : {
132 : // DEBUG: null pointer check
133 0 : if (item == nullptr)
134 : {
135 0 : rust_debug ("something really terrible has gone wrong - "
136 : "null pointer item in crate.");
137 0 : return "nullptr_POINTER_MARK";
138 : }
139 :
140 0 : str += "\n " + item->to_string ();
141 : }
142 : }
143 :
144 0 : return str;
145 0 : }
146 :
147 : std::string
148 0 : Crate::to_string () const
149 : {
150 0 : std::string str;
151 0 : if (!inner_attrs.empty ())
152 0 : for (const auto &attr : inner_attrs)
153 0 : str += attr.as_string () + "\n";
154 :
155 0 : if (!items.empty ())
156 0 : for (const auto &item : items)
157 0 : str += item->to_string () + "\n";
158 :
159 0 : return str;
160 : }
161 :
162 : std::string
163 4 : Visibility::to_string () const
164 : {
165 4 : switch (vis_type)
166 : {
167 4 : case VisType::Private:
168 8 : return std::string ("private");
169 0 : case VisType::Public:
170 0 : return std::string ("pub");
171 0 : case VisType::Restricted:
172 0 : return std::string ("pub(in ") + path.get_mappings ().as_string ()
173 0 : + std::string (")");
174 0 : default:
175 0 : rust_unreachable ();
176 : }
177 : }
178 :
179 : // Creates a string that reflects the visibility stored.
180 : std::string
181 3 : VisItem::to_string () const
182 : {
183 : // FIXME: can't do formatting on string to make identation occur.
184 3 : std::string str = Item::to_string ();
185 :
186 3 : if (has_visibility ())
187 : {
188 6 : str = visibility.to_string () + " ";
189 : }
190 :
191 3 : return str;
192 : }
193 :
194 : // Creates a string that reflects the outer attributes stored.
195 : std::string
196 6 : Item::to_string () const
197 : {
198 6 : std::string str;
199 :
200 6 : if (!outer_attrs.empty ())
201 : {
202 0 : for (const auto &attr : outer_attrs)
203 : {
204 0 : str += attr.as_string () + "\n";
205 : }
206 : }
207 :
208 6 : return str;
209 : }
210 :
211 : std::string
212 0 : Module::to_string () const
213 : {
214 : // get module string for "[vis] mod [name]"
215 0 : std::string str = VisItem::to_string () + "mod " + module_name.as_string ();
216 :
217 : // inner attributes
218 0 : str += "\n inner attributes: ";
219 0 : if (inner_attrs.empty ())
220 : {
221 0 : str += "none";
222 : }
223 : else
224 : {
225 : /* note that this does not print them with "inner attribute" syntax -
226 : * just the body */
227 0 : for (const auto &attr : inner_attrs)
228 : {
229 0 : str += "\n " + attr.as_string ();
230 : }
231 : }
232 :
233 : // items
234 0 : str += "\n items: ";
235 0 : if (items.empty ())
236 : {
237 0 : str += "none";
238 : }
239 : else
240 : {
241 0 : for (const auto &item : items)
242 : {
243 : // DEBUG: null pointer check
244 0 : if (item == nullptr)
245 : {
246 0 : rust_debug ("something really terrible has gone wrong - "
247 : "null pointer item in crate.");
248 0 : return "nullptr_POINTER_MARK";
249 : }
250 :
251 0 : str += "\n " + item->to_string ();
252 : }
253 : }
254 :
255 0 : return str + "\n";
256 0 : }
257 :
258 : std::string
259 4 : Item::item_kind_string (Item::ItemKind kind)
260 : {
261 4 : switch (kind)
262 : {
263 1 : case Item::ItemKind::Static:
264 1 : return "static";
265 0 : case Item::ItemKind::Constant:
266 0 : return "constant";
267 1 : case Item::ItemKind::TypeAlias:
268 1 : return "type alias";
269 1 : case Item::ItemKind::Function:
270 1 : return "function";
271 0 : case Item::ItemKind::UseDeclaration:
272 0 : return "use declaration";
273 0 : case Item::ItemKind::ExternBlock:
274 0 : return "extern block";
275 0 : case Item::ItemKind::ExternCrate:
276 0 : return "extern crate";
277 0 : case Item::ItemKind::Struct:
278 0 : return "struct";
279 0 : case Item::ItemKind::Union:
280 0 : return "union";
281 1 : case Item::ItemKind::Enum:
282 1 : return "enum";
283 0 : case Item::ItemKind::EnumItem:
284 0 : return "enum item";
285 0 : case Item::ItemKind::Trait:
286 0 : return "trait";
287 0 : case Item::ItemKind::Impl:
288 0 : return "impl";
289 0 : case Item::ItemKind::Module:
290 0 : return "module";
291 0 : default:
292 0 : rust_unreachable ();
293 : }
294 : }
295 :
296 : std::string
297 0 : StaticItem::to_string () const
298 : {
299 0 : std::string str = VisItem::to_string ();
300 :
301 0 : str += indent_spaces (stay) + "static";
302 :
303 0 : if (is_mut ())
304 : {
305 0 : str += " mut";
306 : }
307 :
308 0 : str += name.as_string ();
309 :
310 : // DEBUG: null pointer check
311 0 : if (type == nullptr)
312 : {
313 0 : rust_debug ("something really terrible has gone wrong - null "
314 : "pointer type in static item.");
315 0 : return "nullptr_POINTER_MARK";
316 : }
317 0 : str += "\n" + indent_spaces (stay) + "Type: " + type->to_string ();
318 :
319 : // DEBUG: null pointer check
320 0 : if (expr == nullptr)
321 : {
322 0 : rust_debug ("something really terrible has gone wrong - null "
323 : "pointer expr in static item.");
324 0 : return "nullptr_POINTER_MARK";
325 : }
326 0 : str += "\n" + indent_spaces (stay) + "Expression: " + expr->to_string ();
327 :
328 0 : return str + "\n";
329 0 : }
330 :
331 : std::string
332 0 : ExternCrate::to_string () const
333 : {
334 0 : std::string str = VisItem::to_string ();
335 :
336 0 : str += "extern crate " + referenced_crate;
337 :
338 0 : if (has_as_clause ())
339 : {
340 0 : str += " as " + as_clause_name;
341 : }
342 :
343 0 : return str;
344 : }
345 :
346 : std::string
347 0 : TupleStruct::to_string () const
348 : {
349 0 : std::string str = VisItem::to_string ();
350 :
351 0 : str += "struct " + struct_name.as_string ();
352 :
353 : // generic params
354 0 : str += "\n Generic params: ";
355 0 : if (generic_params.empty ())
356 : {
357 0 : str += "none";
358 : }
359 : else
360 : {
361 0 : for (const auto ¶m : generic_params)
362 : {
363 : // DEBUG: null pointer check
364 0 : if (param == nullptr)
365 : {
366 0 : rust_debug (
367 : "something really terrible has gone wrong - null pointer "
368 : "generic param in enum.");
369 0 : return "nullptr_POINTER_MARK";
370 : }
371 :
372 0 : str += "\n " + param->to_string ();
373 : }
374 : }
375 :
376 : // tuple fields
377 0 : str += "\n Tuple fields: ";
378 0 : if (fields.empty ())
379 : {
380 0 : str += "none";
381 : }
382 : else
383 : {
384 0 : for (const auto &field : fields)
385 : {
386 0 : str += "\n " + field.to_string ();
387 : }
388 : }
389 :
390 0 : str += "\n Where clause: ";
391 0 : if (has_where_clause ())
392 : {
393 0 : str += where_clause.to_string ();
394 : }
395 : else
396 : {
397 0 : str += "none";
398 : }
399 :
400 0 : return str;
401 0 : }
402 :
403 : std::string
404 0 : ConstantItem::to_string () const
405 : {
406 0 : std::string str = VisItem::to_string ();
407 :
408 0 : str += "const " + identifier.as_string ();
409 :
410 : // DEBUG: null pointer check
411 0 : if (type == nullptr)
412 : {
413 0 : rust_debug ("something really terrible has gone wrong - null "
414 : "pointer type in const item.");
415 0 : return "nullptr_POINTER_MARK";
416 : }
417 0 : str += "\n Type: " + type->to_string ();
418 :
419 : // DEBUG: null pointer check
420 0 : if (const_expr == nullptr)
421 : {
422 0 : rust_debug ("something really terrible has gone wrong - null "
423 : "pointer expr in const item.");
424 0 : return "nullptr_POINTER_MARK";
425 : }
426 0 : str += "\n Expression: " + const_expr->to_string ();
427 :
428 0 : return str + "\n";
429 0 : }
430 :
431 : std::string
432 0 : ImplBlock::to_string () const
433 : {
434 0 : std::string str = VisItem::to_string ();
435 :
436 0 : str += "impl ";
437 :
438 : // generic params
439 0 : str += "\n Generic params: ";
440 0 : if (generic_params.empty ())
441 : {
442 0 : str += "none";
443 : }
444 : else
445 : {
446 0 : for (const auto ¶m : generic_params)
447 : {
448 : // DEBUG: null pointer check
449 0 : if (param == nullptr)
450 : {
451 0 : rust_debug (
452 : "something really terrible has gone wrong - null pointer "
453 : "generic param in impl.");
454 0 : return "nullptr_POINTER_MARK";
455 : }
456 :
457 0 : str += "\n " + param->to_string ();
458 : }
459 : }
460 :
461 0 : str += "\n Type: " + impl_type->to_string ();
462 :
463 0 : str += "\n Where clause: ";
464 0 : if (has_where_clause ())
465 : {
466 0 : str += where_clause.to_string ();
467 : }
468 : else
469 : {
470 0 : str += "none";
471 : }
472 :
473 : // inner attributes
474 0 : str += "\n inner attributes: ";
475 0 : if (inner_attrs.empty ())
476 : {
477 0 : str += "none";
478 : }
479 : else
480 : {
481 : /* note that this does not print them with "inner attribute" syntax -
482 : * just the body */
483 0 : for (const auto &attr : inner_attrs)
484 : {
485 0 : str += "\n " + attr.as_string ();
486 : }
487 : }
488 :
489 0 : str += "\n impl items: ";
490 0 : if (!has_impl_items ())
491 : {
492 0 : str += "none";
493 : }
494 : else
495 : {
496 0 : for (const auto &item : impl_items)
497 : {
498 0 : str += "\n " + item->to_string ();
499 : }
500 : }
501 :
502 0 : return str;
503 0 : }
504 :
505 : std::string
506 0 : StructStruct::to_string () const
507 : {
508 0 : std::string str = VisItem::to_string ();
509 :
510 0 : str += "struct " + struct_name.as_string ();
511 :
512 : // generic params
513 0 : str += "\n Generic params: ";
514 0 : if (generic_params.empty ())
515 : {
516 0 : str += "none";
517 : }
518 : else
519 : {
520 0 : for (const auto ¶m : generic_params)
521 : {
522 : // DEBUG: null pointer check
523 0 : if (param == nullptr)
524 : {
525 0 : rust_debug (
526 : "something really terrible has gone wrong - null pointer "
527 : "generic param in enum.");
528 0 : return "nullptr_POINTER_MARK";
529 : }
530 :
531 0 : str += "\n " + param->to_string ();
532 : }
533 : }
534 :
535 0 : str += "\n Where clause: ";
536 0 : if (has_where_clause ())
537 : {
538 0 : str += where_clause.to_string ();
539 : }
540 : else
541 : {
542 0 : str += "none";
543 : }
544 :
545 : // struct fields
546 0 : str += "\n Struct fields: ";
547 0 : if (is_unit)
548 : {
549 0 : str += "none (unit)";
550 : }
551 0 : else if (fields.empty ())
552 : {
553 0 : str += "none (non-unit)";
554 : }
555 : else
556 : {
557 0 : for (const auto &field : fields)
558 : {
559 0 : str += "\n - " + field.to_string ();
560 : }
561 0 : str += "\n";
562 : }
563 :
564 0 : return str;
565 0 : }
566 :
567 : std::string
568 0 : UseDeclaration::to_string () const
569 : {
570 0 : std::string str = VisItem::to_string ();
571 :
572 : // DEBUG: null pointer check
573 0 : if (use_tree == nullptr)
574 : {
575 0 : rust_debug (
576 : "something really terrible has gone wrong - null pointer use tree in "
577 : "use declaration.");
578 0 : return "nullptr_POINTER_MARK";
579 : }
580 :
581 0 : str += "use " + use_tree->to_string ();
582 :
583 0 : return str;
584 0 : }
585 :
586 : std::string
587 0 : UseTreeGlob::to_string () const
588 : {
589 0 : switch (glob_type)
590 : {
591 0 : case NO_PATH:
592 0 : return "*";
593 0 : case GLOBAL:
594 0 : return "::*";
595 0 : case PATH_PREFIXED:
596 0 : {
597 0 : std::string path_str = path.as_string ();
598 0 : return path_str + "::*";
599 0 : }
600 0 : default:
601 : // some kind of error
602 0 : return "ERROR-PATH";
603 : }
604 : rust_unreachable ();
605 : }
606 :
607 : std::string
608 0 : UseTreeList::to_string () const
609 : {
610 0 : std::string path_str;
611 0 : switch (path_type)
612 : {
613 0 : case NO_PATH:
614 0 : path_str = "{";
615 0 : break;
616 0 : case GLOBAL:
617 0 : path_str = "::{";
618 0 : break;
619 0 : case PATH_PREFIXED:
620 0 : {
621 0 : path_str = path.as_string () + "::{";
622 0 : break;
623 : }
624 0 : default:
625 : // some kind of error
626 0 : return "ERROR-PATH-LIST";
627 : }
628 :
629 0 : if (has_trees ())
630 : {
631 0 : auto i = trees.begin ();
632 0 : auto e = trees.end ();
633 :
634 : // DEBUG: null pointer check
635 0 : if (*i == nullptr)
636 : {
637 0 : rust_debug ("something really terrible has gone wrong - null pointer "
638 : "tree in use tree list.");
639 0 : return "nullptr_POINTER_MARK";
640 : }
641 :
642 0 : for (; i != e; i++)
643 : {
644 0 : path_str += (*i)->to_string ();
645 0 : if (e != i + 1)
646 0 : path_str += ", ";
647 : }
648 : }
649 : else
650 : {
651 0 : path_str += "none";
652 : }
653 :
654 0 : return path_str + "}";
655 0 : }
656 :
657 : std::string
658 0 : UseTreeRebind::to_string () const
659 : {
660 0 : std::string path_str = path.as_string ();
661 :
662 0 : switch (bind_type)
663 : {
664 : case NONE:
665 : // nothing to add, just path
666 : break;
667 0 : case IDENTIFIER:
668 0 : path_str += " as " + identifier.as_string ();
669 0 : break;
670 0 : case WILDCARD:
671 0 : path_str += " as _";
672 0 : break;
673 0 : default:
674 : // error
675 0 : return "ERROR-PATH-REBIND";
676 : }
677 :
678 0 : return path_str;
679 0 : }
680 :
681 : std::string
682 3 : Enum::to_string () const
683 : {
684 3 : std::string str = VisItem::to_string ();
685 3 : str += enum_name.as_string ();
686 :
687 : // generic params
688 3 : str += "\n Generic params: ";
689 3 : if (generic_params.empty ())
690 : {
691 3 : str += "none";
692 : }
693 : else
694 : {
695 0 : for (const auto ¶m : generic_params)
696 : {
697 : // DEBUG: null pointer check
698 0 : if (param == nullptr)
699 : {
700 0 : rust_debug (
701 : "something really terrible has gone wrong - null pointer "
702 : "generic param in enum.");
703 0 : return "nullptr_POINTER_MARK";
704 : }
705 :
706 0 : str += "\n " + param->to_string ();
707 : }
708 : }
709 :
710 3 : str += "\n Where clause: ";
711 3 : if (has_where_clause ())
712 : {
713 0 : str += where_clause.to_string ();
714 : }
715 : else
716 : {
717 3 : str += "none";
718 : }
719 :
720 : // items
721 3 : str += "\n Items: ";
722 3 : if (items.empty ())
723 : {
724 1 : str += "none";
725 : }
726 : else
727 : {
728 5 : for (const auto &item : items)
729 : {
730 : // DEBUG: null pointer check
731 3 : if (item == nullptr)
732 : {
733 0 : rust_debug (
734 : "something really terrible has gone wrong - null pointer "
735 : "enum item in enum.");
736 0 : return "nullptr_POINTER_MARK";
737 : }
738 :
739 6 : str += "\n " + item->to_string ();
740 : }
741 : }
742 :
743 3 : return str;
744 3 : }
745 :
746 : std::string
747 0 : Trait::to_string () const
748 : {
749 0 : std::string str = VisItem::to_string ();
750 :
751 0 : if (unsafety == Unsafety::Unsafe)
752 : {
753 0 : str += "unsafe ";
754 : }
755 :
756 0 : str += "trait " + name.as_string ();
757 :
758 : // generic params
759 0 : str += "\n Generic params: ";
760 0 : if (generic_params.empty ())
761 : {
762 0 : str += "none";
763 : }
764 : else
765 : {
766 0 : for (const auto ¶m : generic_params)
767 : {
768 : // DEBUG: null pointer check
769 0 : if (param == nullptr)
770 : {
771 0 : rust_debug (
772 : "something really terrible has gone wrong - null pointer "
773 : "generic param in trait.");
774 0 : return "nullptr_POINTER_MARK";
775 : }
776 :
777 0 : str += "\n " + param->to_string ();
778 : }
779 : }
780 :
781 0 : str += "\n Type param bounds: ";
782 0 : if (!has_type_param_bounds ())
783 : {
784 0 : str += "none";
785 : }
786 : else
787 : {
788 0 : for (const auto &bound : type_param_bounds)
789 : {
790 : // DEBUG: null pointer check
791 0 : if (bound == nullptr)
792 : {
793 0 : rust_debug (
794 : "something really terrible has gone wrong - null pointer "
795 : "type param bound in trait.");
796 0 : return "nullptr_POINTER_MARK";
797 : }
798 :
799 0 : str += "\n " + bound->to_string ();
800 : }
801 : }
802 :
803 0 : str += "\n Where clause: ";
804 0 : if (!has_where_clause ())
805 : {
806 0 : str += "none";
807 : }
808 : else
809 : {
810 0 : str += where_clause.to_string ();
811 : }
812 :
813 0 : str += "\n Trait items: ";
814 0 : if (!has_trait_items ())
815 : {
816 0 : str += "none";
817 : }
818 : else
819 : {
820 0 : for (const auto &item : trait_items)
821 : {
822 : // DEBUG: null pointer check
823 0 : if (item == nullptr)
824 : {
825 0 : rust_debug (
826 : "something really terrible has gone wrong - null pointer "
827 : "trait item in trait.");
828 0 : return "nullptr_POINTER_MARK";
829 : }
830 :
831 0 : str += "\n " + item->to_string ();
832 : }
833 : }
834 :
835 0 : return str;
836 0 : }
837 :
838 : std::string
839 0 : Union::to_string () const
840 : {
841 0 : std::string str = VisItem::to_string ();
842 :
843 0 : str += "union " + union_name.as_string ();
844 :
845 : // generic params
846 0 : str += "\n Generic params: ";
847 0 : if (generic_params.empty ())
848 : {
849 0 : str += "none";
850 : }
851 : else
852 : {
853 0 : for (const auto ¶m : generic_params)
854 : {
855 : // DEBUG: null pointer check
856 0 : if (param == nullptr)
857 : {
858 0 : rust_debug (
859 : "something really terrible has gone wrong - null pointer "
860 : "generic param in union.");
861 0 : return "nullptr_POINTER_MARK";
862 : }
863 :
864 0 : str += "\n " + param->to_string ();
865 : }
866 : }
867 :
868 0 : str += "\n Where clause: ";
869 0 : if (has_where_clause ())
870 : {
871 0 : str += where_clause.to_string ();
872 : }
873 : else
874 : {
875 0 : str += "none";
876 : }
877 :
878 : // struct fields
879 0 : str += "\n Struct fields (variants): ";
880 0 : if (variants.empty ())
881 : {
882 0 : str += "none";
883 : }
884 : else
885 : {
886 0 : for (const auto &field : variants)
887 : {
888 0 : str += "\n " + field.to_string ();
889 : }
890 : }
891 :
892 0 : return str;
893 0 : }
894 :
895 : std::string
896 0 : Function::to_string () const
897 : {
898 0 : std::string str = VisItem::to_string () + "\n";
899 0 : std::string qstr = qualifiers.to_string ();
900 0 : if ("" != qstr)
901 0 : str += qstr + " ";
902 :
903 0 : if (has_function_return_type ())
904 : {
905 : // DEBUG: null pointer check
906 0 : if (return_type == nullptr)
907 : {
908 : rust_debug (
909 : "something really terrible has gone wrong - null pointer return "
910 : "type in function.");
911 : return "nullptr_POINTER_MARK";
912 : }
913 :
914 0 : str += return_type->to_string () + " ";
915 : }
916 : else
917 : {
918 0 : str += "void ";
919 : }
920 :
921 0 : str += function_name.as_string ();
922 :
923 0 : if (has_generics ())
924 : {
925 0 : str += "<";
926 :
927 0 : auto i = generic_params.begin ();
928 0 : auto e = generic_params.end ();
929 :
930 : // DEBUG: null pointer check
931 0 : if (i == e)
932 : {
933 0 : rust_debug ("something really terrible has gone wrong - null pointer "
934 : "generic param in function item.");
935 0 : return "nullptr_POINTER_MARK";
936 : }
937 :
938 0 : for (; i != e; i++)
939 : {
940 0 : str += (*i)->to_string ();
941 0 : if (e != i + 1)
942 0 : str += ", ";
943 : }
944 0 : str += ">";
945 : }
946 :
947 0 : if (has_function_params ())
948 : {
949 0 : auto i = function_params.begin ();
950 0 : auto e = function_params.end ();
951 0 : str += "(";
952 0 : for (; i != e; i++)
953 : {
954 0 : str += (*i).to_string ();
955 0 : if (e != i + 1)
956 0 : str += ", ";
957 : }
958 0 : str += ")";
959 : }
960 : else
961 : {
962 0 : str += "()";
963 : }
964 :
965 0 : if (has_where_clause ())
966 : {
967 0 : str += " where " + where_clause.to_string ();
968 : }
969 :
970 0 : str += "\n";
971 :
972 : // DEBUG: null pointer check
973 0 : if (function_body == nullptr)
974 : {
975 0 : rust_debug (
976 : "something really terrible has gone wrong - null pointer function "
977 : "body in function.");
978 0 : return "nullptr_POINTER_MARK";
979 : }
980 0 : return str + function_body->to_string ();
981 0 : }
982 :
983 : std::string
984 0 : WhereClause::to_string () const
985 : {
986 : // just print where clause items, don't mention "where" or "where clause"
987 0 : std::string str;
988 :
989 0 : if (where_clause_items.empty ())
990 : {
991 0 : str = "none";
992 : }
993 : else
994 : {
995 0 : for (const auto &item : where_clause_items)
996 : {
997 0 : str += "\n " + item->to_string ();
998 : }
999 : }
1000 :
1001 0 : return str;
1002 : }
1003 :
1004 : std::string
1005 5 : BlockExpr::to_string () const
1006 : {
1007 5 : std::string istr = indent_spaces (enter);
1008 5 : std::string str = istr + "BlockExpr:\n" + istr;
1009 : // get outer attributes
1010 10 : str += "{\n" + indent_spaces (stay) + Expr::to_string ();
1011 :
1012 : // inner attributes
1013 15 : str += "\n" + indent_spaces (stay) + "inner attributes: ";
1014 5 : if (inner_attrs.empty ())
1015 : {
1016 5 : str += "none";
1017 : }
1018 : else
1019 : {
1020 : /* note that this does not print them with "inner attribute" syntax -
1021 : * just the body */
1022 0 : for (const auto &attr : inner_attrs)
1023 : {
1024 0 : str += "\n" + indent_spaces (stay) + attr.as_string ();
1025 : }
1026 : }
1027 :
1028 : // statements
1029 15 : str += "\n" + indent_spaces (stay) + "statements: ";
1030 5 : if (statements.empty ())
1031 : {
1032 0 : str += "none";
1033 : }
1034 : else
1035 : {
1036 11 : for (const auto &stmt : statements)
1037 : {
1038 : // DEBUG: null pointer check
1039 6 : if (stmt == nullptr)
1040 : {
1041 0 : rust_debug (
1042 : "something really terrible has gone wrong - null pointer "
1043 : "stmt in block expr.");
1044 0 : return "nullptr_POINTER_MARK";
1045 : }
1046 :
1047 12 : str += "\n" + indent_spaces (stay) + stmt->to_string ();
1048 : }
1049 : }
1050 :
1051 : // final expression
1052 15 : str += "\n" + indent_spaces (stay) + "final expression: ";
1053 5 : if (expr == nullptr)
1054 : {
1055 1 : str += "none";
1056 : }
1057 : else
1058 : {
1059 8 : str += "\n" + expr->to_string ();
1060 : }
1061 :
1062 15 : str += "\n" + indent_spaces (out) + "}";
1063 5 : return str;
1064 5 : }
1065 :
1066 : std::string
1067 0 : AnonConst::to_string () const
1068 : {
1069 0 : std::string istr = indent_spaces (enter);
1070 0 : std::string str = istr + "AnonConst:\n" + istr;
1071 :
1072 0 : if (expr.has_value ())
1073 0 : str += get_inner_expr ().to_string ();
1074 : else
1075 0 : str += "_";
1076 :
1077 0 : str += "\n" + indent_spaces (out);
1078 :
1079 0 : return str;
1080 0 : }
1081 :
1082 : std::string
1083 0 : ConstBlock::to_string () const
1084 : {
1085 0 : std::string istr = indent_spaces (enter);
1086 :
1087 0 : std::string str = istr + "ConstBlock:\n" + istr;
1088 :
1089 0 : str += get_const_expr ().to_string ();
1090 :
1091 0 : str += "\n" + indent_spaces (out);
1092 :
1093 0 : return str;
1094 0 : }
1095 :
1096 : std::string
1097 0 : TypeAlias::to_string () const
1098 : {
1099 0 : std::string str = VisItem::to_string ();
1100 :
1101 0 : str += " " + new_type_name.as_string ();
1102 :
1103 : // generic params
1104 0 : str += "\n Generic params: ";
1105 0 : if (!has_generics ())
1106 : {
1107 0 : str += "none";
1108 : }
1109 : else
1110 : {
1111 : auto i = generic_params.begin ();
1112 : auto e = generic_params.end ();
1113 :
1114 0 : for (; i != e; i++)
1115 : {
1116 0 : str += (*i)->to_string ();
1117 0 : if (e != i + 1)
1118 0 : str += ", ";
1119 : }
1120 : }
1121 :
1122 0 : str += "\n Where clause: ";
1123 0 : if (!has_where_clause ())
1124 : {
1125 0 : str += "none";
1126 : }
1127 : else
1128 : {
1129 0 : str += where_clause.to_string ();
1130 : }
1131 :
1132 0 : str += "\n Type: " + existing_type->to_string ();
1133 :
1134 0 : return str;
1135 : }
1136 :
1137 : std::string
1138 0 : ExternBlock::to_string () const
1139 : {
1140 0 : std::string str = VisItem::to_string ();
1141 :
1142 0 : str += "extern ";
1143 0 : str += "\"" + get_string_from_abi (abi) + "\" ";
1144 :
1145 : // inner attributes
1146 0 : str += "\n inner attributes: ";
1147 0 : if (inner_attrs.empty ())
1148 : {
1149 0 : str += "none";
1150 : }
1151 : else
1152 : {
1153 : /* note that this does not print them with "inner attribute" syntax -
1154 : * just the body */
1155 0 : for (const auto &attr : inner_attrs)
1156 : {
1157 0 : str += "\n " + attr.as_string ();
1158 : }
1159 : }
1160 :
1161 0 : str += "\n external items: ";
1162 0 : if (!has_extern_items ())
1163 : {
1164 0 : str += "none";
1165 : }
1166 : else
1167 : {
1168 0 : for (const auto &item : extern_items)
1169 : {
1170 0 : str += "\n " + item->to_string ();
1171 : }
1172 : }
1173 :
1174 0 : return str;
1175 : }
1176 :
1177 : std::string
1178 48 : PathInExpression::to_string () const
1179 : {
1180 48 : std::string str;
1181 :
1182 48 : if (has_opening_scope_resolution)
1183 : {
1184 0 : str = "::";
1185 : }
1186 :
1187 48 : return str + PathPattern::to_string ();
1188 48 : }
1189 :
1190 : std::string
1191 1 : ExprStmt::to_string () const
1192 : {
1193 2 : std::string str = indent_spaces (enter) + "ExprStmt:\n";
1194 :
1195 1 : if (expr == nullptr)
1196 : {
1197 0 : str += "none (this should not happen and is an error)";
1198 : }
1199 : else
1200 : {
1201 1 : indent_spaces (enter);
1202 2 : str += expr->to_string ();
1203 1 : indent_spaces (out);
1204 : }
1205 :
1206 1 : indent_spaces (out);
1207 1 : return str;
1208 : }
1209 :
1210 : std::string
1211 0 : ClosureParam::to_string () const
1212 : {
1213 0 : std::string str (pattern->to_string ());
1214 :
1215 0 : if (has_type_given ())
1216 : {
1217 0 : str += " : " + type->to_string ();
1218 : }
1219 :
1220 0 : return str;
1221 : }
1222 :
1223 : std::string
1224 0 : ClosureExpr::to_string () const
1225 : {
1226 0 : std::string str ("ClosureExpr:\n Has move: ");
1227 0 : if (has_move)
1228 : {
1229 0 : str += "true";
1230 : }
1231 : else
1232 : {
1233 0 : str += "false";
1234 : }
1235 :
1236 0 : str += "\n Params: ";
1237 0 : if (params.empty ())
1238 : {
1239 0 : str += "none";
1240 : }
1241 : else
1242 : {
1243 0 : for (const auto ¶m : params)
1244 : {
1245 0 : str += "\n " + param.to_string ();
1246 : }
1247 : }
1248 :
1249 0 : str += "\n Return type: "
1250 0 : + (has_return_type () ? return_type->to_string () : "none");
1251 :
1252 0 : str += "\n Body: " + expr->to_string ();
1253 :
1254 0 : return str;
1255 : }
1256 :
1257 : std::string
1258 48 : PathPattern::to_string () const
1259 : {
1260 48 : if (is_lang_item ())
1261 0 : return LangItem::PrettyString (*lang_item);
1262 :
1263 48 : std::string str;
1264 :
1265 96 : for (const auto &segment : segments)
1266 : {
1267 144 : str += segment.to_string () + "::";
1268 : }
1269 :
1270 : // basically a hack - remove last two characters of string (remove final ::)
1271 48 : str.erase (str.length () - 2);
1272 :
1273 48 : return str;
1274 48 : }
1275 :
1276 : std::string
1277 6 : QualifiedPathType::to_string () const
1278 : {
1279 6 : std::string str ("<");
1280 12 : str += type->to_string ();
1281 :
1282 6 : if (has_as_clause ())
1283 : {
1284 12 : str += " as " + trait->to_string ();
1285 : }
1286 :
1287 6 : return str + ">";
1288 6 : }
1289 :
1290 : std::string
1291 0 : QualifiedPathInExpression::to_string () const
1292 : {
1293 0 : return path_type.to_string () + "::" + PathPattern::to_string ();
1294 : }
1295 :
1296 : std::string
1297 0 : BorrowExpr::to_string () const
1298 : {
1299 0 : std::string str ("&");
1300 :
1301 0 : if (is_mut ())
1302 : {
1303 0 : str += "mut ";
1304 : }
1305 :
1306 0 : str += main_or_left_expr->to_string ();
1307 :
1308 0 : return str;
1309 : }
1310 :
1311 : std::string
1312 0 : BoxExpr::to_string () const
1313 : {
1314 0 : std::string str = "box ";
1315 0 : rust_assert (expr != nullptr);
1316 0 : str += expr->to_string ();
1317 0 : return str;
1318 : }
1319 :
1320 : std::string
1321 0 : ReturnExpr::to_string () const
1322 : {
1323 0 : std::string str ("return ");
1324 :
1325 0 : if (has_return_expr ())
1326 : {
1327 0 : str += return_expr->to_string ();
1328 : }
1329 :
1330 0 : return str;
1331 : }
1332 :
1333 : std::string
1334 0 : GroupedExpr::to_string () const
1335 : {
1336 0 : std::string str ("Grouped expr:");
1337 :
1338 : // inner attributes
1339 0 : str += "\n inner attributes: ";
1340 0 : if (inner_attrs.empty ())
1341 : {
1342 0 : str += "none";
1343 : }
1344 : else
1345 : {
1346 : /* note that this does not print them with "inner attribute" syntax -
1347 : * just the body */
1348 0 : for (const auto &attr : inner_attrs)
1349 : {
1350 0 : str += "\n " + attr.as_string ();
1351 : }
1352 : }
1353 :
1354 0 : str += "\n Expr in parens: " + expr_in_parens->to_string ();
1355 :
1356 0 : return str;
1357 : }
1358 :
1359 : std::string
1360 0 : RangeToExpr::to_string () const
1361 : {
1362 0 : return ".." + to->to_string ();
1363 : }
1364 :
1365 : std::string
1366 0 : ContinueExpr::to_string () const
1367 : {
1368 0 : std::string str ("continue ");
1369 :
1370 0 : if (has_label ())
1371 : {
1372 0 : str += get_label ().to_string ();
1373 : }
1374 :
1375 0 : return str;
1376 : }
1377 :
1378 : std::string
1379 2199 : NegationExpr::to_string () const
1380 : {
1381 2199 : std::string str;
1382 :
1383 2199 : switch (expr_type)
1384 : {
1385 2199 : case NegationOperator::NEGATE:
1386 2199 : str = "-";
1387 2199 : break;
1388 0 : case NegationOperator::NOT:
1389 0 : str = "!";
1390 0 : break;
1391 0 : default:
1392 0 : return "ERROR_MARK_STRING - negation expr";
1393 : }
1394 :
1395 4398 : str += main_or_left_expr->to_string ();
1396 :
1397 2199 : return str;
1398 2199 : }
1399 :
1400 : std::string
1401 0 : RangeFromExpr::to_string () const
1402 : {
1403 0 : return from->to_string () + "..";
1404 : }
1405 :
1406 : std::string
1407 0 : RangeFullExpr::to_string () const
1408 : {
1409 0 : return "..";
1410 : }
1411 :
1412 : std::string
1413 0 : ArrayIndexExpr::to_string () const
1414 : {
1415 0 : return array_expr->to_string () + "[" + index_expr->to_string () + "]";
1416 : }
1417 :
1418 : std::string
1419 0 : AssignmentExpr::to_string () const
1420 : {
1421 0 : return main_or_left_expr->to_string () + " = " + right_expr->to_string ();
1422 : }
1423 :
1424 : std::string
1425 0 : CompoundAssignmentExpr::get_operator_str () const
1426 : {
1427 0 : std::string operator_str;
1428 0 : operator_str.reserve (1);
1429 :
1430 : // get operator string
1431 0 : switch (expr_type)
1432 : {
1433 0 : case ArithmeticOrLogicalOperator::ADD:
1434 0 : operator_str = "+";
1435 0 : break;
1436 0 : case ArithmeticOrLogicalOperator::SUBTRACT:
1437 0 : operator_str = "-";
1438 0 : break;
1439 0 : case ArithmeticOrLogicalOperator::MULTIPLY:
1440 0 : operator_str = "*";
1441 0 : break;
1442 0 : case ArithmeticOrLogicalOperator::DIVIDE:
1443 0 : operator_str = "/";
1444 0 : break;
1445 0 : case ArithmeticOrLogicalOperator::MODULUS:
1446 0 : operator_str = "%";
1447 0 : break;
1448 0 : case ArithmeticOrLogicalOperator::BITWISE_AND:
1449 0 : operator_str = "&";
1450 0 : break;
1451 0 : case ArithmeticOrLogicalOperator::BITWISE_OR:
1452 0 : operator_str = "|";
1453 0 : break;
1454 0 : case ArithmeticOrLogicalOperator::BITWISE_XOR:
1455 0 : operator_str = "^";
1456 0 : break;
1457 0 : case ArithmeticOrLogicalOperator::LEFT_SHIFT:
1458 0 : operator_str = "<<";
1459 0 : break;
1460 0 : case ArithmeticOrLogicalOperator::RIGHT_SHIFT:
1461 0 : operator_str = ">>";
1462 0 : break;
1463 0 : default:
1464 0 : rust_unreachable ();
1465 0 : break;
1466 : }
1467 :
1468 0 : operator_str += "=";
1469 :
1470 0 : return operator_str;
1471 : }
1472 :
1473 : std::string
1474 0 : CompoundAssignmentExpr::to_string () const
1475 : {
1476 0 : std::string str ("CompoundAssignmentExpr: ");
1477 0 : std::string operator_str = get_operator_str ();
1478 0 : if (main_or_left_expr == nullptr || right_expr == nullptr)
1479 : {
1480 0 : str += "error. this is probably a parsing failure.";
1481 : }
1482 : else
1483 : {
1484 0 : str += "\n left: " + main_or_left_expr->to_string ();
1485 0 : str += "\n right: " + right_expr->to_string ();
1486 0 : str += "\n operator: " + operator_str;
1487 : }
1488 :
1489 0 : return str;
1490 0 : }
1491 :
1492 : std::string
1493 0 : AsyncBlockExpr::to_string () const
1494 : {
1495 0 : std::string str = "AsyncBlockExpr: ";
1496 :
1497 : // get outer attributes
1498 0 : str += "\n " + Expr::to_string ();
1499 :
1500 0 : str += "\n Has move: ";
1501 0 : str += has_move ? "true" : "false";
1502 :
1503 0 : return str + "\n" + block_expr->to_string ();
1504 0 : }
1505 :
1506 : std::string
1507 0 : ComparisonExpr::to_string () const
1508 : {
1509 0 : std::string str (main_or_left_expr->to_string ());
1510 :
1511 0 : switch (expr_type)
1512 : {
1513 0 : case ComparisonOperator::EQUAL:
1514 0 : str += " == ";
1515 0 : break;
1516 0 : case ComparisonOperator::NOT_EQUAL:
1517 0 : str += " != ";
1518 0 : break;
1519 0 : case ComparisonOperator::GREATER_THAN:
1520 0 : str += " > ";
1521 0 : break;
1522 0 : case ComparisonOperator::LESS_THAN:
1523 0 : str += " < ";
1524 0 : break;
1525 0 : case ComparisonOperator::GREATER_OR_EQUAL:
1526 0 : str += " >= ";
1527 0 : break;
1528 0 : case ComparisonOperator::LESS_OR_EQUAL:
1529 0 : str += " <= ";
1530 0 : break;
1531 0 : default:
1532 0 : return "ERROR_MARK_STRING - comparison expr";
1533 : }
1534 :
1535 0 : str += right_expr->to_string ();
1536 :
1537 0 : return str;
1538 0 : }
1539 :
1540 : std::string
1541 0 : MethodCallExpr::to_string () const
1542 : {
1543 0 : std::string str ("MethodCallExpr: \n Object (receiver) expr: ");
1544 :
1545 0 : str += receiver->to_string ();
1546 :
1547 0 : str += "\n Method path segment: \n";
1548 :
1549 0 : str += method_name.to_string ();
1550 :
1551 0 : str += "\n Call params:";
1552 0 : if (params.empty ())
1553 : {
1554 0 : str += "none";
1555 : }
1556 : else
1557 : {
1558 0 : for (const auto ¶m : params)
1559 : {
1560 0 : if (param == nullptr)
1561 : {
1562 0 : return "ERROR_MARK_STRING - method call expr param is null";
1563 : }
1564 :
1565 0 : str += "\n " + param->to_string ();
1566 : }
1567 : }
1568 :
1569 0 : return str;
1570 0 : }
1571 :
1572 : std::string
1573 0 : TupleIndexExpr::to_string () const
1574 : {
1575 0 : return tuple_expr->to_string () + "." + std::to_string (tuple_index);
1576 : }
1577 :
1578 : std::string
1579 0 : DereferenceExpr::to_string () const
1580 : {
1581 0 : return "*" + main_or_left_expr->to_string ();
1582 : }
1583 :
1584 : std::string
1585 0 : FieldAccessExpr::to_string () const
1586 : {
1587 0 : return receiver->to_string () + "." + field.as_string ();
1588 : }
1589 :
1590 : std::string
1591 0 : LazyBooleanExpr::to_string () const
1592 : {
1593 0 : std::string str (main_or_left_expr->to_string ());
1594 :
1595 0 : switch (expr_type)
1596 : {
1597 0 : case LazyBooleanOperator::LOGICAL_OR:
1598 0 : str += " || ";
1599 0 : break;
1600 0 : case LazyBooleanOperator::LOGICAL_AND:
1601 0 : str += " && ";
1602 0 : break;
1603 0 : default:
1604 0 : return "ERROR_MARK_STRING - lazy boolean expr out of bounds";
1605 : }
1606 :
1607 0 : str += right_expr->to_string ();
1608 :
1609 0 : return str;
1610 0 : }
1611 :
1612 : std::string
1613 0 : RangeFromToExpr::to_string () const
1614 : {
1615 0 : return from->to_string () + ".." + to->to_string ();
1616 : }
1617 :
1618 : std::string
1619 0 : RangeToInclExpr::to_string () const
1620 : {
1621 0 : return "..=" + to->to_string ();
1622 : }
1623 :
1624 : std::string
1625 0 : UnsafeBlockExpr::to_string () const
1626 : {
1627 0 : std::string istr = indent_spaces (enter);
1628 0 : std::string str = istr + "UnsafeBlockExpr:";
1629 0 : str += istr + "{";
1630 :
1631 : // get outer attributes
1632 0 : str += "\n" + indent_spaces (stay) + Expr::to_string ();
1633 :
1634 0 : return str + "\n" + indent_spaces (out) + "}\n" + expr->to_string ();
1635 0 : }
1636 :
1637 : std::string
1638 0 : IfExpr::to_string () const
1639 : {
1640 0 : std::string str ("IfExpr: ");
1641 :
1642 0 : str += "\n Condition expr: " + condition->to_string ();
1643 :
1644 0 : str += "\n If block expr: " + if_block->to_string ();
1645 :
1646 0 : return str;
1647 : }
1648 :
1649 : std::string
1650 0 : IfExprConseqElse::to_string () const
1651 : {
1652 0 : std::string str = IfExpr::to_string ();
1653 :
1654 0 : str += "\n Else expr: " + else_block->to_string ();
1655 :
1656 0 : return str;
1657 : }
1658 :
1659 : std::string
1660 0 : RangeFromToInclExpr::to_string () const
1661 : {
1662 0 : return from->to_string () + "..=" + to->to_string ();
1663 : }
1664 :
1665 : std::string
1666 0 : ErrorPropagationExpr::to_string () const
1667 : {
1668 0 : return main_or_left_expr->to_string () + "?";
1669 : }
1670 :
1671 : std::string
1672 7 : ArithmeticOrLogicalExpr::get_operator_str () const
1673 : {
1674 7 : std::string operator_str;
1675 7 : operator_str.reserve (1);
1676 :
1677 : // get operator string
1678 7 : switch (expr_type)
1679 : {
1680 7 : case ArithmeticOrLogicalOperator::ADD:
1681 7 : operator_str = "+";
1682 7 : break;
1683 0 : case ArithmeticOrLogicalOperator::SUBTRACT:
1684 0 : operator_str = "-";
1685 0 : break;
1686 0 : case ArithmeticOrLogicalOperator::MULTIPLY:
1687 0 : operator_str = "*";
1688 0 : break;
1689 0 : case ArithmeticOrLogicalOperator::DIVIDE:
1690 0 : operator_str = "/";
1691 0 : break;
1692 0 : case ArithmeticOrLogicalOperator::MODULUS:
1693 0 : operator_str = "%";
1694 0 : break;
1695 0 : case ArithmeticOrLogicalOperator::BITWISE_AND:
1696 0 : operator_str = "&";
1697 0 : break;
1698 0 : case ArithmeticOrLogicalOperator::BITWISE_OR:
1699 0 : operator_str = "|";
1700 0 : break;
1701 0 : case ArithmeticOrLogicalOperator::BITWISE_XOR:
1702 0 : operator_str = "^";
1703 0 : break;
1704 0 : case ArithmeticOrLogicalOperator::LEFT_SHIFT:
1705 0 : operator_str = "<<";
1706 0 : break;
1707 0 : case ArithmeticOrLogicalOperator::RIGHT_SHIFT:
1708 0 : operator_str = ">>";
1709 0 : break;
1710 0 : default:
1711 0 : rust_unreachable ();
1712 7 : break;
1713 : }
1714 :
1715 7 : return operator_str;
1716 : }
1717 :
1718 : std::string
1719 4 : ArithmeticOrLogicalExpr::to_string () const
1720 : {
1721 8 : std::string str = main_or_left_expr->to_string () + " ";
1722 12 : str += get_operator_str () + " ";
1723 8 : str += right_expr->to_string ();
1724 :
1725 8 : return "( " + str + " )";
1726 4 : }
1727 :
1728 : std::string
1729 1 : CallExpr::to_string () const
1730 : {
1731 2 : std::string str = function->to_string () + "(";
1732 1 : if (!has_params ())
1733 1 : str += "none";
1734 : else
1735 : {
1736 0 : for (const auto ¶m : params)
1737 : {
1738 0 : if (param == nullptr)
1739 : {
1740 0 : return "ERROR_MARK_STRING - call expr param is null";
1741 : }
1742 :
1743 0 : str += param->to_string () + ",";
1744 : }
1745 : }
1746 1 : return str + ")";
1747 1 : }
1748 :
1749 : std::string
1750 0 : WhileLoopExpr::to_string () const
1751 : {
1752 0 : std::string str ("WhileLoopExpr: ");
1753 :
1754 0 : str += "\n Label: ";
1755 0 : if (!has_loop_label ())
1756 : {
1757 0 : str += "none";
1758 : }
1759 : else
1760 : {
1761 0 : str += get_loop_label ().to_string ();
1762 : }
1763 :
1764 0 : str += "\n Conditional expr: " + condition->to_string ();
1765 :
1766 0 : str += "\n Loop block: " + loop_block->to_string ();
1767 :
1768 0 : return str;
1769 : }
1770 :
1771 : std::string
1772 0 : WhileLetLoopExpr::to_string () const
1773 : {
1774 0 : std::string str ("WhileLetLoopExpr: ");
1775 :
1776 0 : str += "\n Label: ";
1777 0 : if (!has_loop_label ())
1778 : {
1779 0 : str += "none";
1780 : }
1781 : else
1782 : {
1783 0 : str += get_loop_label ().to_string ();
1784 : }
1785 :
1786 0 : str += "\n Match arm patterns: ";
1787 0 : if (match_arm_pattern == nullptr)
1788 : {
1789 0 : str += "none";
1790 : }
1791 : else
1792 : {
1793 0 : str += "\n " + match_arm_pattern->to_string ();
1794 : }
1795 :
1796 0 : str += "\n Scrutinee expr: " + condition->to_string ();
1797 :
1798 0 : str += "\n Loop block: " + loop_block->to_string ();
1799 :
1800 0 : return str;
1801 : }
1802 :
1803 : std::string
1804 0 : LoopExpr::to_string () const
1805 : {
1806 0 : std::string str ("LoopExpr: (infinite loop)");
1807 :
1808 0 : str += "\n Label: ";
1809 0 : if (!has_loop_label ())
1810 : {
1811 0 : str += "none";
1812 : }
1813 : else
1814 : {
1815 0 : str += get_loop_label ().to_string ();
1816 : }
1817 :
1818 0 : str += "\n Loop block: " + loop_block->to_string ();
1819 :
1820 0 : return str;
1821 : }
1822 :
1823 : std::string
1824 0 : ArrayExpr::to_string () const
1825 : {
1826 0 : std::string str ("ArrayExpr:");
1827 :
1828 : // inner attributes
1829 0 : str += "\n inner attributes: ";
1830 0 : if (inner_attrs.empty ())
1831 : {
1832 0 : str += "none";
1833 : }
1834 : else
1835 : {
1836 : /* note that this does not print them with "inner attribute" syntax -
1837 : * just the body */
1838 0 : for (const auto &attr : inner_attrs)
1839 : {
1840 0 : str += "\n " + attr.as_string ();
1841 : }
1842 : }
1843 :
1844 0 : str += "\n Array elems: ";
1845 0 : if (!has_array_elems ())
1846 : {
1847 0 : str += "none";
1848 : }
1849 : else
1850 : {
1851 0 : str += internal_elements->to_string ();
1852 : }
1853 :
1854 0 : return str;
1855 : }
1856 :
1857 : std::string
1858 0 : AwaitExpr::to_string () const
1859 : {
1860 0 : return awaited_expr->to_string () + ".await";
1861 : }
1862 :
1863 : std::string
1864 0 : BreakExpr::to_string () const
1865 : {
1866 0 : std::string str ("break ");
1867 :
1868 0 : if (has_label ())
1869 : {
1870 0 : str += get_label ().to_string () + " ";
1871 : }
1872 :
1873 0 : if (has_break_expr ())
1874 : {
1875 0 : str += break_expr->to_string ();
1876 : }
1877 :
1878 0 : return str;
1879 : }
1880 :
1881 : std::string
1882 0 : LoopLabel::to_string () const
1883 : {
1884 0 : return label.to_string () + ": (label) ";
1885 : }
1886 :
1887 : std::string
1888 0 : MatchArm::to_string () const
1889 : {
1890 : // outer attributes
1891 0 : std::string str = "Outer attributes: ";
1892 0 : if (outer_attrs.empty ())
1893 : {
1894 0 : str += "none";
1895 : }
1896 : else
1897 : {
1898 : /* note that this does not print them with "outer attribute" syntax -
1899 : * just the body */
1900 0 : for (const auto &attr : outer_attrs)
1901 : {
1902 0 : str += "\n " + attr.as_string ();
1903 : }
1904 : }
1905 :
1906 0 : str += "\nPatterns: ";
1907 0 : if (match_arm_pattern == nullptr)
1908 0 : str += "none";
1909 : else
1910 0 : str += "\n " + match_arm_pattern->to_string ();
1911 :
1912 0 : str += "\nGuard expr: ";
1913 0 : if (!has_match_arm_guard ())
1914 : {
1915 0 : str += "none";
1916 : }
1917 : else
1918 : {
1919 0 : str += guard_expr->to_string ();
1920 : }
1921 :
1922 0 : return str;
1923 : }
1924 :
1925 : std::string
1926 0 : MatchCase::to_debug_string () const
1927 : {
1928 0 : std::string str ("MatchCase: (match arm) ");
1929 :
1930 0 : str += "\n Match arm matcher: \n" + arm.to_string ();
1931 0 : str += "\n Expr: " + expr->to_string ();
1932 :
1933 0 : return str;
1934 : }
1935 :
1936 : std::string
1937 0 : MatchCase::to_string () const
1938 : {
1939 0 : std::string str = arm.to_string ();
1940 0 : str += " => ";
1941 0 : str += expr ? expr->to_string () : "null";
1942 0 : return str;
1943 : }
1944 :
1945 : /*std::string
1946 : MatchCaseBlockExpr::to_string () const
1947 : {
1948 : std::string str = MatchCase::to_string ();
1949 :
1950 : str += "\n Block expr: " + block_expr->to_string ();
1951 :
1952 : return str;
1953 : }
1954 :
1955 : std::string
1956 : MatchCaseExpr::to_string () const
1957 : {
1958 : std::string str = MatchCase::to_string ();
1959 :
1960 : str += "\n Expr: " + expr->to_string ();
1961 :
1962 : return str;
1963 : }*/
1964 :
1965 : std::string
1966 0 : MatchExpr::to_string () const
1967 : {
1968 0 : std::string str ("MatchExpr:");
1969 :
1970 0 : str += "\n Scrutinee expr: " + branch_value->to_string ();
1971 :
1972 : // inner attributes
1973 0 : str += "\n inner attributes: ";
1974 0 : if (inner_attrs.empty ())
1975 : {
1976 0 : str += "none";
1977 : }
1978 : else
1979 : {
1980 : /* note that this does not print them with "inner attribute" syntax -
1981 : * just the body */
1982 0 : for (const auto &attr : inner_attrs)
1983 : {
1984 0 : str += "\n " + attr.as_string ();
1985 : }
1986 : }
1987 :
1988 : // match arms
1989 0 : str += "\n Match arms: ";
1990 0 : if (match_arms.empty ())
1991 : {
1992 0 : str += "none";
1993 : }
1994 : else
1995 : {
1996 0 : for (const auto &arm : match_arms)
1997 0 : str += "\n " + arm.to_string ();
1998 : }
1999 :
2000 0 : return str;
2001 : }
2002 :
2003 : std::string
2004 0 : TupleExpr::to_string () const
2005 : {
2006 0 : std::string str ("TupleExpr:");
2007 :
2008 : // inner attributes
2009 0 : str += "\n inner attributes: ";
2010 0 : if (inner_attrs.empty ())
2011 : {
2012 0 : str += "none";
2013 : }
2014 : else
2015 : {
2016 : /* note that this does not print them with "inner attribute" syntax -
2017 : * just the body */
2018 0 : for (const auto &attr : inner_attrs)
2019 : {
2020 0 : str += "\n " + attr.as_string ();
2021 : }
2022 : }
2023 :
2024 0 : str += "\n Tuple elements: ";
2025 0 : if (tuple_elems.empty ())
2026 : {
2027 0 : str += "none";
2028 : }
2029 : else
2030 : {
2031 0 : for (const auto &elem : tuple_elems)
2032 : {
2033 0 : str += "\n " + elem->to_string ();
2034 : }
2035 : }
2036 :
2037 0 : return str;
2038 : }
2039 :
2040 : std::string
2041 0 : FunctionParam::to_string () const
2042 : {
2043 0 : return param_name->to_string () + " : " + type->to_string ();
2044 : }
2045 :
2046 : std::string
2047 2 : FunctionQualifiers::to_string () const
2048 : {
2049 2 : std::string str;
2050 :
2051 2 : if (is_const ())
2052 0 : str += "const ";
2053 2 : if (is_async ())
2054 0 : str += "async ";
2055 2 : if (is_unsafe ())
2056 0 : str += "unsafe ";
2057 :
2058 2 : if (has_extern)
2059 : {
2060 0 : str += "extern";
2061 0 : str += " \"" + get_string_from_abi (abi) + "\"";
2062 : }
2063 :
2064 2 : return str;
2065 : }
2066 :
2067 : std::string
2068 0 : TraitBound::to_debug_string () const
2069 : {
2070 0 : std::string str ("TraitBound:");
2071 :
2072 0 : switch (polarity)
2073 : {
2074 : case RegularBound:
2075 : break;
2076 0 : case NegativeBound:
2077 0 : str += "!";
2078 0 : break;
2079 0 : case AntiBound:
2080 0 : str += "?";
2081 0 : break;
2082 : }
2083 :
2084 0 : str += "\n For lifetimes: ";
2085 0 : if (!has_for_lifetimes ())
2086 : {
2087 0 : str += "none";
2088 : }
2089 : else
2090 : {
2091 0 : for (const auto &lifetime : for_lifetimes)
2092 : {
2093 0 : str += "\n " + lifetime.to_string ();
2094 : }
2095 : }
2096 :
2097 0 : str += "\n Type path: " + type_path.to_string ();
2098 :
2099 0 : return str;
2100 : }
2101 :
2102 : std::string
2103 0 : TraitBound::to_string () const
2104 : {
2105 0 : std::string str;
2106 0 : switch (polarity)
2107 : {
2108 : case RegularBound:
2109 : break;
2110 0 : case NegativeBound:
2111 0 : str += "!";
2112 0 : break;
2113 0 : case AntiBound:
2114 0 : str += "?";
2115 0 : break;
2116 : }
2117 :
2118 0 : if (has_for_lifetimes ())
2119 0 : for (const auto &lifetime : for_lifetimes)
2120 0 : str += "\n " + lifetime.to_string ();
2121 :
2122 0 : str += "\n" + type_path.to_string ();
2123 :
2124 0 : return str;
2125 : }
2126 :
2127 : std::string
2128 6 : QualifiedPathInType::to_string () const
2129 : {
2130 6 : std::string str = path_type.to_string ();
2131 :
2132 12 : str += "::" + associated_segment->to_string ();
2133 6 : for (const auto &segment : segments)
2134 : {
2135 0 : str += "::" + segment->to_string ();
2136 : }
2137 :
2138 6 : return str;
2139 : }
2140 :
2141 : std::string
2142 146 : Lifetime::to_string () const
2143 : {
2144 146 : switch (lifetime_type)
2145 : {
2146 37 : case AST::Lifetime::LifetimeType::NAMED:
2147 37 : return "'" + lifetime_name;
2148 14 : case AST::Lifetime::LifetimeType::STATIC:
2149 14 : return "'static";
2150 95 : case AST::Lifetime::LifetimeType::WILDCARD:
2151 95 : return "'_";
2152 0 : default:
2153 0 : return "ERROR-MARK-STRING: lifetime type failure";
2154 : }
2155 : }
2156 :
2157 : std::string
2158 2003 : TypePath::to_string () const
2159 : {
2160 2003 : std::string str;
2161 :
2162 2003 : if (has_opening_scope_resolution)
2163 : {
2164 59 : str = "::";
2165 : }
2166 :
2167 4256 : for (const auto &segment : segments)
2168 : {
2169 6759 : str += segment->to_string () + "::";
2170 : }
2171 :
2172 : // kinda hack - remove last 2 '::' characters
2173 2003 : str.erase (str.length () - 2);
2174 :
2175 2003 : return str;
2176 : }
2177 :
2178 : std::string
2179 0 : TypeParam::to_debug_string () const
2180 : {
2181 0 : std::string str ("TypeParam: ");
2182 :
2183 0 : str += "\n Outer attributes: ";
2184 0 : if (outer_attrs.empty ())
2185 : {
2186 0 : str += "\nnone";
2187 : }
2188 : else
2189 : {
2190 : /* note that this does not print them with "outer attribute" syntax -
2191 : * just the body */
2192 0 : for (const auto &attr : outer_attrs)
2193 : {
2194 0 : str += "\n " + attr.as_string ();
2195 : }
2196 : }
2197 :
2198 0 : str += "\n Identifier: " + type_representation.as_string ();
2199 :
2200 0 : str += "\n Type param bounds: ";
2201 0 : if (!has_type_param_bounds ())
2202 : {
2203 0 : str += "none";
2204 : }
2205 : else
2206 : {
2207 0 : for (const auto &bound : type_param_bounds)
2208 : {
2209 0 : str += "\n " + bound->to_string ();
2210 : }
2211 : }
2212 :
2213 0 : str += "\n Type: ";
2214 0 : if (!has_type ())
2215 : {
2216 0 : str += "none";
2217 : }
2218 : else
2219 : {
2220 0 : str += type.value ()->to_string ();
2221 : }
2222 :
2223 0 : return str;
2224 : }
2225 :
2226 : std::string
2227 0 : TypeParam::to_string () const
2228 : {
2229 0 : std::string str;
2230 0 : if (!outer_attrs.empty ())
2231 : {
2232 0 : for (const auto &attr : outer_attrs)
2233 : {
2234 0 : str += attr.as_string () + "\n";
2235 : }
2236 : }
2237 :
2238 0 : str += type_representation.as_string ();
2239 :
2240 0 : if (!has_type_param_bounds ())
2241 : {
2242 0 : str += ": ";
2243 0 : for (size_t i = 0; i < type_param_bounds.size (); ++i)
2244 : {
2245 0 : if (i > 0)
2246 0 : str += " + ";
2247 0 : str += type_param_bounds[i]->to_string ();
2248 : }
2249 : }
2250 :
2251 0 : if (has_type ())
2252 0 : str += ": " + type.value ()->to_string ();
2253 :
2254 0 : return str;
2255 : }
2256 :
2257 : AST::SimplePath
2258 5 : PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const
2259 : {
2260 5 : rust_assert (kind == Kind::Segmented);
2261 :
2262 5 : if (!has_segments ())
2263 : {
2264 0 : return AST::SimplePath::create_empty ();
2265 : }
2266 :
2267 : // create vector of reserved size (to minimise reallocations)
2268 5 : std::vector<AST::SimplePathSegment> simple_segments;
2269 5 : simple_segments.reserve (segments.size ());
2270 :
2271 10 : for (const auto &segment : segments)
2272 : {
2273 : // return empty path if doesn't meet simple path segment requirements
2274 5 : if (segment.has_generic_args () || segment.to_string () == "Self")
2275 : {
2276 0 : return AST::SimplePath::create_empty ();
2277 : }
2278 :
2279 : // create segment and add to vector
2280 5 : std::string segment_str = segment.to_string ();
2281 5 : simple_segments.emplace_back (std::move (segment_str),
2282 5 : segment.get_locus ());
2283 5 : }
2284 :
2285 : // kind of a HACK to get locus depending on opening scope resolution
2286 5 : location_t locus = UNKNOWN_LOCATION;
2287 5 : if (with_opening_scope_resolution)
2288 : {
2289 0 : locus = simple_segments[0].get_locus () - 2; // minus 2 chars for ::
2290 : }
2291 : else
2292 : {
2293 5 : locus = simple_segments[0].get_locus ();
2294 : }
2295 :
2296 5 : return AST::SimplePath (std::move (simple_segments),
2297 5 : with_opening_scope_resolution, locus);
2298 5 : }
2299 :
2300 : AST::SimplePath
2301 3 : TypePath::as_simple_path () const
2302 : {
2303 3 : if (segments.empty ())
2304 : {
2305 0 : return AST::SimplePath::create_empty ();
2306 : }
2307 :
2308 : // create vector of reserved size (to minimise reallocations)
2309 3 : std::vector<AST::SimplePathSegment> simple_segments;
2310 3 : simple_segments.reserve (segments.size ());
2311 :
2312 6 : for (const auto &segment : segments)
2313 : {
2314 : // return empty path if doesn't meet simple path segment requirements
2315 3 : if (segment == nullptr || segment->is_error ()
2316 6 : || !segment->is_ident_only () || segment->to_string () == "Self")
2317 : {
2318 0 : return AST::SimplePath::create_empty ();
2319 : }
2320 :
2321 : // create segment and add to vector
2322 3 : std::string segment_str = segment->to_string ();
2323 3 : simple_segments.emplace_back (std::move (segment_str),
2324 3 : segment->get_locus ());
2325 3 : }
2326 :
2327 3 : return AST::SimplePath (std::move (simple_segments),
2328 3 : has_opening_scope_resolution, locus);
2329 3 : }
2330 :
2331 : std::string
2332 66 : PathExprSegment::to_string () const
2333 : {
2334 66 : std::string ident_str = segment_name.to_string ();
2335 66 : if (has_generic_args ())
2336 : {
2337 0 : ident_str += "::<" + generic_args.to_string () + ">";
2338 : }
2339 :
2340 66 : return ident_str;
2341 : }
2342 :
2343 : std::string
2344 1910 : GenericArgs::to_string () const
2345 : {
2346 1910 : std::string args;
2347 :
2348 : // lifetime args
2349 1910 : if (!lifetime_args.empty ())
2350 : {
2351 : auto i = lifetime_args.begin ();
2352 : auto e = lifetime_args.end ();
2353 :
2354 59 : for (; i != e; i++)
2355 : {
2356 60 : args += (*i).to_string ();
2357 30 : if (e != i + 1)
2358 1 : args += ", ";
2359 : }
2360 : }
2361 :
2362 : // type args
2363 1910 : if (!type_args.empty ())
2364 : {
2365 : auto i = type_args.begin ();
2366 : auto e = type_args.end ();
2367 :
2368 3842 : for (; i != e; i++)
2369 : {
2370 4010 : args += (*i)->to_string ();
2371 2005 : if (e != i + 1)
2372 168 : args += ", ";
2373 : }
2374 : }
2375 :
2376 : // binding args
2377 1910 : if (!binding_args.empty ())
2378 : {
2379 : auto i = binding_args.begin ();
2380 : auto e = binding_args.end ();
2381 :
2382 0 : for (; i != e; i++)
2383 : {
2384 0 : args += (*i).to_string ();
2385 0 : if (e != i + 1)
2386 0 : args += ", ";
2387 : }
2388 : }
2389 :
2390 1910 : return args;
2391 : }
2392 :
2393 : std::string
2394 0 : GenericArgsBinding::to_string () const
2395 : {
2396 0 : return identifier.as_string () + " = " + type->to_string ();
2397 : }
2398 :
2399 : std::string
2400 0 : RangePattern::to_string () const
2401 : {
2402 0 : if (has_ellipsis_syntax)
2403 : {
2404 0 : return lower->to_string () + "..." + upper->to_string ();
2405 : }
2406 : else
2407 : {
2408 0 : return lower->to_string () + "..=" + upper->to_string ();
2409 : }
2410 : }
2411 :
2412 : std::string
2413 0 : RangePatternBoundLiteral::to_string () const
2414 : {
2415 0 : std::string str;
2416 :
2417 0 : if (has_minus)
2418 : {
2419 0 : str += "-";
2420 : }
2421 :
2422 0 : str += literal.as_string ();
2423 :
2424 0 : return str;
2425 : }
2426 :
2427 : std::string
2428 0 : SlicePatternItemsNoRest::to_string () const
2429 : {
2430 0 : std::string str;
2431 :
2432 0 : for (const auto &pattern : patterns)
2433 : {
2434 0 : str += "\n " + pattern->to_string ();
2435 : }
2436 :
2437 0 : return str;
2438 : }
2439 :
2440 : std::string
2441 0 : SlicePatternItemsHasRest::to_string () const
2442 : {
2443 0 : std::string str;
2444 :
2445 0 : str += "\n Lower patterns: ";
2446 0 : if (lower_patterns.empty ())
2447 : {
2448 0 : str += "none";
2449 : }
2450 : else
2451 : {
2452 0 : for (const auto &lower : lower_patterns)
2453 : {
2454 0 : str += "\n " + lower->to_string ();
2455 : }
2456 : }
2457 :
2458 0 : str += "\n Upper patterns: ";
2459 0 : if (upper_patterns.empty ())
2460 : {
2461 0 : str += "none";
2462 : }
2463 : else
2464 : {
2465 0 : for (const auto &upper : upper_patterns)
2466 : {
2467 0 : str += "\n " + upper->to_string ();
2468 : }
2469 : }
2470 :
2471 0 : return str;
2472 : }
2473 :
2474 : std::string
2475 0 : SlicePattern::to_string () const
2476 : {
2477 0 : return "SlicePattern: " + items->to_string ();
2478 : }
2479 :
2480 : std::string
2481 0 : AltPattern::to_string () const
2482 : {
2483 0 : std::string str ("AltPattern: ");
2484 :
2485 0 : for (const auto &pattern : alts)
2486 : {
2487 0 : str += "\n " + pattern->to_string ();
2488 : }
2489 :
2490 0 : return str;
2491 : }
2492 :
2493 : std::string
2494 4 : TuplePatternItemsNoRest::to_string () const
2495 : {
2496 4 : std::string str;
2497 :
2498 12 : for (const auto &pattern : patterns)
2499 : {
2500 16 : str += "\n " + pattern->to_string ();
2501 : }
2502 :
2503 4 : return str;
2504 : }
2505 :
2506 : std::string
2507 0 : TuplePatternItemsHasRest::to_string () const
2508 : {
2509 0 : std::string str;
2510 :
2511 0 : str += "\n Lower patterns: ";
2512 0 : if (lower_patterns.empty ())
2513 : {
2514 0 : str += "none";
2515 : }
2516 : else
2517 : {
2518 0 : for (const auto &lower : lower_patterns)
2519 : {
2520 0 : str += "\n " + lower->to_string ();
2521 : }
2522 : }
2523 :
2524 0 : str += "\n Upper patterns: ";
2525 0 : if (upper_patterns.empty ())
2526 : {
2527 0 : str += "none";
2528 : }
2529 : else
2530 : {
2531 0 : for (const auto &upper : upper_patterns)
2532 : {
2533 0 : str += "\n " + upper->to_string ();
2534 : }
2535 : }
2536 :
2537 0 : return str;
2538 : }
2539 :
2540 : std::string
2541 4 : TuplePattern::to_string () const
2542 : {
2543 4 : return items->to_string ();
2544 : }
2545 :
2546 : std::string
2547 0 : StructPatternField::to_string () const
2548 : {
2549 : // outer attributes
2550 0 : std::string str ("Outer attributes: ");
2551 0 : if (outer_attrs.empty ())
2552 : {
2553 0 : str += "none";
2554 : }
2555 : else
2556 : {
2557 : /* note that this does not print them with "outer attribute" syntax -
2558 : * just the body */
2559 0 : for (const auto &attr : outer_attrs)
2560 : {
2561 0 : str += "\n " + attr.as_string ();
2562 : }
2563 : }
2564 :
2565 0 : str += "\n item type: ";
2566 0 : switch (get_item_type ())
2567 : {
2568 0 : case ItemType::TUPLE_PAT:
2569 0 : str += "TUPLE_PAT";
2570 0 : break;
2571 0 : case ItemType::IDENT_PAT:
2572 0 : str += "IDENT_PAT";
2573 0 : break;
2574 0 : case ItemType::IDENT:
2575 0 : str += "IDENT";
2576 0 : break;
2577 0 : default:
2578 0 : str += "UNKNOWN";
2579 0 : break;
2580 : }
2581 :
2582 0 : return str;
2583 : }
2584 :
2585 : std::string
2586 0 : StructPatternFieldIdent::to_string () const
2587 : {
2588 0 : std::string str = StructPatternField::to_string ();
2589 :
2590 0 : str += "\n";
2591 :
2592 0 : if (has_ref)
2593 : {
2594 0 : str += "ref ";
2595 : }
2596 :
2597 0 : if (is_mut ())
2598 : {
2599 0 : str += "mut ";
2600 : }
2601 :
2602 0 : str += ident.as_string ();
2603 :
2604 0 : return str;
2605 : }
2606 :
2607 : std::string
2608 0 : StructPatternFieldTuplePat::to_string () const
2609 : {
2610 0 : std::string str = StructPatternField::to_string ();
2611 :
2612 0 : str += "\n";
2613 :
2614 0 : str += std::to_string (index) + " : " + tuple_pattern->to_string ();
2615 :
2616 0 : return str;
2617 : }
2618 :
2619 : std::string
2620 0 : StructPatternFieldIdentPat::to_string () const
2621 : {
2622 0 : std::string str = StructPatternField::to_string ();
2623 :
2624 0 : str += "\n";
2625 :
2626 0 : str += ident.as_string () + " : " + ident_pattern->to_string ();
2627 :
2628 0 : return str;
2629 : }
2630 :
2631 : std::string
2632 0 : StructPatternElements::to_string () const
2633 : {
2634 0 : std::string str ("\n Fields: ");
2635 :
2636 0 : if (!has_struct_pattern_fields ())
2637 : {
2638 0 : str += "none";
2639 : }
2640 : else
2641 : {
2642 0 : for (const auto &field : fields)
2643 : {
2644 0 : str += "\n " + field->to_string ();
2645 : }
2646 : }
2647 :
2648 0 : return str;
2649 : }
2650 :
2651 : std::string
2652 0 : StructPattern::to_string () const
2653 : {
2654 0 : std::string str ("StructPattern: \n Path: ");
2655 :
2656 0 : str += path.to_string ();
2657 :
2658 0 : str += "\n Struct pattern elems: ";
2659 0 : if (!has_struct_pattern_elems ())
2660 : {
2661 0 : str += "none";
2662 : }
2663 : else
2664 : {
2665 0 : str += elems.to_string ();
2666 : }
2667 :
2668 0 : return str;
2669 : }
2670 :
2671 : std::string
2672 0 : LiteralPattern::to_string () const
2673 : {
2674 0 : return (has_minus ? "-" : "") + lit.as_string ();
2675 : }
2676 :
2677 : std::string
2678 40 : ReferencePattern::to_string () const
2679 : {
2680 40 : std::string str ("&");
2681 :
2682 40 : if (is_mut ())
2683 : {
2684 0 : str += "mut ";
2685 : }
2686 :
2687 80 : str += pattern->to_string ();
2688 :
2689 40 : return str;
2690 : }
2691 :
2692 : std::string
2693 142418 : IdentifierPattern::to_string () const
2694 : {
2695 142418 : std::string str;
2696 :
2697 142418 : if (is_ref)
2698 : {
2699 42399 : str += "ref ";
2700 : }
2701 :
2702 142418 : if (is_mut ())
2703 : {
2704 2181 : str += "mut ";
2705 : }
2706 :
2707 142418 : str += variable_ident.as_string ();
2708 :
2709 142418 : if (has_subpattern ())
2710 : {
2711 0 : str += " @ " + subpattern->to_string ();
2712 : }
2713 :
2714 142418 : return str;
2715 : }
2716 :
2717 : std::string
2718 35 : TupleStructItemsNoRest::to_string () const
2719 : {
2720 35 : std::string str;
2721 :
2722 70 : for (const auto &pattern : patterns)
2723 : {
2724 70 : str += "\n " + pattern->to_string ();
2725 : }
2726 :
2727 35 : return str;
2728 : }
2729 :
2730 : std::string
2731 0 : TupleStructItemsHasRest::to_string () const
2732 : {
2733 0 : std::string str ("\n Lower patterns: ");
2734 :
2735 0 : if (lower_patterns.empty ())
2736 : {
2737 0 : str += "none";
2738 : }
2739 : else
2740 : {
2741 0 : for (const auto &lower : lower_patterns)
2742 : {
2743 0 : str += "\n " + lower->to_string ();
2744 : }
2745 : }
2746 :
2747 0 : str += "\n Upper patterns: ";
2748 0 : if (upper_patterns.empty ())
2749 : {
2750 0 : str += "none";
2751 : }
2752 : else
2753 : {
2754 0 : for (const auto &upper : upper_patterns)
2755 : {
2756 0 : str += "\n " + upper->to_string ();
2757 : }
2758 : }
2759 :
2760 0 : return str;
2761 : }
2762 :
2763 : std::string
2764 35 : TupleStructPattern::to_string () const
2765 : {
2766 35 : std::string str ("TupleStructPattern: \n Path: ");
2767 :
2768 70 : str += path.to_string ();
2769 :
2770 70 : str += "\n Tuple struct items: " + items->to_string ();
2771 :
2772 35 : return str;
2773 : }
2774 :
2775 : std::string
2776 2 : LetStmt::to_string () const
2777 : {
2778 : // outer attributes
2779 2 : std::string str = "Outer attributes: ";
2780 2 : if (outer_attrs.empty ())
2781 : {
2782 2 : str += "none";
2783 : }
2784 : else
2785 : {
2786 : /* note that this does not print them with "outer attribute" syntax -
2787 : * just the body */
2788 0 : indent_spaces (enter);
2789 0 : for (const auto &attr : outer_attrs)
2790 : {
2791 0 : str += "\n" + indent_spaces (stay) + attr.as_string ();
2792 : }
2793 0 : indent_spaces (out);
2794 : }
2795 :
2796 6 : str += "\n" + indent_spaces (stay) + "let " + variables_pattern->to_string ();
2797 :
2798 2 : if (has_type ())
2799 : {
2800 0 : str += " : " + get_type ().to_string ();
2801 : }
2802 :
2803 2 : if (has_init_expr ())
2804 : {
2805 4 : str += " = " + get_init_expr ().to_string ();
2806 : }
2807 :
2808 2 : return str;
2809 : }
2810 :
2811 : // Used to get outer attributes for expressions.
2812 : std::string
2813 5 : Expr::to_string () const
2814 : {
2815 : // outer attributes
2816 5 : std::string str = "outer attributes: ";
2817 5 : if (outer_attrs.empty ())
2818 : {
2819 5 : str += "none";
2820 : }
2821 : else
2822 : {
2823 : /* note that this does not print them with "outer attribute" syntax -
2824 : * just the body */
2825 0 : for (const auto &attr : outer_attrs)
2826 : {
2827 0 : str += "\n " + attr.as_string ();
2828 : }
2829 : }
2830 :
2831 5 : return str;
2832 : }
2833 :
2834 : // hopefully definition here will prevent circular dependency issue
2835 : std::unique_ptr<TraitBound>
2836 0 : TypePath::to_trait_bound (bool in_parens) const
2837 : {
2838 : // If already in parentheses, don't convert to trait bound
2839 : // This ensures (TypePath) stays as ParenthesisedType in the parser
2840 0 : if (in_parens)
2841 0 : return nullptr;
2842 :
2843 : // create clone FIXME is this required? or is copy constructor automatically
2844 : // called?
2845 0 : TypePath copy (*this);
2846 0 : return std::make_unique<TraitBound> (mappings, std::move (copy),
2847 0 : copy.get_locus (), in_parens);
2848 0 : }
2849 :
2850 : std::string
2851 3 : InferredType::to_string () const
2852 : {
2853 3 : return "_ (inferred)";
2854 : }
2855 :
2856 : std::string
2857 0 : TypeCastExpr::to_string () const
2858 : {
2859 0 : return main_or_left_expr->to_string () + " as "
2860 0 : + type_to_convert_to->to_string ();
2861 : }
2862 :
2863 : std::string
2864 0 : ImplTraitType::to_string () const
2865 : {
2866 0 : std::string str ("ImplTraitType: \n TypeParamBounds: ");
2867 :
2868 0 : if (type_param_bounds.empty ())
2869 : {
2870 0 : str += "none";
2871 : }
2872 : else
2873 : {
2874 0 : for (const auto &bound : type_param_bounds)
2875 : {
2876 0 : str += "\n " + bound->to_string ();
2877 : }
2878 : }
2879 :
2880 0 : return str;
2881 : }
2882 :
2883 : std::string
2884 110 : ReferenceType::to_string () const
2885 : {
2886 110 : std::string str ("&");
2887 :
2888 110 : if (has_lifetime ())
2889 : {
2890 330 : str += get_lifetime ().to_string () + " ";
2891 : }
2892 :
2893 110 : if (is_mut ())
2894 : {
2895 7 : str += "mut ";
2896 : }
2897 :
2898 220 : str += type->to_string ();
2899 :
2900 110 : return str;
2901 : }
2902 :
2903 : std::string
2904 0 : RawPointerType::to_string () const
2905 : {
2906 0 : return std::string ("*") + (is_mut () ? "mut " : "const ")
2907 0 : + type->to_string ();
2908 : }
2909 :
2910 : std::string
2911 0 : TraitObjectType::to_string () const
2912 : {
2913 0 : std::string str ("TraitObjectType: \n Has dyn dispatch: ");
2914 :
2915 0 : if (has_dyn)
2916 : {
2917 0 : str += "true";
2918 : }
2919 : else
2920 : {
2921 0 : str += "false";
2922 : }
2923 :
2924 0 : str += "\n TypeParamBounds: ";
2925 0 : if (type_param_bounds.empty ())
2926 : {
2927 0 : str += "none";
2928 : }
2929 : else
2930 : {
2931 0 : for (const auto &bound : type_param_bounds)
2932 : {
2933 0 : str += "\n " + bound->to_string ();
2934 : }
2935 : }
2936 :
2937 0 : return str;
2938 : }
2939 :
2940 : std::string
2941 2 : BareFunctionType::to_string () const
2942 : {
2943 2 : std::string str ("BareFunctionType: \n For lifetimes: ");
2944 :
2945 2 : if (!has_for_lifetimes ())
2946 : {
2947 2 : str += "none";
2948 : }
2949 : else
2950 : {
2951 0 : for (const auto &for_lifetime : for_lifetimes)
2952 : {
2953 0 : str += "\n " + for_lifetime.to_string ();
2954 : }
2955 : }
2956 :
2957 4 : str += "\n Qualifiers: " + function_qualifiers.to_string ();
2958 :
2959 2 : str += "\n Params: ";
2960 2 : if (params.empty ())
2961 : {
2962 2 : str += "none";
2963 : }
2964 : else
2965 : {
2966 0 : for (const auto ¶m : params)
2967 : {
2968 0 : str += "\n " + param.to_string ();
2969 : }
2970 : }
2971 :
2972 2 : str += "\n Is variadic: ";
2973 2 : if (is_variadic)
2974 : {
2975 0 : str += "true";
2976 : }
2977 : else
2978 : {
2979 2 : str += "false";
2980 : }
2981 :
2982 2 : str += "\n Return type: ";
2983 2 : if (!has_return_type ())
2984 : {
2985 2 : str += "none (void)";
2986 : }
2987 : else
2988 : {
2989 0 : str += return_type->to_string ();
2990 : }
2991 :
2992 2 : return str;
2993 : }
2994 :
2995 : std::string
2996 1910 : TypePathSegmentGeneric::to_string () const
2997 : {
2998 5730 : return TypePathSegment::to_string () + "<" + generic_args.to_string () + ">";
2999 : }
3000 :
3001 : std::string
3002 0 : TypePathFunction::to_string () const
3003 : {
3004 0 : std::string str ("(");
3005 :
3006 0 : if (has_inputs ())
3007 : {
3008 : auto i = inputs.begin ();
3009 : auto e = inputs.end ();
3010 :
3011 0 : for (; i != e; i++)
3012 : {
3013 0 : str += (*i)->to_string ();
3014 0 : if (e != i + 1)
3015 0 : str += ", ";
3016 : }
3017 : }
3018 :
3019 0 : str += ")";
3020 :
3021 0 : if (has_return_type ())
3022 : {
3023 0 : str += " -> " + return_type->to_string ();
3024 : }
3025 :
3026 0 : return str;
3027 : }
3028 :
3029 : std::string
3030 0 : TypePathSegmentFunction::to_string () const
3031 : {
3032 0 : return TypePathSegment::to_string () + function_path.to_string ();
3033 : }
3034 :
3035 : std::string
3036 0 : ArrayType::to_string () const
3037 : {
3038 0 : return "[" + elem_type->to_string () + "; " + size->to_string () + "]";
3039 : }
3040 :
3041 : std::string
3042 28 : SliceType::to_string () const
3043 : {
3044 56 : return "[" + elem_type->to_string () + "]";
3045 : }
3046 :
3047 : std::string
3048 9 : TupleType::to_string () const
3049 : {
3050 9 : std::string str ("(");
3051 :
3052 9 : if (!is_unit_type ())
3053 : {
3054 : auto i = elems.begin ();
3055 : auto e = elems.end ();
3056 :
3057 5 : for (; i != e; i++)
3058 : {
3059 6 : str += (*i)->to_string ();
3060 3 : if (e != i + 1)
3061 1 : str += ", ";
3062 : }
3063 : }
3064 :
3065 9 : str += ")";
3066 :
3067 9 : return str;
3068 : }
3069 :
3070 : std::string
3071 0 : StructExpr::to_string () const
3072 : {
3073 0 : std::string str = ExprWithoutBlock::to_string ();
3074 0 : indent_spaces (enter);
3075 0 : str += "\n" + indent_spaces (stay) + "StructExpr:";
3076 0 : indent_spaces (enter);
3077 0 : str += "\n" + indent_spaces (stay) + "PathInExpr:\n";
3078 0 : str += indent_spaces (stay) + struct_name.to_string ();
3079 0 : indent_spaces (out);
3080 0 : indent_spaces (out);
3081 0 : return str;
3082 : }
3083 :
3084 : std::string
3085 0 : StructExprStruct::to_string () const
3086 : {
3087 0 : std::string str ("StructExprStruct (or subclass): ");
3088 :
3089 0 : str += "\n Path: " + struct_name.to_string ();
3090 :
3091 : // inner attributes
3092 0 : str += "\n inner attributes: ";
3093 0 : if (inner_attrs.empty ())
3094 : {
3095 0 : str += "none";
3096 : }
3097 : else
3098 : {
3099 : /* note that this does not print them with "inner attribute" syntax -
3100 : * just the body */
3101 0 : for (const auto &attr : inner_attrs)
3102 : {
3103 0 : str += "\n " + attr.as_string ();
3104 : }
3105 : }
3106 :
3107 0 : return str;
3108 : }
3109 :
3110 : std::string
3111 0 : StructBase::to_string () const
3112 : {
3113 0 : if (base_struct != nullptr)
3114 : {
3115 0 : return base_struct->to_string ();
3116 : }
3117 : else
3118 : {
3119 0 : return "ERROR_MARK_STRING - invalid struct base had as string applied";
3120 : }
3121 : }
3122 :
3123 : std::string
3124 0 : StructExprFieldWithVal::to_string () const
3125 : {
3126 : // used to get value string
3127 0 : return value->to_string ();
3128 : }
3129 :
3130 : std::string
3131 0 : StructExprFieldIdentifierValue::to_string () const
3132 : {
3133 0 : return field_name.as_string () + " : " + StructExprFieldWithVal::to_string ();
3134 : }
3135 :
3136 : std::string
3137 0 : StructExprFieldIndexValue::to_string () const
3138 : {
3139 0 : return std::to_string (index) + " : " + StructExprFieldWithVal::to_string ();
3140 : }
3141 :
3142 : std::string
3143 0 : StructExprStructFields::to_string () const
3144 : {
3145 0 : std::string str = StructExprStruct::to_string ();
3146 :
3147 0 : str += "\n Fields: ";
3148 0 : if (fields.empty ())
3149 : {
3150 0 : str += "none";
3151 : }
3152 : else
3153 : {
3154 0 : for (const auto &field : fields)
3155 : {
3156 0 : str += "\n " + field->to_string ();
3157 : }
3158 : }
3159 :
3160 0 : str += "\n Struct base: ";
3161 0 : if (!has_struct_base ())
3162 : {
3163 0 : str += "none";
3164 : }
3165 : else
3166 : {
3167 0 : str += (*struct_base)->to_string ();
3168 : }
3169 :
3170 0 : return str;
3171 : }
3172 :
3173 : std::string
3174 3 : EnumItem::to_string () const
3175 : {
3176 3 : std::string str = Item::to_string ();
3177 3 : str += variant_name.as_string ();
3178 3 : str += " ";
3179 3 : switch (get_enum_item_kind ())
3180 : {
3181 1 : case Named:
3182 1 : str += "[Named variant]";
3183 1 : break;
3184 1 : case Tuple:
3185 1 : str += "[Tuple variant]";
3186 1 : break;
3187 0 : case Struct:
3188 0 : str += "[Struct variant]";
3189 0 : break;
3190 1 : case Discriminant:
3191 1 : str += "[Discriminant variant]";
3192 1 : break;
3193 : }
3194 :
3195 3 : return str;
3196 : }
3197 :
3198 : std::string
3199 1 : EnumItemTuple::to_string () const
3200 : {
3201 1 : std::string str = EnumItem::to_string ();
3202 :
3203 : // add tuple opening parens
3204 1 : str += "(";
3205 :
3206 : // tuple fields
3207 1 : if (has_tuple_fields ())
3208 : {
3209 : auto i = tuple_fields.begin ();
3210 : auto e = tuple_fields.end ();
3211 :
3212 2 : for (; i != e; i++)
3213 : {
3214 2 : str += (*i).to_string ();
3215 1 : if (e != i + 1)
3216 0 : str += ", ";
3217 : }
3218 : }
3219 :
3220 : // add tuple closing parens
3221 1 : str += ")";
3222 :
3223 1 : return str;
3224 : }
3225 :
3226 : std::string
3227 1 : TupleField::to_string () const
3228 : {
3229 : // outer attributes
3230 1 : std::string str = "outer attributes: ";
3231 1 : if (outer_attrs.empty ())
3232 : {
3233 1 : str += "none";
3234 : }
3235 : else
3236 : {
3237 : /* note that this does not print them with "outer attribute" syntax -
3238 : * just the body */
3239 0 : for (const auto &attr : outer_attrs)
3240 : {
3241 0 : str += "\n " + attr.as_string ();
3242 : }
3243 : }
3244 :
3245 1 : if (has_visibility ())
3246 : {
3247 2 : str += "\n" + visibility.to_string ();
3248 : }
3249 :
3250 2 : str += " " + field_type->to_string ();
3251 :
3252 1 : return str;
3253 : }
3254 :
3255 : std::string
3256 0 : EnumItemStruct::to_string () const
3257 : {
3258 0 : std::string str = EnumItem::to_string ();
3259 :
3260 : // add struct opening parens
3261 0 : str += "{";
3262 :
3263 : // tuple fields
3264 0 : if (has_struct_fields ())
3265 : {
3266 : auto i = struct_fields.begin ();
3267 : auto e = struct_fields.end ();
3268 :
3269 0 : for (; i != e; i++)
3270 : {
3271 0 : str += (*i).to_string ();
3272 0 : if (e != i + 1)
3273 0 : str += ", ";
3274 : }
3275 : }
3276 :
3277 : // add struct closing parens
3278 0 : str += "}";
3279 :
3280 0 : return str;
3281 : }
3282 :
3283 : std::string
3284 0 : StructField::to_string () const
3285 : {
3286 : // outer attributes
3287 0 : std::string str = "outer attributes: ";
3288 0 : if (outer_attrs.empty ())
3289 : {
3290 0 : str += "none";
3291 : }
3292 : else
3293 : {
3294 : /* note that this does not print them with "outer attribute" syntax -
3295 : * just the body */
3296 0 : for (const auto &attr : outer_attrs)
3297 : {
3298 0 : str += "\n " + attr.as_string ();
3299 : }
3300 : }
3301 :
3302 0 : if (has_visibility ())
3303 : {
3304 0 : str += "\n" + visibility.to_string ();
3305 : }
3306 :
3307 0 : str += " " + field_name.as_string () + " : " + field_type->to_string ();
3308 :
3309 0 : return str;
3310 : }
3311 :
3312 : std::string
3313 1 : EnumItemDiscriminant::to_string () const
3314 : {
3315 1 : std::string str = EnumItem::to_string ();
3316 :
3317 : // add equal and expression
3318 2 : str += " = " + expression->to_string ();
3319 :
3320 1 : return str;
3321 : }
3322 :
3323 : std::string
3324 0 : ExternalItem::to_string () const
3325 : {
3326 : // outer attributes
3327 0 : std::string str = "outer attributes: ";
3328 0 : if (outer_attrs.empty ())
3329 : {
3330 0 : str += "none";
3331 : }
3332 : else
3333 : {
3334 : /* note that this does not print them with "outer attribute" syntax -
3335 : * just the body */
3336 0 : for (const auto &attr : outer_attrs)
3337 : {
3338 0 : str += "\n " + attr.as_string ();
3339 : }
3340 : }
3341 :
3342 : // start visibility on new line and with a space
3343 0 : str += "\n" + visibility.to_string () + " ";
3344 :
3345 0 : return str;
3346 : }
3347 :
3348 : std::string
3349 0 : ExternalStaticItem::to_string () const
3350 : {
3351 0 : std::string str = ExternalItem::to_string ();
3352 :
3353 0 : str += "static ";
3354 :
3355 0 : if (is_mut ())
3356 : {
3357 0 : str += "mut ";
3358 : }
3359 :
3360 : // add name
3361 0 : str += get_item_name ().as_string ();
3362 :
3363 : // add type on new line
3364 0 : str += "\n Type: " + item_type->to_string ();
3365 :
3366 0 : return str;
3367 : }
3368 :
3369 : std::string
3370 0 : ExternalFunctionItem::to_string () const
3371 : {
3372 0 : std::string str = ExternalItem::to_string ();
3373 :
3374 0 : str += "fn ";
3375 :
3376 : // add name
3377 0 : str += get_item_name ().as_string ();
3378 :
3379 : // generic params
3380 0 : str += "\n Generic params: ";
3381 0 : if (generic_params.empty ())
3382 : {
3383 0 : str += "none";
3384 : }
3385 : else
3386 : {
3387 0 : for (const auto ¶m : generic_params)
3388 : {
3389 : // DEBUG: null pointer check
3390 0 : if (param == nullptr)
3391 : {
3392 0 : rust_debug (
3393 : "something really terrible has gone wrong - null pointer "
3394 : "generic param in external function item.");
3395 0 : return "nullptr_POINTER_MARK";
3396 : }
3397 :
3398 0 : str += "\n " + param->to_string ();
3399 : }
3400 : }
3401 :
3402 : // function params
3403 0 : str += "\n Function params: ";
3404 0 : if (function_params.empty ())
3405 : {
3406 0 : str += "none";
3407 : }
3408 : else
3409 : {
3410 0 : for (const auto ¶m : function_params)
3411 : {
3412 0 : str += "\n " + param.to_string ();
3413 : }
3414 0 : if (has_variadics)
3415 : {
3416 0 : str += "\n .. (variadic)";
3417 : }
3418 : }
3419 :
3420 : // add type on new line)
3421 0 : str += "\n (return) Type: "
3422 0 : + (has_return_type () ? return_type->to_string () : "()");
3423 :
3424 : // where clause
3425 0 : str += "\n Where clause: ";
3426 0 : if (has_where_clause ())
3427 : {
3428 0 : str += where_clause.to_string ();
3429 : }
3430 : else
3431 : {
3432 0 : str += "none";
3433 : }
3434 :
3435 0 : return str;
3436 0 : }
3437 :
3438 : std::string
3439 0 : ExternalTypeItem::to_string () const
3440 : {
3441 0 : std::string str = ExternalItem::to_string ();
3442 :
3443 0 : str += "type ";
3444 :
3445 : // add name
3446 0 : str += get_item_name ().as_string ();
3447 :
3448 0 : return str;
3449 : }
3450 :
3451 : std::string
3452 0 : NamedFunctionParam::to_string () const
3453 : {
3454 0 : std::string str = name.as_string ();
3455 :
3456 0 : str += "\n Type: " + param_type->to_string ();
3457 :
3458 0 : return str;
3459 : }
3460 :
3461 : /*std::string TraitItem::to_string() const {
3462 : // outer attributes
3463 : std::string str = "outer attributes: ";
3464 : if (outer_attrs.empty()) {
3465 : str += "none";
3466 : } else {
3467 : // note that this does not print them with "outer attribute" syntax -
3468 : just the body for (const auto& attr : outer_attrs) { str += "\n " +
3469 : attr.to_string();
3470 : }
3471 : }
3472 :
3473 : return str;
3474 : }*/
3475 :
3476 : std::string
3477 0 : TraitItemFunc::to_string () const
3478 : {
3479 0 : std::string str = "outer attributes: ";
3480 0 : if (outer_attrs.empty ())
3481 : {
3482 0 : str += "none";
3483 : }
3484 : else
3485 : {
3486 : /* note that this does not print them with "outer attribute" syntax -
3487 : * just the body */
3488 0 : for (const auto &attr : outer_attrs)
3489 : {
3490 0 : str += "\n " + attr.as_string ();
3491 : }
3492 : }
3493 :
3494 0 : str += "\n" + decl.to_string ();
3495 :
3496 0 : str += "\n Definition (block expr): ";
3497 0 : if (has_definition ())
3498 : {
3499 0 : str += block_expr->to_string ();
3500 : }
3501 : else
3502 : {
3503 0 : str += "none";
3504 : }
3505 :
3506 0 : return str;
3507 : }
3508 :
3509 : std::string
3510 0 : TraitFunctionDecl::to_string () const
3511 : {
3512 0 : std::string str
3513 0 : = qualifiers.to_string () + "fn " + function_name.as_string ();
3514 :
3515 : // generic params
3516 0 : str += "\n Generic params: ";
3517 0 : if (generic_params.empty ())
3518 : {
3519 0 : str += "none";
3520 : }
3521 : else
3522 : {
3523 0 : for (const auto ¶m : generic_params)
3524 : {
3525 : // DEBUG: null pointer check
3526 0 : if (param == nullptr)
3527 : {
3528 0 : rust_debug (
3529 : "something really terrible has gone wrong - null pointer "
3530 : "generic param in trait function decl.");
3531 0 : return "nullptr_POINTER_MARK";
3532 : }
3533 :
3534 0 : str += "\n " + param->to_string ();
3535 : }
3536 : }
3537 :
3538 0 : str += "\n Function params: ";
3539 0 : if (is_method ())
3540 : {
3541 0 : str += get_self_unchecked ().to_string () + (has_params () ? ", " : "");
3542 : }
3543 :
3544 0 : if (has_params ())
3545 : {
3546 0 : for (const auto ¶m : function_params)
3547 : {
3548 0 : str += "\n " + param.to_string ();
3549 : }
3550 : }
3551 0 : else if (!is_method ())
3552 : {
3553 0 : str += "none";
3554 : }
3555 :
3556 0 : str += "\n Return type: ";
3557 0 : if (has_return_type ())
3558 : {
3559 0 : str += return_type->to_string ();
3560 : }
3561 : else
3562 : {
3563 0 : str += "none (void)";
3564 : }
3565 :
3566 0 : str += "\n Where clause: ";
3567 0 : if (has_where_clause ())
3568 : {
3569 0 : str += where_clause.to_string ();
3570 : }
3571 : else
3572 : {
3573 0 : str += "none";
3574 : }
3575 :
3576 0 : return str;
3577 0 : }
3578 :
3579 : std::string
3580 0 : TraitItemConst::to_string () const
3581 : {
3582 0 : std::string str = "outer attributes: ";
3583 0 : if (outer_attrs.empty ())
3584 : {
3585 0 : str += "none";
3586 : }
3587 : else
3588 : {
3589 : /* note that this does not print them with "outer attribute" syntax -
3590 : * just the body */
3591 0 : for (const auto &attr : outer_attrs)
3592 : {
3593 0 : str += "\n " + attr.as_string ();
3594 : }
3595 : }
3596 :
3597 0 : str += "\nconst " + name.as_string () + " : " + type->to_string ();
3598 :
3599 0 : if (has_expression ())
3600 : {
3601 0 : str += " = " + expr->to_string ();
3602 : }
3603 :
3604 0 : return str;
3605 : }
3606 :
3607 : std::string
3608 0 : TraitItemType::to_string () const
3609 : {
3610 0 : std::string str = "outer attributes: ";
3611 0 : if (outer_attrs.empty ())
3612 : {
3613 0 : str += "none";
3614 : }
3615 : else
3616 : {
3617 : /* note that this does not print them with "outer attribute" syntax -
3618 : * just the body */
3619 0 : for (const auto &attr : outer_attrs)
3620 : {
3621 0 : str += "\n " + attr.as_string ();
3622 : }
3623 : }
3624 :
3625 0 : str += "\ntype " + name.as_string ();
3626 :
3627 0 : if (has_generics ())
3628 : {
3629 0 : str += "<";
3630 0 : for (size_t i = 0; i < generic_params.size (); i++)
3631 : {
3632 0 : if (i > 0)
3633 0 : str += ", ";
3634 0 : str += generic_params[i]->to_string ();
3635 : }
3636 0 : str += ">";
3637 : }
3638 :
3639 0 : str += "\n Type param bounds: ";
3640 0 : if (!has_type_param_bounds ())
3641 : {
3642 0 : str += "none";
3643 : }
3644 : else
3645 : {
3646 0 : for (const auto &bound : type_param_bounds)
3647 : {
3648 : // DEBUG: null pointer check
3649 0 : if (bound == nullptr)
3650 : {
3651 0 : rust_debug (
3652 : "something really terrible has gone wrong - null pointer "
3653 : "type param bound in trait item type.");
3654 0 : return "nullptr_POINTER_MARK";
3655 : }
3656 :
3657 0 : str += "\n " + bound->to_string ();
3658 : }
3659 : }
3660 :
3661 0 : return str;
3662 0 : }
3663 :
3664 : std::string
3665 0 : SelfParam::to_string () const
3666 : {
3667 0 : if (has_type ())
3668 : {
3669 : // type (i.e. not ref, no lifetime)
3670 0 : std::string str;
3671 :
3672 0 : if (is_mut ())
3673 : {
3674 0 : str += "mut ";
3675 : }
3676 :
3677 0 : str += "self : ";
3678 :
3679 0 : str += type->to_string ();
3680 :
3681 0 : return str;
3682 : }
3683 0 : else if (has_lifetime ())
3684 : {
3685 : // ref and lifetime
3686 0 : std::string str = "&" + get_lifetime ().to_string () + " ";
3687 :
3688 0 : if (is_mut ())
3689 : {
3690 0 : str += "mut ";
3691 : }
3692 :
3693 0 : str += "self";
3694 :
3695 0 : return str;
3696 0 : }
3697 0 : else if (is_ref ())
3698 : {
3699 : // ref with no lifetime
3700 0 : std::string str = "&";
3701 :
3702 0 : if (is_mut ())
3703 : {
3704 0 : str += " mut ";
3705 : }
3706 :
3707 0 : str += "self";
3708 :
3709 0 : return str;
3710 0 : }
3711 : else
3712 : {
3713 : // no ref, no type
3714 0 : std::string str;
3715 :
3716 0 : if (is_mut ())
3717 : {
3718 0 : str += "mut ";
3719 : }
3720 :
3721 0 : str += "self";
3722 :
3723 0 : return str;
3724 0 : }
3725 : }
3726 :
3727 : std::string
3728 0 : ArrayElemsCopied::to_string () const
3729 : {
3730 0 : return elem_to_copy->to_string () + "; " + num_copies->to_string ();
3731 : }
3732 :
3733 : std::string
3734 0 : LifetimeWhereClauseItem::to_string () const
3735 : {
3736 0 : std::string str ("Lifetime: ");
3737 :
3738 0 : str += lifetime.to_string ();
3739 :
3740 0 : str += "\nLifetime bounds: ";
3741 :
3742 0 : for (const auto &bound : lifetime_bounds)
3743 : {
3744 0 : str += "\n " + bound.to_string ();
3745 : }
3746 :
3747 0 : return str;
3748 : }
3749 :
3750 : std::string
3751 0 : TypeBoundWhereClauseItem::to_string () const
3752 : {
3753 0 : std::string str ("For lifetimes: ");
3754 :
3755 0 : if (!has_for_lifetimes ())
3756 : {
3757 0 : str += "none";
3758 : }
3759 : else
3760 : {
3761 0 : for (const auto &for_lifetime : for_lifetimes)
3762 : {
3763 0 : str += "\n " + for_lifetime.to_string ();
3764 : }
3765 : }
3766 :
3767 0 : str += "\nType: " + bound_type->to_string ();
3768 :
3769 0 : str += "\nType param bounds bounds: ";
3770 :
3771 0 : for (const auto &bound : type_param_bounds)
3772 : {
3773 : // debug null pointer check
3774 0 : if (bound == nullptr)
3775 : {
3776 0 : return "nullptr_POINTER_MARK - type param bounds";
3777 : }
3778 :
3779 0 : str += "\n " + bound->to_string ();
3780 : }
3781 :
3782 0 : return str;
3783 0 : }
3784 :
3785 : std::string
3786 0 : ArrayElemsValues::to_string () const
3787 : {
3788 0 : std::string str;
3789 :
3790 0 : for (const auto &expr : values)
3791 : {
3792 : // DEBUG: null pointer check
3793 0 : if (expr == nullptr)
3794 : {
3795 0 : rust_debug ("something really terrible has gone wrong - null pointer "
3796 : "expr in array elems values.");
3797 0 : return "nullptr_POINTER_MARK";
3798 : }
3799 :
3800 0 : str += "\n " + expr->to_string ();
3801 : }
3802 :
3803 0 : return str;
3804 0 : }
3805 :
3806 : std::string
3807 0 : MaybeNamedParam::to_string () const
3808 : {
3809 0 : std::string str;
3810 :
3811 0 : switch (param_kind)
3812 : {
3813 : case UNNAMED:
3814 : break;
3815 0 : case IDENTIFIER:
3816 0 : str = name.as_string () + " : ";
3817 0 : break;
3818 0 : case WILDCARD:
3819 0 : str = "_ : ";
3820 0 : break;
3821 0 : default:
3822 0 : return "ERROR_MARK_STRING - maybe named param unrecognised param kind";
3823 : }
3824 :
3825 0 : str += param_type->to_string ();
3826 :
3827 0 : return str;
3828 0 : }
3829 :
3830 : std::string
3831 0 : enum_to_str (MaybeNamedParam::ParamKind pk)
3832 : {
3833 0 : switch (pk)
3834 : {
3835 0 : case MaybeNamedParam::ParamKind::UNNAMED:
3836 0 : return "UNNAMED";
3837 0 : case MaybeNamedParam::ParamKind::IDENTIFIER:
3838 0 : return "IDENTIFIER";
3839 0 : case MaybeNamedParam::ParamKind::WILDCARD:
3840 0 : return "WILDCARD";
3841 : }
3842 0 : gcc_unreachable ();
3843 : }
3844 :
3845 : std::string
3846 0 : enum_to_str (UseTreeRebind::NewBindType nbt)
3847 : {
3848 0 : switch (nbt)
3849 : {
3850 0 : case UseTreeRebind::NewBindType::NONE:
3851 0 : return "NONE";
3852 0 : case UseTreeRebind::NewBindType::IDENTIFIER:
3853 0 : return "IDENTIFIER";
3854 0 : case UseTreeRebind::NewBindType::WILDCARD:
3855 0 : return "WILDCARD";
3856 : }
3857 0 : gcc_unreachable ();
3858 : }
3859 :
3860 : /* Override that calls the function recursively on all items contained within
3861 : * the module. */
3862 : void
3863 0 : Module::add_crate_name (std::vector<std::string> &names) const
3864 : {
3865 : /* TODO: test whether module has been 'cfg'-ed out to determine whether to
3866 : * exclude it from search */
3867 :
3868 0 : for (const auto &item : items)
3869 0 : item->add_crate_name (names);
3870 0 : }
3871 :
3872 : /* All accept_vis method below */
3873 :
3874 : void
3875 5873 : Lifetime::accept_vis (HIRFullVisitor &vis)
3876 : {
3877 5873 : vis.visit (*this);
3878 5873 : }
3879 :
3880 : void
3881 160 : LifetimeParam::accept_vis (HIRFullVisitor &vis)
3882 : {
3883 160 : vis.visit (*this);
3884 160 : }
3885 :
3886 : void
3887 173066 : PathInExpression::accept_vis (HIRFullVisitor &vis)
3888 : {
3889 173066 : vis.visit (*this);
3890 173066 : }
3891 : void
3892 135399 : PathInExpression::accept_vis (HIRExpressionVisitor &vis)
3893 : {
3894 135399 : vis.visit (*this);
3895 135399 : }
3896 :
3897 : void
3898 45971 : TypePathSegment::accept_vis (HIRFullVisitor &vis)
3899 : {
3900 45971 : vis.visit (*this);
3901 45971 : }
3902 :
3903 : void
3904 2335 : TypePathSegmentGeneric::accept_vis (HIRFullVisitor &vis)
3905 : {
3906 2335 : vis.visit (*this);
3907 2335 : }
3908 :
3909 : void
3910 27 : TypePathSegmentFunction::accept_vis (HIRFullVisitor &vis)
3911 : {
3912 27 : vis.visit (*this);
3913 27 : }
3914 :
3915 : void
3916 49910 : TypePath::accept_vis (HIRFullVisitor &vis)
3917 : {
3918 49910 : vis.visit (*this);
3919 49910 : }
3920 :
3921 : void
3922 195 : QualifiedPathInExpression::accept_vis (HIRFullVisitor &vis)
3923 : {
3924 195 : vis.visit (*this);
3925 195 : }
3926 : void
3927 336 : QualifiedPathInExpression::accept_vis (HIRExpressionVisitor &vis)
3928 : {
3929 336 : vis.visit (*this);
3930 336 : }
3931 :
3932 : void
3933 199 : QualifiedPathInType::accept_vis (HIRFullVisitor &vis)
3934 : {
3935 199 : vis.visit (*this);
3936 199 : }
3937 :
3938 : void
3939 89369 : LiteralExpr::accept_vis (HIRFullVisitor &vis)
3940 : {
3941 89369 : vis.visit (*this);
3942 89369 : }
3943 :
3944 : void
3945 62397 : LiteralExpr::accept_vis (HIRExpressionVisitor &vis)
3946 : {
3947 62397 : vis.visit (*this);
3948 62397 : }
3949 :
3950 : void
3951 8945 : BorrowExpr::accept_vis (HIRFullVisitor &vis)
3952 : {
3953 8945 : vis.visit (*this);
3954 8945 : }
3955 :
3956 : void
3957 80 : InlineAsm::accept_vis (HIRExpressionVisitor &vis)
3958 : {
3959 80 : vis.visit (*this);
3960 80 : }
3961 :
3962 : void
3963 131 : InlineAsm::accept_vis (HIRFullVisitor &vis)
3964 : {
3965 131 : vis.visit (*this);
3966 131 : }
3967 :
3968 : void
3969 12 : LlvmInlineAsm::accept_vis (HIRFullVisitor &vis)
3970 : {
3971 12 : vis.visit (*this);
3972 12 : }
3973 : void
3974 6 : LlvmInlineAsm::accept_vis (HIRExpressionVisitor &vis)
3975 : {
3976 6 : vis.visit (*this);
3977 6 : }
3978 :
3979 : void
3980 5573 : BorrowExpr::accept_vis (HIRExpressionVisitor &vis)
3981 : {
3982 5573 : vis.visit (*this);
3983 5573 : }
3984 :
3985 : void
3986 15853 : DereferenceExpr::accept_vis (HIRFullVisitor &vis)
3987 : {
3988 15853 : vis.visit (*this);
3989 15853 : }
3990 :
3991 : void
3992 11438 : DereferenceExpr::accept_vis (HIRExpressionVisitor &vis)
3993 : {
3994 11438 : vis.visit (*this);
3995 11438 : }
3996 :
3997 : void
3998 0 : ErrorPropagationExpr::accept_vis (HIRFullVisitor &vis)
3999 : {
4000 0 : vis.visit (*this);
4001 0 : }
4002 :
4003 : void
4004 0 : ErrorPropagationExpr::accept_vis (HIRExpressionVisitor &vis)
4005 : {
4006 0 : vis.visit (*this);
4007 0 : }
4008 :
4009 : void
4010 2776 : NegationExpr::accept_vis (HIRFullVisitor &vis)
4011 : {
4012 2776 : vis.visit (*this);
4013 2776 : }
4014 :
4015 : void
4016 1982 : NegationExpr::accept_vis (HIRExpressionVisitor &vis)
4017 : {
4018 1982 : vis.visit (*this);
4019 1982 : }
4020 :
4021 : void
4022 14897 : ArithmeticOrLogicalExpr::accept_vis (HIRFullVisitor &vis)
4023 : {
4024 14897 : vis.visit (*this);
4025 14897 : }
4026 :
4027 : void
4028 9964 : ArithmeticOrLogicalExpr::accept_vis (HIRExpressionVisitor &vis)
4029 : {
4030 9964 : vis.visit (*this);
4031 9964 : }
4032 :
4033 : void
4034 17061 : ComparisonExpr::accept_vis (HIRFullVisitor &vis)
4035 : {
4036 17061 : vis.visit (*this);
4037 17061 : }
4038 :
4039 : void
4040 10215 : ComparisonExpr::accept_vis (HIRExpressionVisitor &vis)
4041 : {
4042 10215 : vis.visit (*this);
4043 10215 : }
4044 :
4045 : void
4046 2480 : LazyBooleanExpr::accept_vis (HIRFullVisitor &vis)
4047 : {
4048 2480 : vis.visit (*this);
4049 2480 : }
4050 :
4051 : void
4052 1155 : LazyBooleanExpr::accept_vis (HIRExpressionVisitor &vis)
4053 : {
4054 1155 : vis.visit (*this);
4055 1155 : }
4056 :
4057 : void
4058 27806 : TypeCastExpr::accept_vis (HIRFullVisitor &vis)
4059 : {
4060 27806 : vis.visit (*this);
4061 27806 : }
4062 :
4063 : void
4064 14468 : TypeCastExpr::accept_vis (HIRExpressionVisitor &vis)
4065 : {
4066 14468 : vis.visit (*this);
4067 14468 : }
4068 :
4069 : void
4070 12225 : AssignmentExpr::accept_vis (HIRFullVisitor &vis)
4071 : {
4072 12225 : vis.visit (*this);
4073 12225 : }
4074 :
4075 : void
4076 7295 : AssignmentExpr::accept_vis (HIRExpressionVisitor &vis)
4077 : {
4078 7295 : vis.visit (*this);
4079 7295 : }
4080 :
4081 : void
4082 3216 : CompoundAssignmentExpr::accept_vis (HIRFullVisitor &vis)
4083 : {
4084 3216 : vis.visit (*this);
4085 3216 : }
4086 :
4087 : void
4088 2021 : CompoundAssignmentExpr::accept_vis (HIRExpressionVisitor &vis)
4089 : {
4090 2021 : vis.visit (*this);
4091 2021 : }
4092 :
4093 : void
4094 1484 : GroupedExpr::accept_vis (HIRFullVisitor &vis)
4095 : {
4096 1484 : vis.visit (*this);
4097 1484 : }
4098 :
4099 : void
4100 956 : GroupedExpr::accept_vis (HIRExpressionVisitor &vis)
4101 : {
4102 956 : vis.visit (*this);
4103 956 : }
4104 :
4105 : void
4106 1185 : ArrayElemsValues::accept_vis (HIRFullVisitor &vis)
4107 : {
4108 1185 : vis.visit (*this);
4109 1185 : }
4110 :
4111 : void
4112 464 : ArrayElemsCopied::accept_vis (HIRFullVisitor &vis)
4113 : {
4114 464 : vis.visit (*this);
4115 464 : }
4116 :
4117 : void
4118 1649 : ArrayExpr::accept_vis (HIRFullVisitor &vis)
4119 : {
4120 1649 : vis.visit (*this);
4121 1649 : }
4122 :
4123 : void
4124 1368 : ArrayIndexExpr::accept_vis (HIRFullVisitor &vis)
4125 : {
4126 1368 : vis.visit (*this);
4127 1368 : }
4128 :
4129 : void
4130 2452 : TupleExpr::accept_vis (HIRFullVisitor &vis)
4131 : {
4132 2452 : vis.visit (*this);
4133 2452 : }
4134 :
4135 : void
4136 3760 : TupleIndexExpr::accept_vis (HIRFullVisitor &vis)
4137 : {
4138 3760 : vis.visit (*this);
4139 3760 : }
4140 :
4141 : void
4142 327 : StructExprStruct::accept_vis (HIRFullVisitor &vis)
4143 : {
4144 327 : vis.visit (*this);
4145 327 : }
4146 :
4147 : void
4148 168 : StructExprFieldIndexValue::accept_vis (HIRFullVisitor &vis)
4149 : {
4150 168 : vis.visit (*this);
4151 168 : }
4152 :
4153 : void
4154 5513 : StructExprStructFields::accept_vis (HIRFullVisitor &vis)
4155 : {
4156 5513 : vis.visit (*this);
4157 5513 : }
4158 :
4159 : void
4160 0 : StructExprStructBase::accept_vis (HIRFullVisitor &vis)
4161 : {
4162 0 : vis.visit (*this);
4163 0 : }
4164 :
4165 : void
4166 0 : StructExprStructBase::accept_vis (HIRExpressionVisitor &vis)
4167 : {
4168 0 : vis.visit (*this);
4169 0 : }
4170 :
4171 : void
4172 59866 : CallExpr::accept_vis (HIRFullVisitor &vis)
4173 : {
4174 59866 : vis.visit (*this);
4175 59866 : }
4176 :
4177 : void
4178 11930 : MethodCallExpr::accept_vis (HIRFullVisitor &vis)
4179 : {
4180 11930 : vis.visit (*this);
4181 11930 : }
4182 :
4183 : void
4184 23858 : FieldAccessExpr::accept_vis (HIRFullVisitor &vis)
4185 : {
4186 23858 : vis.visit (*this);
4187 23858 : }
4188 :
4189 : void
4190 232 : ClosureExpr::accept_vis (HIRFullVisitor &vis)
4191 : {
4192 232 : vis.visit (*this);
4193 232 : }
4194 :
4195 : void
4196 112138 : BlockExpr::accept_vis (HIRFullVisitor &vis)
4197 : {
4198 112138 : vis.visit (*this);
4199 112138 : }
4200 :
4201 : void
4202 888 : AnonConst::accept_vis (HIRFullVisitor &vis)
4203 : {
4204 888 : vis.visit (*this);
4205 888 : }
4206 :
4207 : void
4208 59 : ConstBlock::accept_vis (HIRFullVisitor &vis)
4209 : {
4210 59 : vis.visit (*this);
4211 59 : }
4212 :
4213 : void
4214 63 : ContinueExpr::accept_vis (HIRFullVisitor &vis)
4215 : {
4216 63 : vis.visit (*this);
4217 63 : }
4218 :
4219 : void
4220 395 : BreakExpr::accept_vis (HIRFullVisitor &vis)
4221 : {
4222 395 : vis.visit (*this);
4223 395 : }
4224 :
4225 : void
4226 257 : RangeFromToExpr::accept_vis (HIRFullVisitor &vis)
4227 : {
4228 257 : vis.visit (*this);
4229 257 : }
4230 :
4231 : void
4232 21 : RangeFromExpr::accept_vis (HIRFullVisitor &vis)
4233 : {
4234 21 : vis.visit (*this);
4235 21 : }
4236 :
4237 : void
4238 21 : RangeToExpr::accept_vis (HIRFullVisitor &vis)
4239 : {
4240 21 : vis.visit (*this);
4241 21 : }
4242 :
4243 : void
4244 0 : RangeFullExpr::accept_vis (HIRFullVisitor &vis)
4245 : {
4246 0 : vis.visit (*this);
4247 0 : }
4248 :
4249 : void
4250 21 : RangeFromToInclExpr::accept_vis (HIRFullVisitor &vis)
4251 : {
4252 21 : vis.visit (*this);
4253 21 : }
4254 :
4255 : void
4256 0 : RangeToInclExpr::accept_vis (HIRFullVisitor &vis)
4257 : {
4258 0 : vis.visit (*this);
4259 0 : }
4260 :
4261 : void
4262 6 : BoxExpr::accept_vis (HIRFullVisitor &vis)
4263 : {
4264 6 : vis.visit (*this);
4265 6 : }
4266 :
4267 : void
4268 3093 : ReturnExpr::accept_vis (HIRFullVisitor &vis)
4269 : {
4270 3093 : vis.visit (*this);
4271 3093 : }
4272 :
4273 : void
4274 19301 : UnsafeBlockExpr::accept_vis (HIRFullVisitor &vis)
4275 : {
4276 19301 : vis.visit (*this);
4277 19301 : }
4278 :
4279 : void
4280 602 : LoopExpr::accept_vis (HIRFullVisitor &vis)
4281 : {
4282 602 : vis.visit (*this);
4283 602 : }
4284 :
4285 : void
4286 423 : WhileLoopExpr::accept_vis (HIRFullVisitor &vis)
4287 : {
4288 423 : vis.visit (*this);
4289 423 : }
4290 :
4291 : void
4292 0 : WhileLetLoopExpr::accept_vis (HIRFullVisitor &vis)
4293 : {
4294 0 : vis.visit (*this);
4295 0 : }
4296 :
4297 : void
4298 7439 : IfExpr::accept_vis (HIRFullVisitor &vis)
4299 : {
4300 7439 : vis.visit (*this);
4301 7439 : }
4302 :
4303 : void
4304 5795 : IfExprConseqElse::accept_vis (HIRFullVisitor &vis)
4305 : {
4306 5795 : vis.visit (*this);
4307 5795 : }
4308 :
4309 : void
4310 5532 : MatchExpr::accept_vis (HIRFullVisitor &vis)
4311 : {
4312 5532 : vis.visit (*this);
4313 5532 : }
4314 :
4315 : void
4316 0 : AwaitExpr::accept_vis (HIRFullVisitor &vis)
4317 : {
4318 0 : vis.visit (*this);
4319 0 : }
4320 :
4321 : void
4322 0 : AsyncBlockExpr::accept_vis (HIRFullVisitor &vis)
4323 : {
4324 0 : vis.visit (*this);
4325 0 : }
4326 :
4327 : void
4328 8133 : TypeParam::accept_vis (HIRFullVisitor &vis)
4329 : {
4330 8133 : vis.visit (*this);
4331 8133 : }
4332 :
4333 : void
4334 0 : LifetimeWhereClauseItem::accept_vis (HIRFullVisitor &vis)
4335 : {
4336 0 : vis.visit (*this);
4337 0 : }
4338 :
4339 : void
4340 139 : TypeBoundWhereClauseItem::accept_vis (HIRFullVisitor &vis)
4341 : {
4342 139 : vis.visit (*this);
4343 139 : }
4344 :
4345 : void
4346 7406 : Module::accept_vis (HIRFullVisitor &vis)
4347 : {
4348 7406 : vis.visit (*this);
4349 7406 : }
4350 :
4351 : void
4352 2384 : Module::accept_vis (HIRStmtVisitor &vis)
4353 : {
4354 2384 : vis.visit (*this);
4355 2384 : }
4356 :
4357 : void
4358 4862 : Module::accept_vis (HIRVisItemVisitor &vis)
4359 : {
4360 4862 : vis.visit (*this);
4361 4862 : }
4362 :
4363 : void
4364 0 : ExternCrate::accept_vis (HIRFullVisitor &vis)
4365 : {
4366 0 : vis.visit (*this);
4367 0 : }
4368 :
4369 : void
4370 0 : UseTreeGlob::accept_vis (HIRFullVisitor &vis)
4371 : {
4372 0 : vis.visit (*this);
4373 0 : }
4374 :
4375 : void
4376 0 : UseTreeList::accept_vis (HIRFullVisitor &vis)
4377 : {
4378 0 : vis.visit (*this);
4379 0 : }
4380 :
4381 : void
4382 0 : UseTreeRebind::accept_vis (HIRFullVisitor &vis)
4383 : {
4384 0 : vis.visit (*this);
4385 0 : }
4386 :
4387 : void
4388 0 : UseDeclaration::accept_vis (HIRFullVisitor &vis)
4389 : {
4390 0 : vis.visit (*this);
4391 0 : }
4392 :
4393 : void
4394 82974 : Function::accept_vis (HIRFullVisitor &vis)
4395 : {
4396 82974 : vis.visit (*this);
4397 82974 : }
4398 :
4399 : void
4400 6244 : TypeAlias::accept_vis (HIRFullVisitor &vis)
4401 : {
4402 6244 : vis.visit (*this);
4403 6244 : }
4404 :
4405 : void
4406 11299 : StructStruct::accept_vis (HIRFullVisitor &vis)
4407 : {
4408 11299 : vis.visit (*this);
4409 11299 : }
4410 :
4411 : void
4412 7362 : TupleStruct::accept_vis (HIRFullVisitor &vis)
4413 : {
4414 7362 : vis.visit (*this);
4415 7362 : }
4416 :
4417 : void
4418 1572 : EnumItem::accept_vis (HIRFullVisitor &vis)
4419 : {
4420 1572 : vis.visit (*this);
4421 1572 : }
4422 :
4423 : void
4424 781 : EnumItemTuple::accept_vis (HIRFullVisitor &vis)
4425 : {
4426 781 : vis.visit (*this);
4427 781 : }
4428 :
4429 : void
4430 158 : EnumItemStruct::accept_vis (HIRFullVisitor &vis)
4431 : {
4432 158 : vis.visit (*this);
4433 158 : }
4434 :
4435 : void
4436 547 : EnumItemDiscriminant::accept_vis (HIRFullVisitor &vis)
4437 : {
4438 547 : vis.visit (*this);
4439 547 : }
4440 :
4441 : void
4442 3435 : Enum::accept_vis (HIRFullVisitor &vis)
4443 : {
4444 3435 : vis.visit (*this);
4445 3435 : }
4446 :
4447 : void
4448 732 : Union::accept_vis (HIRFullVisitor &vis)
4449 : {
4450 732 : vis.visit (*this);
4451 732 : }
4452 :
4453 : void
4454 3744 : ConstantItem::accept_vis (HIRFullVisitor &vis)
4455 : {
4456 3744 : vis.visit (*this);
4457 3744 : }
4458 :
4459 : void
4460 350 : StaticItem::accept_vis (HIRFullVisitor &vis)
4461 : {
4462 350 : vis.visit (*this);
4463 350 : }
4464 :
4465 : void
4466 10034 : TraitItemFunc::accept_vis (HIRFullVisitor &vis)
4467 : {
4468 10034 : vis.visit (*this);
4469 10034 : }
4470 :
4471 : void
4472 123 : TraitItemConst::accept_vis (HIRFullVisitor &vis)
4473 : {
4474 123 : vis.visit (*this);
4475 123 : }
4476 :
4477 : void
4478 2843 : TraitItemType::accept_vis (HIRFullVisitor &vis)
4479 : {
4480 2843 : vis.visit (*this);
4481 2843 : }
4482 :
4483 : void
4484 22504 : Trait::accept_vis (HIRFullVisitor &vis)
4485 : {
4486 22504 : vis.visit (*this);
4487 22504 : }
4488 :
4489 : void
4490 31648 : ImplBlock::accept_vis (HIRFullVisitor &vis)
4491 : {
4492 31648 : vis.visit (*this);
4493 31648 : }
4494 :
4495 : void
4496 3 : ExternalStaticItem::accept_vis (HIRFullVisitor &vis)
4497 : {
4498 3 : vis.visit (*this);
4499 3 : }
4500 :
4501 : void
4502 10035 : ExternalFunctionItem::accept_vis (HIRFullVisitor &vis)
4503 : {
4504 10035 : vis.visit (*this);
4505 10035 : }
4506 :
4507 : void
4508 0 : ExternalTypeItem::accept_vis (HIRFullVisitor &vis)
4509 : {
4510 0 : vis.visit (*this);
4511 0 : }
4512 :
4513 : void
4514 9783 : ExternBlock::accept_vis (HIRFullVisitor &vis)
4515 : {
4516 9783 : vis.visit (*this);
4517 9783 : }
4518 :
4519 : void
4520 405 : LiteralPattern::accept_vis (HIRFullVisitor &vis)
4521 : {
4522 405 : vis.visit (*this);
4523 405 : }
4524 :
4525 : void
4526 8361 : IdentifierPattern::accept_vis (HIRFullVisitor &vis)
4527 : {
4528 8361 : vis.visit (*this);
4529 8361 : }
4530 :
4531 : void
4532 749 : WildcardPattern::accept_vis (HIRFullVisitor &vis)
4533 : {
4534 749 : vis.visit (*this);
4535 749 : }
4536 :
4537 : void
4538 77 : RangePatternBoundLiteral::accept_vis (HIRFullVisitor &vis)
4539 : {
4540 77 : vis.visit (*this);
4541 77 : }
4542 :
4543 : void
4544 21 : RangePatternBoundPath::accept_vis (HIRFullVisitor &vis)
4545 : {
4546 21 : vis.visit (*this);
4547 21 : }
4548 :
4549 : void
4550 0 : RangePatternBoundQualPath::accept_vis (HIRFullVisitor &vis)
4551 : {
4552 0 : vis.visit (*this);
4553 0 : }
4554 :
4555 : void
4556 49 : RangePattern::accept_vis (HIRFullVisitor &vis)
4557 : {
4558 49 : vis.visit (*this);
4559 49 : }
4560 :
4561 : void
4562 173 : ReferencePattern::accept_vis (HIRFullVisitor &vis)
4563 : {
4564 173 : vis.visit (*this);
4565 173 : }
4566 :
4567 : void
4568 18 : StructPatternFieldTuplePat::accept_vis (HIRFullVisitor &vis)
4569 : {
4570 18 : vis.visit (*this);
4571 18 : }
4572 :
4573 : void
4574 120 : StructPatternFieldIdentPat::accept_vis (HIRFullVisitor &vis)
4575 : {
4576 120 : vis.visit (*this);
4577 120 : }
4578 :
4579 : void
4580 95 : StructPatternFieldIdent::accept_vis (HIRFullVisitor &vis)
4581 : {
4582 95 : vis.visit (*this);
4583 95 : }
4584 :
4585 : void
4586 137 : StructPattern::accept_vis (HIRFullVisitor &vis)
4587 : {
4588 137 : vis.visit (*this);
4589 137 : }
4590 :
4591 : void
4592 880 : TupleStructItemsNoRest::accept_vis (HIRFullVisitor &vis)
4593 : {
4594 880 : vis.visit (*this);
4595 880 : }
4596 :
4597 : void
4598 36 : TupleStructItemsHasRest::accept_vis (HIRFullVisitor &vis)
4599 : {
4600 36 : vis.visit (*this);
4601 36 : }
4602 :
4603 : void
4604 916 : TupleStructPattern::accept_vis (HIRFullVisitor &vis)
4605 : {
4606 916 : vis.visit (*this);
4607 916 : }
4608 :
4609 : void
4610 100 : TuplePatternItemsNoRest::accept_vis (HIRFullVisitor &vis)
4611 : {
4612 100 : vis.visit (*this);
4613 100 : }
4614 :
4615 : void
4616 23 : TuplePatternItemsHasRest::accept_vis (HIRFullVisitor &vis)
4617 : {
4618 23 : vis.visit (*this);
4619 23 : }
4620 :
4621 : void
4622 123 : TuplePattern::accept_vis (HIRFullVisitor &vis)
4623 : {
4624 123 : vis.visit (*this);
4625 123 : }
4626 :
4627 : void
4628 31 : SlicePatternItemsNoRest::accept_vis (HIRFullVisitor &vis)
4629 : {
4630 31 : vis.visit (*this);
4631 31 : }
4632 :
4633 : void
4634 44 : SlicePatternItemsHasRest::accept_vis (HIRFullVisitor &vis)
4635 : {
4636 44 : vis.visit (*this);
4637 44 : }
4638 :
4639 : void
4640 75 : SlicePattern::accept_vis (HIRFullVisitor &vis)
4641 : {
4642 75 : vis.visit (*this);
4643 75 : }
4644 :
4645 : void
4646 145 : AltPattern::accept_vis (HIRFullVisitor &vis)
4647 : {
4648 145 : vis.visit (*this);
4649 145 : }
4650 :
4651 : void
4652 226 : EmptyStmt::accept_vis (HIRFullVisitor &vis)
4653 : {
4654 226 : vis.visit (*this);
4655 226 : }
4656 :
4657 : void
4658 66080 : LetStmt::accept_vis (HIRFullVisitor &vis)
4659 : {
4660 66080 : vis.visit (*this);
4661 66080 : }
4662 :
4663 : void
4664 56655 : ExprStmt::accept_vis (HIRFullVisitor &vis)
4665 : {
4666 56655 : vis.visit (*this);
4667 56655 : }
4668 :
4669 : void
4670 1681 : TraitBound::accept_vis (HIRFullVisitor &vis)
4671 : {
4672 1681 : vis.visit (*this);
4673 1681 : }
4674 :
4675 : void
4676 28 : ImplTraitType::accept_vis (HIRFullVisitor &vis)
4677 : {
4678 28 : vis.visit (*this);
4679 28 : }
4680 :
4681 : void
4682 91 : TraitObjectType::accept_vis (HIRFullVisitor &vis)
4683 : {
4684 91 : vis.visit (*this);
4685 91 : }
4686 :
4687 : void
4688 5 : ParenthesisedType::accept_vis (HIRFullVisitor &vis)
4689 : {
4690 5 : vis.visit (*this);
4691 5 : }
4692 :
4693 : void
4694 340 : TupleType::accept_vis (HIRFullVisitor &vis)
4695 : {
4696 340 : vis.visit (*this);
4697 340 : }
4698 :
4699 : void
4700 185 : NeverType::accept_vis (HIRFullVisitor &vis)
4701 : {
4702 185 : vis.visit (*this);
4703 185 : }
4704 :
4705 : void
4706 4362 : RawPointerType::accept_vis (HIRFullVisitor &vis)
4707 : {
4708 4362 : vis.visit (*this);
4709 4362 : }
4710 :
4711 : void
4712 5907 : ReferenceType::accept_vis (HIRFullVisitor &vis)
4713 : {
4714 5907 : vis.visit (*this);
4715 5907 : }
4716 :
4717 : void
4718 836 : ArrayType::accept_vis (HIRFullVisitor &vis)
4719 : {
4720 836 : vis.visit (*this);
4721 836 : }
4722 :
4723 : void
4724 849 : SliceType::accept_vis (HIRFullVisitor &vis)
4725 : {
4726 849 : vis.visit (*this);
4727 849 : }
4728 :
4729 : void
4730 14 : InferredType::accept_vis (HIRFullVisitor &vis)
4731 : {
4732 14 : vis.visit (*this);
4733 14 : }
4734 :
4735 : void
4736 41 : BareFunctionType::accept_vis (HIRFullVisitor &vis)
4737 : {
4738 41 : vis.visit (*this);
4739 41 : }
4740 :
4741 : void
4742 188 : NeverType::accept_vis (HIRTypeVisitor &vis)
4743 : {
4744 188 : vis.visit (*this);
4745 188 : }
4746 :
4747 : void
4748 5 : ParenthesisedType::accept_vis (HIRTypeVisitor &vis)
4749 : {
4750 5 : vis.visit (*this);
4751 5 : }
4752 :
4753 : void
4754 136 : EmptyStmt::accept_vis (HIRStmtVisitor &vis)
4755 : {
4756 136 : vis.visit (*this);
4757 136 : }
4758 :
4759 : void
4760 2798 : WildcardPattern::accept_vis (HIRPatternVisitor &vis)
4761 : {
4762 2798 : vis.visit (*this);
4763 2798 : }
4764 :
4765 : void
4766 739 : TraitItemType::accept_vis (HIRTraitItemVisitor &vis)
4767 : {
4768 739 : vis.visit (*this);
4769 739 : }
4770 :
4771 : void
4772 39 : TraitItemConst::accept_vis (HIRTraitItemVisitor &vis)
4773 : {
4774 39 : vis.visit (*this);
4775 39 : }
4776 :
4777 : void
4778 2836 : TraitItemFunc::accept_vis (HIRTraitItemVisitor &vis)
4779 : {
4780 2836 : vis.visit (*this);
4781 2836 : }
4782 :
4783 : void
4784 5063 : ExternalFunctionItem::accept_vis (HIRExternalItemVisitor &vis)
4785 : {
4786 5063 : vis.visit (*this);
4787 5063 : }
4788 :
4789 : void
4790 0 : ExternalTypeItem::accept_vis (HIRExternalItemVisitor &vis)
4791 : {
4792 0 : vis.visit (*this);
4793 0 : }
4794 :
4795 : void
4796 1 : ExternalStaticItem::accept_vis (HIRExternalItemVisitor &vis)
4797 : {
4798 1 : vis.visit (*this);
4799 1 : }
4800 :
4801 : void
4802 0 : EnumItemDiscriminant::accept_vis (HIRStmtVisitor &vis)
4803 : {
4804 0 : vis.visit (*this);
4805 0 : }
4806 :
4807 : void
4808 0 : EnumItemStruct::accept_vis (HIRStmtVisitor &vis)
4809 : {
4810 0 : vis.visit (*this);
4811 0 : }
4812 :
4813 : void
4814 0 : EnumItemTuple::accept_vis (HIRStmtVisitor &vis)
4815 : {
4816 0 : vis.visit (*this);
4817 0 : }
4818 :
4819 : void
4820 0 : EnumItem::accept_vis (HIRStmtVisitor &vis)
4821 : {
4822 0 : vis.visit (*this);
4823 0 : }
4824 :
4825 : void
4826 3990 : StructExprStructFields::accept_vis (HIRExpressionVisitor &vis)
4827 : {
4828 3990 : vis.visit (*this);
4829 3990 : }
4830 :
4831 : void
4832 42 : StructExprFieldIndexValue::accept_vis (HIRExpressionVisitor &vis)
4833 : {
4834 42 : vis.visit (*this);
4835 42 : }
4836 :
4837 : void
4838 10886 : StructExprFieldIdentifierValue::accept_vis (HIRFullVisitor &vis)
4839 : {
4840 10886 : vis.visit (*this);
4841 10886 : }
4842 :
4843 : void
4844 2645 : StructExprFieldIdentifierValue::accept_vis (HIRExpressionVisitor &vis)
4845 : {
4846 2645 : vis.visit (*this);
4847 2645 : }
4848 :
4849 : void
4850 845 : StructExprFieldIdentifier::accept_vis (HIRFullVisitor &vis)
4851 : {
4852 845 : vis.visit (*this);
4853 845 : }
4854 :
4855 : void
4856 215 : StructExprFieldIdentifier::accept_vis (HIRExpressionVisitor &vis)
4857 : {
4858 215 : vis.visit (*this);
4859 215 : }
4860 :
4861 : void
4862 239 : StructExprStruct::accept_vis (HIRExpressionVisitor &vis)
4863 : {
4864 239 : vis.visit (*this);
4865 239 : }
4866 :
4867 : void
4868 399 : TupleType::accept_vis (HIRTypeVisitor &vis)
4869 : {
4870 399 : vis.visit (*this);
4871 399 : }
4872 :
4873 : void
4874 877 : SliceType::accept_vis (HIRTypeVisitor &vis)
4875 : {
4876 877 : vis.visit (*this);
4877 877 : }
4878 :
4879 : void
4880 674 : ArrayType::accept_vis (HIRTypeVisitor &vis)
4881 : {
4882 674 : vis.visit (*this);
4883 674 : }
4884 :
4885 : void
4886 63 : BareFunctionType::accept_vis (HIRTypeVisitor &vis)
4887 : {
4888 63 : vis.visit (*this);
4889 63 : }
4890 :
4891 : void
4892 215 : TraitObjectType::accept_vis (HIRTypeVisitor &vis)
4893 : {
4894 215 : vis.visit (*this);
4895 215 : }
4896 :
4897 : void
4898 6666 : RawPointerType::accept_vis (HIRTypeVisitor &vis)
4899 : {
4900 6666 : vis.visit (*this);
4901 6666 : }
4902 :
4903 : void
4904 4420 : ReferenceType::accept_vis (HIRTypeVisitor &vis)
4905 : {
4906 4420 : vis.visit (*this);
4907 4420 : }
4908 :
4909 : void
4910 29 : ImplTraitType::accept_vis (HIRTypeVisitor &vis)
4911 : {
4912 29 : vis.visit (*this);
4913 29 : }
4914 :
4915 : void
4916 211 : InferredType::accept_vis (HIRTypeVisitor &vis)
4917 : {
4918 211 : vis.visit (*this);
4919 211 : }
4920 :
4921 : void
4922 37096 : LetStmt::accept_vis (HIRStmtVisitor &vis)
4923 : {
4924 37096 : vis.visit (*this);
4925 37096 : }
4926 :
4927 : void
4928 2487 : TupleStructPattern::accept_vis (HIRPatternVisitor &vis)
4929 : {
4930 2487 : vis.visit (*this);
4931 2487 : }
4932 :
4933 : void
4934 74586 : IdentifierPattern::accept_vis (HIRPatternVisitor &vis)
4935 : {
4936 74586 : vis.visit (*this);
4937 74586 : }
4938 :
4939 : void
4940 565 : ReferencePattern::accept_vis (HIRPatternVisitor &vis)
4941 : {
4942 565 : vis.visit (*this);
4943 565 : }
4944 :
4945 : void
4946 1234 : LiteralPattern::accept_vis (HIRPatternVisitor &vis)
4947 : {
4948 1234 : vis.visit (*this);
4949 1234 : }
4950 :
4951 : void
4952 443 : StructPattern::accept_vis (HIRPatternVisitor &vis)
4953 : {
4954 443 : vis.visit (*this);
4955 443 : }
4956 :
4957 : void
4958 1250 : TuplePattern::accept_vis (HIRPatternVisitor &vis)
4959 : {
4960 1250 : vis.visit (*this);
4961 1250 : }
4962 :
4963 : void
4964 226 : SlicePattern::accept_vis (HIRPatternVisitor &vis)
4965 : {
4966 226 : vis.visit (*this);
4967 226 : }
4968 :
4969 : void
4970 231 : AltPattern::accept_vis (HIRPatternVisitor &vis)
4971 : {
4972 231 : vis.visit (*this);
4973 231 : }
4974 :
4975 : void
4976 132 : RangePattern::accept_vis (HIRPatternVisitor &vis)
4977 : {
4978 132 : vis.visit (*this);
4979 132 : }
4980 :
4981 : void
4982 47687 : TypePath::accept_vis (HIRTypeVisitor &vis)
4983 : {
4984 47687 : vis.visit (*this);
4985 47687 : }
4986 :
4987 : void
4988 242 : QualifiedPathInType::accept_vis (HIRTypeVisitor &vis)
4989 : {
4990 242 : vis.visit (*this);
4991 242 : }
4992 :
4993 : void
4994 31625 : ExprStmt::accept_vis (HIRStmtVisitor &vis)
4995 : {
4996 31625 : vis.visit (*this);
4997 31625 : }
4998 :
4999 : void
5000 1603 : TupleExpr::accept_vis (HIRExpressionVisitor &vis)
5001 : {
5002 1603 : vis.visit (*this);
5003 1603 : }
5004 :
5005 : void
5006 2689 : MatchExpr::accept_vis (HIRExpressionVisitor &vis)
5007 : {
5008 2689 : vis.visit (*this);
5009 2689 : }
5010 :
5011 : void
5012 226 : BreakExpr::accept_vis (HIRExpressionVisitor &vis)
5013 : {
5014 226 : vis.visit (*this);
5015 226 : }
5016 :
5017 : void
5018 0 : AwaitExpr::accept_vis (HIRExpressionVisitor &vis)
5019 : {
5020 0 : vis.visit (*this);
5021 0 : }
5022 :
5023 : void
5024 1231 : ArrayExpr::accept_vis (HIRExpressionVisitor &vis)
5025 : {
5026 1231 : vis.visit (*this);
5027 1231 : }
5028 :
5029 : void
5030 363 : LoopExpr::accept_vis (HIRExpressionVisitor &vis)
5031 : {
5032 363 : vis.visit (*this);
5033 363 : }
5034 :
5035 : void
5036 0 : WhileLetLoopExpr::accept_vis (HIRExpressionVisitor &vis)
5037 : {
5038 0 : vis.visit (*this);
5039 0 : }
5040 :
5041 : void
5042 232 : WhileLoopExpr::accept_vis (HIRExpressionVisitor &vis)
5043 : {
5044 232 : vis.visit (*this);
5045 232 : }
5046 :
5047 : void
5048 35989 : CallExpr::accept_vis (HIRExpressionVisitor &vis)
5049 : {
5050 35989 : vis.visit (*this);
5051 35989 : }
5052 :
5053 : void
5054 21 : RangeFromToInclExpr::accept_vis (HIRExpressionVisitor &vis)
5055 : {
5056 21 : vis.visit (*this);
5057 21 : }
5058 :
5059 : void
5060 4644 : IfExprConseqElse::accept_vis (HIRExpressionVisitor &vis)
5061 : {
5062 4644 : vis.visit (*this);
5063 4644 : }
5064 :
5065 : void
5066 4895 : IfExpr::accept_vis (HIRExpressionVisitor &vis)
5067 : {
5068 4895 : vis.visit (*this);
5069 4895 : }
5070 :
5071 : void
5072 186 : ClosureExpr::accept_vis (HIRExpressionVisitor &vis)
5073 : {
5074 186 : vis.visit (*this);
5075 186 : }
5076 :
5077 : void
5078 10254 : UnsafeBlockExpr::accept_vis (HIRExpressionVisitor &vis)
5079 : {
5080 10254 : vis.visit (*this);
5081 10254 : }
5082 :
5083 : void
5084 0 : RangeToInclExpr::accept_vis (HIRExpressionVisitor &vis)
5085 : {
5086 0 : vis.visit (*this);
5087 0 : }
5088 :
5089 : void
5090 198 : RangeFromToExpr::accept_vis (HIRExpressionVisitor &vis)
5091 : {
5092 198 : vis.visit (*this);
5093 198 : }
5094 :
5095 : void
5096 16169 : FieldAccessExpr::accept_vis (HIRExpressionVisitor &vis)
5097 : {
5098 16169 : vis.visit (*this);
5099 16169 : }
5100 :
5101 : void
5102 2670 : TupleIndexExpr::accept_vis (HIRExpressionVisitor &vis)
5103 : {
5104 2670 : vis.visit (*this);
5105 2670 : }
5106 :
5107 : void
5108 8115 : MethodCallExpr::accept_vis (HIRExpressionVisitor &vis)
5109 : {
5110 8115 : vis.visit (*this);
5111 8115 : }
5112 :
5113 : void
5114 0 : AsyncBlockExpr::accept_vis (HIRExpressionVisitor &vis)
5115 : {
5116 0 : vis.visit (*this);
5117 0 : }
5118 :
5119 : void
5120 865 : ArrayIndexExpr::accept_vis (HIRExpressionVisitor &vis)
5121 : {
5122 865 : vis.visit (*this);
5123 865 : }
5124 :
5125 : void
5126 0 : RangeFullExpr::accept_vis (HIRExpressionVisitor &vis)
5127 : {
5128 0 : vis.visit (*this);
5129 0 : }
5130 :
5131 : void
5132 21 : RangeFromExpr::accept_vis (HIRExpressionVisitor &vis)
5133 : {
5134 21 : vis.visit (*this);
5135 21 : }
5136 :
5137 : void
5138 42 : ContinueExpr::accept_vis (HIRExpressionVisitor &vis)
5139 : {
5140 42 : vis.visit (*this);
5141 42 : }
5142 :
5143 : void
5144 21 : RangeToExpr::accept_vis (HIRExpressionVisitor &vis)
5145 : {
5146 21 : vis.visit (*this);
5147 21 : }
5148 :
5149 : void
5150 5 : BoxExpr::accept_vis (HIRExpressionVisitor &vis)
5151 : {
5152 5 : vis.visit (*this);
5153 5 : }
5154 :
5155 : void
5156 1429 : ReturnExpr::accept_vis (HIRExpressionVisitor &vis)
5157 : {
5158 1429 : vis.visit (*this);
5159 1429 : }
5160 :
5161 : void
5162 0 : QualifiedPathInExpression::accept_vis (HIRPatternVisitor &vis)
5163 : {
5164 0 : vis.visit (*this);
5165 0 : }
5166 :
5167 : void
5168 2601 : PathInExpression::accept_vis (HIRPatternVisitor &vis)
5169 : {
5170 2601 : vis.visit (*this);
5171 2601 : }
5172 :
5173 : void
5174 3278 : ExternBlock::accept_vis (HIRStmtVisitor &vis)
5175 : {
5176 3278 : vis.visit (*this);
5177 3278 : }
5178 :
5179 : void
5180 6485 : ExternBlock::accept_vis (HIRVisItemVisitor &vis)
5181 : {
5182 6485 : vis.visit (*this);
5183 6485 : }
5184 :
5185 : void
5186 2470 : TypeAlias::accept_vis (HIRStmtVisitor &vis)
5187 : {
5188 2470 : vis.visit (*this);
5189 2470 : }
5190 :
5191 : void
5192 1420 : TypeAlias::accept_vis (HIRVisItemVisitor &vis)
5193 : {
5194 1420 : vis.visit (*this);
5195 1420 : }
5196 :
5197 : void
5198 4348 : TypeAlias::accept_vis (HIRImplVisitor &vis)
5199 : {
5200 4348 : vis.visit (*this);
5201 4348 : }
5202 :
5203 : void
5204 49451 : BlockExpr::accept_vis (HIRExpressionVisitor &vis)
5205 : {
5206 49451 : vis.visit (*this);
5207 49451 : }
5208 :
5209 : void
5210 1354 : AnonConst::accept_vis (HIRExpressionVisitor &vis)
5211 : {
5212 1354 : vis.visit (*this);
5213 1354 : }
5214 :
5215 : void
5216 45 : ConstBlock::accept_vis (HIRExpressionVisitor &vis)
5217 : {
5218 45 : vis.visit (*this);
5219 45 : }
5220 :
5221 : void
5222 31830 : Function::accept_vis (HIRStmtVisitor &vis)
5223 : {
5224 31830 : vis.visit (*this);
5225 31830 : }
5226 :
5227 : void
5228 33041 : Function::accept_vis (HIRVisItemVisitor &vis)
5229 : {
5230 33041 : vis.visit (*this);
5231 33041 : }
5232 :
5233 : void
5234 18851 : Function::accept_vis (HIRImplVisitor &vis)
5235 : {
5236 18851 : vis.visit (*this);
5237 18851 : }
5238 :
5239 : void
5240 201 : Union::accept_vis (HIRStmtVisitor &vis)
5241 : {
5242 201 : vis.visit (*this);
5243 201 : }
5244 :
5245 : void
5246 443 : Union::accept_vis (HIRVisItemVisitor &vis)
5247 : {
5248 443 : vis.visit (*this);
5249 443 : }
5250 :
5251 : void
5252 7517 : Trait::accept_vis (HIRStmtVisitor &vis)
5253 : {
5254 7517 : vis.visit (*this);
5255 7517 : }
5256 :
5257 : void
5258 17651 : Trait::accept_vis (HIRVisItemVisitor &vis)
5259 : {
5260 17651 : vis.visit (*this);
5261 17651 : }
5262 :
5263 : void
5264 989 : Enum::accept_vis (HIRStmtVisitor &vis)
5265 : {
5266 989 : vis.visit (*this);
5267 989 : }
5268 :
5269 : void
5270 2051 : Enum::accept_vis (HIRVisItemVisitor &vis)
5271 : {
5272 2051 : vis.visit (*this);
5273 2051 : }
5274 :
5275 : void
5276 0 : UseDeclaration::accept_vis (HIRStmtVisitor &vis)
5277 : {
5278 0 : vis.visit (*this);
5279 0 : }
5280 :
5281 : void
5282 0 : UseDeclaration::accept_vis (HIRVisItemVisitor &vis)
5283 : {
5284 0 : vis.visit (*this);
5285 0 : }
5286 :
5287 : void
5288 3111 : StructStruct::accept_vis (HIRStmtVisitor &vis)
5289 : {
5290 3111 : vis.visit (*this);
5291 3111 : }
5292 :
5293 : void
5294 5886 : StructStruct::accept_vis (HIRVisItemVisitor &vis)
5295 : {
5296 5886 : vis.visit (*this);
5297 5886 : }
5298 :
5299 : void
5300 11257 : ImplBlock::accept_vis (HIRStmtVisitor &vis)
5301 : {
5302 11257 : vis.visit (*this);
5303 11257 : }
5304 :
5305 : void
5306 22576 : ImplBlock::accept_vis (HIRVisItemVisitor &vis)
5307 : {
5308 22576 : vis.visit (*this);
5309 22576 : }
5310 :
5311 : void
5312 1215 : ConstantItem::accept_vis (HIRStmtVisitor &vis)
5313 : {
5314 1215 : vis.visit (*this);
5315 1215 : }
5316 :
5317 : void
5318 1685 : ConstantItem::accept_vis (HIRVisItemVisitor &vis)
5319 : {
5320 1685 : vis.visit (*this);
5321 1685 : }
5322 :
5323 : void
5324 194 : ConstantItem::accept_vis (HIRImplVisitor &vis)
5325 : {
5326 194 : vis.visit (*this);
5327 194 : }
5328 :
5329 : void
5330 2004 : TupleStruct::accept_vis (HIRStmtVisitor &vis)
5331 : {
5332 2004 : vis.visit (*this);
5333 2004 : }
5334 :
5335 : void
5336 3410 : TupleStruct::accept_vis (HIRVisItemVisitor &vis)
5337 : {
5338 3410 : vis.visit (*this);
5339 3410 : }
5340 :
5341 : void
5342 0 : ExternCrate::accept_vis (HIRStmtVisitor &vis)
5343 : {
5344 0 : vis.visit (*this);
5345 0 : }
5346 :
5347 : void
5348 0 : ExternCrate::accept_vis (HIRVisItemVisitor &vis)
5349 : {
5350 0 : vis.visit (*this);
5351 0 : }
5352 :
5353 : void
5354 111 : StaticItem::accept_vis (HIRStmtVisitor &vis)
5355 : {
5356 111 : vis.visit (*this);
5357 111 : }
5358 :
5359 : void
5360 209 : StaticItem::accept_vis (HIRVisItemVisitor &vis)
5361 : {
5362 209 : vis.visit (*this);
5363 209 : }
5364 :
5365 : } // namespace HIR
5366 : } // namespace Rust
|