aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve/rust-ast-resolve-item.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve-item.cc')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.cc155
1 files changed, 0 insertions, 155 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index d990153..3aba117f 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -147,161 +147,6 @@ ResolveTraitItems::visit (AST::TraitItemType &type)
}
void
-ResolveTraitItems::visit (AST::TraitItemFunc &func)
-{
- auto decl = CanonicalPath::new_seg (
- func.get_node_id (),
- func.get_trait_function_decl ().get_identifier ().as_string ());
- auto path = prefix.append (decl);
- auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (func.get_node_id (), cpath);
-
- NodeId scope_node_id = func.get_node_id ();
- resolver->get_name_scope ().push (scope_node_id);
- resolver->get_type_scope ().push (scope_node_id);
- resolver->get_label_scope ().push (scope_node_id);
- resolver->push_new_name_rib (resolver->get_name_scope ().peek ());
- resolver->push_new_type_rib (resolver->get_type_scope ().peek ());
- resolver->push_new_label_rib (resolver->get_type_scope ().peek ());
-
- AST::TraitFunctionDecl &function = func.get_trait_function_decl ();
- if (function.has_generics ())
- for (auto &generic : function.get_generic_params ())
- ResolveGenericParam::go (generic.get (), prefix, canonical_prefix);
-
- if (function.has_return_type ())
- ResolveType::go (function.get_return_type ().get ());
-
- std::vector<PatternBinding> bindings
- = {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())};
-
- // we make a new scope so the names of parameters are resolved and shadowed
- // correctly
- for (auto &p : function.get_function_params ())
- {
- if (p->is_variadic ())
- {
- auto param = static_cast<AST::VariadicParam *> (p.get ());
- PatternDeclaration::go (param->get_pattern ().get (),
- Rib::ItemType::Param, bindings);
- }
- else if (p->is_self ())
- {
- auto param = static_cast<AST::SelfParam *> (p.get ());
- ResolveType::go (param->get_type ().get ());
- }
- else
- {
- auto param = static_cast<AST::FunctionParam *> (p.get ());
- ResolveType::go (param->get_type ().get ());
- PatternDeclaration::go (param->get_pattern ().get (),
- Rib::ItemType::Param, bindings);
- }
- }
-
- if (function.has_where_clause ())
- ResolveWhereClause::Resolve (function.get_where_clause ());
-
- // trait items have an optional body
- if (func.has_definition ())
- ResolveExpr::go (func.get_definition ().get (), path, cpath);
-
- resolver->get_name_scope ().pop ();
- resolver->get_type_scope ().pop ();
- resolver->get_label_scope ().pop ();
-}
-
-void
-ResolveTraitItems::visit (AST::TraitItemMethod &func)
-{
- auto decl = CanonicalPath::new_seg (
- func.get_node_id (),
- func.get_trait_method_decl ().get_identifier ().as_string ());
- auto path = prefix.append (decl);
- auto cpath = canonical_prefix.append (decl);
- mappings->insert_canonical_path (func.get_node_id (), cpath);
-
- NodeId scope_node_id = func.get_node_id ();
- resolver->get_name_scope ().push (scope_node_id);
- resolver->get_type_scope ().push (scope_node_id);
- resolver->get_label_scope ().push (scope_node_id);
- resolver->push_new_name_rib (resolver->get_name_scope ().peek ());
- resolver->push_new_type_rib (resolver->get_type_scope ().peek ());
- resolver->push_new_label_rib (resolver->get_type_scope ().peek ());
-
- AST::TraitMethodDecl &function = func.get_trait_method_decl ();
- if (function.has_generics ())
- for (auto &generic : function.get_generic_params ())
- ResolveGenericParam::go (generic.get (), prefix, canonical_prefix);
-
- if (function.has_return_type ())
- ResolveType::go (function.get_return_type ().get ());
-
- // self turns into (self: Self) as a function param
- std::vector<PatternBinding> bindings
- = {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())};
-
- // we make a new scope so the names of parameters are resolved and shadowed
- // correctly
- for (auto &p : function.get_function_params ())
- {
- if (p->is_variadic ())
- {
- auto param = static_cast<AST::VariadicParam *> (p.get ());
- PatternDeclaration::go (param->get_pattern ().get (),
- Rib::ItemType::Param, bindings);
- }
- else if (p->is_self ())
- {
- auto param = static_cast<AST::SelfParam *> (p.get ());
- // FIXME: which location should be used for Rust::Identifier `self`?
- AST::IdentifierPattern self_pattern (
- param->get_node_id (), {"self"}, param->get_locus (),
- param->get_has_ref (), param->get_is_mut (),
- std::unique_ptr<AST::Pattern> (nullptr));
-
- PatternDeclaration::go (&self_pattern, Rib::ItemType::Param);
-
- if (param->has_type ())
- {
- // This shouldn't happen the parser should already error for this
- rust_assert (!param->get_has_ref ());
- ResolveType::go (param->get_type ().get ());
- }
- else
- {
- // here we implicitly make self have a type path of Self
- std::vector<std::unique_ptr<AST::TypePathSegment>> segments;
- segments.push_back (std::unique_ptr<AST::TypePathSegment> (
- new AST::TypePathSegment ("Self", false, param->get_locus ())));
-
- AST::TypePath self_type_path (std::move (segments),
- param->get_locus ());
- ResolveType::go (&self_type_path);
- }
- }
- else
- {
- auto param = static_cast<AST::FunctionParam *> (p.get ());
- ResolveType::go (param->get_type ().get ());
- PatternDeclaration::go (param->get_pattern ().get (),
- Rib::ItemType::Param, bindings);
- }
- }
-
- if (function.has_where_clause ())
- ResolveWhereClause::Resolve (function.get_where_clause ());
-
- // trait items have an optional body
- if (func.has_definition ())
- ResolveExpr::go (func.get_definition ().get (), path, cpath);
-
- resolver->get_name_scope ().pop ();
- resolver->get_type_scope ().pop ();
- resolver->get_label_scope ().pop ();
-}
-
-void
ResolveTraitItems::visit (AST::TraitItemConst &constant)
{
auto decl = CanonicalPath::new_seg (constant.get_node_id (),