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