LCOV - code coverage report
Current view: top level - gcc/rust/expand - rust-derive-coerce-pointee.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 11 11
Test Date: 2026-10-24 16:24:59 Functions: 100.0 % 2 2
Legend: Lines:     hit not hit

            Line data    Source code
       1              : // Copyright (C) 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              : #include "rust-derive-coerce-pointee.h"
      20              : #include "rust-session-manager.h"
      21              : #include "rust-feature.h"
      22              : #include "rust-feature-store.h"
      23              : 
      24              : namespace Rust {
      25              : namespace AST {
      26              : 
      27            3 : DeriveCoercePointee::DeriveCoercePointee (location_t loc,
      28              :                                           Builder::Source item_source)
      29            3 :   : DeriveVisitor (loc, item_source)
      30            3 : {}
      31              : 
      32              : std::unique_ptr<AST::Item>
      33            3 : DeriveCoercePointee::go (Item &item)
      34              : {
      35            6 :   Features::EarlyFeatureGateStore::get ().add (
      36              :     Feature::Name::DERIVE_COERCE_POINTEE,
      37            3 :     Error (loc, "use of unstable library feature %<derive_coerce_pointee%>"));
      38              : 
      39              :   // NOTE: This is technically a library feature, so I don't think this is
      40              :   // how it should be gated. But as far as I can tell at the moment we have
      41              :   // no mechanisms for handling these, and furthermore this will go through
      42              :   // our compatibility layer.
      43              :   //
      44              :   // What this means is that the `CoercePointee` macro will *not* be defined
      45              :   // in the `core` that we will be using to compile the kernel at first.
      46              :   //
      47              :   // The basic example for `CoercePointee` is something like this:
      48              :   //
      49              :   // ```rust
      50              :   // use std::marker::CoercePointee;
      51              :   //
      52              :   // #[derive(CoercePointee)]
      53              :   // struct Flip<Flop>(*const Flop);
      54              :   // ```
      55              :   //
      56              :   // but the marker will not be present in the `core` we will be using at
      57              :   // first, so we will need to fake its existence with
      58              :   // -frust-compat-version, and then the compiler can assume that it is a
      59              :   // built-in derive. At least that's my expectation.
      60              : 
      61            3 :   if (!Session::get_instance ().should_support_coerce_pointee ())
      62              :     {
      63            1 :       rust_error_at (loc, "derive(CoercePointee) requires a compatibility mode "
      64              :                           "greater or equal to 1.84");
      65            1 :       return {};
      66              :     }
      67              : 
      68            2 :   rust_warning_at (
      69              :     loc, 0,
      70              :     "derive(CoercePointee) is currently unimplemented and has no effect");
      71              : 
      72            2 :   return {};
      73              : }
      74              : 
      75              : } // namespace AST
      76              : } // namespace Rust
        

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