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