LCOV - code coverage report
Current view: top level - gcc/rust/expand - rust-derive-eq.h Coverage Total Hit
Test: gcc.info Lines: 100.0 % 1 1
Test Date: 2026-02-28 14:20:25 Functions: - 0 0
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // Copyright (C) 2025-2026 Free Software Foundation, Inc.
       2              : 
       3              : // This file is part of GCC.
       4              : 
       5              : // GCC is free software; you can redistribute it and/or modify it under
       6              : // the terms of the GNU General Public License as published by the Free
       7              : // Software Foundation; either version 3, or (at your option) any later
       8              : // version.
       9              : 
      10              : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      11              : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12              : // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      13              : // for more details.
      14              : 
      15              : // You should have received a copy of the GNU General Public License
      16              : // along with GCC; see the file COPYING3.  If not see
      17              : // <http://www.gnu.org/licenses/>.
      18              : 
      19              : #ifndef RUST_DERIVE_EQ_H
      20              : #define RUST_DERIVE_EQ_H
      21              : 
      22              : #include "rust-derive.h"
      23              : 
      24              : namespace Rust {
      25              : namespace AST {
      26              : 
      27              : // FIXME: Need to figure out structuraleq marker trait
      28              : 
      29           47 : class DeriveEq : DeriveVisitor
      30              : {
      31              : public:
      32              :   DeriveEq (location_t loc);
      33              : 
      34              :   std::vector<std::unique_ptr<Item>> go (Item &item);
      35              : 
      36              : private:
      37              :   std::vector<std::unique_ptr<Item>> expanded;
      38              : 
      39              :   /**
      40              :    * Create the actual `assert_receiver_is_total_eq` function of the
      41              :    * implementation, which asserts that every type contained within our targeted
      42              :    * type also implements `Eq`.
      43              :    */
      44              :   std::unique_ptr<AssociatedItem>
      45              :   assert_receiver_is_total_eq_fn (std::vector<std::unique_ptr<Type>> &&types);
      46              : 
      47              :   /**
      48              :    * Create the Eq trait implementation for a type
      49              :    *
      50              :    * impl Eq for <type> {
      51              :    *     <assert_receiver_is_total_eq>
      52              :    * }
      53              :    *
      54              :    */
      55              :   std::vector<std::unique_ptr<Item>>
      56              :   eq_impls (std::unique_ptr<AssociatedItem> &&fn, std::string name,
      57              :             const std::vector<std::unique_ptr<GenericParam>> &type_generics);
      58              : 
      59              :   /**
      60              :    * Generate the following structure definition
      61              :    *
      62              :    * struct AssertParamIsEq<T: Eq + ?Sized> { _t: PhantomData<T> }
      63              :    */
      64              :   std::unique_ptr<Stmt> assert_param_is_eq ();
      65              : 
      66              :   /**
      67              :    * Generate a let statement to assert a type implements `Eq`
      68              :    *
      69              :    * let _: AssertParamIsEq<type>;
      70              :    */
      71              :   std::unique_ptr<Stmt> assert_type_is_eq (std::unique_ptr<Type> &&type);
      72              : 
      73              :   virtual void visit_struct (StructStruct &item) override;
      74              :   virtual void visit_tuple (TupleStruct &item) override;
      75              :   virtual void visit_enum (Enum &item) override;
      76              :   virtual void visit_union (Union &item) override;
      77              : };
      78              : 
      79              : } // namespace AST
      80              : } // namespace Rust
      81              : 
      82              : #endif // ! RUST_DERIVE_EQ_H
        

Generated by: LCOV version 2.4-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.