Debian Codegraph @

gcc/rust/hir/tree/rust-hir.cc

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