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 21 : indent_spaces (enum indent_mode mode)
43 : {
44 21 : static int indent = 0;
45 21 : std::string str = "";
46 21 : if (out == mode)
47 4 : indent--;
48 64 : for (int i = 0; i < indent; i++)
49 43 : str += " ";
50 21 : if (enter == mode)
51 4 : indent++;
52 :
53 21 : 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 4341 : Crate::Crate (std::vector<std::unique_ptr<Item>> items,
75 4341 : AST::AttrVec inner_attrs, Analysis::NodeMapping mappings)
76 4341 : : WithInnerAttrs (std::move (inner_attrs)), items (std::move (items)),
77 4341 : mappings (mappings)
78 4341 : {}
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 0 : Visibility::to_string () const
164 : {
165 0 : switch (vis_type)
166 : {
167 0 : case PRIVATE:
168 0 : return std::string ("private");
169 0 : case PUBLIC:
170 0 : return std::string ("pub");
171 0 : case 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 0 : VisItem::to_string () const
182 : {
183 : // FIXME: can't do formatting on string to make identation occur.
184 0 : std::string str = Item::to_string ();
185 :
186 0 : if (has_visibility ())
187 : {
188 0 : str = visibility.to_string () + " ";
189 : }
190 :
191 0 : return str;
192 : }
193 :
194 : // Creates a string that reflects the outer attributes stored.
195 : std::string
196 0 : Item::to_string () const
197 : {
198 0 : std::string str;
199 :
200 0 : 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 0 : 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 0 : Enum::to_string () const
683 : {
684 0 : std::string str = VisItem::to_string ();
685 0 : str += enum_name.as_string ();
686 :
687 : // generic params
688 0 : str += "\n Generic params: ";
689 0 : if (generic_params.empty ())
690 : {
691 0 : 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 0 : str += "\n Where clause: ";
711 0 : if (has_where_clause ())
712 : {
713 0 : str += where_clause.to_string ();
714 : }
715 : else
716 : {
717 0 : str += "none";
718 : }
719 :
720 : // items
721 0 : str += "\n Items: ";
722 0 : if (items.empty ())
723 : {
724 0 : str += "none";
725 : }
726 : else
727 : {
728 0 : for (const auto &item : items)
729 : {
730 : // DEBUG: null pointer check
731 0 : 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 0 : str += "\n " + item->to_string ();
740 : }
741 : }
742 :
743 0 : return str;
744 0 : }
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 2 : BlockExpr::to_string () const
1006 : {
1007 2 : std::string istr = indent_spaces (enter);
1008 2 : std::string str = istr + "BlockExpr:\n" + istr;
1009 : // get outer attributes
1010 4 : str += "{\n" + indent_spaces (stay) + Expr::to_string ();
1011 :
1012 : // inner attributes
1013 6 : str += "\n" + indent_spaces (stay) + "inner attributes: ";
1014 2 : if (inner_attrs.empty ())
1015 : {
1016 2 : 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 6 : str += "\n" + indent_spaces (stay) + "statements: ";
1030 2 : if (statements.empty ())
1031 : {
1032 0 : str += "none";
1033 : }
1034 : else
1035 : {
1036 5 : for (const auto &stmt : statements)
1037 : {
1038 : // DEBUG: null pointer check
1039 3 : 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 6 : str += "\n" + indent_spaces (stay) + stmt->to_string ();
1048 : }
1049 : }
1050 :
1051 : // final expression
1052 6 : str += "\n" + indent_spaces (stay) + "final expression: ";
1053 2 : if (expr == nullptr)
1054 : {
1055 1 : str += "none";
1056 : }
1057 : else
1058 : {
1059 2 : str += "\n" + expr->to_string ();
1060 : }
1061 :
1062 6 : str += "\n" + indent_spaces (out) + "}";
1063 2 : return str;
1064 2 : }
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 : ReturnExpr::to_string () const
1313 : {
1314 0 : std::string str ("return ");
1315 :
1316 0 : if (has_return_expr ())
1317 : {
1318 0 : str += return_expr->to_string ();
1319 : }
1320 :
1321 0 : return str;
1322 : }
1323 :
1324 : std::string
1325 0 : GroupedExpr::to_string () const
1326 : {
1327 0 : std::string str ("Grouped expr:");
1328 :
1329 : // inner attributes
1330 0 : str += "\n inner attributes: ";
1331 0 : if (inner_attrs.empty ())
1332 : {
1333 0 : str += "none";
1334 : }
1335 : else
1336 : {
1337 : /* note that this does not print them with "inner attribute" syntax -
1338 : * just the body */
1339 0 : for (const auto &attr : inner_attrs)
1340 : {
1341 0 : str += "\n " + attr.as_string ();
1342 : }
1343 : }
1344 :
1345 0 : str += "\n Expr in parens: " + expr_in_parens->to_string ();
1346 :
1347 0 : return str;
1348 : }
1349 :
1350 : std::string
1351 0 : RangeToExpr::to_string () const
1352 : {
1353 0 : return ".." + to->to_string ();
1354 : }
1355 :
1356 : std::string
1357 0 : ContinueExpr::to_string () const
1358 : {
1359 0 : std::string str ("continue ");
1360 :
1361 0 : if (has_label ())
1362 : {
1363 0 : str += get_label ().to_string ();
1364 : }
1365 :
1366 0 : return str;
1367 : }
1368 :
1369 : std::string
1370 2200 : NegationExpr::to_string () const
1371 : {
1372 2200 : std::string str;
1373 :
1374 2200 : switch (expr_type)
1375 : {
1376 2200 : case NegationOperator::NEGATE:
1377 2200 : str = "-";
1378 2200 : break;
1379 0 : case NegationOperator::NOT:
1380 0 : str = "!";
1381 0 : break;
1382 0 : default:
1383 0 : return "ERROR_MARK_STRING - negation expr";
1384 : }
1385 :
1386 4400 : str += main_or_left_expr->to_string ();
1387 :
1388 2200 : return str;
1389 2200 : }
1390 :
1391 : std::string
1392 0 : RangeFromExpr::to_string () const
1393 : {
1394 0 : return from->to_string () + "..";
1395 : }
1396 :
1397 : std::string
1398 0 : RangeFullExpr::to_string () const
1399 : {
1400 0 : return "..";
1401 : }
1402 :
1403 : std::string
1404 0 : ArrayIndexExpr::to_string () const
1405 : {
1406 0 : return array_expr->to_string () + "[" + index_expr->to_string () + "]";
1407 : }
1408 :
1409 : std::string
1410 0 : AssignmentExpr::to_string () const
1411 : {
1412 0 : return main_or_left_expr->to_string () + " = " + right_expr->to_string ();
1413 : }
1414 :
1415 : std::string
1416 0 : CompoundAssignmentExpr::get_operator_str () const
1417 : {
1418 0 : std::string operator_str;
1419 0 : operator_str.reserve (1);
1420 :
1421 : // get operator string
1422 0 : switch (expr_type)
1423 : {
1424 0 : case ArithmeticOrLogicalOperator::ADD:
1425 0 : operator_str = "+";
1426 0 : break;
1427 0 : case ArithmeticOrLogicalOperator::SUBTRACT:
1428 0 : operator_str = "-";
1429 0 : break;
1430 0 : case ArithmeticOrLogicalOperator::MULTIPLY:
1431 0 : operator_str = "*";
1432 0 : break;
1433 0 : case ArithmeticOrLogicalOperator::DIVIDE:
1434 0 : operator_str = "/";
1435 0 : break;
1436 0 : case ArithmeticOrLogicalOperator::MODULUS:
1437 0 : operator_str = "%";
1438 0 : break;
1439 0 : case ArithmeticOrLogicalOperator::BITWISE_AND:
1440 0 : operator_str = "&";
1441 0 : break;
1442 0 : case ArithmeticOrLogicalOperator::BITWISE_OR:
1443 0 : operator_str = "|";
1444 0 : break;
1445 0 : case ArithmeticOrLogicalOperator::BITWISE_XOR:
1446 0 : operator_str = "^";
1447 0 : break;
1448 0 : case ArithmeticOrLogicalOperator::LEFT_SHIFT:
1449 0 : operator_str = "<<";
1450 0 : break;
1451 0 : case ArithmeticOrLogicalOperator::RIGHT_SHIFT:
1452 0 : operator_str = ">>";
1453 0 : break;
1454 0 : default:
1455 0 : rust_unreachable ();
1456 0 : break;
1457 : }
1458 :
1459 0 : operator_str += "=";
1460 :
1461 0 : return operator_str;
1462 : }
1463 :
1464 : std::string
1465 0 : CompoundAssignmentExpr::to_string () const
1466 : {
1467 0 : std::string str ("CompoundAssignmentExpr: ");
1468 0 : std::string operator_str = get_operator_str ();
1469 0 : if (main_or_left_expr == nullptr || right_expr == nullptr)
1470 : {
1471 0 : str += "error. this is probably a parsing failure.";
1472 : }
1473 : else
1474 : {
1475 0 : str += "\n left: " + main_or_left_expr->to_string ();
1476 0 : str += "\n right: " + right_expr->to_string ();
1477 0 : str += "\n operator: " + operator_str;
1478 : }
1479 :
1480 0 : return str;
1481 0 : }
1482 :
1483 : std::string
1484 0 : AsyncBlockExpr::to_string () const
1485 : {
1486 0 : std::string str = "AsyncBlockExpr: ";
1487 :
1488 : // get outer attributes
1489 0 : str += "\n " + Expr::to_string ();
1490 :
1491 0 : str += "\n Has move: ";
1492 0 : str += has_move ? "true" : "false";
1493 :
1494 0 : return str + "\n" + block_expr->to_string ();
1495 0 : }
1496 :
1497 : std::string
1498 0 : ComparisonExpr::to_string () const
1499 : {
1500 0 : std::string str (main_or_left_expr->to_string ());
1501 :
1502 0 : switch (expr_type)
1503 : {
1504 0 : case ComparisonOperator::EQUAL:
1505 0 : str += " == ";
1506 0 : break;
1507 0 : case ComparisonOperator::NOT_EQUAL:
1508 0 : str += " != ";
1509 0 : break;
1510 0 : case ComparisonOperator::GREATER_THAN:
1511 0 : str += " > ";
1512 0 : break;
1513 0 : case ComparisonOperator::LESS_THAN:
1514 0 : str += " < ";
1515 0 : break;
1516 0 : case ComparisonOperator::GREATER_OR_EQUAL:
1517 0 : str += " >= ";
1518 0 : break;
1519 0 : case ComparisonOperator::LESS_OR_EQUAL:
1520 0 : str += " <= ";
1521 0 : break;
1522 0 : default:
1523 0 : return "ERROR_MARK_STRING - comparison expr";
1524 : }
1525 :
1526 0 : str += right_expr->to_string ();
1527 :
1528 0 : return str;
1529 0 : }
1530 :
1531 : std::string
1532 0 : MethodCallExpr::to_string () const
1533 : {
1534 0 : std::string str ("MethodCallExpr: \n Object (receiver) expr: ");
1535 :
1536 0 : str += receiver->to_string ();
1537 :
1538 0 : str += "\n Method path segment: \n";
1539 :
1540 0 : str += method_name.to_string ();
1541 :
1542 0 : str += "\n Call params:";
1543 0 : if (params.empty ())
1544 : {
1545 0 : str += "none";
1546 : }
1547 : else
1548 : {
1549 0 : for (const auto ¶m : params)
1550 : {
1551 0 : if (param == nullptr)
1552 : {
1553 0 : return "ERROR_MARK_STRING - method call expr param is null";
1554 : }
1555 :
1556 0 : str += "\n " + param->to_string ();
1557 : }
1558 : }
1559 :
1560 0 : return str;
1561 0 : }
1562 :
1563 : std::string
1564 0 : TupleIndexExpr::to_string () const
1565 : {
1566 0 : return tuple_expr->to_string () + "." + std::to_string (tuple_index);
1567 : }
1568 :
1569 : std::string
1570 0 : DereferenceExpr::to_string () const
1571 : {
1572 0 : return "*" + main_or_left_expr->to_string ();
1573 : }
1574 :
1575 : std::string
1576 0 : FieldAccessExpr::to_string () const
1577 : {
1578 0 : return receiver->to_string () + "." + field.as_string ();
1579 : }
1580 :
1581 : std::string
1582 0 : LazyBooleanExpr::to_string () const
1583 : {
1584 0 : std::string str (main_or_left_expr->to_string ());
1585 :
1586 0 : switch (expr_type)
1587 : {
1588 0 : case LazyBooleanOperator::LOGICAL_OR:
1589 0 : str += " || ";
1590 0 : break;
1591 0 : case LazyBooleanOperator::LOGICAL_AND:
1592 0 : str += " && ";
1593 0 : break;
1594 0 : default:
1595 0 : return "ERROR_MARK_STRING - lazy boolean expr out of bounds";
1596 : }
1597 :
1598 0 : str += right_expr->to_string ();
1599 :
1600 0 : return str;
1601 0 : }
1602 :
1603 : std::string
1604 0 : RangeFromToExpr::to_string () const
1605 : {
1606 0 : return from->to_string () + ".." + to->to_string ();
1607 : }
1608 :
1609 : std::string
1610 0 : RangeToInclExpr::to_string () const
1611 : {
1612 0 : return "..=" + to->to_string ();
1613 : }
1614 :
1615 : std::string
1616 0 : UnsafeBlockExpr::to_string () const
1617 : {
1618 0 : std::string istr = indent_spaces (enter);
1619 0 : std::string str = istr + "UnsafeBlockExpr:";
1620 0 : str += istr + "{";
1621 :
1622 : // get outer attributes
1623 0 : str += "\n" + indent_spaces (stay) + Expr::to_string ();
1624 :
1625 0 : return str + "\n" + indent_spaces (out) + "}\n" + expr->to_string ();
1626 0 : }
1627 :
1628 : std::string
1629 0 : IfExpr::to_string () const
1630 : {
1631 0 : std::string str ("IfExpr: ");
1632 :
1633 0 : str += "\n Condition expr: " + condition->to_string ();
1634 :
1635 0 : str += "\n If block expr: " + if_block->to_string ();
1636 :
1637 0 : return str;
1638 : }
1639 :
1640 : std::string
1641 0 : IfExprConseqElse::to_string () const
1642 : {
1643 0 : std::string str = IfExpr::to_string ();
1644 :
1645 0 : str += "\n Else expr: " + else_block->to_string ();
1646 :
1647 0 : return str;
1648 : }
1649 :
1650 : std::string
1651 0 : RangeFromToInclExpr::to_string () const
1652 : {
1653 0 : return from->to_string () + "..=" + to->to_string ();
1654 : }
1655 :
1656 : std::string
1657 0 : ErrorPropagationExpr::to_string () const
1658 : {
1659 0 : return main_or_left_expr->to_string () + "?";
1660 : }
1661 :
1662 : std::string
1663 7 : ArithmeticOrLogicalExpr::get_operator_str () const
1664 : {
1665 7 : std::string operator_str;
1666 7 : operator_str.reserve (1);
1667 :
1668 : // get operator string
1669 7 : switch (expr_type)
1670 : {
1671 7 : case ArithmeticOrLogicalOperator::ADD:
1672 7 : operator_str = "+";
1673 7 : break;
1674 0 : case ArithmeticOrLogicalOperator::SUBTRACT:
1675 0 : operator_str = "-";
1676 0 : break;
1677 0 : case ArithmeticOrLogicalOperator::MULTIPLY:
1678 0 : operator_str = "*";
1679 0 : break;
1680 0 : case ArithmeticOrLogicalOperator::DIVIDE:
1681 0 : operator_str = "/";
1682 0 : break;
1683 0 : case ArithmeticOrLogicalOperator::MODULUS:
1684 0 : operator_str = "%";
1685 0 : break;
1686 0 : case ArithmeticOrLogicalOperator::BITWISE_AND:
1687 0 : operator_str = "&";
1688 0 : break;
1689 0 : case ArithmeticOrLogicalOperator::BITWISE_OR:
1690 0 : operator_str = "|";
1691 0 : break;
1692 0 : case ArithmeticOrLogicalOperator::BITWISE_XOR:
1693 0 : operator_str = "^";
1694 0 : break;
1695 0 : case ArithmeticOrLogicalOperator::LEFT_SHIFT:
1696 0 : operator_str = "<<";
1697 0 : break;
1698 0 : case ArithmeticOrLogicalOperator::RIGHT_SHIFT:
1699 0 : operator_str = ">>";
1700 0 : break;
1701 0 : default:
1702 0 : rust_unreachable ();
1703 7 : break;
1704 : }
1705 :
1706 7 : return operator_str;
1707 : }
1708 :
1709 : std::string
1710 4 : ArithmeticOrLogicalExpr::to_string () const
1711 : {
1712 8 : std::string str = main_or_left_expr->to_string () + " ";
1713 12 : str += get_operator_str () + " ";
1714 8 : str += right_expr->to_string ();
1715 :
1716 8 : return "( " + str + " )";
1717 4 : }
1718 :
1719 : std::string
1720 1 : CallExpr::to_string () const
1721 : {
1722 2 : std::string str = function->to_string () + "(";
1723 1 : if (!has_params ())
1724 1 : str += "none";
1725 : else
1726 : {
1727 0 : for (const auto ¶m : params)
1728 : {
1729 0 : if (param == nullptr)
1730 : {
1731 0 : return "ERROR_MARK_STRING - call expr param is null";
1732 : }
1733 :
1734 0 : str += param->to_string () + ",";
1735 : }
1736 : }
1737 1 : return str + ")";
1738 1 : }
1739 :
1740 : std::string
1741 0 : WhileLoopExpr::to_string () const
1742 : {
1743 0 : std::string str ("WhileLoopExpr: ");
1744 :
1745 0 : str += "\n Label: ";
1746 0 : if (!has_loop_label ())
1747 : {
1748 0 : str += "none";
1749 : }
1750 : else
1751 : {
1752 0 : str += get_loop_label ().to_string ();
1753 : }
1754 :
1755 0 : str += "\n Conditional expr: " + condition->to_string ();
1756 :
1757 0 : str += "\n Loop block: " + loop_block->to_string ();
1758 :
1759 0 : return str;
1760 : }
1761 :
1762 : std::string
1763 0 : WhileLetLoopExpr::to_string () const
1764 : {
1765 0 : std::string str ("WhileLetLoopExpr: ");
1766 :
1767 0 : str += "\n Label: ";
1768 0 : if (!has_loop_label ())
1769 : {
1770 0 : str += "none";
1771 : }
1772 : else
1773 : {
1774 0 : str += get_loop_label ().to_string ();
1775 : }
1776 :
1777 0 : str += "\n Match arm patterns: ";
1778 0 : if (match_arm_pattern == nullptr)
1779 : {
1780 0 : str += "none";
1781 : }
1782 : else
1783 : {
1784 0 : str += "\n " + match_arm_pattern->to_string ();
1785 : }
1786 :
1787 0 : str += "\n Scrutinee expr: " + condition->to_string ();
1788 :
1789 0 : str += "\n Loop block: " + loop_block->to_string ();
1790 :
1791 0 : return str;
1792 : }
1793 :
1794 : std::string
1795 0 : LoopExpr::to_string () const
1796 : {
1797 0 : std::string str ("LoopExpr: (infinite loop)");
1798 :
1799 0 : str += "\n Label: ";
1800 0 : if (!has_loop_label ())
1801 : {
1802 0 : str += "none";
1803 : }
1804 : else
1805 : {
1806 0 : str += get_loop_label ().to_string ();
1807 : }
1808 :
1809 0 : str += "\n Loop block: " + loop_block->to_string ();
1810 :
1811 0 : return str;
1812 : }
1813 :
1814 : std::string
1815 0 : ArrayExpr::to_string () const
1816 : {
1817 0 : std::string str ("ArrayExpr:");
1818 :
1819 : // inner attributes
1820 0 : str += "\n inner attributes: ";
1821 0 : if (inner_attrs.empty ())
1822 : {
1823 0 : str += "none";
1824 : }
1825 : else
1826 : {
1827 : /* note that this does not print them with "inner attribute" syntax -
1828 : * just the body */
1829 0 : for (const auto &attr : inner_attrs)
1830 : {
1831 0 : str += "\n " + attr.as_string ();
1832 : }
1833 : }
1834 :
1835 0 : str += "\n Array elems: ";
1836 0 : if (!has_array_elems ())
1837 : {
1838 0 : str += "none";
1839 : }
1840 : else
1841 : {
1842 0 : str += internal_elements->to_string ();
1843 : }
1844 :
1845 0 : return str;
1846 : }
1847 :
1848 : std::string
1849 0 : AwaitExpr::to_string () const
1850 : {
1851 0 : return awaited_expr->to_string () + ".await";
1852 : }
1853 :
1854 : std::string
1855 0 : BreakExpr::to_string () const
1856 : {
1857 0 : std::string str ("break ");
1858 :
1859 0 : if (has_label ())
1860 : {
1861 0 : str += get_label ().to_string () + " ";
1862 : }
1863 :
1864 0 : if (has_break_expr ())
1865 : {
1866 0 : str += break_expr->to_string ();
1867 : }
1868 :
1869 0 : return str;
1870 : }
1871 :
1872 : std::string
1873 0 : LoopLabel::to_string () const
1874 : {
1875 0 : return label.to_string () + ": (label) ";
1876 : }
1877 :
1878 : std::string
1879 0 : MatchArm::to_string () const
1880 : {
1881 : // outer attributes
1882 0 : std::string str = "Outer attributes: ";
1883 0 : if (outer_attrs.empty ())
1884 : {
1885 0 : str += "none";
1886 : }
1887 : else
1888 : {
1889 : /* note that this does not print them with "outer attribute" syntax -
1890 : * just the body */
1891 0 : for (const auto &attr : outer_attrs)
1892 : {
1893 0 : str += "\n " + attr.as_string ();
1894 : }
1895 : }
1896 :
1897 0 : str += "\nPatterns: ";
1898 0 : if (match_arm_pattern == nullptr)
1899 0 : str += "none";
1900 : else
1901 0 : str += "\n " + match_arm_pattern->to_string ();
1902 :
1903 0 : str += "\nGuard expr: ";
1904 0 : if (!has_match_arm_guard ())
1905 : {
1906 0 : str += "none";
1907 : }
1908 : else
1909 : {
1910 0 : str += guard_expr->to_string ();
1911 : }
1912 :
1913 0 : return str;
1914 : }
1915 :
1916 : std::string
1917 0 : MatchCase::to_debug_string () const
1918 : {
1919 0 : std::string str ("MatchCase: (match arm) ");
1920 :
1921 0 : str += "\n Match arm matcher: \n" + arm.to_string ();
1922 0 : str += "\n Expr: " + expr->to_string ();
1923 :
1924 0 : return str;
1925 : }
1926 :
1927 : std::string
1928 0 : MatchCase::to_string () const
1929 : {
1930 0 : std::string str = arm.to_string ();
1931 0 : str += " => ";
1932 0 : str += expr ? expr->to_string () : "null";
1933 0 : return str;
1934 : }
1935 :
1936 : /*std::string
1937 : MatchCaseBlockExpr::to_string () const
1938 : {
1939 : std::string str = MatchCase::to_string ();
1940 :
1941 : str += "\n Block expr: " + block_expr->to_string ();
1942 :
1943 : return str;
1944 : }
1945 :
1946 : std::string
1947 : MatchCaseExpr::to_string () const
1948 : {
1949 : std::string str = MatchCase::to_string ();
1950 :
1951 : str += "\n Expr: " + expr->to_string ();
1952 :
1953 : return str;
1954 : }*/
1955 :
1956 : std::string
1957 0 : MatchExpr::to_string () const
1958 : {
1959 0 : std::string str ("MatchExpr:");
1960 :
1961 0 : str += "\n Scrutinee expr: " + branch_value->to_string ();
1962 :
1963 : // inner attributes
1964 0 : str += "\n inner attributes: ";
1965 0 : if (inner_attrs.empty ())
1966 : {
1967 0 : str += "none";
1968 : }
1969 : else
1970 : {
1971 : /* note that this does not print them with "inner attribute" syntax -
1972 : * just the body */
1973 0 : for (const auto &attr : inner_attrs)
1974 : {
1975 0 : str += "\n " + attr.as_string ();
1976 : }
1977 : }
1978 :
1979 : // match arms
1980 0 : str += "\n Match arms: ";
1981 0 : if (match_arms.empty ())
1982 : {
1983 0 : str += "none";
1984 : }
1985 : else
1986 : {
1987 0 : for (const auto &arm : match_arms)
1988 0 : str += "\n " + arm.to_string ();
1989 : }
1990 :
1991 0 : return str;
1992 : }
1993 :
1994 : std::string
1995 0 : TupleExpr::to_string () const
1996 : {
1997 0 : std::string str ("TupleExpr:");
1998 :
1999 : // inner attributes
2000 0 : str += "\n inner attributes: ";
2001 0 : if (inner_attrs.empty ())
2002 : {
2003 0 : str += "none";
2004 : }
2005 : else
2006 : {
2007 : /* note that this does not print them with "inner attribute" syntax -
2008 : * just the body */
2009 0 : for (const auto &attr : inner_attrs)
2010 : {
2011 0 : str += "\n " + attr.as_string ();
2012 : }
2013 : }
2014 :
2015 0 : str += "\n Tuple elements: ";
2016 0 : if (tuple_elems.empty ())
2017 : {
2018 0 : str += "none";
2019 : }
2020 : else
2021 : {
2022 0 : for (const auto &elem : tuple_elems)
2023 : {
2024 0 : str += "\n " + elem->to_string ();
2025 : }
2026 : }
2027 :
2028 0 : return str;
2029 : }
2030 :
2031 : std::string
2032 0 : FunctionParam::to_string () const
2033 : {
2034 0 : return param_name->to_string () + " : " + type->to_string ();
2035 : }
2036 :
2037 : std::string
2038 2 : FunctionQualifiers::to_string () const
2039 : {
2040 2 : std::string str;
2041 :
2042 2 : if (is_const ())
2043 0 : str += "const ";
2044 2 : if (is_async ())
2045 0 : str += "async ";
2046 2 : if (is_unsafe ())
2047 0 : str += "unsafe ";
2048 :
2049 2 : if (has_extern)
2050 : {
2051 0 : str += "extern";
2052 0 : str += " \"" + get_string_from_abi (abi) + "\"";
2053 : }
2054 :
2055 2 : return str;
2056 : }
2057 :
2058 : std::string
2059 0 : TraitBound::to_debug_string () const
2060 : {
2061 0 : std::string str ("TraitBound:");
2062 :
2063 0 : switch (polarity)
2064 : {
2065 : case RegularBound:
2066 : break;
2067 0 : case NegativeBound:
2068 0 : str += "!";
2069 0 : break;
2070 0 : case AntiBound:
2071 0 : str += "?";
2072 0 : break;
2073 : }
2074 :
2075 0 : str += "\n For lifetimes: ";
2076 0 : if (!has_for_lifetimes ())
2077 : {
2078 0 : str += "none";
2079 : }
2080 : else
2081 : {
2082 0 : for (const auto &lifetime : for_lifetimes)
2083 : {
2084 0 : str += "\n " + lifetime.to_string ();
2085 : }
2086 : }
2087 :
2088 0 : str += "\n Type path: " + type_path.to_string ();
2089 :
2090 0 : return str;
2091 : }
2092 :
2093 : std::string
2094 0 : TraitBound::to_string () const
2095 : {
2096 0 : std::string str;
2097 0 : switch (polarity)
2098 : {
2099 : case RegularBound:
2100 : break;
2101 0 : case NegativeBound:
2102 0 : str += "!";
2103 0 : break;
2104 0 : case AntiBound:
2105 0 : str += "?";
2106 0 : break;
2107 : }
2108 :
2109 0 : if (has_for_lifetimes ())
2110 0 : for (const auto &lifetime : for_lifetimes)
2111 0 : str += "\n " + lifetime.to_string ();
2112 :
2113 0 : str += "\n" + type_path.to_string ();
2114 :
2115 0 : return str;
2116 : }
2117 :
2118 : std::string
2119 6 : QualifiedPathInType::to_string () const
2120 : {
2121 6 : std::string str = path_type.to_string ();
2122 :
2123 12 : str += "::" + associated_segment->to_string ();
2124 6 : for (const auto &segment : segments)
2125 : {
2126 0 : str += "::" + segment->to_string ();
2127 : }
2128 :
2129 6 : return str;
2130 : }
2131 :
2132 : std::string
2133 145 : Lifetime::to_string () const
2134 : {
2135 145 : switch (lifetime_type)
2136 : {
2137 37 : case AST::Lifetime::LifetimeType::NAMED:
2138 37 : return "'" + lifetime_name;
2139 14 : case AST::Lifetime::LifetimeType::STATIC:
2140 14 : return "'static";
2141 94 : case AST::Lifetime::LifetimeType::WILDCARD:
2142 94 : return "'_";
2143 0 : default:
2144 0 : return "ERROR-MARK-STRING: lifetime type failure";
2145 : }
2146 : }
2147 :
2148 : std::string
2149 48531 : TypePath::to_string () const
2150 : {
2151 48531 : std::string str;
2152 :
2153 48531 : if (has_opening_scope_resolution)
2154 : {
2155 201 : str = "::";
2156 : }
2157 :
2158 98594 : for (const auto &segment : segments)
2159 : {
2160 150189 : str += segment->to_string () + "::";
2161 : }
2162 :
2163 : // kinda hack - remove last 2 '::' characters
2164 48531 : str.erase (str.length () - 2);
2165 :
2166 48531 : return str;
2167 : }
2168 :
2169 : std::string
2170 0 : TypeParam::to_debug_string () const
2171 : {
2172 0 : std::string str ("TypeParam: ");
2173 :
2174 0 : str += "\n Outer attributes: ";
2175 0 : if (outer_attrs.empty ())
2176 : {
2177 0 : str += "\nnone";
2178 : }
2179 : else
2180 : {
2181 : /* note that this does not print them with "outer attribute" syntax -
2182 : * just the body */
2183 0 : for (const auto &attr : outer_attrs)
2184 : {
2185 0 : str += "\n " + attr.as_string ();
2186 : }
2187 : }
2188 :
2189 0 : str += "\n Identifier: " + type_representation.as_string ();
2190 :
2191 0 : str += "\n Type param bounds: ";
2192 0 : if (!has_type_param_bounds ())
2193 : {
2194 0 : str += "none";
2195 : }
2196 : else
2197 : {
2198 0 : for (const auto &bound : type_param_bounds)
2199 : {
2200 0 : str += "\n " + bound->to_string ();
2201 : }
2202 : }
2203 :
2204 0 : str += "\n Type: ";
2205 0 : if (!has_type ())
2206 : {
2207 0 : str += "none";
2208 : }
2209 : else
2210 : {
2211 0 : str += type.value ()->to_string ();
2212 : }
2213 :
2214 0 : return str;
2215 : }
2216 :
2217 : std::string
2218 0 : TypeParam::to_string () const
2219 : {
2220 0 : std::string str;
2221 0 : if (!outer_attrs.empty ())
2222 : {
2223 0 : for (const auto &attr : outer_attrs)
2224 : {
2225 0 : str += attr.as_string () + "\n";
2226 : }
2227 : }
2228 :
2229 0 : str += type_representation.as_string ();
2230 :
2231 0 : if (!has_type_param_bounds ())
2232 : {
2233 0 : str += ": ";
2234 0 : for (size_t i = 0; i < type_param_bounds.size (); ++i)
2235 : {
2236 0 : if (i > 0)
2237 0 : str += " + ";
2238 0 : str += type_param_bounds[i]->to_string ();
2239 : }
2240 : }
2241 :
2242 0 : if (has_type ())
2243 0 : str += ": " + type.value ()->to_string ();
2244 :
2245 0 : return str;
2246 : }
2247 :
2248 : AST::SimplePath
2249 5 : PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const
2250 : {
2251 5 : rust_assert (kind == Kind::Segmented);
2252 :
2253 5 : if (!has_segments ())
2254 : {
2255 0 : return AST::SimplePath::create_empty ();
2256 : }
2257 :
2258 : // create vector of reserved size (to minimise reallocations)
2259 5 : std::vector<AST::SimplePathSegment> simple_segments;
2260 5 : simple_segments.reserve (segments.size ());
2261 :
2262 10 : for (const auto &segment : segments)
2263 : {
2264 : // return empty path if doesn't meet simple path segment requirements
2265 5 : if (segment.has_generic_args () || segment.to_string () == "Self")
2266 : {
2267 0 : return AST::SimplePath::create_empty ();
2268 : }
2269 :
2270 : // create segment and add to vector
2271 5 : std::string segment_str = segment.to_string ();
2272 5 : simple_segments.emplace_back (std::move (segment_str),
2273 5 : segment.get_locus ());
2274 5 : }
2275 :
2276 : // kind of a HACK to get locus depending on opening scope resolution
2277 5 : location_t locus = UNKNOWN_LOCATION;
2278 5 : if (with_opening_scope_resolution)
2279 : {
2280 0 : locus = simple_segments[0].get_locus () - 2; // minus 2 chars for ::
2281 : }
2282 : else
2283 : {
2284 5 : locus = simple_segments[0].get_locus ();
2285 : }
2286 :
2287 5 : return AST::SimplePath (std::move (simple_segments),
2288 5 : with_opening_scope_resolution, locus);
2289 5 : }
2290 :
2291 : AST::SimplePath
2292 2 : TypePath::as_simple_path () const
2293 : {
2294 2 : if (segments.empty ())
2295 : {
2296 0 : return AST::SimplePath::create_empty ();
2297 : }
2298 :
2299 : // create vector of reserved size (to minimise reallocations)
2300 2 : std::vector<AST::SimplePathSegment> simple_segments;
2301 2 : simple_segments.reserve (segments.size ());
2302 :
2303 4 : for (const auto &segment : segments)
2304 : {
2305 : // return empty path if doesn't meet simple path segment requirements
2306 2 : if (segment == nullptr || segment->is_error ()
2307 4 : || !segment->is_ident_only () || segment->to_string () == "Self")
2308 : {
2309 0 : return AST::SimplePath::create_empty ();
2310 : }
2311 :
2312 : // create segment and add to vector
2313 2 : std::string segment_str = segment->to_string ();
2314 2 : simple_segments.emplace_back (std::move (segment_str),
2315 2 : segment->get_locus ());
2316 2 : }
2317 :
2318 2 : return AST::SimplePath (std::move (simple_segments),
2319 2 : has_opening_scope_resolution, locus);
2320 2 : }
2321 :
2322 : std::string
2323 66 : PathExprSegment::to_string () const
2324 : {
2325 66 : std::string ident_str = segment_name.to_string ();
2326 66 : if (has_generic_args ())
2327 : {
2328 0 : ident_str += "::<" + generic_args.to_string () + ">";
2329 : }
2330 :
2331 66 : return ident_str;
2332 : }
2333 :
2334 : std::string
2335 1894 : GenericArgs::to_string () const
2336 : {
2337 1894 : std::string args;
2338 :
2339 : // lifetime args
2340 1894 : if (!lifetime_args.empty ())
2341 : {
2342 : auto i = lifetime_args.begin ();
2343 : auto e = lifetime_args.end ();
2344 :
2345 59 : for (; i != e; i++)
2346 : {
2347 60 : args += (*i).to_string ();
2348 30 : if (e != i + 1)
2349 1 : args += ", ";
2350 : }
2351 : }
2352 :
2353 : // type args
2354 1894 : if (!type_args.empty ())
2355 : {
2356 : auto i = type_args.begin ();
2357 : auto e = type_args.end ();
2358 :
2359 3809 : for (; i != e; i++)
2360 : {
2361 3972 : args += (*i)->to_string ();
2362 1986 : if (e != i + 1)
2363 163 : args += ", ";
2364 : }
2365 : }
2366 :
2367 : // binding args
2368 1894 : if (!binding_args.empty ())
2369 : {
2370 : auto i = binding_args.begin ();
2371 : auto e = binding_args.end ();
2372 :
2373 0 : for (; i != e; i++)
2374 : {
2375 0 : args += (*i).to_string ();
2376 0 : if (e != i + 1)
2377 0 : args += ", ";
2378 : }
2379 : }
2380 :
2381 1894 : return args;
2382 : }
2383 :
2384 : std::string
2385 0 : GenericArgsBinding::to_string () const
2386 : {
2387 0 : return identifier.as_string () + " = " + type->to_string ();
2388 : }
2389 :
2390 : std::string
2391 0 : RangePattern::to_string () const
2392 : {
2393 0 : if (has_ellipsis_syntax)
2394 : {
2395 0 : return lower->to_string () + "..." + upper->to_string ();
2396 : }
2397 : else
2398 : {
2399 0 : return lower->to_string () + "..=" + upper->to_string ();
2400 : }
2401 : }
2402 :
2403 : std::string
2404 0 : RangePatternBoundLiteral::to_string () const
2405 : {
2406 0 : std::string str;
2407 :
2408 0 : if (has_minus)
2409 : {
2410 0 : str += "-";
2411 : }
2412 :
2413 0 : str += literal.as_string ();
2414 :
2415 0 : return str;
2416 : }
2417 :
2418 : std::string
2419 0 : SlicePatternItemsNoRest::to_string () const
2420 : {
2421 0 : std::string str;
2422 :
2423 0 : for (const auto &pattern : patterns)
2424 : {
2425 0 : str += "\n " + pattern->to_string ();
2426 : }
2427 :
2428 0 : return str;
2429 : }
2430 :
2431 : std::string
2432 0 : SlicePatternItemsHasRest::to_string () const
2433 : {
2434 0 : std::string str;
2435 :
2436 0 : str += "\n Lower patterns: ";
2437 0 : if (lower_patterns.empty ())
2438 : {
2439 0 : str += "none";
2440 : }
2441 : else
2442 : {
2443 0 : for (const auto &lower : lower_patterns)
2444 : {
2445 0 : str += "\n " + lower->to_string ();
2446 : }
2447 : }
2448 :
2449 0 : str += "\n Upper patterns: ";
2450 0 : if (upper_patterns.empty ())
2451 : {
2452 0 : str += "none";
2453 : }
2454 : else
2455 : {
2456 0 : for (const auto &upper : upper_patterns)
2457 : {
2458 0 : str += "\n " + upper->to_string ();
2459 : }
2460 : }
2461 :
2462 0 : return str;
2463 : }
2464 :
2465 : std::string
2466 0 : SlicePattern::to_string () const
2467 : {
2468 0 : return "SlicePattern: " + items->to_string ();
2469 : }
2470 :
2471 : std::string
2472 0 : AltPattern::to_string () const
2473 : {
2474 0 : std::string str ("AltPattern: ");
2475 :
2476 0 : for (const auto &pattern : alts)
2477 : {
2478 0 : str += "\n " + pattern->to_string ();
2479 : }
2480 :
2481 0 : return str;
2482 : }
2483 :
2484 : std::string
2485 4 : TuplePatternItemsNoRest::to_string () const
2486 : {
2487 4 : std::string str;
2488 :
2489 12 : for (const auto &pattern : patterns)
2490 : {
2491 16 : str += "\n " + pattern->to_string ();
2492 : }
2493 :
2494 4 : return str;
2495 : }
2496 :
2497 : std::string
2498 0 : TuplePatternItemsHasRest::to_string () const
2499 : {
2500 0 : std::string str;
2501 :
2502 0 : str += "\n Lower patterns: ";
2503 0 : if (lower_patterns.empty ())
2504 : {
2505 0 : str += "none";
2506 : }
2507 : else
2508 : {
2509 0 : for (const auto &lower : lower_patterns)
2510 : {
2511 0 : str += "\n " + lower->to_string ();
2512 : }
2513 : }
2514 :
2515 0 : str += "\n Upper patterns: ";
2516 0 : if (upper_patterns.empty ())
2517 : {
2518 0 : str += "none";
2519 : }
2520 : else
2521 : {
2522 0 : for (const auto &upper : upper_patterns)
2523 : {
2524 0 : str += "\n " + upper->to_string ();
2525 : }
2526 : }
2527 :
2528 0 : return str;
2529 : }
2530 :
2531 : std::string
2532 4 : TuplePattern::to_string () const
2533 : {
2534 4 : return items->to_string ();
2535 : }
2536 :
2537 : std::string
2538 0 : StructPatternField::to_string () const
2539 : {
2540 : // outer attributes
2541 0 : std::string str ("Outer attributes: ");
2542 0 : if (outer_attrs.empty ())
2543 : {
2544 0 : str += "none";
2545 : }
2546 : else
2547 : {
2548 : /* note that this does not print them with "outer attribute" syntax -
2549 : * just the body */
2550 0 : for (const auto &attr : outer_attrs)
2551 : {
2552 0 : str += "\n " + attr.as_string ();
2553 : }
2554 : }
2555 :
2556 0 : str += "\n item type: ";
2557 0 : switch (get_item_type ())
2558 : {
2559 0 : case ItemType::TUPLE_PAT:
2560 0 : str += "TUPLE_PAT";
2561 0 : break;
2562 0 : case ItemType::IDENT_PAT:
2563 0 : str += "IDENT_PAT";
2564 0 : break;
2565 0 : case ItemType::IDENT:
2566 0 : str += "IDENT";
2567 0 : break;
2568 0 : default:
2569 0 : str += "UNKNOWN";
2570 0 : break;
2571 : }
2572 :
2573 0 : return str;
2574 : }
2575 :
2576 : std::string
2577 0 : StructPatternFieldIdent::to_string () const
2578 : {
2579 0 : std::string str = StructPatternField::to_string ();
2580 :
2581 0 : str += "\n";
2582 :
2583 0 : if (has_ref)
2584 : {
2585 0 : str += "ref ";
2586 : }
2587 :
2588 0 : if (is_mut ())
2589 : {
2590 0 : str += "mut ";
2591 : }
2592 :
2593 0 : str += ident.as_string ();
2594 :
2595 0 : return str;
2596 : }
2597 :
2598 : std::string
2599 0 : StructPatternFieldTuplePat::to_string () const
2600 : {
2601 0 : std::string str = StructPatternField::to_string ();
2602 :
2603 0 : str += "\n";
2604 :
2605 0 : str += std::to_string (index) + " : " + tuple_pattern->to_string ();
2606 :
2607 0 : return str;
2608 : }
2609 :
2610 : std::string
2611 0 : StructPatternFieldIdentPat::to_string () const
2612 : {
2613 0 : std::string str = StructPatternField::to_string ();
2614 :
2615 0 : str += "\n";
2616 :
2617 0 : str += ident.as_string () + " : " + ident_pattern->to_string ();
2618 :
2619 0 : return str;
2620 : }
2621 :
2622 : std::string
2623 0 : StructPatternElements::to_string () const
2624 : {
2625 0 : std::string str ("\n Fields: ");
2626 :
2627 0 : if (!has_struct_pattern_fields ())
2628 : {
2629 0 : str += "none";
2630 : }
2631 : else
2632 : {
2633 0 : for (const auto &field : fields)
2634 : {
2635 0 : str += "\n " + field->to_string ();
2636 : }
2637 : }
2638 :
2639 0 : return str;
2640 : }
2641 :
2642 : std::string
2643 0 : StructPattern::to_string () const
2644 : {
2645 0 : std::string str ("StructPattern: \n Path: ");
2646 :
2647 0 : str += path.to_string ();
2648 :
2649 0 : str += "\n Struct pattern elems: ";
2650 0 : if (!has_struct_pattern_elems ())
2651 : {
2652 0 : str += "none";
2653 : }
2654 : else
2655 : {
2656 0 : str += elems.to_string ();
2657 : }
2658 :
2659 0 : return str;
2660 : }
2661 :
2662 : std::string
2663 0 : LiteralPattern::to_string () const
2664 : {
2665 0 : return (has_minus ? "-" : "") + lit.as_string ();
2666 : }
2667 :
2668 : std::string
2669 40 : ReferencePattern::to_string () const
2670 : {
2671 40 : std::string str ("&");
2672 :
2673 40 : if (is_mut ())
2674 : {
2675 0 : str += "mut ";
2676 : }
2677 :
2678 80 : str += pattern->to_string ();
2679 :
2680 40 : return str;
2681 : }
2682 :
2683 : std::string
2684 138948 : IdentifierPattern::to_string () const
2685 : {
2686 138948 : std::string str;
2687 :
2688 138948 : if (is_ref)
2689 : {
2690 41787 : str += "ref ";
2691 : }
2692 :
2693 138948 : if (is_mut ())
2694 : {
2695 2066 : str += "mut ";
2696 : }
2697 :
2698 138948 : str += variable_ident.as_string ();
2699 :
2700 138948 : if (has_subpattern ())
2701 : {
2702 0 : str += " @ " + subpattern->to_string ();
2703 : }
2704 :
2705 138948 : return str;
2706 : }
2707 :
2708 : std::string
2709 35 : TupleStructItemsNoRest::to_string () const
2710 : {
2711 35 : std::string str;
2712 :
2713 70 : for (const auto &pattern : patterns)
2714 : {
2715 70 : str += "\n " + pattern->to_string ();
2716 : }
2717 :
2718 35 : return str;
2719 : }
2720 :
2721 : std::string
2722 0 : TupleStructItemsHasRest::to_string () const
2723 : {
2724 0 : std::string str ("\n Lower patterns: ");
2725 :
2726 0 : if (lower_patterns.empty ())
2727 : {
2728 0 : str += "none";
2729 : }
2730 : else
2731 : {
2732 0 : for (const auto &lower : lower_patterns)
2733 : {
2734 0 : str += "\n " + lower->to_string ();
2735 : }
2736 : }
2737 :
2738 0 : str += "\n Upper patterns: ";
2739 0 : if (upper_patterns.empty ())
2740 : {
2741 0 : str += "none";
2742 : }
2743 : else
2744 : {
2745 0 : for (const auto &upper : upper_patterns)
2746 : {
2747 0 : str += "\n " + upper->to_string ();
2748 : }
2749 : }
2750 :
2751 0 : return str;
2752 : }
2753 :
2754 : std::string
2755 35 : TupleStructPattern::to_string () const
2756 : {
2757 35 : std::string str ("TupleStructPattern: \n Path: ");
2758 :
2759 70 : str += path.to_string ();
2760 :
2761 70 : str += "\n Tuple struct items: " + items->to_string ();
2762 :
2763 35 : return str;
2764 : }
2765 :
2766 : std::string
2767 2 : LetStmt::to_string () const
2768 : {
2769 : // outer attributes
2770 2 : std::string str = "Outer attributes: ";
2771 2 : if (outer_attrs.empty ())
2772 : {
2773 2 : str += "none";
2774 : }
2775 : else
2776 : {
2777 : /* note that this does not print them with "outer attribute" syntax -
2778 : * just the body */
2779 0 : indent_spaces (enter);
2780 0 : for (const auto &attr : outer_attrs)
2781 : {
2782 0 : str += "\n" + indent_spaces (stay) + attr.as_string ();
2783 : }
2784 0 : indent_spaces (out);
2785 : }
2786 :
2787 6 : str += "\n" + indent_spaces (stay) + "let " + variables_pattern->to_string ();
2788 :
2789 2 : if (has_type ())
2790 : {
2791 0 : str += " : " + get_type ().to_string ();
2792 : }
2793 :
2794 2 : if (has_init_expr ())
2795 : {
2796 4 : str += " = " + get_init_expr ().to_string ();
2797 : }
2798 :
2799 2 : return str;
2800 : }
2801 :
2802 : // Used to get outer attributes for expressions.
2803 : std::string
2804 2 : Expr::to_string () const
2805 : {
2806 : // outer attributes
2807 2 : std::string str = "outer attributes: ";
2808 2 : if (outer_attrs.empty ())
2809 : {
2810 2 : str += "none";
2811 : }
2812 : else
2813 : {
2814 : /* note that this does not print them with "outer attribute" syntax -
2815 : * just the body */
2816 0 : for (const auto &attr : outer_attrs)
2817 : {
2818 0 : str += "\n " + attr.as_string ();
2819 : }
2820 : }
2821 :
2822 2 : return str;
2823 : }
2824 :
2825 : // hopefully definition here will prevent circular dependency issue
2826 : std::unique_ptr<TraitBound>
2827 0 : TypePath::to_trait_bound (bool in_parens) const
2828 : {
2829 : // If already in parentheses, don't convert to trait bound
2830 : // This ensures (TypePath) stays as ParenthesisedType in the parser
2831 0 : if (in_parens)
2832 0 : return nullptr;
2833 :
2834 : // create clone FIXME is this required? or is copy constructor automatically
2835 : // called?
2836 0 : TypePath copy (*this);
2837 0 : return std::make_unique<TraitBound> (mappings, std::move (copy),
2838 0 : copy.get_locus (), in_parens);
2839 0 : }
2840 :
2841 : std::string
2842 3 : InferredType::to_string () const
2843 : {
2844 3 : return "_ (inferred)";
2845 : }
2846 :
2847 : std::string
2848 0 : TypeCastExpr::to_string () const
2849 : {
2850 0 : return main_or_left_expr->to_string () + " as "
2851 0 : + type_to_convert_to->to_string ();
2852 : }
2853 :
2854 : std::string
2855 0 : ImplTraitType::to_string () const
2856 : {
2857 0 : std::string str ("ImplTraitType: \n TypeParamBounds: ");
2858 :
2859 0 : if (type_param_bounds.empty ())
2860 : {
2861 0 : str += "none";
2862 : }
2863 : else
2864 : {
2865 0 : for (const auto &bound : type_param_bounds)
2866 : {
2867 0 : str += "\n " + bound->to_string ();
2868 : }
2869 : }
2870 :
2871 0 : return str;
2872 : }
2873 :
2874 : std::string
2875 109 : ReferenceType::to_string () const
2876 : {
2877 109 : std::string str ("&");
2878 :
2879 109 : if (has_lifetime ())
2880 : {
2881 327 : str += get_lifetime ().to_string () + " ";
2882 : }
2883 :
2884 109 : if (is_mut ())
2885 : {
2886 7 : str += "mut ";
2887 : }
2888 :
2889 218 : str += type->to_string ();
2890 :
2891 109 : return str;
2892 : }
2893 :
2894 : std::string
2895 0 : RawPointerType::to_string () const
2896 : {
2897 0 : return std::string ("*") + (is_mut () ? "mut " : "const ")
2898 0 : + type->to_string ();
2899 : }
2900 :
2901 : std::string
2902 0 : TraitObjectType::to_string () const
2903 : {
2904 0 : std::string str ("TraitObjectType: \n Has dyn dispatch: ");
2905 :
2906 0 : if (has_dyn)
2907 : {
2908 0 : str += "true";
2909 : }
2910 : else
2911 : {
2912 0 : str += "false";
2913 : }
2914 :
2915 0 : str += "\n TypeParamBounds: ";
2916 0 : if (type_param_bounds.empty ())
2917 : {
2918 0 : str += "none";
2919 : }
2920 : else
2921 : {
2922 0 : for (const auto &bound : type_param_bounds)
2923 : {
2924 0 : str += "\n " + bound->to_string ();
2925 : }
2926 : }
2927 :
2928 0 : return str;
2929 : }
2930 :
2931 : std::string
2932 2 : BareFunctionType::to_string () const
2933 : {
2934 2 : std::string str ("BareFunctionType: \n For lifetimes: ");
2935 :
2936 2 : if (!has_for_lifetimes ())
2937 : {
2938 2 : str += "none";
2939 : }
2940 : else
2941 : {
2942 0 : for (const auto &for_lifetime : for_lifetimes)
2943 : {
2944 0 : str += "\n " + for_lifetime.to_string ();
2945 : }
2946 : }
2947 :
2948 4 : str += "\n Qualifiers: " + function_qualifiers.to_string ();
2949 :
2950 2 : str += "\n Params: ";
2951 2 : if (params.empty ())
2952 : {
2953 2 : str += "none";
2954 : }
2955 : else
2956 : {
2957 0 : for (const auto ¶m : params)
2958 : {
2959 0 : str += "\n " + param.to_string ();
2960 : }
2961 : }
2962 :
2963 2 : str += "\n Is variadic: ";
2964 2 : if (is_variadic)
2965 : {
2966 0 : str += "true";
2967 : }
2968 : else
2969 : {
2970 2 : str += "false";
2971 : }
2972 :
2973 2 : str += "\n Return type: ";
2974 2 : if (!has_return_type ())
2975 : {
2976 2 : str += "none (void)";
2977 : }
2978 : else
2979 : {
2980 0 : str += return_type->to_string ();
2981 : }
2982 :
2983 2 : return str;
2984 : }
2985 :
2986 : std::string
2987 1894 : TypePathSegmentGeneric::to_string () const
2988 : {
2989 5682 : return TypePathSegment::to_string () + "<" + generic_args.to_string () + ">";
2990 : }
2991 :
2992 : std::string
2993 0 : TypePathFunction::to_string () const
2994 : {
2995 0 : std::string str ("(");
2996 :
2997 0 : if (has_inputs ())
2998 : {
2999 : auto i = inputs.begin ();
3000 : auto e = inputs.end ();
3001 :
3002 0 : for (; i != e; i++)
3003 : {
3004 0 : str += (*i)->to_string ();
3005 0 : if (e != i + 1)
3006 0 : str += ", ";
3007 : }
3008 : }
3009 :
3010 0 : str += ")";
3011 :
3012 0 : if (has_return_type ())
3013 : {
3014 0 : str += " -> " + return_type->to_string ();
3015 : }
3016 :
3017 0 : return str;
3018 : }
3019 :
3020 : std::string
3021 0 : TypePathSegmentFunction::to_string () const
3022 : {
3023 0 : return TypePathSegment::to_string () + function_path.to_string ();
3024 : }
3025 :
3026 : std::string
3027 0 : ArrayType::to_string () const
3028 : {
3029 0 : return "[" + elem_type->to_string () + "; " + size->to_string () + "]";
3030 : }
3031 :
3032 : std::string
3033 28 : SliceType::to_string () const
3034 : {
3035 56 : return "[" + elem_type->to_string () + "]";
3036 : }
3037 :
3038 : std::string
3039 9 : TupleType::to_string () const
3040 : {
3041 9 : std::string str ("(");
3042 :
3043 9 : if (!is_unit_type ())
3044 : {
3045 : auto i = elems.begin ();
3046 : auto e = elems.end ();
3047 :
3048 5 : for (; i != e; i++)
3049 : {
3050 6 : str += (*i)->to_string ();
3051 3 : if (e != i + 1)
3052 1 : str += ", ";
3053 : }
3054 : }
3055 :
3056 9 : str += ")";
3057 :
3058 9 : return str;
3059 : }
3060 :
3061 : std::string
3062 0 : StructExpr::to_string () const
3063 : {
3064 0 : std::string str = ExprWithoutBlock::to_string ();
3065 0 : indent_spaces (enter);
3066 0 : str += "\n" + indent_spaces (stay) + "StructExpr:";
3067 0 : indent_spaces (enter);
3068 0 : str += "\n" + indent_spaces (stay) + "PathInExpr:\n";
3069 0 : str += indent_spaces (stay) + struct_name.to_string ();
3070 0 : indent_spaces (out);
3071 0 : indent_spaces (out);
3072 0 : return str;
3073 : }
3074 :
3075 : std::string
3076 0 : StructExprStruct::to_string () const
3077 : {
3078 0 : std::string str ("StructExprStruct (or subclass): ");
3079 :
3080 0 : str += "\n Path: " + struct_name.to_string ();
3081 :
3082 : // inner attributes
3083 0 : str += "\n inner attributes: ";
3084 0 : if (inner_attrs.empty ())
3085 : {
3086 0 : str += "none";
3087 : }
3088 : else
3089 : {
3090 : /* note that this does not print them with "inner attribute" syntax -
3091 : * just the body */
3092 0 : for (const auto &attr : inner_attrs)
3093 : {
3094 0 : str += "\n " + attr.as_string ();
3095 : }
3096 : }
3097 :
3098 0 : return str;
3099 : }
3100 :
3101 : std::string
3102 0 : StructBase::to_string () const
3103 : {
3104 0 : if (base_struct != nullptr)
3105 : {
3106 0 : return base_struct->to_string ();
3107 : }
3108 : else
3109 : {
3110 0 : return "ERROR_MARK_STRING - invalid struct base had as string applied";
3111 : }
3112 : }
3113 :
3114 : std::string
3115 0 : StructExprFieldWithVal::to_string () const
3116 : {
3117 : // used to get value string
3118 0 : return value->to_string ();
3119 : }
3120 :
3121 : std::string
3122 0 : StructExprFieldIdentifierValue::to_string () const
3123 : {
3124 0 : return field_name.as_string () + " : " + StructExprFieldWithVal::to_string ();
3125 : }
3126 :
3127 : std::string
3128 0 : StructExprFieldIndexValue::to_string () const
3129 : {
3130 0 : return std::to_string (index) + " : " + StructExprFieldWithVal::to_string ();
3131 : }
3132 :
3133 : std::string
3134 0 : StructExprStructFields::to_string () const
3135 : {
3136 0 : std::string str = StructExprStruct::to_string ();
3137 :
3138 0 : str += "\n Fields: ";
3139 0 : if (fields.empty ())
3140 : {
3141 0 : str += "none";
3142 : }
3143 : else
3144 : {
3145 0 : for (const auto &field : fields)
3146 : {
3147 0 : str += "\n " + field->to_string ();
3148 : }
3149 : }
3150 :
3151 0 : str += "\n Struct base: ";
3152 0 : if (!has_struct_base ())
3153 : {
3154 0 : str += "none";
3155 : }
3156 : else
3157 : {
3158 0 : str += (*struct_base)->to_string ();
3159 : }
3160 :
3161 0 : return str;
3162 : }
3163 :
3164 : std::string
3165 0 : EnumItem::to_string () const
3166 : {
3167 0 : std::string str = Item::to_string ();
3168 0 : str += variant_name.as_string ();
3169 0 : str += " ";
3170 0 : switch (get_enum_item_kind ())
3171 : {
3172 0 : case Named:
3173 0 : str += "[Named variant]";
3174 0 : break;
3175 0 : case Tuple:
3176 0 : str += "[Tuple variant]";
3177 0 : break;
3178 0 : case Struct:
3179 0 : str += "[Struct variant]";
3180 0 : break;
3181 0 : case Discriminant:
3182 0 : str += "[Discriminant variant]";
3183 0 : break;
3184 : }
3185 :
3186 0 : return str;
3187 : }
3188 :
3189 : std::string
3190 0 : EnumItemTuple::to_string () const
3191 : {
3192 0 : std::string str = EnumItem::to_string ();
3193 :
3194 : // add tuple opening parens
3195 0 : str += "(";
3196 :
3197 : // tuple fields
3198 0 : if (has_tuple_fields ())
3199 : {
3200 : auto i = tuple_fields.begin ();
3201 : auto e = tuple_fields.end ();
3202 :
3203 0 : for (; i != e; i++)
3204 : {
3205 0 : str += (*i).to_string ();
3206 0 : if (e != i + 1)
3207 0 : str += ", ";
3208 : }
3209 : }
3210 :
3211 : // add tuple closing parens
3212 0 : str += ")";
3213 :
3214 0 : return str;
3215 : }
3216 :
3217 : std::string
3218 0 : TupleField::to_string () const
3219 : {
3220 : // outer attributes
3221 0 : std::string str = "outer attributes: ";
3222 0 : if (outer_attrs.empty ())
3223 : {
3224 0 : str += "none";
3225 : }
3226 : else
3227 : {
3228 : /* note that this does not print them with "outer attribute" syntax -
3229 : * just the body */
3230 0 : for (const auto &attr : outer_attrs)
3231 : {
3232 0 : str += "\n " + attr.as_string ();
3233 : }
3234 : }
3235 :
3236 0 : if (has_visibility ())
3237 : {
3238 0 : str += "\n" + visibility.to_string ();
3239 : }
3240 :
3241 0 : str += " " + field_type->to_string ();
3242 :
3243 0 : return str;
3244 : }
3245 :
3246 : std::string
3247 0 : EnumItemStruct::to_string () const
3248 : {
3249 0 : std::string str = EnumItem::to_string ();
3250 :
3251 : // add struct opening parens
3252 0 : str += "{";
3253 :
3254 : // tuple fields
3255 0 : if (has_struct_fields ())
3256 : {
3257 : auto i = struct_fields.begin ();
3258 : auto e = struct_fields.end ();
3259 :
3260 0 : for (; i != e; i++)
3261 : {
3262 0 : str += (*i).to_string ();
3263 0 : if (e != i + 1)
3264 0 : str += ", ";
3265 : }
3266 : }
3267 :
3268 : // add struct closing parens
3269 0 : str += "}";
3270 :
3271 0 : return str;
3272 : }
3273 :
3274 : std::string
3275 0 : StructField::to_string () const
3276 : {
3277 : // outer attributes
3278 0 : std::string str = "outer attributes: ";
3279 0 : if (outer_attrs.empty ())
3280 : {
3281 0 : str += "none";
3282 : }
3283 : else
3284 : {
3285 : /* note that this does not print them with "outer attribute" syntax -
3286 : * just the body */
3287 0 : for (const auto &attr : outer_attrs)
3288 : {
3289 0 : str += "\n " + attr.as_string ();
3290 : }
3291 : }
3292 :
3293 0 : if (has_visibility ())
3294 : {
3295 0 : str += "\n" + visibility.to_string ();
3296 : }
3297 :
3298 0 : str += " " + field_name.as_string () + " : " + field_type->to_string ();
3299 :
3300 0 : return str;
3301 : }
3302 :
3303 : std::string
3304 0 : EnumItemDiscriminant::to_string () const
3305 : {
3306 0 : std::string str = EnumItem::to_string ();
3307 :
3308 : // add equal and expression
3309 0 : str += " = " + expression->to_string ();
3310 :
3311 0 : return str;
3312 : }
3313 :
3314 : std::string
3315 0 : ExternalItem::to_string () const
3316 : {
3317 : // outer attributes
3318 0 : std::string str = "outer attributes: ";
3319 0 : if (outer_attrs.empty ())
3320 : {
3321 0 : str += "none";
3322 : }
3323 : else
3324 : {
3325 : /* note that this does not print them with "outer attribute" syntax -
3326 : * just the body */
3327 0 : for (const auto &attr : outer_attrs)
3328 : {
3329 0 : str += "\n " + attr.as_string ();
3330 : }
3331 : }
3332 :
3333 : // start visibility on new line and with a space
3334 0 : str += "\n" + visibility.to_string () + " ";
3335 :
3336 0 : return str;
3337 : }
3338 :
3339 : std::string
3340 0 : ExternalStaticItem::to_string () const
3341 : {
3342 0 : std::string str = ExternalItem::to_string ();
3343 :
3344 0 : str += "static ";
3345 :
3346 0 : if (is_mut ())
3347 : {
3348 0 : str += "mut ";
3349 : }
3350 :
3351 : // add name
3352 0 : str += get_item_name ().as_string ();
3353 :
3354 : // add type on new line
3355 0 : str += "\n Type: " + item_type->to_string ();
3356 :
3357 0 : return str;
3358 : }
3359 :
3360 : std::string
3361 0 : ExternalFunctionItem::to_string () const
3362 : {
3363 0 : std::string str = ExternalItem::to_string ();
3364 :
3365 0 : str += "fn ";
3366 :
3367 : // add name
3368 0 : str += get_item_name ().as_string ();
3369 :
3370 : // generic params
3371 0 : str += "\n Generic params: ";
3372 0 : if (generic_params.empty ())
3373 : {
3374 0 : str += "none";
3375 : }
3376 : else
3377 : {
3378 0 : for (const auto ¶m : generic_params)
3379 : {
3380 : // DEBUG: null pointer check
3381 0 : if (param == nullptr)
3382 : {
3383 0 : rust_debug (
3384 : "something really terrible has gone wrong - null pointer "
3385 : "generic param in external function item.");
3386 0 : return "nullptr_POINTER_MARK";
3387 : }
3388 :
3389 0 : str += "\n " + param->to_string ();
3390 : }
3391 : }
3392 :
3393 : // function params
3394 0 : str += "\n Function params: ";
3395 0 : if (function_params.empty ())
3396 : {
3397 0 : str += "none";
3398 : }
3399 : else
3400 : {
3401 0 : for (const auto ¶m : function_params)
3402 : {
3403 0 : str += "\n " + param.to_string ();
3404 : }
3405 0 : if (has_variadics)
3406 : {
3407 0 : str += "\n .. (variadic)";
3408 : }
3409 : }
3410 :
3411 : // add type on new line)
3412 0 : str += "\n (return) Type: "
3413 0 : + (has_return_type () ? return_type->to_string () : "()");
3414 :
3415 : // where clause
3416 0 : str += "\n Where clause: ";
3417 0 : if (has_where_clause ())
3418 : {
3419 0 : str += where_clause.to_string ();
3420 : }
3421 : else
3422 : {
3423 0 : str += "none";
3424 : }
3425 :
3426 0 : return str;
3427 0 : }
3428 :
3429 : std::string
3430 0 : ExternalTypeItem::to_string () const
3431 : {
3432 0 : std::string str = ExternalItem::to_string ();
3433 :
3434 0 : str += "type ";
3435 :
3436 : // add name
3437 0 : str += get_item_name ().as_string ();
3438 :
3439 0 : return str;
3440 : }
3441 :
3442 : std::string
3443 0 : NamedFunctionParam::to_string () const
3444 : {
3445 0 : std::string str = name.as_string ();
3446 :
3447 0 : str += "\n Type: " + param_type->to_string ();
3448 :
3449 0 : return str;
3450 : }
3451 :
3452 : /*std::string TraitItem::to_string() const {
3453 : // outer attributes
3454 : std::string str = "outer attributes: ";
3455 : if (outer_attrs.empty()) {
3456 : str += "none";
3457 : } else {
3458 : // note that this does not print them with "outer attribute" syntax -
3459 : just the body for (const auto& attr : outer_attrs) { str += "\n " +
3460 : attr.to_string();
3461 : }
3462 : }
3463 :
3464 : return str;
3465 : }*/
3466 :
3467 : std::string
3468 0 : TraitItemFunc::to_string () const
3469 : {
3470 0 : std::string str = "outer attributes: ";
3471 0 : if (outer_attrs.empty ())
3472 : {
3473 0 : str += "none";
3474 : }
3475 : else
3476 : {
3477 : /* note that this does not print them with "outer attribute" syntax -
3478 : * just the body */
3479 0 : for (const auto &attr : outer_attrs)
3480 : {
3481 0 : str += "\n " + attr.as_string ();
3482 : }
3483 : }
3484 :
3485 0 : str += "\n" + decl.to_string ();
3486 :
3487 0 : str += "\n Definition (block expr): ";
3488 0 : if (has_definition ())
3489 : {
3490 0 : str += block_expr->to_string ();
3491 : }
3492 : else
3493 : {
3494 0 : str += "none";
3495 : }
3496 :
3497 0 : return str;
3498 : }
3499 :
3500 : std::string
3501 0 : TraitFunctionDecl::to_string () const
3502 : {
3503 0 : std::string str
3504 0 : = qualifiers.to_string () + "fn " + function_name.as_string ();
3505 :
3506 : // generic params
3507 0 : str += "\n Generic params: ";
3508 0 : if (generic_params.empty ())
3509 : {
3510 0 : str += "none";
3511 : }
3512 : else
3513 : {
3514 0 : for (const auto ¶m : generic_params)
3515 : {
3516 : // DEBUG: null pointer check
3517 0 : if (param == nullptr)
3518 : {
3519 0 : rust_debug (
3520 : "something really terrible has gone wrong - null pointer "
3521 : "generic param in trait function decl.");
3522 0 : return "nullptr_POINTER_MARK";
3523 : }
3524 :
3525 0 : str += "\n " + param->to_string ();
3526 : }
3527 : }
3528 :
3529 0 : str += "\n Function params: ";
3530 0 : if (is_method ())
3531 : {
3532 0 : str += get_self_unchecked ().to_string () + (has_params () ? ", " : "");
3533 : }
3534 :
3535 0 : if (has_params ())
3536 : {
3537 0 : for (const auto ¶m : function_params)
3538 : {
3539 0 : str += "\n " + param.to_string ();
3540 : }
3541 : }
3542 0 : else if (!is_method ())
3543 : {
3544 0 : str += "none";
3545 : }
3546 :
3547 0 : str += "\n Return type: ";
3548 0 : if (has_return_type ())
3549 : {
3550 0 : str += return_type->to_string ();
3551 : }
3552 : else
3553 : {
3554 0 : str += "none (void)";
3555 : }
3556 :
3557 0 : str += "\n Where clause: ";
3558 0 : if (has_where_clause ())
3559 : {
3560 0 : str += where_clause.to_string ();
3561 : }
3562 : else
3563 : {
3564 0 : str += "none";
3565 : }
3566 :
3567 0 : return str;
3568 0 : }
3569 :
3570 : std::string
3571 0 : TraitItemConst::to_string () const
3572 : {
3573 0 : std::string str = "outer attributes: ";
3574 0 : if (outer_attrs.empty ())
3575 : {
3576 0 : str += "none";
3577 : }
3578 : else
3579 : {
3580 : /* note that this does not print them with "outer attribute" syntax -
3581 : * just the body */
3582 0 : for (const auto &attr : outer_attrs)
3583 : {
3584 0 : str += "\n " + attr.as_string ();
3585 : }
3586 : }
3587 :
3588 0 : str += "\nconst " + name.as_string () + " : " + type->to_string ();
3589 :
3590 0 : if (has_expression ())
3591 : {
3592 0 : str += " = " + expr->to_string ();
3593 : }
3594 :
3595 0 : return str;
3596 : }
3597 :
3598 : std::string
3599 0 : TraitItemType::to_string () const
3600 : {
3601 0 : std::string str = "outer attributes: ";
3602 0 : if (outer_attrs.empty ())
3603 : {
3604 0 : str += "none";
3605 : }
3606 : else
3607 : {
3608 : /* note that this does not print them with "outer attribute" syntax -
3609 : * just the body */
3610 0 : for (const auto &attr : outer_attrs)
3611 : {
3612 0 : str += "\n " + attr.as_string ();
3613 : }
3614 : }
3615 :
3616 0 : str += "\ntype " + name.as_string ();
3617 :
3618 0 : if (has_generics ())
3619 : {
3620 0 : str += "<";
3621 0 : for (size_t i = 0; i < generic_params.size (); i++)
3622 : {
3623 0 : if (i > 0)
3624 0 : str += ", ";
3625 0 : str += generic_params[i]->to_string ();
3626 : }
3627 0 : str += ">";
3628 : }
3629 :
3630 0 : str += "\n Type param bounds: ";
3631 0 : if (!has_type_param_bounds ())
3632 : {
3633 0 : str += "none";
3634 : }
3635 : else
3636 : {
3637 0 : for (const auto &bound : type_param_bounds)
3638 : {
3639 : // DEBUG: null pointer check
3640 0 : if (bound == nullptr)
3641 : {
3642 0 : rust_debug (
3643 : "something really terrible has gone wrong - null pointer "
3644 : "type param bound in trait item type.");
3645 0 : return "nullptr_POINTER_MARK";
3646 : }
3647 :
3648 0 : str += "\n " + bound->to_string ();
3649 : }
3650 : }
3651 :
3652 0 : return str;
3653 0 : }
3654 :
3655 : std::string
3656 0 : SelfParam::to_string () const
3657 : {
3658 0 : if (has_type ())
3659 : {
3660 : // type (i.e. not ref, no lifetime)
3661 0 : std::string str;
3662 :
3663 0 : if (is_mut ())
3664 : {
3665 0 : str += "mut ";
3666 : }
3667 :
3668 0 : str += "self : ";
3669 :
3670 0 : str += type->to_string ();
3671 :
3672 0 : return str;
3673 : }
3674 0 : else if (has_lifetime ())
3675 : {
3676 : // ref and lifetime
3677 0 : std::string str = "&" + get_lifetime ().to_string () + " ";
3678 :
3679 0 : if (is_mut ())
3680 : {
3681 0 : str += "mut ";
3682 : }
3683 :
3684 0 : str += "self";
3685 :
3686 0 : return str;
3687 0 : }
3688 0 : else if (is_ref ())
3689 : {
3690 : // ref with no lifetime
3691 0 : std::string str = "&";
3692 :
3693 0 : if (is_mut ())
3694 : {
3695 0 : str += " mut ";
3696 : }
3697 :
3698 0 : str += "self";
3699 :
3700 0 : return str;
3701 0 : }
3702 : else
3703 : {
3704 : // no ref, no type
3705 0 : std::string str;
3706 :
3707 0 : if (is_mut ())
3708 : {
3709 0 : str += "mut ";
3710 : }
3711 :
3712 0 : str += "self";
3713 :
3714 0 : return str;
3715 0 : }
3716 : }
3717 :
3718 : std::string
3719 0 : ArrayElemsCopied::to_string () const
3720 : {
3721 0 : return elem_to_copy->to_string () + "; " + num_copies->to_string ();
3722 : }
3723 :
3724 : std::string
3725 0 : LifetimeWhereClauseItem::to_string () const
3726 : {
3727 0 : std::string str ("Lifetime: ");
3728 :
3729 0 : str += lifetime.to_string ();
3730 :
3731 0 : str += "\nLifetime bounds: ";
3732 :
3733 0 : for (const auto &bound : lifetime_bounds)
3734 : {
3735 0 : str += "\n " + bound.to_string ();
3736 : }
3737 :
3738 0 : return str;
3739 : }
3740 :
3741 : std::string
3742 0 : TypeBoundWhereClauseItem::to_string () const
3743 : {
3744 0 : std::string str ("For lifetimes: ");
3745 :
3746 0 : if (!has_for_lifetimes ())
3747 : {
3748 0 : str += "none";
3749 : }
3750 : else
3751 : {
3752 0 : for (const auto &for_lifetime : for_lifetimes)
3753 : {
3754 0 : str += "\n " + for_lifetime.to_string ();
3755 : }
3756 : }
3757 :
3758 0 : str += "\nType: " + bound_type->to_string ();
3759 :
3760 0 : str += "\nType param bounds bounds: ";
3761 :
3762 0 : for (const auto &bound : type_param_bounds)
3763 : {
3764 : // debug null pointer check
3765 0 : if (bound == nullptr)
3766 : {
3767 0 : return "nullptr_POINTER_MARK - type param bounds";
3768 : }
3769 :
3770 0 : str += "\n " + bound->to_string ();
3771 : }
3772 :
3773 0 : return str;
3774 0 : }
3775 :
3776 : std::string
3777 0 : ArrayElemsValues::to_string () const
3778 : {
3779 0 : std::string str;
3780 :
3781 0 : for (const auto &expr : values)
3782 : {
3783 : // DEBUG: null pointer check
3784 0 : if (expr == nullptr)
3785 : {
3786 0 : rust_debug ("something really terrible has gone wrong - null pointer "
3787 : "expr in array elems values.");
3788 0 : return "nullptr_POINTER_MARK";
3789 : }
3790 :
3791 0 : str += "\n " + expr->to_string ();
3792 : }
3793 :
3794 0 : return str;
3795 0 : }
3796 :
3797 : std::string
3798 0 : MaybeNamedParam::to_string () const
3799 : {
3800 0 : std::string str;
3801 :
3802 0 : switch (param_kind)
3803 : {
3804 : case UNNAMED:
3805 : break;
3806 0 : case IDENTIFIER:
3807 0 : str = name.as_string () + " : ";
3808 0 : break;
3809 0 : case WILDCARD:
3810 0 : str = "_ : ";
3811 0 : break;
3812 0 : default:
3813 0 : return "ERROR_MARK_STRING - maybe named param unrecognised param kind";
3814 : }
3815 :
3816 0 : str += param_type->to_string ();
3817 :
3818 0 : return str;
3819 0 : }
3820 :
3821 : std::string
3822 0 : enum_to_str (MaybeNamedParam::ParamKind pk)
3823 : {
3824 0 : switch (pk)
3825 : {
3826 0 : case MaybeNamedParam::ParamKind::UNNAMED:
3827 0 : return "UNNAMED";
3828 0 : case MaybeNamedParam::ParamKind::IDENTIFIER:
3829 0 : return "IDENTIFIER";
3830 0 : case MaybeNamedParam::ParamKind::WILDCARD:
3831 0 : return "WILDCARD";
3832 : }
3833 0 : gcc_unreachable ();
3834 : }
3835 :
3836 : std::string
3837 0 : enum_to_str (UseTreeRebind::NewBindType nbt)
3838 : {
3839 0 : switch (nbt)
3840 : {
3841 0 : case UseTreeRebind::NewBindType::NONE:
3842 0 : return "NONE";
3843 0 : case UseTreeRebind::NewBindType::IDENTIFIER:
3844 0 : return "IDENTIFIER";
3845 0 : case UseTreeRebind::NewBindType::WILDCARD:
3846 0 : return "WILDCARD";
3847 : }
3848 0 : gcc_unreachable ();
3849 : }
3850 :
3851 : /* Override that calls the function recursively on all items contained within
3852 : * the module. */
3853 : void
3854 0 : Module::add_crate_name (std::vector<std::string> &names) const
3855 : {
3856 : /* TODO: test whether module has been 'cfg'-ed out to determine whether to
3857 : * exclude it from search */
3858 :
3859 0 : for (const auto &item : items)
3860 0 : item->add_crate_name (names);
3861 0 : }
3862 :
3863 : /* All accept_vis method below */
3864 :
3865 : void
3866 5855 : Lifetime::accept_vis (HIRFullVisitor &vis)
3867 : {
3868 5855 : vis.visit (*this);
3869 5855 : }
3870 :
3871 : void
3872 173 : LifetimeParam::accept_vis (HIRFullVisitor &vis)
3873 : {
3874 173 : vis.visit (*this);
3875 173 : }
3876 :
3877 : void
3878 168287 : PathInExpression::accept_vis (HIRFullVisitor &vis)
3879 : {
3880 168287 : vis.visit (*this);
3881 168287 : }
3882 : void
3883 129523 : PathInExpression::accept_vis (HIRExpressionVisitor &vis)
3884 : {
3885 129523 : vis.visit (*this);
3886 129523 : }
3887 :
3888 : void
3889 44946 : TypePathSegment::accept_vis (HIRFullVisitor &vis)
3890 : {
3891 44946 : vis.visit (*this);
3892 44946 : }
3893 :
3894 : void
3895 2307 : TypePathSegmentGeneric::accept_vis (HIRFullVisitor &vis)
3896 : {
3897 2307 : vis.visit (*this);
3898 2307 : }
3899 :
3900 : void
3901 27 : TypePathSegmentFunction::accept_vis (HIRFullVisitor &vis)
3902 : {
3903 27 : vis.visit (*this);
3904 27 : }
3905 :
3906 : void
3907 48846 : TypePath::accept_vis (HIRFullVisitor &vis)
3908 : {
3909 48846 : vis.visit (*this);
3910 48846 : }
3911 :
3912 : void
3913 195 : QualifiedPathInExpression::accept_vis (HIRFullVisitor &vis)
3914 : {
3915 195 : vis.visit (*this);
3916 195 : }
3917 : void
3918 333 : QualifiedPathInExpression::accept_vis (HIRExpressionVisitor &vis)
3919 : {
3920 333 : vis.visit (*this);
3921 333 : }
3922 :
3923 : void
3924 199 : QualifiedPathInType::accept_vis (HIRFullVisitor &vis)
3925 : {
3926 199 : vis.visit (*this);
3927 199 : }
3928 :
3929 : void
3930 79127 : LiteralExpr::accept_vis (HIRFullVisitor &vis)
3931 : {
3932 79127 : vis.visit (*this);
3933 79127 : }
3934 :
3935 : void
3936 56095 : LiteralExpr::accept_vis (HIRExpressionVisitor &vis)
3937 : {
3938 56095 : vis.visit (*this);
3939 56095 : }
3940 :
3941 : void
3942 8643 : BorrowExpr::accept_vis (HIRFullVisitor &vis)
3943 : {
3944 8643 : vis.visit (*this);
3945 8643 : }
3946 :
3947 : void
3948 80 : InlineAsm::accept_vis (HIRExpressionVisitor &vis)
3949 : {
3950 80 : vis.visit (*this);
3951 80 : }
3952 :
3953 : void
3954 131 : InlineAsm::accept_vis (HIRFullVisitor &vis)
3955 : {
3956 131 : vis.visit (*this);
3957 131 : }
3958 :
3959 : void
3960 12 : LlvmInlineAsm::accept_vis (HIRFullVisitor &vis)
3961 : {
3962 12 : vis.visit (*this);
3963 12 : }
3964 : void
3965 6 : LlvmInlineAsm::accept_vis (HIRExpressionVisitor &vis)
3966 : {
3967 6 : vis.visit (*this);
3968 6 : }
3969 :
3970 : void
3971 5362 : BorrowExpr::accept_vis (HIRExpressionVisitor &vis)
3972 : {
3973 5362 : vis.visit (*this);
3974 5362 : }
3975 :
3976 : void
3977 15789 : DereferenceExpr::accept_vis (HIRFullVisitor &vis)
3978 : {
3979 15789 : vis.visit (*this);
3980 15789 : }
3981 :
3982 : void
3983 11400 : DereferenceExpr::accept_vis (HIRExpressionVisitor &vis)
3984 : {
3985 11400 : vis.visit (*this);
3986 11400 : }
3987 :
3988 : void
3989 0 : ErrorPropagationExpr::accept_vis (HIRFullVisitor &vis)
3990 : {
3991 0 : vis.visit (*this);
3992 0 : }
3993 :
3994 : void
3995 0 : ErrorPropagationExpr::accept_vis (HIRExpressionVisitor &vis)
3996 : {
3997 0 : vis.visit (*this);
3998 0 : }
3999 :
4000 : void
4001 1995 : NegationExpr::accept_vis (HIRFullVisitor &vis)
4002 : {
4003 1995 : vis.visit (*this);
4004 1995 : }
4005 :
4006 : void
4007 1513 : NegationExpr::accept_vis (HIRExpressionVisitor &vis)
4008 : {
4009 1513 : vis.visit (*this);
4010 1513 : }
4011 :
4012 : void
4013 14780 : ArithmeticOrLogicalExpr::accept_vis (HIRFullVisitor &vis)
4014 : {
4015 14780 : vis.visit (*this);
4016 14780 : }
4017 :
4018 : void
4019 9883 : ArithmeticOrLogicalExpr::accept_vis (HIRExpressionVisitor &vis)
4020 : {
4021 9883 : vis.visit (*this);
4022 9883 : }
4023 :
4024 : void
4025 12858 : ComparisonExpr::accept_vis (HIRFullVisitor &vis)
4026 : {
4027 12858 : vis.visit (*this);
4028 12858 : }
4029 :
4030 : void
4031 7725 : ComparisonExpr::accept_vis (HIRExpressionVisitor &vis)
4032 : {
4033 7725 : vis.visit (*this);
4034 7725 : }
4035 :
4036 : void
4037 2390 : LazyBooleanExpr::accept_vis (HIRFullVisitor &vis)
4038 : {
4039 2390 : vis.visit (*this);
4040 2390 : }
4041 :
4042 : void
4043 1101 : LazyBooleanExpr::accept_vis (HIRExpressionVisitor &vis)
4044 : {
4045 1101 : vis.visit (*this);
4046 1101 : }
4047 :
4048 : void
4049 27356 : TypeCastExpr::accept_vis (HIRFullVisitor &vis)
4050 : {
4051 27356 : vis.visit (*this);
4052 27356 : }
4053 :
4054 : void
4055 14149 : TypeCastExpr::accept_vis (HIRExpressionVisitor &vis)
4056 : {
4057 14149 : vis.visit (*this);
4058 14149 : }
4059 :
4060 : void
4061 12178 : AssignmentExpr::accept_vis (HIRFullVisitor &vis)
4062 : {
4063 12178 : vis.visit (*this);
4064 12178 : }
4065 :
4066 : void
4067 7275 : AssignmentExpr::accept_vis (HIRExpressionVisitor &vis)
4068 : {
4069 7275 : vis.visit (*this);
4070 7275 : }
4071 :
4072 : void
4073 3200 : CompoundAssignmentExpr::accept_vis (HIRFullVisitor &vis)
4074 : {
4075 3200 : vis.visit (*this);
4076 3200 : }
4077 :
4078 : void
4079 2012 : CompoundAssignmentExpr::accept_vis (HIRExpressionVisitor &vis)
4080 : {
4081 2012 : vis.visit (*this);
4082 2012 : }
4083 :
4084 : void
4085 1462 : GroupedExpr::accept_vis (HIRFullVisitor &vis)
4086 : {
4087 1462 : vis.visit (*this);
4088 1462 : }
4089 :
4090 : void
4091 941 : GroupedExpr::accept_vis (HIRExpressionVisitor &vis)
4092 : {
4093 941 : vis.visit (*this);
4094 941 : }
4095 :
4096 : void
4097 1150 : ArrayElemsValues::accept_vis (HIRFullVisitor &vis)
4098 : {
4099 1150 : vis.visit (*this);
4100 1150 : }
4101 :
4102 : void
4103 464 : ArrayElemsCopied::accept_vis (HIRFullVisitor &vis)
4104 : {
4105 464 : vis.visit (*this);
4106 464 : }
4107 :
4108 : void
4109 1614 : ArrayExpr::accept_vis (HIRFullVisitor &vis)
4110 : {
4111 1614 : vis.visit (*this);
4112 1614 : }
4113 :
4114 : void
4115 1080 : ArrayIndexExpr::accept_vis (HIRFullVisitor &vis)
4116 : {
4117 1080 : vis.visit (*this);
4118 1080 : }
4119 :
4120 : void
4121 2439 : TupleExpr::accept_vis (HIRFullVisitor &vis)
4122 : {
4123 2439 : vis.visit (*this);
4124 2439 : }
4125 :
4126 : void
4127 3755 : TupleIndexExpr::accept_vis (HIRFullVisitor &vis)
4128 : {
4129 3755 : vis.visit (*this);
4130 3755 : }
4131 :
4132 : void
4133 327 : StructExprStruct::accept_vis (HIRFullVisitor &vis)
4134 : {
4135 327 : vis.visit (*this);
4136 327 : }
4137 :
4138 : void
4139 168 : StructExprFieldIndexValue::accept_vis (HIRFullVisitor &vis)
4140 : {
4141 168 : vis.visit (*this);
4142 168 : }
4143 :
4144 : void
4145 5321 : StructExprStructFields::accept_vis (HIRFullVisitor &vis)
4146 : {
4147 5321 : vis.visit (*this);
4148 5321 : }
4149 :
4150 : void
4151 0 : StructExprStructBase::accept_vis (HIRFullVisitor &vis)
4152 : {
4153 0 : vis.visit (*this);
4154 0 : }
4155 :
4156 : void
4157 0 : StructExprStructBase::accept_vis (HIRExpressionVisitor &vis)
4158 : {
4159 0 : vis.visit (*this);
4160 0 : }
4161 :
4162 : void
4163 52177 : CallExpr::accept_vis (HIRFullVisitor &vis)
4164 : {
4165 52177 : vis.visit (*this);
4166 52177 : }
4167 :
4168 : void
4169 11586 : MethodCallExpr::accept_vis (HIRFullVisitor &vis)
4170 : {
4171 11586 : vis.visit (*this);
4172 11586 : }
4173 :
4174 : void
4175 23292 : FieldAccessExpr::accept_vis (HIRFullVisitor &vis)
4176 : {
4177 23292 : vis.visit (*this);
4178 23292 : }
4179 :
4180 : void
4181 232 : ClosureExpr::accept_vis (HIRFullVisitor &vis)
4182 : {
4183 232 : vis.visit (*this);
4184 232 : }
4185 :
4186 : void
4187 105587 : BlockExpr::accept_vis (HIRFullVisitor &vis)
4188 : {
4189 105587 : vis.visit (*this);
4190 105587 : }
4191 :
4192 : void
4193 884 : AnonConst::accept_vis (HIRFullVisitor &vis)
4194 : {
4195 884 : vis.visit (*this);
4196 884 : }
4197 :
4198 : void
4199 59 : ConstBlock::accept_vis (HIRFullVisitor &vis)
4200 : {
4201 59 : vis.visit (*this);
4202 59 : }
4203 :
4204 : void
4205 63 : ContinueExpr::accept_vis (HIRFullVisitor &vis)
4206 : {
4207 63 : vis.visit (*this);
4208 63 : }
4209 :
4210 : void
4211 379 : BreakExpr::accept_vis (HIRFullVisitor &vis)
4212 : {
4213 379 : vis.visit (*this);
4214 379 : }
4215 :
4216 : void
4217 257 : RangeFromToExpr::accept_vis (HIRFullVisitor &vis)
4218 : {
4219 257 : vis.visit (*this);
4220 257 : }
4221 :
4222 : void
4223 21 : RangeFromExpr::accept_vis (HIRFullVisitor &vis)
4224 : {
4225 21 : vis.visit (*this);
4226 21 : }
4227 :
4228 : void
4229 21 : RangeToExpr::accept_vis (HIRFullVisitor &vis)
4230 : {
4231 21 : vis.visit (*this);
4232 21 : }
4233 :
4234 : void
4235 0 : RangeFullExpr::accept_vis (HIRFullVisitor &vis)
4236 : {
4237 0 : vis.visit (*this);
4238 0 : }
4239 :
4240 : void
4241 21 : RangeFromToInclExpr::accept_vis (HIRFullVisitor &vis)
4242 : {
4243 21 : vis.visit (*this);
4244 21 : }
4245 :
4246 : void
4247 0 : RangeToInclExpr::accept_vis (HIRFullVisitor &vis)
4248 : {
4249 0 : vis.visit (*this);
4250 0 : }
4251 :
4252 : void
4253 3078 : ReturnExpr::accept_vis (HIRFullVisitor &vis)
4254 : {
4255 3078 : vis.visit (*this);
4256 3078 : }
4257 :
4258 : void
4259 18625 : UnsafeBlockExpr::accept_vis (HIRFullVisitor &vis)
4260 : {
4261 18625 : vis.visit (*this);
4262 18625 : }
4263 :
4264 : void
4265 594 : LoopExpr::accept_vis (HIRFullVisitor &vis)
4266 : {
4267 594 : vis.visit (*this);
4268 594 : }
4269 :
4270 : void
4271 417 : WhileLoopExpr::accept_vis (HIRFullVisitor &vis)
4272 : {
4273 417 : vis.visit (*this);
4274 417 : }
4275 :
4276 : void
4277 0 : WhileLetLoopExpr::accept_vis (HIRFullVisitor &vis)
4278 : {
4279 0 : vis.visit (*this);
4280 0 : }
4281 :
4282 : void
4283 3540 : IfExpr::accept_vis (HIRFullVisitor &vis)
4284 : {
4285 3540 : vis.visit (*this);
4286 3540 : }
4287 :
4288 : void
4289 5515 : IfExprConseqElse::accept_vis (HIRFullVisitor &vis)
4290 : {
4291 5515 : vis.visit (*this);
4292 5515 : }
4293 :
4294 : void
4295 5479 : MatchExpr::accept_vis (HIRFullVisitor &vis)
4296 : {
4297 5479 : vis.visit (*this);
4298 5479 : }
4299 :
4300 : void
4301 0 : AwaitExpr::accept_vis (HIRFullVisitor &vis)
4302 : {
4303 0 : vis.visit (*this);
4304 0 : }
4305 :
4306 : void
4307 0 : AsyncBlockExpr::accept_vis (HIRFullVisitor &vis)
4308 : {
4309 0 : vis.visit (*this);
4310 0 : }
4311 :
4312 : void
4313 7727 : TypeParam::accept_vis (HIRFullVisitor &vis)
4314 : {
4315 7727 : vis.visit (*this);
4316 7727 : }
4317 :
4318 : void
4319 0 : LifetimeWhereClauseItem::accept_vis (HIRFullVisitor &vis)
4320 : {
4321 0 : vis.visit (*this);
4322 0 : }
4323 :
4324 : void
4325 139 : TypeBoundWhereClauseItem::accept_vis (HIRFullVisitor &vis)
4326 : {
4327 139 : vis.visit (*this);
4328 139 : }
4329 :
4330 : void
4331 7338 : Module::accept_vis (HIRFullVisitor &vis)
4332 : {
4333 7338 : vis.visit (*this);
4334 7338 : }
4335 :
4336 : void
4337 2362 : Module::accept_vis (HIRStmtVisitor &vis)
4338 : {
4339 2362 : vis.visit (*this);
4340 2362 : }
4341 :
4342 : void
4343 4818 : Module::accept_vis (HIRVisItemVisitor &vis)
4344 : {
4345 4818 : vis.visit (*this);
4346 4817 : }
4347 :
4348 : void
4349 0 : ExternCrate::accept_vis (HIRFullVisitor &vis)
4350 : {
4351 0 : vis.visit (*this);
4352 0 : }
4353 :
4354 : void
4355 0 : UseTreeGlob::accept_vis (HIRFullVisitor &vis)
4356 : {
4357 0 : vis.visit (*this);
4358 0 : }
4359 :
4360 : void
4361 0 : UseTreeList::accept_vis (HIRFullVisitor &vis)
4362 : {
4363 0 : vis.visit (*this);
4364 0 : }
4365 :
4366 : void
4367 0 : UseTreeRebind::accept_vis (HIRFullVisitor &vis)
4368 : {
4369 0 : vis.visit (*this);
4370 0 : }
4371 :
4372 : void
4373 0 : UseDeclaration::accept_vis (HIRFullVisitor &vis)
4374 : {
4375 0 : vis.visit (*this);
4376 0 : }
4377 :
4378 : void
4379 80851 : Function::accept_vis (HIRFullVisitor &vis)
4380 : {
4381 80851 : vis.visit (*this);
4382 80851 : }
4383 :
4384 : void
4385 6114 : TypeAlias::accept_vis (HIRFullVisitor &vis)
4386 : {
4387 6114 : vis.visit (*this);
4388 6114 : }
4389 :
4390 : void
4391 10866 : StructStruct::accept_vis (HIRFullVisitor &vis)
4392 : {
4393 10866 : vis.visit (*this);
4394 10866 : }
4395 :
4396 : void
4397 7326 : TupleStruct::accept_vis (HIRFullVisitor &vis)
4398 : {
4399 7326 : vis.visit (*this);
4400 7326 : }
4401 :
4402 : void
4403 1543 : EnumItem::accept_vis (HIRFullVisitor &vis)
4404 : {
4405 1543 : vis.visit (*this);
4406 1543 : }
4407 :
4408 : void
4409 777 : EnumItemTuple::accept_vis (HIRFullVisitor &vis)
4410 : {
4411 777 : vis.visit (*this);
4412 777 : }
4413 :
4414 : void
4415 158 : EnumItemStruct::accept_vis (HIRFullVisitor &vis)
4416 : {
4417 158 : vis.visit (*this);
4418 158 : }
4419 :
4420 : void
4421 537 : EnumItemDiscriminant::accept_vis (HIRFullVisitor &vis)
4422 : {
4423 537 : vis.visit (*this);
4424 537 : }
4425 :
4426 : void
4427 3379 : Enum::accept_vis (HIRFullVisitor &vis)
4428 : {
4429 3379 : vis.visit (*this);
4430 3379 : }
4431 :
4432 : void
4433 692 : Union::accept_vis (HIRFullVisitor &vis)
4434 : {
4435 692 : vis.visit (*this);
4436 692 : }
4437 :
4438 : void
4439 3682 : ConstantItem::accept_vis (HIRFullVisitor &vis)
4440 : {
4441 3682 : vis.visit (*this);
4442 3682 : }
4443 :
4444 : void
4445 350 : StaticItem::accept_vis (HIRFullVisitor &vis)
4446 : {
4447 350 : vis.visit (*this);
4448 350 : }
4449 :
4450 : void
4451 9874 : TraitItemFunc::accept_vis (HIRFullVisitor &vis)
4452 : {
4453 9874 : vis.visit (*this);
4454 9874 : }
4455 :
4456 : void
4457 123 : TraitItemConst::accept_vis (HIRFullVisitor &vis)
4458 : {
4459 123 : vis.visit (*this);
4460 123 : }
4461 :
4462 : void
4463 2836 : TraitItemType::accept_vis (HIRFullVisitor &vis)
4464 : {
4465 2836 : vis.visit (*this);
4466 2836 : }
4467 :
4468 : void
4469 21220 : Trait::accept_vis (HIRFullVisitor &vis)
4470 : {
4471 21220 : vis.visit (*this);
4472 21220 : }
4473 :
4474 : void
4475 31125 : ImplBlock::accept_vis (HIRFullVisitor &vis)
4476 : {
4477 31125 : vis.visit (*this);
4478 31125 : }
4479 :
4480 : void
4481 3 : ExternalStaticItem::accept_vis (HIRFullVisitor &vis)
4482 : {
4483 3 : vis.visit (*this);
4484 3 : }
4485 :
4486 : void
4487 8758 : ExternalFunctionItem::accept_vis (HIRFullVisitor &vis)
4488 : {
4489 8758 : vis.visit (*this);
4490 8758 : }
4491 :
4492 : void
4493 0 : ExternalTypeItem::accept_vis (HIRFullVisitor &vis)
4494 : {
4495 0 : vis.visit (*this);
4496 0 : }
4497 :
4498 : void
4499 8714 : ExternBlock::accept_vis (HIRFullVisitor &vis)
4500 : {
4501 8714 : vis.visit (*this);
4502 8714 : }
4503 :
4504 : void
4505 405 : LiteralPattern::accept_vis (HIRFullVisitor &vis)
4506 : {
4507 405 : vis.visit (*this);
4508 405 : }
4509 :
4510 : void
4511 8322 : IdentifierPattern::accept_vis (HIRFullVisitor &vis)
4512 : {
4513 8322 : vis.visit (*this);
4514 8322 : }
4515 :
4516 : void
4517 739 : WildcardPattern::accept_vis (HIRFullVisitor &vis)
4518 : {
4519 739 : vis.visit (*this);
4520 739 : }
4521 :
4522 : void
4523 53 : RangePatternBoundLiteral::accept_vis (HIRFullVisitor &vis)
4524 : {
4525 53 : vis.visit (*this);
4526 53 : }
4527 :
4528 : void
4529 21 : RangePatternBoundPath::accept_vis (HIRFullVisitor &vis)
4530 : {
4531 21 : vis.visit (*this);
4532 21 : }
4533 :
4534 : void
4535 0 : RangePatternBoundQualPath::accept_vis (HIRFullVisitor &vis)
4536 : {
4537 0 : vis.visit (*this);
4538 0 : }
4539 :
4540 : void
4541 37 : RangePattern::accept_vis (HIRFullVisitor &vis)
4542 : {
4543 37 : vis.visit (*this);
4544 37 : }
4545 :
4546 : void
4547 173 : ReferencePattern::accept_vis (HIRFullVisitor &vis)
4548 : {
4549 173 : vis.visit (*this);
4550 173 : }
4551 :
4552 : void
4553 18 : StructPatternFieldTuplePat::accept_vis (HIRFullVisitor &vis)
4554 : {
4555 18 : vis.visit (*this);
4556 18 : }
4557 :
4558 : void
4559 114 : StructPatternFieldIdentPat::accept_vis (HIRFullVisitor &vis)
4560 : {
4561 114 : vis.visit (*this);
4562 114 : }
4563 :
4564 : void
4565 95 : StructPatternFieldIdent::accept_vis (HIRFullVisitor &vis)
4566 : {
4567 95 : vis.visit (*this);
4568 95 : }
4569 :
4570 : void
4571 134 : StructPattern::accept_vis (HIRFullVisitor &vis)
4572 : {
4573 134 : vis.visit (*this);
4574 134 : }
4575 :
4576 : void
4577 878 : TupleStructItemsNoRest::accept_vis (HIRFullVisitor &vis)
4578 : {
4579 878 : vis.visit (*this);
4580 878 : }
4581 :
4582 : void
4583 36 : TupleStructItemsHasRest::accept_vis (HIRFullVisitor &vis)
4584 : {
4585 36 : vis.visit (*this);
4586 36 : }
4587 :
4588 : void
4589 914 : TupleStructPattern::accept_vis (HIRFullVisitor &vis)
4590 : {
4591 914 : vis.visit (*this);
4592 914 : }
4593 :
4594 : void
4595 100 : TuplePatternItemsNoRest::accept_vis (HIRFullVisitor &vis)
4596 : {
4597 100 : vis.visit (*this);
4598 100 : }
4599 :
4600 : void
4601 22 : TuplePatternItemsHasRest::accept_vis (HIRFullVisitor &vis)
4602 : {
4603 22 : vis.visit (*this);
4604 22 : }
4605 :
4606 : void
4607 122 : TuplePattern::accept_vis (HIRFullVisitor &vis)
4608 : {
4609 122 : vis.visit (*this);
4610 122 : }
4611 :
4612 : void
4613 31 : SlicePatternItemsNoRest::accept_vis (HIRFullVisitor &vis)
4614 : {
4615 31 : vis.visit (*this);
4616 31 : }
4617 :
4618 : void
4619 44 : SlicePatternItemsHasRest::accept_vis (HIRFullVisitor &vis)
4620 : {
4621 44 : vis.visit (*this);
4622 44 : }
4623 :
4624 : void
4625 75 : SlicePattern::accept_vis (HIRFullVisitor &vis)
4626 : {
4627 75 : vis.visit (*this);
4628 75 : }
4629 :
4630 : void
4631 145 : AltPattern::accept_vis (HIRFullVisitor &vis)
4632 : {
4633 145 : vis.visit (*this);
4634 145 : }
4635 :
4636 : void
4637 226 : EmptyStmt::accept_vis (HIRFullVisitor &vis)
4638 : {
4639 226 : vis.visit (*this);
4640 226 : }
4641 :
4642 : void
4643 64878 : LetStmt::accept_vis (HIRFullVisitor &vis)
4644 : {
4645 64878 : vis.visit (*this);
4646 64878 : }
4647 :
4648 : void
4649 48722 : ExprStmt::accept_vis (HIRFullVisitor &vis)
4650 : {
4651 48722 : vis.visit (*this);
4652 48722 : }
4653 :
4654 : void
4655 1678 : TraitBound::accept_vis (HIRFullVisitor &vis)
4656 : {
4657 1678 : vis.visit (*this);
4658 1678 : }
4659 :
4660 : void
4661 28 : ImplTraitType::accept_vis (HIRFullVisitor &vis)
4662 : {
4663 28 : vis.visit (*this);
4664 28 : }
4665 :
4666 : void
4667 91 : TraitObjectType::accept_vis (HIRFullVisitor &vis)
4668 : {
4669 91 : vis.visit (*this);
4670 91 : }
4671 :
4672 : void
4673 5 : ParenthesisedType::accept_vis (HIRFullVisitor &vis)
4674 : {
4675 5 : vis.visit (*this);
4676 5 : }
4677 :
4678 : void
4679 336 : TupleType::accept_vis (HIRFullVisitor &vis)
4680 : {
4681 336 : vis.visit (*this);
4682 336 : }
4683 :
4684 : void
4685 44 : NeverType::accept_vis (HIRFullVisitor &vis)
4686 : {
4687 44 : vis.visit (*this);
4688 44 : }
4689 :
4690 : void
4691 4240 : RawPointerType::accept_vis (HIRFullVisitor &vis)
4692 : {
4693 4240 : vis.visit (*this);
4694 4240 : }
4695 :
4696 : void
4697 5899 : ReferenceType::accept_vis (HIRFullVisitor &vis)
4698 : {
4699 5899 : vis.visit (*this);
4700 5899 : }
4701 :
4702 : void
4703 832 : ArrayType::accept_vis (HIRFullVisitor &vis)
4704 : {
4705 832 : vis.visit (*this);
4706 832 : }
4707 :
4708 : void
4709 820 : SliceType::accept_vis (HIRFullVisitor &vis)
4710 : {
4711 820 : vis.visit (*this);
4712 820 : }
4713 :
4714 : void
4715 14 : InferredType::accept_vis (HIRFullVisitor &vis)
4716 : {
4717 14 : vis.visit (*this);
4718 14 : }
4719 :
4720 : void
4721 41 : BareFunctionType::accept_vis (HIRFullVisitor &vis)
4722 : {
4723 41 : vis.visit (*this);
4724 41 : }
4725 :
4726 : void
4727 46 : NeverType::accept_vis (HIRTypeVisitor &vis)
4728 : {
4729 46 : vis.visit (*this);
4730 46 : }
4731 :
4732 : void
4733 5 : ParenthesisedType::accept_vis (HIRTypeVisitor &vis)
4734 : {
4735 5 : vis.visit (*this);
4736 5 : }
4737 :
4738 : void
4739 136 : EmptyStmt::accept_vis (HIRStmtVisitor &vis)
4740 : {
4741 136 : vis.visit (*this);
4742 136 : }
4743 :
4744 : void
4745 2719 : WildcardPattern::accept_vis (HIRPatternVisitor &vis)
4746 : {
4747 2719 : vis.visit (*this);
4748 2719 : }
4749 :
4750 : void
4751 736 : TraitItemType::accept_vis (HIRTraitItemVisitor &vis)
4752 : {
4753 736 : vis.visit (*this);
4754 736 : }
4755 :
4756 : void
4757 38 : TraitItemConst::accept_vis (HIRTraitItemVisitor &vis)
4758 : {
4759 38 : vis.visit (*this);
4760 38 : }
4761 :
4762 : void
4763 2791 : TraitItemFunc::accept_vis (HIRTraitItemVisitor &vis)
4764 : {
4765 2791 : vis.visit (*this);
4766 2791 : }
4767 :
4768 : void
4769 4414 : ExternalFunctionItem::accept_vis (HIRExternalItemVisitor &vis)
4770 : {
4771 4414 : vis.visit (*this);
4772 4413 : }
4773 :
4774 : void
4775 0 : ExternalTypeItem::accept_vis (HIRExternalItemVisitor &vis)
4776 : {
4777 0 : vis.visit (*this);
4778 0 : }
4779 :
4780 : void
4781 1 : ExternalStaticItem::accept_vis (HIRExternalItemVisitor &vis)
4782 : {
4783 1 : vis.visit (*this);
4784 1 : }
4785 :
4786 : void
4787 0 : EnumItemDiscriminant::accept_vis (HIRStmtVisitor &vis)
4788 : {
4789 0 : vis.visit (*this);
4790 0 : }
4791 :
4792 : void
4793 0 : EnumItemStruct::accept_vis (HIRStmtVisitor &vis)
4794 : {
4795 0 : vis.visit (*this);
4796 0 : }
4797 :
4798 : void
4799 0 : EnumItemTuple::accept_vis (HIRStmtVisitor &vis)
4800 : {
4801 0 : vis.visit (*this);
4802 0 : }
4803 :
4804 : void
4805 0 : EnumItem::accept_vis (HIRStmtVisitor &vis)
4806 : {
4807 0 : vis.visit (*this);
4808 0 : }
4809 :
4810 : void
4811 3852 : StructExprStructFields::accept_vis (HIRExpressionVisitor &vis)
4812 : {
4813 3852 : vis.visit (*this);
4814 3852 : }
4815 :
4816 : void
4817 42 : StructExprFieldIndexValue::accept_vis (HIRExpressionVisitor &vis)
4818 : {
4819 42 : vis.visit (*this);
4820 42 : }
4821 :
4822 : void
4823 10670 : StructExprFieldIdentifierValue::accept_vis (HIRFullVisitor &vis)
4824 : {
4825 10670 : vis.visit (*this);
4826 10670 : }
4827 :
4828 : void
4829 2593 : StructExprFieldIdentifierValue::accept_vis (HIRExpressionVisitor &vis)
4830 : {
4831 2593 : vis.visit (*this);
4832 2593 : }
4833 :
4834 : void
4835 845 : StructExprFieldIdentifier::accept_vis (HIRFullVisitor &vis)
4836 : {
4837 845 : vis.visit (*this);
4838 845 : }
4839 :
4840 : void
4841 215 : StructExprFieldIdentifier::accept_vis (HIRExpressionVisitor &vis)
4842 : {
4843 215 : vis.visit (*this);
4844 215 : }
4845 :
4846 : void
4847 239 : StructExprStruct::accept_vis (HIRExpressionVisitor &vis)
4848 : {
4849 239 : vis.visit (*this);
4850 239 : }
4851 :
4852 : void
4853 386 : TupleType::accept_vis (HIRTypeVisitor &vis)
4854 : {
4855 386 : vis.visit (*this);
4856 386 : }
4857 :
4858 : void
4859 841 : SliceType::accept_vis (HIRTypeVisitor &vis)
4860 : {
4861 841 : vis.visit (*this);
4862 841 : }
4863 :
4864 : void
4865 663 : ArrayType::accept_vis (HIRTypeVisitor &vis)
4866 : {
4867 663 : vis.visit (*this);
4868 663 : }
4869 :
4870 : void
4871 60 : BareFunctionType::accept_vis (HIRTypeVisitor &vis)
4872 : {
4873 60 : vis.visit (*this);
4874 60 : }
4875 :
4876 : void
4877 166 : TraitObjectType::accept_vis (HIRTypeVisitor &vis)
4878 : {
4879 166 : vis.visit (*this);
4880 166 : }
4881 :
4882 : void
4883 6487 : RawPointerType::accept_vis (HIRTypeVisitor &vis)
4884 : {
4885 6487 : vis.visit (*this);
4886 6487 : }
4887 :
4888 : void
4889 4367 : ReferenceType::accept_vis (HIRTypeVisitor &vis)
4890 : {
4891 4367 : vis.visit (*this);
4892 4367 : }
4893 :
4894 : void
4895 29 : ImplTraitType::accept_vis (HIRTypeVisitor &vis)
4896 : {
4897 29 : vis.visit (*this);
4898 29 : }
4899 :
4900 : void
4901 206 : InferredType::accept_vis (HIRTypeVisitor &vis)
4902 : {
4903 206 : vis.visit (*this);
4904 206 : }
4905 :
4906 : void
4907 36359 : LetStmt::accept_vis (HIRStmtVisitor &vis)
4908 : {
4909 36359 : vis.visit (*this);
4910 36359 : }
4911 :
4912 : void
4913 2478 : TupleStructPattern::accept_vis (HIRPatternVisitor &vis)
4914 : {
4915 2478 : vis.visit (*this);
4916 2478 : }
4917 :
4918 : void
4919 73112 : IdentifierPattern::accept_vis (HIRPatternVisitor &vis)
4920 : {
4921 73112 : vis.visit (*this);
4922 73112 : }
4923 :
4924 : void
4925 565 : ReferencePattern::accept_vis (HIRPatternVisitor &vis)
4926 : {
4927 565 : vis.visit (*this);
4928 565 : }
4929 :
4930 : void
4931 1234 : LiteralPattern::accept_vis (HIRPatternVisitor &vis)
4932 : {
4933 1234 : vis.visit (*this);
4934 1234 : }
4935 :
4936 : void
4937 440 : StructPattern::accept_vis (HIRPatternVisitor &vis)
4938 : {
4939 440 : vis.visit (*this);
4940 440 : }
4941 :
4942 : void
4943 1247 : TuplePattern::accept_vis (HIRPatternVisitor &vis)
4944 : {
4945 1247 : vis.visit (*this);
4946 1247 : }
4947 :
4948 : void
4949 226 : SlicePattern::accept_vis (HIRPatternVisitor &vis)
4950 : {
4951 226 : vis.visit (*this);
4952 226 : }
4953 :
4954 : void
4955 231 : AltPattern::accept_vis (HIRPatternVisitor &vis)
4956 : {
4957 231 : vis.visit (*this);
4958 231 : }
4959 :
4960 : void
4961 120 : RangePattern::accept_vis (HIRPatternVisitor &vis)
4962 : {
4963 120 : vis.visit (*this);
4964 120 : }
4965 :
4966 : void
4967 46548 : TypePath::accept_vis (HIRTypeVisitor &vis)
4968 : {
4969 46548 : vis.visit (*this);
4970 46548 : }
4971 :
4972 : void
4973 242 : QualifiedPathInType::accept_vis (HIRTypeVisitor &vis)
4974 : {
4975 242 : vis.visit (*this);
4976 242 : }
4977 :
4978 : void
4979 26926 : ExprStmt::accept_vis (HIRStmtVisitor &vis)
4980 : {
4981 26926 : vis.visit (*this);
4982 26926 : }
4983 :
4984 : void
4985 1595 : TupleExpr::accept_vis (HIRExpressionVisitor &vis)
4986 : {
4987 1595 : vis.visit (*this);
4988 1595 : }
4989 :
4990 : void
4991 2656 : MatchExpr::accept_vis (HIRExpressionVisitor &vis)
4992 : {
4993 2656 : vis.visit (*this);
4994 2656 : }
4995 :
4996 : void
4997 214 : BreakExpr::accept_vis (HIRExpressionVisitor &vis)
4998 : {
4999 214 : vis.visit (*this);
5000 214 : }
5001 :
5002 : void
5003 0 : AwaitExpr::accept_vis (HIRExpressionVisitor &vis)
5004 : {
5005 0 : vis.visit (*this);
5006 0 : }
5007 :
5008 : void
5009 1209 : ArrayExpr::accept_vis (HIRExpressionVisitor &vis)
5010 : {
5011 1209 : vis.visit (*this);
5012 1209 : }
5013 :
5014 : void
5015 356 : LoopExpr::accept_vis (HIRExpressionVisitor &vis)
5016 : {
5017 356 : vis.visit (*this);
5018 356 : }
5019 :
5020 : void
5021 0 : WhileLetLoopExpr::accept_vis (HIRExpressionVisitor &vis)
5022 : {
5023 0 : vis.visit (*this);
5024 0 : }
5025 :
5026 : void
5027 229 : WhileLoopExpr::accept_vis (HIRExpressionVisitor &vis)
5028 : {
5029 229 : vis.visit (*this);
5030 229 : }
5031 :
5032 : void
5033 31380 : CallExpr::accept_vis (HIRExpressionVisitor &vis)
5034 : {
5035 31380 : vis.visit (*this);
5036 31380 : }
5037 :
5038 : void
5039 21 : RangeFromToInclExpr::accept_vis (HIRExpressionVisitor &vis)
5040 : {
5041 21 : vis.visit (*this);
5042 21 : }
5043 :
5044 : void
5045 4420 : IfExprConseqElse::accept_vis (HIRExpressionVisitor &vis)
5046 : {
5047 4420 : vis.visit (*this);
5048 4420 : }
5049 :
5050 : void
5051 1859 : IfExpr::accept_vis (HIRExpressionVisitor &vis)
5052 : {
5053 1859 : vis.visit (*this);
5054 1859 : }
5055 :
5056 : void
5057 186 : ClosureExpr::accept_vis (HIRExpressionVisitor &vis)
5058 : {
5059 186 : vis.visit (*this);
5060 186 : }
5061 :
5062 : void
5063 9830 : UnsafeBlockExpr::accept_vis (HIRExpressionVisitor &vis)
5064 : {
5065 9830 : vis.visit (*this);
5066 9830 : }
5067 :
5068 : void
5069 0 : RangeToInclExpr::accept_vis (HIRExpressionVisitor &vis)
5070 : {
5071 0 : vis.visit (*this);
5072 0 : }
5073 :
5074 : void
5075 198 : RangeFromToExpr::accept_vis (HIRExpressionVisitor &vis)
5076 : {
5077 198 : vis.visit (*this);
5078 198 : }
5079 :
5080 : void
5081 15814 : FieldAccessExpr::accept_vis (HIRExpressionVisitor &vis)
5082 : {
5083 15814 : vis.visit (*this);
5084 15814 : }
5085 :
5086 : void
5087 2661 : TupleIndexExpr::accept_vis (HIRExpressionVisitor &vis)
5088 : {
5089 2661 : vis.visit (*this);
5090 2661 : }
5091 :
5092 : void
5093 7896 : MethodCallExpr::accept_vis (HIRExpressionVisitor &vis)
5094 : {
5095 7896 : vis.visit (*this);
5096 7896 : }
5097 :
5098 : void
5099 0 : AsyncBlockExpr::accept_vis (HIRExpressionVisitor &vis)
5100 : {
5101 0 : vis.visit (*this);
5102 0 : }
5103 :
5104 : void
5105 721 : ArrayIndexExpr::accept_vis (HIRExpressionVisitor &vis)
5106 : {
5107 721 : vis.visit (*this);
5108 721 : }
5109 :
5110 : void
5111 0 : RangeFullExpr::accept_vis (HIRExpressionVisitor &vis)
5112 : {
5113 0 : vis.visit (*this);
5114 0 : }
5115 :
5116 : void
5117 21 : RangeFromExpr::accept_vis (HIRExpressionVisitor &vis)
5118 : {
5119 21 : vis.visit (*this);
5120 21 : }
5121 :
5122 : void
5123 42 : ContinueExpr::accept_vis (HIRExpressionVisitor &vis)
5124 : {
5125 42 : vis.visit (*this);
5126 42 : }
5127 :
5128 : void
5129 21 : RangeToExpr::accept_vis (HIRExpressionVisitor &vis)
5130 : {
5131 21 : vis.visit (*this);
5132 21 : }
5133 :
5134 : void
5135 1420 : ReturnExpr::accept_vis (HIRExpressionVisitor &vis)
5136 : {
5137 1420 : vis.visit (*this);
5138 1420 : }
5139 :
5140 : void
5141 0 : QualifiedPathInExpression::accept_vis (HIRPatternVisitor &vis)
5142 : {
5143 0 : vis.visit (*this);
5144 0 : }
5145 :
5146 : void
5147 2526 : PathInExpression::accept_vis (HIRPatternVisitor &vis)
5148 : {
5149 2526 : vis.visit (*this);
5150 2526 : }
5151 :
5152 : void
5153 2924 : ExternBlock::accept_vis (HIRStmtVisitor &vis)
5154 : {
5155 2924 : vis.visit (*this);
5156 2924 : }
5157 :
5158 : void
5159 5770 : ExternBlock::accept_vis (HIRVisItemVisitor &vis)
5160 : {
5161 5770 : vis.visit (*this);
5162 5769 : }
5163 :
5164 : void
5165 2424 : TypeAlias::accept_vis (HIRStmtVisitor &vis)
5166 : {
5167 2424 : vis.visit (*this);
5168 2424 : }
5169 :
5170 : void
5171 1350 : TypeAlias::accept_vis (HIRVisItemVisitor &vis)
5172 : {
5173 1350 : vis.visit (*this);
5174 1350 : }
5175 :
5176 : void
5177 3602 : TypeAlias::accept_vis (HIRImplVisitor &vis)
5178 : {
5179 3602 : vis.visit (*this);
5180 3602 : }
5181 :
5182 : void
5183 46621 : BlockExpr::accept_vis (HIRExpressionVisitor &vis)
5184 : {
5185 46621 : vis.visit (*this);
5186 46621 : }
5187 :
5188 : void
5189 1334 : AnonConst::accept_vis (HIRExpressionVisitor &vis)
5190 : {
5191 1334 : vis.visit (*this);
5192 1334 : }
5193 :
5194 : void
5195 45 : ConstBlock::accept_vis (HIRExpressionVisitor &vis)
5196 : {
5197 45 : vis.visit (*this);
5198 45 : }
5199 :
5200 : void
5201 31094 : Function::accept_vis (HIRStmtVisitor &vis)
5202 : {
5203 31094 : vis.visit (*this);
5204 31094 : }
5205 :
5206 : void
5207 31973 : Function::accept_vis (HIRVisItemVisitor &vis)
5208 : {
5209 31973 : vis.visit (*this);
5210 31973 : }
5211 :
5212 : void
5213 18614 : Function::accept_vis (HIRImplVisitor &vis)
5214 : {
5215 18614 : vis.visit (*this);
5216 18614 : }
5217 :
5218 : void
5219 193 : Union::accept_vis (HIRStmtVisitor &vis)
5220 : {
5221 193 : vis.visit (*this);
5222 193 : }
5223 :
5224 : void
5225 427 : Union::accept_vis (HIRVisItemVisitor &vis)
5226 : {
5227 427 : vis.visit (*this);
5228 427 : }
5229 :
5230 : void
5231 7071 : Trait::accept_vis (HIRStmtVisitor &vis)
5232 : {
5233 7071 : vis.visit (*this);
5234 7071 : }
5235 :
5236 : void
5237 16568 : Trait::accept_vis (HIRVisItemVisitor &vis)
5238 : {
5239 16568 : vis.visit (*this);
5240 16568 : }
5241 :
5242 : void
5243 970 : Enum::accept_vis (HIRStmtVisitor &vis)
5244 : {
5245 970 : vis.visit (*this);
5246 970 : }
5247 :
5248 : void
5249 2013 : Enum::accept_vis (HIRVisItemVisitor &vis)
5250 : {
5251 2013 : vis.visit (*this);
5252 2013 : }
5253 :
5254 : void
5255 0 : UseDeclaration::accept_vis (HIRStmtVisitor &vis)
5256 : {
5257 0 : vis.visit (*this);
5258 0 : }
5259 :
5260 : void
5261 0 : UseDeclaration::accept_vis (HIRVisItemVisitor &vis)
5262 : {
5263 0 : vis.visit (*this);
5264 0 : }
5265 :
5266 : void
5267 3001 : StructStruct::accept_vis (HIRStmtVisitor &vis)
5268 : {
5269 3001 : vis.visit (*this);
5270 3001 : }
5271 :
5272 : void
5273 5635 : StructStruct::accept_vis (HIRVisItemVisitor &vis)
5274 : {
5275 5635 : vis.visit (*this);
5276 5635 : }
5277 :
5278 : void
5279 11077 : ImplBlock::accept_vis (HIRStmtVisitor &vis)
5280 : {
5281 11077 : vis.visit (*this);
5282 11077 : }
5283 :
5284 : void
5285 22208 : ImplBlock::accept_vis (HIRVisItemVisitor &vis)
5286 : {
5287 22208 : vis.visit (*this);
5288 22208 : }
5289 :
5290 : void
5291 1191 : ConstantItem::accept_vis (HIRStmtVisitor &vis)
5292 : {
5293 1191 : vis.visit (*this);
5294 1191 : }
5295 :
5296 : void
5297 1655 : ConstantItem::accept_vis (HIRVisItemVisitor &vis)
5298 : {
5299 1655 : vis.visit (*this);
5300 1655 : }
5301 :
5302 : void
5303 191 : ConstantItem::accept_vis (HIRImplVisitor &vis)
5304 : {
5305 191 : vis.visit (*this);
5306 191 : }
5307 :
5308 : void
5309 1992 : TupleStruct::accept_vis (HIRStmtVisitor &vis)
5310 : {
5311 1992 : vis.visit (*this);
5312 1992 : }
5313 :
5314 : void
5315 3394 : TupleStruct::accept_vis (HIRVisItemVisitor &vis)
5316 : {
5317 3394 : vis.visit (*this);
5318 3394 : }
5319 :
5320 : void
5321 0 : ExternCrate::accept_vis (HIRStmtVisitor &vis)
5322 : {
5323 0 : vis.visit (*this);
5324 0 : }
5325 :
5326 : void
5327 0 : ExternCrate::accept_vis (HIRVisItemVisitor &vis)
5328 : {
5329 0 : vis.visit (*this);
5330 0 : }
5331 :
5332 : void
5333 111 : StaticItem::accept_vis (HIRStmtVisitor &vis)
5334 : {
5335 111 : vis.visit (*this);
5336 111 : }
5337 :
5338 : void
5339 209 : StaticItem::accept_vis (HIRVisItemVisitor &vis)
5340 : {
5341 209 : vis.visit (*this);
5342 209 : }
5343 :
5344 : } // namespace HIR
5345 : } // namespace Rust
|