Line data Source code
1 : // Copyright (C) 2020-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_TYTY_UTIL_H
20 : #define RUST_TYTY_UTIL_H
21 :
22 : #include "rust-hir-map.h"
23 :
24 : namespace Rust {
25 : namespace TyTy {
26 :
27 : class BaseType;
28 : class ConstType;
29 :
30 : // this is a placeholder for types that can change like inference variables
31 : class TyVar
32 : {
33 : public:
34 : explicit TyVar (HirId ref);
35 :
36 31 : HirId get_ref () const { return ref; }
37 :
38 : BaseType *get_tyty () const;
39 :
40 : TyVar clone () const;
41 :
42 : TyVar monomorphized_clone () const;
43 :
44 : static TyVar get_implicit_infer_var (location_t locus);
45 :
46 : static TyVar get_implicit_const_infer_var (location_t locus,
47 : TyVar *implicit_type = nullptr);
48 :
49 : static TyVar subst_covariant_var (TyTy::BaseType *orig,
50 : TyTy::BaseType *subst);
51 :
52 : private:
53 : HirId ref;
54 : };
55 :
56 : class TyWithLocation
57 : {
58 : public:
59 : explicit TyWithLocation (BaseType *ty, location_t locus);
60 : explicit TyWithLocation (BaseType *ty);
61 :
62 6539345 : BaseType *get_ty () const { return ty; }
63 128447 : location_t get_locus () const { return locus; }
64 :
65 : private:
66 : BaseType *ty;
67 : location_t locus;
68 : };
69 :
70 : } // namespace TyTy
71 : } // namespace Rust
72 :
73 : #endif // RUST_TYTY_UTIL_H
|