1 // Copyright (C) 2021-2025 Free Software Foundation, Inc.
3 // This file is part of GCC.
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
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
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/>.
19 #ifndef RUST_HIR_TRAIT_RESOLVE_H
20 #define RUST_HIR_TRAIT_RESOLVE_H
22 #include "rust-hir-type-check-type.h"
23 #include "rust-hir-visitor.h"
28 class ResolveTraitItemToRef
: public TypeCheckBase
,
29 private HIR::HIRTraitItemVisitor
32 static TraitItemReference
33 Resolve (HIR::TraitItem
&item
, TyTy::BaseType
*self
,
34 std::vector
<TyTy::SubstitutionParamMapping
> substitutions
);
36 void visit (HIR::TraitItemType
&type
) override
;
38 void visit (HIR::TraitItemConst
&cst
) override
;
40 void visit (HIR::TraitItemFunc
&fn
) override
;
43 ResolveTraitItemToRef (
45 std::vector
<TyTy::SubstitutionParamMapping
> &&substitutions
);
47 TraitItemReference resolved
;
49 std::vector
<TyTy::SubstitutionParamMapping
> substitutions
;
52 class TraitResolver
: public TypeCheckBase
55 static TraitReference
*Resolve (HIR::TypePath
&path
);
57 static TraitReference
*Resolve (HIR::Trait
&trait
);
59 static TraitReference
*Lookup (HIR::TypePath
&path
);
64 TraitReference
*resolve_path (HIR::TypePath
&path
);
66 TraitReference
*resolve_trait (HIR::Trait
*trait_reference
);
68 TraitReference
*lookup_path (HIR::TypePath
&path
);
70 bool resolve_path_to_trait (const HIR::TypePath
&path
,
71 HIR::Trait
**resolved
) const;
74 } // namespace Resolver
77 #endif // RUST_HIR_TRAIT_RESOLVE_H