LCOV - code coverage report
Current view: top level - gcc/rust/typecheck - rust-tyty-cmp.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 46.0 % 835 384
Test Date: 2025-08-30 13:27:53 Functions: 61.7 % 149 92
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             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                 :             : #ifndef RUST_TYTY_CMP_H
      20                 :             : #define RUST_TYTY_CMP_H
      21                 :             : 
      22                 :             : #include "rust-diagnostics.h"
      23                 :             : #include "rust-tyty.h"
      24                 :             : #include "rust-tyty-visitor.h"
      25                 :             : #include "rust-hir-map.h"
      26                 :             : #include "rust-hir-type-check.h"
      27                 :             : 
      28                 :             : namespace Rust {
      29                 :             : namespace TyTy {
      30                 :             : 
      31                 :             : class BaseCmp : public TyConstVisitor
      32                 :             : {
      33                 :             : public:
      34                 :     1473514 :   virtual bool can_eq (const BaseType *other)
      35                 :             :   {
      36                 :     1473514 :     if (other->get_kind () == TypeKind::PARAM)
      37                 :             :       {
      38                 :       37806 :         const ParamType *p = static_cast<const ParamType *> (other);
      39                 :       37806 :         other = p->resolve ();
      40                 :             :       }
      41                 :     1473514 :     if (other->get_kind () == TypeKind::PLACEHOLDER)
      42                 :             :       {
      43                 :         118 :         const PlaceholderType *p = static_cast<const PlaceholderType *> (other);
      44                 :         118 :         if (p->can_resolve ())
      45                 :             :           {
      46                 :         111 :             other = p->resolve ();
      47                 :             :           }
      48                 :             :       }
      49                 :     1473514 :     if (other->get_kind () == TypeKind::PROJECTION)
      50                 :             :       {
      51                 :        1091 :         const ProjectionType *p = static_cast<const ProjectionType *> (other);
      52                 :        1091 :         other = p->get ();
      53                 :             :       }
      54                 :             : 
      55                 :     1473514 :     other->accept_vis (*this);
      56                 :     1473514 :     return ok;
      57                 :             :   }
      58                 :             : 
      59                 :          45 :   virtual void visit (const TupleType &type) override
      60                 :             :   {
      61                 :          45 :     ok = false;
      62                 :             : 
      63                 :          45 :     if (emit_error_flag)
      64                 :             :       {
      65                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
      66                 :           0 :         location_t base_locus
      67                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
      68                 :           0 :         rich_location r (line_table, ref_locus);
      69                 :           0 :         r.add_range (base_locus);
      70                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
      71                 :           0 :                        get_base ()->as_string ().c_str (),
      72                 :           0 :                        type.as_string ().c_str ());
      73                 :           0 :       }
      74                 :          45 :   }
      75                 :             : 
      76                 :      289809 :   virtual void visit (const ADTType &type) override
      77                 :             :   {
      78                 :      289809 :     ok = false;
      79                 :      289809 :     if (emit_error_flag)
      80                 :             :       {
      81                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
      82                 :           0 :         location_t base_locus
      83                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
      84                 :           0 :         rich_location r (line_table, ref_locus);
      85                 :           0 :         r.add_range (base_locus);
      86                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
      87                 :           0 :                        get_base ()->as_string ().c_str (),
      88                 :           0 :                        type.as_string ().c_str ());
      89                 :           0 :       }
      90                 :      289809 :   }
      91                 :             : 
      92                 :         190 :   virtual void visit (const InferType &type) override
      93                 :             :   {
      94                 :         190 :     ok = false;
      95                 :         190 :     if (emit_error_flag)
      96                 :             :       {
      97                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
      98                 :           0 :         location_t base_locus
      99                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     100                 :           0 :         rich_location r (line_table, ref_locus);
     101                 :           0 :         r.add_range (base_locus);
     102                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     103                 :           0 :                        get_base ()->as_string ().c_str (),
     104                 :           0 :                        type.as_string ().c_str ());
     105                 :           0 :       }
     106                 :         190 :   }
     107                 :             : 
     108                 :           0 :   virtual void visit (const FnType &type) override
     109                 :             :   {
     110                 :           0 :     ok = false;
     111                 :           0 :     if (emit_error_flag)
     112                 :             :       {
     113                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     114                 :           0 :         location_t base_locus
     115                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     116                 :           0 :         rich_location r (line_table, ref_locus);
     117                 :           0 :         r.add_range (base_locus);
     118                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     119                 :           0 :                        get_base ()->as_string ().c_str (),
     120                 :           0 :                        type.as_string ().c_str ());
     121                 :           0 :       }
     122                 :           0 :   }
     123                 :             : 
     124                 :           0 :   virtual void visit (const FnPtr &type) override
     125                 :             :   {
     126                 :           0 :     ok = false;
     127                 :           0 :     if (emit_error_flag)
     128                 :             :       {
     129                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     130                 :           0 :         location_t base_locus
     131                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     132                 :           0 :         rich_location r (line_table, ref_locus);
     133                 :           0 :         r.add_range (base_locus);
     134                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     135                 :           0 :                        get_base ()->as_string ().c_str (),
     136                 :           0 :                        type.as_string ().c_str ());
     137                 :           0 :       }
     138                 :           0 :   }
     139                 :             : 
     140                 :       11066 :   virtual void visit (const ArrayType &type) override
     141                 :             :   {
     142                 :       11066 :     ok = false;
     143                 :       11066 :     if (emit_error_flag)
     144                 :             :       {
     145                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     146                 :           0 :         location_t base_locus
     147                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     148                 :           0 :         rich_location r (line_table, ref_locus);
     149                 :           0 :         r.add_range (base_locus);
     150                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     151                 :           0 :                        get_base ()->as_string ().c_str (),
     152                 :           0 :                        type.as_string ().c_str ());
     153                 :           0 :       }
     154                 :       11066 :   }
     155                 :             : 
     156                 :        2715 :   virtual void visit (const SliceType &type) override
     157                 :             :   {
     158                 :        2715 :     ok = false;
     159                 :        2715 :     if (emit_error_flag)
     160                 :             :       {
     161                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     162                 :           0 :         location_t base_locus
     163                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     164                 :           0 :         rich_location r (line_table, ref_locus);
     165                 :           0 :         r.add_range (base_locus);
     166                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     167                 :           0 :                        get_base ()->as_string ().c_str (),
     168                 :           0 :                        type.as_string ().c_str ());
     169                 :           0 :       }
     170                 :        2715 :   }
     171                 :             : 
     172                 :       23914 :   virtual void visit (const BoolType &type) override
     173                 :             :   {
     174                 :       23914 :     ok = false;
     175                 :       23914 :     if (emit_error_flag)
     176                 :             :       {
     177                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     178                 :           0 :         location_t base_locus
     179                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     180                 :           0 :         rich_location r (line_table, ref_locus);
     181                 :           0 :         r.add_range (base_locus);
     182                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     183                 :           0 :                        get_base ()->as_string ().c_str (),
     184                 :           0 :                        type.as_string ().c_str ());
     185                 :           0 :       }
     186                 :       23914 :   }
     187                 :             : 
     188                 :      208541 :   virtual void visit (const IntType &type) override
     189                 :             :   {
     190                 :      208541 :     ok = false;
     191                 :      208541 :     if (emit_error_flag)
     192                 :             :       {
     193                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     194                 :           0 :         location_t base_locus
     195                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     196                 :           0 :         rich_location r (line_table, ref_locus);
     197                 :           0 :         r.add_range (base_locus);
     198                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     199                 :           0 :                        get_base ()->as_string ().c_str (),
     200                 :           0 :                        type.as_string ().c_str ());
     201                 :           0 :       }
     202                 :      208541 :   }
     203                 :             : 
     204                 :      226862 :   virtual void visit (const UintType &type) override
     205                 :             :   {
     206                 :      226862 :     ok = false;
     207                 :      226862 :     if (emit_error_flag)
     208                 :             :       {
     209                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     210                 :           0 :         location_t base_locus
     211                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     212                 :           0 :         rich_location r (line_table, ref_locus);
     213                 :           0 :         r.add_range (base_locus);
     214                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     215                 :           0 :                        get_base ()->as_string ().c_str (),
     216                 :           0 :                        type.as_string ().c_str ());
     217                 :           0 :       }
     218                 :      226862 :   }
     219                 :             : 
     220                 :      140646 :   virtual void visit (const USizeType &type) override
     221                 :             :   {
     222                 :      140646 :     ok = false;
     223                 :      140646 :     if (emit_error_flag)
     224                 :             :       {
     225                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     226                 :           0 :         location_t base_locus
     227                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     228                 :           0 :         rich_location r (line_table, ref_locus);
     229                 :           0 :         r.add_range (base_locus);
     230                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     231                 :           0 :                        get_base ()->as_string ().c_str (),
     232                 :           0 :                        type.as_string ().c_str ());
     233                 :           0 :       }
     234                 :      140646 :   }
     235                 :             : 
     236                 :       80863 :   virtual void visit (const ISizeType &type) override
     237                 :             :   {
     238                 :       80863 :     ok = false;
     239                 :       80863 :     if (emit_error_flag)
     240                 :             :       {
     241                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     242                 :           0 :         location_t base_locus
     243                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     244                 :           0 :         rich_location r (line_table, ref_locus);
     245                 :           0 :         r.add_range (base_locus);
     246                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     247                 :           0 :                        get_base ()->as_string ().c_str (),
     248                 :           0 :                        type.as_string ().c_str ());
     249                 :           0 :       }
     250                 :       80863 :   }
     251                 :             : 
     252                 :       83216 :   virtual void visit (const FloatType &type) override
     253                 :             :   {
     254                 :       83216 :     ok = false;
     255                 :       83216 :     if (emit_error_flag)
     256                 :             :       {
     257                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     258                 :           0 :         location_t base_locus
     259                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     260                 :           0 :         rich_location r (line_table, ref_locus);
     261                 :           0 :         r.add_range (base_locus);
     262                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     263                 :           0 :                        get_base ()->as_string ().c_str (),
     264                 :           0 :                        type.as_string ().c_str ());
     265                 :           0 :       }
     266                 :       83216 :   }
     267                 :             : 
     268                 :           1 :   virtual void visit (const ErrorType &type) override
     269                 :             :   {
     270                 :           1 :     ok = false;
     271                 :           1 :     if (emit_error_flag)
     272                 :             :       {
     273                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     274                 :           0 :         location_t base_locus
     275                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     276                 :           0 :         rich_location r (line_table, ref_locus);
     277                 :           0 :         r.add_range (base_locus);
     278                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     279                 :           0 :                        get_base ()->as_string ().c_str (),
     280                 :           0 :                        type.as_string ().c_str ());
     281                 :           0 :       }
     282                 :           1 :   }
     283                 :             : 
     284                 :       23130 :   virtual void visit (const CharType &type) override
     285                 :             :   {
     286                 :       23130 :     ok = false;
     287                 :       23130 :     if (emit_error_flag)
     288                 :             :       {
     289                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     290                 :           0 :         location_t base_locus
     291                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     292                 :           0 :         rich_location r (line_table, ref_locus);
     293                 :           0 :         r.add_range (base_locus);
     294                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     295                 :           0 :                        get_base ()->as_string ().c_str (),
     296                 :           0 :                        type.as_string ().c_str ());
     297                 :           0 :       }
     298                 :       23130 :   }
     299                 :             : 
     300                 :       47394 :   virtual void visit (const ReferenceType &type) override
     301                 :             :   {
     302                 :       47394 :     ok = false;
     303                 :       47394 :     if (emit_error_flag)
     304                 :             :       {
     305                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     306                 :           0 :         location_t base_locus
     307                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     308                 :           0 :         rich_location r (line_table, ref_locus);
     309                 :           0 :         r.add_range (base_locus);
     310                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     311                 :           0 :                        get_base ()->as_string ().c_str (),
     312                 :           0 :                        type.as_string ().c_str ());
     313                 :           0 :       }
     314                 :       47394 :   }
     315                 :             : 
     316                 :        1980 :   virtual void visit (const PointerType &type) override
     317                 :             :   {
     318                 :        1980 :     ok = false;
     319                 :        1980 :     if (emit_error_flag)
     320                 :             :       {
     321                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     322                 :           0 :         location_t base_locus
     323                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     324                 :           0 :         rich_location r (line_table, ref_locus);
     325                 :           0 :         r.add_range (base_locus);
     326                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     327                 :           0 :                        get_base ()->as_string ().c_str (),
     328                 :           0 :                        type.as_string ().c_str ());
     329                 :           0 :       }
     330                 :        1980 :   }
     331                 :             : 
     332                 :           0 :   virtual void visit (const StrType &type) override
     333                 :             :   {
     334                 :           0 :     ok = false;
     335                 :           0 :     if (emit_error_flag)
     336                 :             :       {
     337                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     338                 :           0 :         location_t base_locus
     339                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     340                 :           0 :         rich_location r (line_table, ref_locus);
     341                 :           0 :         r.add_range (base_locus);
     342                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     343                 :           0 :                        get_base ()->as_string ().c_str (),
     344                 :           0 :                        type.as_string ().c_str ());
     345                 :           0 :       }
     346                 :           0 :   }
     347                 :             : 
     348                 :        4272 :   virtual void visit (const NeverType &type) override
     349                 :             :   {
     350                 :        4272 :     ok = false;
     351                 :        4272 :     if (emit_error_flag)
     352                 :             :       {
     353                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     354                 :           0 :         location_t base_locus
     355                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     356                 :           0 :         rich_location r (line_table, ref_locus);
     357                 :           0 :         r.add_range (base_locus);
     358                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     359                 :           0 :                        get_base ()->as_string ().c_str (),
     360                 :           0 :                        type.as_string ().c_str ());
     361                 :           0 :       }
     362                 :        4272 :   }
     363                 :             : 
     364                 :           0 :   virtual void visit (const ProjectionType &type) override
     365                 :             :   {
     366                 :           0 :     ok = false;
     367                 :           0 :     if (emit_error_flag)
     368                 :             :       {
     369                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     370                 :           0 :         location_t base_locus
     371                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     372                 :           0 :         rich_location r (line_table, ref_locus);
     373                 :           0 :         r.add_range (base_locus);
     374                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     375                 :           0 :                        get_base ()->as_string ().c_str (),
     376                 :           0 :                        type.as_string ().c_str ());
     377                 :           0 :       }
     378                 :           0 :   }
     379                 :             : 
     380                 :          72 :   virtual void visit (const PlaceholderType &type) override
     381                 :             :   {
     382                 :             :     // it is ok for types to can eq to a placeholder
     383                 :          72 :     ok = true;
     384                 :          72 :   }
     385                 :             : 
     386                 :       22799 :   virtual void visit (const ParamType &type) override
     387                 :             :   {
     388                 :       22799 :     ok = false;
     389                 :       22799 :     if (emit_error_flag)
     390                 :             :       {
     391                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     392                 :           0 :         location_t base_locus
     393                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     394                 :           0 :         rich_location r (line_table, ref_locus);
     395                 :           0 :         r.add_range (base_locus);
     396                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     397                 :           0 :                        get_base ()->as_string ().c_str (),
     398                 :           0 :                        type.as_string ().c_str ());
     399                 :           0 :       }
     400                 :       22799 :   }
     401                 :             : 
     402                 :       13188 :   virtual void visit (const DynamicObjectType &type) override
     403                 :             :   {
     404                 :       13188 :     ok = false;
     405                 :       13188 :     if (emit_error_flag)
     406                 :             :       {
     407                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     408                 :           0 :         location_t base_locus
     409                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     410                 :           0 :         rich_location r (line_table, ref_locus);
     411                 :           0 :         r.add_range (base_locus);
     412                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     413                 :           0 :                        get_base ()->as_string ().c_str (),
     414                 :           0 :                        type.as_string ().c_str ());
     415                 :           0 :       }
     416                 :       13188 :   }
     417                 :             : 
     418                 :           7 :   virtual void visit (const ClosureType &type) override
     419                 :             :   {
     420                 :           7 :     ok = false;
     421                 :           7 :     if (emit_error_flag)
     422                 :             :       {
     423                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     424                 :           0 :         location_t base_locus
     425                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     426                 :           0 :         rich_location r (line_table, ref_locus);
     427                 :           0 :         r.add_range (base_locus);
     428                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     429                 :           0 :                        get_base ()->as_string ().c_str (),
     430                 :           0 :                        type.as_string ().c_str ());
     431                 :           0 :       }
     432                 :           7 :   }
     433                 :             : 
     434                 :           0 :   virtual void visit (const OpaqueType &type) override
     435                 :             :   {
     436                 :           0 :     ok = false;
     437                 :           0 :     if (emit_error_flag)
     438                 :             :       {
     439                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     440                 :           0 :         location_t base_locus
     441                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     442                 :           0 :         rich_location r (line_table, ref_locus);
     443                 :           0 :         r.add_range (base_locus);
     444                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     445                 :           0 :                        get_base ()->as_string ().c_str (),
     446                 :           0 :                        type.as_string ().c_str ());
     447                 :           0 :       }
     448                 :           0 :   }
     449                 :             : 
     450                 :           0 :   virtual void visit (const ConstType &type) override
     451                 :             :   {
     452                 :           0 :     ok = false;
     453                 :           0 :     if (emit_error_flag)
     454                 :             :       {
     455                 :           0 :         location_t ref_locus = mappings.lookup_location (type.get_ref ());
     456                 :           0 :         location_t base_locus
     457                 :           0 :           = mappings.lookup_location (get_base ()->get_ref ());
     458                 :           0 :         rich_location r (line_table, ref_locus);
     459                 :           0 :         r.add_range (base_locus);
     460                 :           0 :         rust_error_at (r, "expected [%s] got [%s]",
     461                 :           0 :                        get_base ()->as_string ().c_str (),
     462                 :           0 :                        type.as_string ().c_str ());
     463                 :           0 :       }
     464                 :           0 :   }
     465                 :             : 
     466                 :             : protected:
     467                 :     1505200 :   BaseCmp (const BaseType *base, bool emit_errors)
     468                 :     3010400 :     : mappings (Analysis::Mappings::get ()),
     469                 :     1505200 :       context (Resolver::TypeCheckContext::get ()), ok (false),
     470                 :     1505200 :       emit_error_flag (emit_errors)
     471                 :     1505200 :   {}
     472                 :             : 
     473                 :             :   Analysis::Mappings &mappings;
     474                 :             :   Resolver::TypeCheckContext *context;
     475                 :             : 
     476                 :             :   bool ok;
     477                 :             :   bool emit_error_flag;
     478                 :             : 
     479                 :             : private:
     480                 :             :   /* Returns a pointer to the ty that created this rule. */
     481                 :             :   virtual const BaseType *get_base () const = 0;
     482                 :             : };
     483                 :             : 
     484                 :             : class InferCmp : public BaseCmp
     485                 :             : {
     486                 :             :   using Rust::TyTy::BaseCmp::visit;
     487                 :             : 
     488                 :             : public:
     489                 :       16584 :   InferCmp (const InferType *base, bool emit_errors)
     490                 :       16584 :     : BaseCmp (base, emit_errors), base (base)
     491                 :             :   {}
     492                 :             : 
     493                 :         480 :   void visit (const BoolType &type) override
     494                 :             :   {
     495                 :         480 :     bool is_valid
     496                 :         480 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     497                 :         480 :     if (is_valid)
     498                 :             :       {
     499                 :         441 :         ok = true;
     500                 :         441 :         return;
     501                 :             :       }
     502                 :             : 
     503                 :          39 :     BaseCmp::visit (type);
     504                 :             :   }
     505                 :             : 
     506                 :        2467 :   void visit (const IntType &type) override
     507                 :             :   {
     508                 :        2467 :     bool is_valid
     509                 :        2467 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL)
     510                 :        2467 :         || (base->get_infer_kind ()
     511                 :        2467 :             == TyTy::InferType::InferTypeKind::INTEGRAL);
     512                 :        2467 :     if (is_valid)
     513                 :             :       {
     514                 :        2467 :         ok = true;
     515                 :        2467 :         return;
     516                 :             :       }
     517                 :             : 
     518                 :           0 :     BaseCmp::visit (type);
     519                 :             :   }
     520                 :             : 
     521                 :        4105 :   void visit (const UintType &type) override
     522                 :             :   {
     523                 :        4105 :     bool is_valid
     524                 :        4105 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL)
     525                 :        4105 :         || (base->get_infer_kind ()
     526                 :        4105 :             == TyTy::InferType::InferTypeKind::INTEGRAL);
     527                 :        4105 :     if (is_valid)
     528                 :             :       {
     529                 :        4105 :         ok = true;
     530                 :        4105 :         return;
     531                 :             :       }
     532                 :             : 
     533                 :           0 :     BaseCmp::visit (type);
     534                 :             :   }
     535                 :             : 
     536                 :        2110 :   void visit (const USizeType &type) override
     537                 :             :   {
     538                 :        2110 :     bool is_valid
     539                 :        2110 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL)
     540                 :        2110 :         || (base->get_infer_kind ()
     541                 :        2110 :             == TyTy::InferType::InferTypeKind::INTEGRAL);
     542                 :        2110 :     if (is_valid)
     543                 :             :       {
     544                 :        2110 :         ok = true;
     545                 :        2110 :         return;
     546                 :             :       }
     547                 :             : 
     548                 :           0 :     BaseCmp::visit (type);
     549                 :             :   }
     550                 :             : 
     551                 :         558 :   void visit (const ISizeType &type) override
     552                 :             :   {
     553                 :         558 :     bool is_valid
     554                 :         558 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL)
     555                 :         558 :         || (base->get_infer_kind ()
     556                 :         558 :             == TyTy::InferType::InferTypeKind::INTEGRAL);
     557                 :         558 :     if (is_valid)
     558                 :             :       {
     559                 :         558 :         ok = true;
     560                 :         558 :         return;
     561                 :             :       }
     562                 :             : 
     563                 :           0 :     BaseCmp::visit (type);
     564                 :             :   }
     565                 :             : 
     566                 :        2029 :   void visit (const FloatType &type) override
     567                 :             :   {
     568                 :        2029 :     bool is_valid
     569                 :        2029 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL)
     570                 :        2029 :         || (base->get_infer_kind () == TyTy::InferType::InferTypeKind::FLOAT);
     571                 :        2029 :     if (is_valid)
     572                 :             :       {
     573                 :        1901 :         ok = true;
     574                 :        1901 :         return;
     575                 :             :       }
     576                 :             : 
     577                 :         128 :     BaseCmp::visit (type);
     578                 :             :   }
     579                 :             : 
     580                 :           0 :   void visit (const ArrayType &type) override
     581                 :             :   {
     582                 :           0 :     bool is_valid
     583                 :           0 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     584                 :           0 :     if (is_valid)
     585                 :             :       {
     586                 :           0 :         ok = true;
     587                 :           0 :         return;
     588                 :             :       }
     589                 :             : 
     590                 :           0 :     BaseCmp::visit (type);
     591                 :             :   }
     592                 :             : 
     593                 :          77 :   void visit (const SliceType &type) override
     594                 :             :   {
     595                 :          77 :     bool is_valid
     596                 :          77 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     597                 :          77 :     if (is_valid)
     598                 :             :       {
     599                 :           0 :         ok = true;
     600                 :           0 :         return;
     601                 :             :       }
     602                 :             : 
     603                 :          77 :     BaseCmp::visit (type);
     604                 :             :   }
     605                 :             : 
     606                 :         723 :   void visit (const ADTType &type) override
     607                 :             :   {
     608                 :         723 :     bool is_valid
     609                 :         723 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     610                 :         723 :     if (is_valid)
     611                 :             :       {
     612                 :         624 :         ok = true;
     613                 :         624 :         return;
     614                 :             :       }
     615                 :             : 
     616                 :          99 :     BaseCmp::visit (type);
     617                 :             :   }
     618                 :             : 
     619                 :           0 :   void visit (const TupleType &type) override
     620                 :             :   {
     621                 :           0 :     bool is_valid
     622                 :           0 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     623                 :           0 :     if (is_valid)
     624                 :             :       {
     625                 :           0 :         ok = true;
     626                 :           0 :         return;
     627                 :             :       }
     628                 :             : 
     629                 :           0 :     BaseCmp::visit (type);
     630                 :             :   }
     631                 :             : 
     632                 :         327 :   void visit (const InferType &type) override
     633                 :             :   {
     634                 :         327 :     switch (base->get_infer_kind ())
     635                 :             :       {
     636                 :         298 :       case InferType::InferTypeKind::GENERAL:
     637                 :         298 :         ok = true;
     638                 :         298 :         return;
     639                 :             : 
     640                 :          29 :       case InferType::InferTypeKind::INTEGRAL:
     641                 :          29 :         {
     642                 :          29 :           if (type.get_infer_kind () == InferType::InferTypeKind::INTEGRAL)
     643                 :             :             {
     644                 :           5 :               ok = true;
     645                 :           5 :               return;
     646                 :             :             }
     647                 :          24 :           else if (type.get_infer_kind () == InferType::InferTypeKind::GENERAL)
     648                 :             :             {
     649                 :          24 :               ok = true;
     650                 :          24 :               return;
     651                 :             :             }
     652                 :             :         }
     653                 :             :         break;
     654                 :             : 
     655                 :           0 :       case InferType::InferTypeKind::FLOAT:
     656                 :           0 :         {
     657                 :           0 :           if (type.get_infer_kind () == InferType::InferTypeKind::FLOAT)
     658                 :             :             {
     659                 :           0 :               ok = true;
     660                 :           0 :               return;
     661                 :             :             }
     662                 :           0 :           else if (type.get_infer_kind () == InferType::InferTypeKind::GENERAL)
     663                 :             :             {
     664                 :           0 :               ok = true;
     665                 :           0 :               return;
     666                 :             :             }
     667                 :             :         }
     668                 :             :         break;
     669                 :             :       }
     670                 :             : 
     671                 :           0 :     BaseCmp::visit (type);
     672                 :             :   }
     673                 :             : 
     674                 :         472 :   void visit (const CharType &type) override
     675                 :             :   {
     676                 :         472 :     {
     677                 :         472 :       bool is_valid
     678                 :         472 :         = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     679                 :         472 :       if (is_valid)
     680                 :             :         {
     681                 :         440 :           ok = true;
     682                 :         440 :           return;
     683                 :             :         }
     684                 :             : 
     685                 :          32 :       BaseCmp::visit (type);
     686                 :             :     }
     687                 :             :   }
     688                 :             : 
     689                 :          42 :   void visit (const ReferenceType &type) override
     690                 :             :   {
     691                 :          42 :     bool is_valid
     692                 :          42 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     693                 :          42 :     if (is_valid)
     694                 :             :       {
     695                 :          28 :         ok = true;
     696                 :          28 :         return;
     697                 :             :       }
     698                 :             : 
     699                 :          14 :     BaseCmp::visit (type);
     700                 :             :   }
     701                 :             : 
     702                 :           0 :   void visit (const PointerType &type) override
     703                 :             :   {
     704                 :           0 :     bool is_valid
     705                 :           0 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     706                 :           0 :     if (is_valid)
     707                 :             :       {
     708                 :           0 :         ok = true;
     709                 :           0 :         return;
     710                 :             :       }
     711                 :             : 
     712                 :           0 :     BaseCmp::visit (type);
     713                 :             :   }
     714                 :             : 
     715                 :        3194 :   void visit (const ParamType &) override { ok = true; }
     716                 :             : 
     717                 :           0 :   void visit (const DynamicObjectType &type) override
     718                 :             :   {
     719                 :           0 :     bool is_valid
     720                 :           0 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     721                 :           0 :     if (is_valid)
     722                 :             :       {
     723                 :           0 :         ok = true;
     724                 :           0 :         return;
     725                 :             :       }
     726                 :             : 
     727                 :           0 :     BaseCmp::visit (type);
     728                 :             :   }
     729                 :             : 
     730                 :           0 :   void visit (const ClosureType &type) override
     731                 :             :   {
     732                 :           0 :     bool is_valid
     733                 :           0 :       = (base->get_infer_kind () == TyTy::InferType::InferTypeKind::GENERAL);
     734                 :           0 :     if (is_valid)
     735                 :             :       {
     736                 :           0 :         ok = true;
     737                 :           0 :         return;
     738                 :             :       }
     739                 :             : 
     740                 :           0 :     BaseCmp::visit (type);
     741                 :             :   }
     742                 :             : 
     743                 :             : private:
     744                 :           0 :   const BaseType *get_base () const override { return base; }
     745                 :             :   const InferType *base;
     746                 :             : };
     747                 :             : 
     748                 :             : class FnCmp : public BaseCmp
     749                 :             : {
     750                 :             :   using Rust::TyTy::BaseCmp::visit;
     751                 :             : 
     752                 :             : public:
     753                 :           0 :   FnCmp (const FnType *base, bool emit_errors)
     754                 :           0 :     : BaseCmp (base, emit_errors), base (base)
     755                 :             :   {}
     756                 :             : 
     757                 :           0 :   void visit (const InferType &type) override
     758                 :             :   {
     759                 :           0 :     ok = type.get_infer_kind () == InferType::InferTypeKind::GENERAL;
     760                 :           0 :   }
     761                 :             : 
     762                 :           0 :   void visit (const FnType &type) override
     763                 :             :   {
     764                 :           0 :     if (base->num_params () != type.num_params ())
     765                 :             :       {
     766                 :           0 :         BaseCmp::visit (type);
     767                 :           0 :         return;
     768                 :             :       }
     769                 :             : 
     770                 :           0 :     for (size_t i = 0; i < base->num_params (); i++)
     771                 :             :       {
     772                 :           0 :         auto a = base->param_at (i).get_type ();
     773                 :           0 :         auto b = type.param_at (i).get_type ();
     774                 :             : 
     775                 :           0 :         if (!a->can_eq (b, emit_error_flag))
     776                 :             :           {
     777                 :           0 :             emit_error_flag = false;
     778                 :           0 :             BaseCmp::visit (type);
     779                 :           0 :             return;
     780                 :             :           }
     781                 :             :       }
     782                 :             : 
     783                 :           0 :     if (!base->get_return_type ()->can_eq (type.get_return_type (),
     784                 :           0 :                                            emit_error_flag))
     785                 :             :       {
     786                 :           0 :         emit_error_flag = false;
     787                 :           0 :         BaseCmp::visit (type);
     788                 :           0 :         return;
     789                 :             :       }
     790                 :             : 
     791                 :           0 :     ok = true;
     792                 :             :   }
     793                 :             : 
     794                 :             : private:
     795                 :           0 :   const BaseType *get_base () const override { return base; }
     796                 :             :   const FnType *base;
     797                 :             : };
     798                 :             : 
     799                 :             : class FnptrCmp : public BaseCmp
     800                 :             : {
     801                 :             :   using Rust::TyTy::BaseCmp::visit;
     802                 :             : 
     803                 :             : public:
     804                 :           0 :   FnptrCmp (const FnPtr *base, bool emit_errors)
     805                 :           0 :     : BaseCmp (base, emit_errors), base (base)
     806                 :             :   {}
     807                 :             : 
     808                 :           0 :   void visit (const InferType &type) override
     809                 :             :   {
     810                 :           0 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
     811                 :             :       {
     812                 :           0 :         BaseCmp::visit (type);
     813                 :           0 :         return;
     814                 :             :       }
     815                 :             : 
     816                 :           0 :     ok = true;
     817                 :             :   }
     818                 :             : 
     819                 :           0 :   void visit (const FnPtr &type) override
     820                 :             :   {
     821                 :           0 :     if (base->num_params () != type.num_params ())
     822                 :             :       {
     823                 :           0 :         BaseCmp::visit (type);
     824                 :           0 :         return;
     825                 :             :       }
     826                 :             : 
     827                 :           0 :     auto this_ret_type = base->get_return_type ();
     828                 :           0 :     auto other_ret_type = type.get_return_type ();
     829                 :           0 :     if (!this_ret_type->can_eq (other_ret_type, emit_error_flag))
     830                 :             :       {
     831                 :           0 :         BaseCmp::visit (type);
     832                 :           0 :         return;
     833                 :             :       }
     834                 :             : 
     835                 :           0 :     for (size_t i = 0; i < base->num_params (); i++)
     836                 :             :       {
     837                 :           0 :         auto this_param = base->get_param_type_at (i);
     838                 :           0 :         auto other_param = type.get_param_type_at (i);
     839                 :           0 :         if (!this_param->can_eq (other_param, emit_error_flag))
     840                 :             :           {
     841                 :           0 :             BaseCmp::visit (type);
     842                 :           0 :             return;
     843                 :             :           }
     844                 :             :       }
     845                 :             : 
     846                 :           0 :     ok = true;
     847                 :             :   }
     848                 :             : 
     849                 :           0 :   void visit (const FnType &type) override
     850                 :             :   {
     851                 :           0 :     if (base->num_params () != type.num_params ())
     852                 :             :       {
     853                 :           0 :         BaseCmp::visit (type);
     854                 :           0 :         return;
     855                 :             :       }
     856                 :             : 
     857                 :           0 :     auto this_ret_type = base->get_return_type ();
     858                 :           0 :     auto other_ret_type = type.get_return_type ();
     859                 :           0 :     if (!this_ret_type->can_eq (other_ret_type, emit_error_flag))
     860                 :             :       {
     861                 :           0 :         BaseCmp::visit (type);
     862                 :           0 :         return;
     863                 :             :       }
     864                 :             : 
     865                 :           0 :     for (size_t i = 0; i < base->num_params (); i++)
     866                 :             :       {
     867                 :           0 :         auto this_param = base->get_param_type_at (i);
     868                 :           0 :         auto other_param = type.param_at (i).get_type ();
     869                 :           0 :         if (!this_param->can_eq (other_param, emit_error_flag))
     870                 :             :           {
     871                 :           0 :             BaseCmp::visit (type);
     872                 :           0 :             return;
     873                 :             :           }
     874                 :             :       }
     875                 :             : 
     876                 :           0 :     ok = true;
     877                 :             :   }
     878                 :             : 
     879                 :             : private:
     880                 :           0 :   const BaseType *get_base () const override { return base; }
     881                 :             :   const FnPtr *base;
     882                 :             : };
     883                 :             : 
     884                 :             : class ClosureCmp : public BaseCmp
     885                 :             : {
     886                 :             :   using Rust::TyTy::BaseCmp::visit;
     887                 :             : 
     888                 :             : public:
     889                 :          67 :   ClosureCmp (const ClosureType *base, bool emit_errors)
     890                 :          67 :     : BaseCmp (base, emit_errors), base (base)
     891                 :             :   {}
     892                 :             : 
     893                 :           0 :   void visit (const InferType &type) override
     894                 :             :   {
     895                 :           0 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
     896                 :             :       {
     897                 :           0 :         BaseCmp::visit (type);
     898                 :           0 :         return;
     899                 :             :       }
     900                 :             : 
     901                 :           0 :     ok = true;
     902                 :             :   }
     903                 :             : 
     904                 :          67 :   void visit (const ClosureType &type) override
     905                 :             :   {
     906                 :          67 :     if (base->get_def_id () != type.get_def_id ())
     907                 :             :       {
     908                 :           7 :         BaseCmp::visit (type);
     909                 :           7 :         return;
     910                 :             :       }
     911                 :             : 
     912                 :          60 :     if (!base->get_parameters ().can_eq (&type.get_parameters (), false))
     913                 :             :       {
     914                 :           0 :         BaseCmp::visit (type);
     915                 :           0 :         return;
     916                 :             :       }
     917                 :             : 
     918                 :          60 :     if (!base->get_result_type ().can_eq (&type.get_result_type (), false))
     919                 :             :       {
     920                 :           0 :         BaseCmp::visit (type);
     921                 :           0 :         return;
     922                 :             :       }
     923                 :             : 
     924                 :          60 :     ok = true;
     925                 :             :   }
     926                 :             : 
     927                 :             : private:
     928                 :           0 :   const BaseType *get_base () const override { return base; }
     929                 :             :   const ClosureType *base;
     930                 :             : };
     931                 :             : 
     932                 :             : class ArrayCmp : public BaseCmp
     933                 :             : {
     934                 :             :   using Rust::TyTy::BaseCmp::visit;
     935                 :             : 
     936                 :             : public:
     937                 :       11871 :   ArrayCmp (const ArrayType *base, bool emit_errors)
     938                 :       11871 :     : BaseCmp (base, emit_errors), base (base)
     939                 :             :   {}
     940                 :             : 
     941                 :          85 :   void visit (const ArrayType &type) override
     942                 :             :   {
     943                 :             :     // check base type
     944                 :          85 :     const BaseType *base_element = base->get_element_type ();
     945                 :          85 :     const BaseType *other_element = type.get_element_type ();
     946                 :          85 :     if (!base_element->can_eq (other_element, emit_error_flag))
     947                 :             :       {
     948                 :           0 :         BaseCmp::visit (type);
     949                 :           0 :         return;
     950                 :             :       }
     951                 :             : 
     952                 :          85 :     ok = true;
     953                 :             :   }
     954                 :             : 
     955                 :           0 :   void visit (const InferType &type) override
     956                 :             :   {
     957                 :           0 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
     958                 :             :       {
     959                 :           0 :         BaseCmp::visit (type);
     960                 :           0 :         return;
     961                 :             :       }
     962                 :             : 
     963                 :           0 :     ok = true;
     964                 :             :   }
     965                 :             : 
     966                 :             : private:
     967                 :           0 :   const BaseType *get_base () const override { return base; }
     968                 :             :   const ArrayType *base;
     969                 :             : };
     970                 :             : 
     971                 :             : class SliceCmp : public BaseCmp
     972                 :             : {
     973                 :             :   using Rust::TyTy::BaseCmp::visit;
     974                 :             : 
     975                 :             : public:
     976                 :        3534 :   SliceCmp (const SliceType *base, bool emit_errors)
     977                 :        3534 :     : BaseCmp (base, emit_errors), base (base)
     978                 :             :   {}
     979                 :             : 
     980                 :         721 :   void visit (const SliceType &type) override
     981                 :             :   {
     982                 :             :     // check base type
     983                 :         721 :     const BaseType *base_element = base->get_element_type ();
     984                 :         721 :     const BaseType *other_element = type.get_element_type ();
     985                 :         721 :     if (!base_element->can_eq (other_element, emit_error_flag))
     986                 :             :       {
     987                 :           0 :         BaseCmp::visit (type);
     988                 :           0 :         return;
     989                 :             :       }
     990                 :             : 
     991                 :         721 :     ok = true;
     992                 :             :   }
     993                 :             : 
     994                 :          77 :   void visit (const InferType &type) override
     995                 :             :   {
     996                 :          77 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
     997                 :             :       {
     998                 :          77 :         BaseCmp::visit (type);
     999                 :          77 :         return;
    1000                 :             :       }
    1001                 :             : 
    1002                 :           0 :     ok = true;
    1003                 :             :   }
    1004                 :             : 
    1005                 :             : private:
    1006                 :           0 :   const BaseType *get_base () const override { return base; }
    1007                 :             :   const SliceType *base;
    1008                 :             : };
    1009                 :             : 
    1010                 :             : class BoolCmp : public BaseCmp
    1011                 :             : {
    1012                 :             :   using Rust::TyTy::BaseCmp::visit;
    1013                 :             : 
    1014                 :             : public:
    1015                 :       24987 :   BoolCmp (const BoolType *base, bool emit_errors)
    1016                 :       24987 :     : BaseCmp (base, emit_errors), base (base)
    1017                 :             :   {}
    1018                 :             : 
    1019                 :         780 :   void visit (const BoolType &type) override { ok = true; }
    1020                 :             : 
    1021                 :          39 :   void visit (const InferType &type) override
    1022                 :             :   {
    1023                 :          39 :     ok = type.get_infer_kind () == InferType::InferTypeKind::GENERAL;
    1024                 :          39 :   }
    1025                 :             : 
    1026                 :             : private:
    1027                 :           0 :   const BaseType *get_base () const override { return base; }
    1028                 :             :   const BoolType *base;
    1029                 :             : };
    1030                 :             : 
    1031                 :             : class IntCmp : public BaseCmp
    1032                 :             : {
    1033                 :             :   using Rust::TyTy::BaseCmp::visit;
    1034                 :             : 
    1035                 :             : public:
    1036                 :      273750 :   IntCmp (const IntType *base, bool emit_errors)
    1037                 :      273750 :     : BaseCmp (base, emit_errors), base (base)
    1038                 :             :   {}
    1039                 :             : 
    1040                 :         227 :   void visit (const InferType &type) override
    1041                 :             :   {
    1042                 :         227 :     ok = type.get_infer_kind () != InferType::InferTypeKind::FLOAT;
    1043                 :         227 :   }
    1044                 :             : 
    1045                 :       63141 :   void visit (const IntType &type) override
    1046                 :             :   {
    1047                 :       63141 :     ok = type.get_int_kind () == base->get_int_kind ();
    1048                 :       63141 :   }
    1049                 :             : 
    1050                 :             : private:
    1051                 :           0 :   const BaseType *get_base () const override { return base; }
    1052                 :             :   const IntType *base;
    1053                 :             : };
    1054                 :             : 
    1055                 :             : class UintCmp : public BaseCmp
    1056                 :             : {
    1057                 :             :   using Rust::TyTy::BaseCmp::visit;
    1058                 :             : 
    1059                 :             : public:
    1060                 :      355438 :   UintCmp (const UintType *base, bool emit_errors)
    1061                 :      355438 :     : BaseCmp (base, emit_errors), base (base)
    1062                 :             :   {}
    1063                 :             : 
    1064                 :          25 :   void visit (const InferType &type) override
    1065                 :             :   {
    1066                 :          25 :     ok = type.get_infer_kind () != InferType::InferTypeKind::FLOAT;
    1067                 :          25 :   }
    1068                 :             : 
    1069                 :      119592 :   void visit (const UintType &type) override
    1070                 :             :   {
    1071                 :      119592 :     ok = type.get_uint_kind () == base->get_uint_kind ();
    1072                 :      119592 :   }
    1073                 :             : 
    1074                 :             : private:
    1075                 :           0 :   const BaseType *get_base () const override { return base; }
    1076                 :             :   const UintType *base;
    1077                 :             : };
    1078                 :             : 
    1079                 :             : class FloatCmp : public BaseCmp
    1080                 :             : {
    1081                 :             :   using Rust::TyTy::BaseCmp::visit;
    1082                 :             : 
    1083                 :             : public:
    1084                 :       87889 :   FloatCmp (const FloatType *base, bool emit_errors)
    1085                 :       87889 :     : BaseCmp (base, emit_errors), base (base)
    1086                 :             :   {}
    1087                 :             : 
    1088                 :         136 :   void visit (const InferType &type) override
    1089                 :             :   {
    1090                 :         136 :     ok = type.get_infer_kind () != InferType::InferTypeKind::INTEGRAL;
    1091                 :         136 :   }
    1092                 :             : 
    1093                 :        4190 :   void visit (const FloatType &type) override
    1094                 :             :   {
    1095                 :        4190 :     ok = type.get_float_kind () == base->get_float_kind ();
    1096                 :        4190 :   }
    1097                 :             : 
    1098                 :             : private:
    1099                 :           0 :   const BaseType *get_base () const override { return base; }
    1100                 :             :   const FloatType *base;
    1101                 :             : };
    1102                 :             : 
    1103                 :             : class ADTCmp : public BaseCmp
    1104                 :             : {
    1105                 :             :   using Rust::TyTy::BaseCmp::visit;
    1106                 :             : 
    1107                 :             : public:
    1108                 :      322089 :   ADTCmp (const ADTType *base, bool emit_errors)
    1109                 :      322089 :     : BaseCmp (base, emit_errors), base (base)
    1110                 :             :   {}
    1111                 :             : 
    1112                 :       90037 :   void visit (const ADTType &type) override
    1113                 :             :   {
    1114                 :       90037 :     if (base->get_adt_kind () != type.get_adt_kind ())
    1115                 :             :       {
    1116                 :       42678 :         BaseCmp::visit (type);
    1117                 :       42678 :         return;
    1118                 :             :       }
    1119                 :             : 
    1120                 :      142077 :     if (base->get_identifier ().compare (type.get_identifier ()) != 0)
    1121                 :             :       {
    1122                 :       18479 :         BaseCmp::visit (type);
    1123                 :       18479 :         return;
    1124                 :             :       }
    1125                 :             : 
    1126                 :       28880 :     if (base->number_of_variants () != type.number_of_variants ())
    1127                 :             :       {
    1128                 :           0 :         BaseCmp::visit (type);
    1129                 :           0 :         return;
    1130                 :             :       }
    1131                 :             : 
    1132                 :       65219 :     for (size_t i = 0; i < type.number_of_variants (); ++i)
    1133                 :             :       {
    1134                 :       37500 :         TyTy::VariantDef *a = base->get_variants ().at (i);
    1135                 :       37500 :         TyTy::VariantDef *b = type.get_variants ().at (i);
    1136                 :             : 
    1137                 :       37500 :         if (a->num_fields () != b->num_fields ())
    1138                 :             :           {
    1139                 :           0 :             BaseCmp::visit (type);
    1140                 :           0 :             return;
    1141                 :             :           }
    1142                 :             : 
    1143                 :       74197 :         for (size_t j = 0; j < a->num_fields (); j++)
    1144                 :             :           {
    1145                 :       37858 :             TyTy::StructFieldType *base_field = a->get_field_at_index (j);
    1146                 :       37858 :             TyTy::StructFieldType *other_field = b->get_field_at_index (j);
    1147                 :             : 
    1148                 :       37858 :             TyTy::BaseType *this_field_ty = base_field->get_field_type ();
    1149                 :       37858 :             TyTy::BaseType *other_field_ty = other_field->get_field_type ();
    1150                 :             : 
    1151                 :       37858 :             if (!this_field_ty->can_eq (other_field_ty, emit_error_flag))
    1152                 :             :               {
    1153                 :        1161 :                 BaseCmp::visit (type);
    1154                 :        1161 :                 return;
    1155                 :             :               }
    1156                 :             :           }
    1157                 :             :       }
    1158                 :             : 
    1159                 :       27719 :     ok = true;
    1160                 :             :   }
    1161                 :             : 
    1162                 :         717 :   void visit (const InferType &type) override
    1163                 :             :   {
    1164                 :         717 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
    1165                 :             :       {
    1166                 :          99 :         BaseCmp::visit (type);
    1167                 :          99 :         return;
    1168                 :             :       }
    1169                 :             : 
    1170                 :         618 :     ok = true;
    1171                 :             :   }
    1172                 :             : 
    1173                 :             : private:
    1174                 :           0 :   const BaseType *get_base () const override { return base; }
    1175                 :             :   const ADTType *base;
    1176                 :             : };
    1177                 :             : 
    1178                 :             : class TupleCmp : public BaseCmp
    1179                 :             : {
    1180                 :             :   using Rust::TyTy::BaseCmp::visit;
    1181                 :             : 
    1182                 :             : public:
    1183                 :         244 :   TupleCmp (const TupleType *base, bool emit_errors)
    1184                 :         244 :     : BaseCmp (base, emit_errors), base (base)
    1185                 :             :   {}
    1186                 :             : 
    1187                 :         177 :   void visit (const TupleType &type) override
    1188                 :             :   {
    1189                 :         177 :     if (base->num_fields () != type.num_fields ())
    1190                 :             :       {
    1191                 :           0 :         BaseCmp::visit (type);
    1192                 :           0 :         return;
    1193                 :             :       }
    1194                 :             : 
    1195                 :         367 :     for (size_t i = 0; i < base->num_fields (); i++)
    1196                 :             :       {
    1197                 :         190 :         BaseType *bo = base->get_field (i);
    1198                 :         190 :         BaseType *fo = type.get_field (i);
    1199                 :             : 
    1200                 :         190 :         if (!bo->can_eq (fo, emit_error_flag))
    1201                 :             :           {
    1202                 :           0 :             BaseCmp::visit (type);
    1203                 :           0 :             return;
    1204                 :             :           }
    1205                 :             :       }
    1206                 :             : 
    1207                 :         177 :     ok = true;
    1208                 :             :   }
    1209                 :             : 
    1210                 :           1 :   void visit (const InferType &type) override
    1211                 :             :   {
    1212                 :           1 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
    1213                 :             :       {
    1214                 :           0 :         BaseCmp::visit (type);
    1215                 :           0 :         return;
    1216                 :             :       }
    1217                 :             : 
    1218                 :           1 :     ok = true;
    1219                 :             :   }
    1220                 :             : 
    1221                 :             : private:
    1222                 :           0 :   const BaseType *get_base () const override { return base; }
    1223                 :             :   const TupleType *base;
    1224                 :             : };
    1225                 :             : 
    1226                 :             : class USizeCmp : public BaseCmp
    1227                 :             : {
    1228                 :             :   using Rust::TyTy::BaseCmp::visit;
    1229                 :             : 
    1230                 :             : public:
    1231                 :      163072 :   USizeCmp (const USizeType *base, bool emit_errors)
    1232                 :      163072 :     : BaseCmp (base, emit_errors), base (base)
    1233                 :             :   {}
    1234                 :             : 
    1235                 :         235 :   void visit (const InferType &type) override
    1236                 :             :   {
    1237                 :         235 :     ok = type.get_infer_kind () != InferType::InferTypeKind::FLOAT;
    1238                 :         235 :   }
    1239                 :             : 
    1240                 :       16838 :   void visit (const USizeType &type) override { ok = true; }
    1241                 :             : 
    1242                 :             : private:
    1243                 :           0 :   const BaseType *get_base () const override { return base; }
    1244                 :             :   const USizeType *base;
    1245                 :             : };
    1246                 :             : 
    1247                 :             : class ISizeCmp : public BaseCmp
    1248                 :             : {
    1249                 :             :   using Rust::TyTy::BaseCmp::visit;
    1250                 :             : 
    1251                 :             : public:
    1252                 :       86159 :   ISizeCmp (const ISizeType *base, bool emit_errors)
    1253                 :       86159 :     : BaseCmp (base, emit_errors), base (base)
    1254                 :             :   {}
    1255                 :             : 
    1256                 :          15 :   void visit (const InferType &type) override
    1257                 :             :   {
    1258                 :          15 :     ok = type.get_infer_kind () != InferType::InferTypeKind::FLOAT;
    1259                 :          15 :   }
    1260                 :             : 
    1261                 :        5072 :   void visit (const ISizeType &type) override { ok = true; }
    1262                 :             : 
    1263                 :             : private:
    1264                 :           0 :   const BaseType *get_base () const override { return base; }
    1265                 :             :   const ISizeType *base;
    1266                 :             : };
    1267                 :             : 
    1268                 :             : class CharCmp : public BaseCmp
    1269                 :             : {
    1270                 :             :   using Rust::TyTy::BaseCmp::visit;
    1271                 :             : 
    1272                 :             : public:
    1273                 :       23742 :   CharCmp (const CharType *base, bool emit_errors)
    1274                 :       23742 :     : BaseCmp (base, emit_errors), base (base)
    1275                 :             :   {}
    1276                 :             : 
    1277                 :          33 :   void visit (const InferType &type) override
    1278                 :             :   {
    1279                 :          33 :     ok = type.get_infer_kind () == InferType::InferTypeKind::GENERAL;
    1280                 :          33 :   }
    1281                 :             : 
    1282                 :         381 :   void visit (const CharType &type) override { ok = true; }
    1283                 :             : 
    1284                 :             : private:
    1285                 :           0 :   const BaseType *get_base () const override { return base; }
    1286                 :             :   const CharType *base;
    1287                 :             : };
    1288                 :             : 
    1289                 :             : class ReferenceCmp : public BaseCmp
    1290                 :             : {
    1291                 :             :   using Rust::TyTy::BaseCmp::visit;
    1292                 :             : 
    1293                 :             : public:
    1294                 :       48395 :   ReferenceCmp (const ReferenceType *base, bool emit_errors)
    1295                 :       48395 :     : BaseCmp (base, emit_errors), base (base)
    1296                 :             :   {}
    1297                 :             : 
    1298                 :        3526 :   void visit (const ReferenceType &type) override
    1299                 :             :   {
    1300                 :        3526 :     auto base_type = base->get_base ();
    1301                 :        3526 :     auto other_base_type = type.get_base ();
    1302                 :             : 
    1303                 :        3526 :     bool mutability_ok = base->is_mutable () ? type.is_mutable () : true;
    1304                 :         382 :     if (!mutability_ok)
    1305                 :             :       {
    1306                 :         214 :         BaseCmp::visit (type);
    1307                 :         214 :         return;
    1308                 :             :       }
    1309                 :             : 
    1310                 :        3312 :     if (!base_type->can_eq (other_base_type, emit_error_flag))
    1311                 :             :       {
    1312                 :        2546 :         BaseCmp::visit (type);
    1313                 :        2546 :         return;
    1314                 :             :       }
    1315                 :             : 
    1316                 :         766 :     ok = true;
    1317                 :             :   }
    1318                 :             : 
    1319                 :          43 :   void visit (const InferType &type) override
    1320                 :             :   {
    1321                 :          43 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
    1322                 :             :       {
    1323                 :          14 :         BaseCmp::visit (type);
    1324                 :          14 :         return;
    1325                 :             :       }
    1326                 :             : 
    1327                 :          29 :     ok = true;
    1328                 :             :   }
    1329                 :             : 
    1330                 :             : private:
    1331                 :           0 :   const BaseType *get_base () const override { return base; }
    1332                 :             :   const ReferenceType *base;
    1333                 :             : };
    1334                 :             : 
    1335                 :             : class PointerCmp : public BaseCmp
    1336                 :             : {
    1337                 :             :   using Rust::TyTy::BaseCmp::visit;
    1338                 :             : 
    1339                 :             : public:
    1340                 :        1986 :   PointerCmp (const PointerType *base, bool emit_errors)
    1341                 :        1986 :     : BaseCmp (base, emit_errors), base (base)
    1342                 :             :   {}
    1343                 :             : 
    1344                 :           6 :   void visit (const PointerType &type) override
    1345                 :             :   {
    1346                 :           6 :     auto base_type = base->get_base ();
    1347                 :           6 :     auto other_base_type = type.get_base ();
    1348                 :             : 
    1349                 :           6 :     bool mutability_ok = base->is_mutable () ? type.is_mutable () : true;
    1350                 :           0 :     if (!mutability_ok)
    1351                 :             :       {
    1352                 :           0 :         BaseCmp::visit (type);
    1353                 :           0 :         return;
    1354                 :             :       }
    1355                 :             : 
    1356                 :           6 :     if (!base_type->can_eq (other_base_type, emit_error_flag))
    1357                 :             :       {
    1358                 :           0 :         BaseCmp::visit (type);
    1359                 :           0 :         return;
    1360                 :             :       }
    1361                 :             : 
    1362                 :           6 :     ok = true;
    1363                 :             :   }
    1364                 :             : 
    1365                 :           0 :   void visit (const InferType &type) override
    1366                 :             :   {
    1367                 :           0 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
    1368                 :             :       {
    1369                 :           0 :         BaseCmp::visit (type);
    1370                 :           0 :         return;
    1371                 :             :       }
    1372                 :             : 
    1373                 :           0 :     ok = true;
    1374                 :             :   }
    1375                 :             : 
    1376                 :             : private:
    1377                 :           0 :   const BaseType *get_base () const override { return base; }
    1378                 :             :   const PointerType *base;
    1379                 :             : };
    1380                 :             : 
    1381                 :             : class ParamCmp : public BaseCmp
    1382                 :             : {
    1383                 :             :   using Rust::TyTy::BaseCmp::visit;
    1384                 :             : 
    1385                 :             : public:
    1386                 :       63951 :   ParamCmp (const ParamType *base, bool emit_errors)
    1387                 :       63951 :     : BaseCmp (base, emit_errors), base (base)
    1388                 :             :   {}
    1389                 :             : 
    1390                 :             :   // param types are a placeholder we shouldn't have cases where we unify
    1391                 :             :   // against it. eg: struct foo<T> { a: T }; When we invoke it we can do either:
    1392                 :             :   //
    1393                 :             :   // foo<i32>{ a: 123 }.
    1394                 :             :   // Then this enforces the i32 type to be referenced on the
    1395                 :             :   // field via an hirid.
    1396                 :             :   //
    1397                 :             :   // rust also allows for a = foo{a:123}; Where we can use an Inference Variable
    1398                 :             :   // to handle the typing of the struct
    1399                 :       63951 :   bool can_eq (const BaseType *other) override
    1400                 :             :   {
    1401                 :       63951 :     if (!base->can_resolve ())
    1402                 :       32479 :       return BaseCmp::can_eq (other);
    1403                 :             : 
    1404                 :       31472 :     auto lookup = base->resolve ();
    1405                 :       31472 :     return lookup->can_eq (other, emit_error_flag);
    1406                 :             :   }
    1407                 :             : 
    1408                 :             :   // imagine the case where we have:
    1409                 :             :   // struct Foo<T>(T);
    1410                 :             :   // Then we declare a generic impl block
    1411                 :             :   // impl <X>Foo<X> { ... }
    1412                 :             :   // both of these types are compatible so we mostly care about the number of
    1413                 :             :   // generic arguments
    1414                 :        6661 :   void visit (const ParamType &) override { ok = true; }
    1415                 :             : 
    1416                 :           0 :   void visit (const TupleType &) override { ok = true; }
    1417                 :             : 
    1418                 :         298 :   void visit (const InferType &) override { ok = true; }
    1419                 :             : 
    1420                 :           0 :   void visit (const FnType &) override { ok = true; }
    1421                 :             : 
    1422                 :           0 :   void visit (const FnPtr &) override { ok = true; }
    1423                 :             : 
    1424                 :        4218 :   void visit (const ADTType &) override { ok = true; }
    1425                 :             : 
    1426                 :         720 :   void visit (const ArrayType &) override { ok = true; }
    1427                 :             : 
    1428                 :           1 :   void visit (const SliceType &) override { ok = true; }
    1429                 :             : 
    1430                 :         375 :   void visit (const BoolType &) override { ok = true; }
    1431                 :             : 
    1432                 :        2341 :   void visit (const IntType &) override { ok = true; }
    1433                 :             : 
    1434                 :        9755 :   void visit (const UintType &) override { ok = true; }
    1435                 :             : 
    1436                 :        5814 :   void visit (const USizeType &) override { ok = true; }
    1437                 :             : 
    1438                 :         312 :   void visit (const ISizeType &) override { ok = true; }
    1439                 :             : 
    1440                 :         824 :   void visit (const FloatType &) override { ok = true; }
    1441                 :             : 
    1442                 :         312 :   void visit (const CharType &) override { ok = true; }
    1443                 :             : 
    1444                 :         346 :   void visit (const ReferenceType &) override { ok = true; }
    1445                 :             : 
    1446                 :           0 :   void visit (const PointerType &) override { ok = true; }
    1447                 :             : 
    1448                 :           0 :   void visit (const StrType &) override { ok = true; }
    1449                 :             : 
    1450                 :         294 :   void visit (const NeverType &) override { ok = true; }
    1451                 :             : 
    1452                 :         208 :   void visit (const DynamicObjectType &) override { ok = true; }
    1453                 :             : 
    1454                 :           0 :   void visit (const PlaceholderType &type) override
    1455                 :             :   {
    1456                 :           0 :     ok = base->get_symbol ().compare (type.get_symbol ()) == 0;
    1457                 :           0 :   }
    1458                 :             : 
    1459                 :             : private:
    1460                 :           0 :   const BaseType *get_base () const override { return base; }
    1461                 :             :   const ParamType *base;
    1462                 :             : };
    1463                 :             : 
    1464                 :             : class StrCmp : public BaseCmp
    1465                 :             : {
    1466                 :             :   // FIXME we will need a enum for the StrType like ByteBuf etc..
    1467                 :             :   using Rust::TyTy::BaseCmp::visit;
    1468                 :             : 
    1469                 :             : public:
    1470                 :          80 :   StrCmp (const StrType *base, bool emit_errors)
    1471                 :          80 :     : BaseCmp (base, emit_errors), base (base)
    1472                 :             :   {}
    1473                 :             : 
    1474                 :          80 :   void visit (const StrType &type) override { ok = true; }
    1475                 :             : 
    1476                 :           0 :   void visit (const InferType &type) override
    1477                 :             :   {
    1478                 :           0 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
    1479                 :             :       {
    1480                 :           0 :         BaseCmp::visit (type);
    1481                 :           0 :         return;
    1482                 :             :       }
    1483                 :             : 
    1484                 :           0 :     ok = true;
    1485                 :             :   }
    1486                 :             : 
    1487                 :             : private:
    1488                 :           0 :   const BaseType *get_base () const override { return base; }
    1489                 :             :   const StrType *base;
    1490                 :             : };
    1491                 :             : 
    1492                 :             : class NeverCmp : public BaseCmp
    1493                 :             : {
    1494                 :             :   using Rust::TyTy::BaseCmp::visit;
    1495                 :             : 
    1496                 :             : public:
    1497                 :        4593 :   NeverCmp (const NeverType *base, bool emit_errors)
    1498                 :        4593 :     : BaseCmp (base, emit_errors), base (base)
    1499                 :             :   {}
    1500                 :             : 
    1501                 :          52 :   void visit (const NeverType &type) override { ok = true; }
    1502                 :             : 
    1503                 :          25 :   void visit (const InferType &type) override
    1504                 :             :   {
    1505                 :          25 :     if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
    1506                 :             :       {
    1507                 :           0 :         BaseCmp::visit (type);
    1508                 :           0 :         return;
    1509                 :             :       }
    1510                 :             : 
    1511                 :          25 :     ok = true;
    1512                 :             :   }
    1513                 :             : 
    1514                 :             : private:
    1515                 :           0 :   const BaseType *get_base () const override { return base; }
    1516                 :             :   const NeverType *base;
    1517                 :             : };
    1518                 :             : 
    1519                 :             : class PlaceholderCmp : public BaseCmp
    1520                 :             : {
    1521                 :             :   using Rust::TyTy::BaseCmp::visit;
    1522                 :             : 
    1523                 :             : public:
    1524                 :        3366 :   PlaceholderCmp (const PlaceholderType *base, bool emit_errors)
    1525                 :        3366 :     : BaseCmp (base, emit_errors), base (base)
    1526                 :             :   {}
    1527                 :             : 
    1528                 :        3366 :   bool can_eq (const BaseType *other) override
    1529                 :             :   {
    1530                 :        3366 :     if (!base->can_resolve ())
    1531                 :        3152 :       return BaseCmp::can_eq (other);
    1532                 :             : 
    1533                 :         214 :     BaseType *lookup = base->resolve ();
    1534                 :         214 :     return lookup->can_eq (other, emit_error_flag);
    1535                 :             :   }
    1536                 :             : 
    1537                 :           0 :   void visit (const TupleType &) override { ok = true; }
    1538                 :             : 
    1539                 :          45 :   void visit (const ADTType &) override { ok = true; }
    1540                 :             : 
    1541                 :           0 :   void visit (const InferType &) override { ok = true; }
    1542                 :             : 
    1543                 :           0 :   void visit (const FnType &) override { ok = true; }
    1544                 :             : 
    1545                 :           0 :   void visit (const FnPtr &) override { ok = true; }
    1546                 :             : 
    1547                 :           0 :   void visit (const ArrayType &) override { ok = true; }
    1548                 :             : 
    1549                 :          96 :   void visit (const BoolType &) override { ok = true; }
    1550                 :             : 
    1551                 :         417 :   void visit (const IntType &) override { ok = true; }
    1552                 :             : 
    1553                 :         787 :   void visit (const UintType &) override { ok = true; }
    1554                 :             : 
    1555                 :         267 :   void visit (const USizeType &) override { ok = true; }
    1556                 :             : 
    1557                 :         113 :   void visit (const ISizeType &) override { ok = true; }
    1558                 :             : 
    1559                 :         390 :   void visit (const FloatType &) override { ok = true; }
    1560                 :             : 
    1561                 :           0 :   void visit (const ErrorType &) override { ok = true; }
    1562                 :             : 
    1563                 :          96 :   void visit (const CharType &) override { ok = true; }
    1564                 :             : 
    1565                 :           1 :   void visit (const ReferenceType &) override { ok = true; }
    1566                 :             : 
    1567                 :         703 :   void visit (const ParamType &) override { ok = true; }
    1568                 :             : 
    1569                 :           0 :   void visit (const StrType &) override { ok = true; }
    1570                 :             : 
    1571                 :          25 :   void visit (const NeverType &) override { ok = true; }
    1572                 :             : 
    1573                 :         140 :   void visit (const SliceType &) override { ok = true; }
    1574                 :             : 
    1575                 :             : private:
    1576                 :           0 :   const BaseType *get_base () const override { return base; }
    1577                 :             : 
    1578                 :             :   const PlaceholderType *base;
    1579                 :             : };
    1580                 :             : 
    1581                 :             : class DynamicCmp : public BaseCmp
    1582                 :             : {
    1583                 :             :   using Rust::TyTy::BaseCmp::visit;
    1584                 :             : 
    1585                 :             : public:
    1586                 :       13403 :   DynamicCmp (const DynamicObjectType *base, bool emit_errors)
    1587                 :       13403 :     : BaseCmp (base, emit_errors), base (base)
    1588                 :             :   {}
    1589                 :             : 
    1590                 :           7 :   void visit (const DynamicObjectType &type) override
    1591                 :             :   {
    1592                 :           7 :     if (base->num_specified_bounds () != type.num_specified_bounds ())
    1593                 :             :       {
    1594                 :           0 :         BaseCmp::visit (type);
    1595                 :           0 :         return;
    1596                 :             :       }
    1597                 :             : 
    1598                 :           7 :     location_t ref_locus = mappings.lookup_location (type.get_ref ());
    1599                 :           7 :     ok = base->bounds_compatible (type, ref_locus, false);
    1600                 :             :   }
    1601                 :             : 
    1602                 :             : private:
    1603                 :           0 :   const BaseType *get_base () const override { return base; }
    1604                 :             : 
    1605                 :             :   const DynamicObjectType *base;
    1606                 :             : };
    1607                 :             : 
    1608                 :             : class OpaqueCmp : public BaseCmp
    1609                 :             : {
    1610                 :             :   using Rust::TyTy::BaseCmp::visit;
    1611                 :             : 
    1612                 :             : public:
    1613                 :           0 :   OpaqueCmp (const OpaqueType *base, bool emit_errors)
    1614                 :           0 :     : BaseCmp (base, emit_errors), base (base)
    1615                 :             :   {}
    1616                 :             : 
    1617                 :             :   // TODO
    1618                 :             : 
    1619                 :             : private:
    1620                 :           0 :   const BaseType *get_base () const override { return base; }
    1621                 :             : 
    1622                 :             :   const OpaqueType *base;
    1623                 :             : };
    1624                 :             : 
    1625                 :             : class ConstCmp : public BaseCmp
    1626                 :             : {
    1627                 :             :   using Rust::TyTy::BaseCmp::visit;
    1628                 :             : 
    1629                 :             : public:
    1630                 :           0 :   ConstCmp (const ConstType *base, bool emit_errors)
    1631                 :           0 :     : BaseCmp (base, emit_errors), base (base)
    1632                 :             :   {}
    1633                 :             : 
    1634                 :             :   // TODO
    1635                 :             : 
    1636                 :             : private:
    1637                 :           0 :   const BaseType *get_base () const override { return base; }
    1638                 :             : 
    1639                 :             :   const ConstType *base;
    1640                 :             : };
    1641                 :             : 
    1642                 :             : } // namespace TyTy
    1643                 :             : } // namespace Rust
    1644                 :             : 
    1645                 :             : #endif // RUST_TYTY_CMP_H
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.