aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorKushal Pal <kushalpal109@gmail.com>2024-01-26 13:21:37 +0530
committerArthur Cohen <arthur.cohen@embecosm.com>2024-02-07 12:40:24 +0100
commit1e114b62e6e4941e9d6ed69c005e5901b6b5f21b (patch)
treea98f374b0d1df3c237c276dc996a5b119db3d4e4 /gcc/rust/resolve
parent6e9dad6a7943a37aba5b1a0609bb9e46741dd1c8 (diff)
downloadgcc-1e114b62e6e4941e9d6ed69c005e5901b6b5f21b.zip
gcc-1e114b62e6e4941e9d6ed69c005e5901b6b5f21b.tar.gz
gcc-1e114b62e6e4941e9d6ed69c005e5901b6b5f21b.tar.bz2
gccrs: Remove obsolete classes and functions.
Trait functions now use AST::Function class, so classes AST::TraitItemFunc, AST::TraitItemMethod, AST::TraitFunctionDecl, AST::TraitMethodDecl and their related functions can be removed. gcc/rust/ChangeLog: * ast/rust-ast-collector.cc (TokenCollector::visit): Remove obsolete classes and functions. * ast/rust-ast-collector.h: Likewise. * ast/rust-ast-full-decls.h (class TraitFunctionDecl): Likewise. (class TraitItemFunc): Likewise. (class TraitMethodDecl): Likewise. (class TraitItemMethod): Likewise. * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Likewise. * ast/rust-ast-visitor.h: Likewise. * ast/rust-ast.cc (TraitItemFunc::TraitItemFunc): Likewise. (TraitItemFunc::operator=): Likewise. (TraitItemFunc::as_string): Likewise. (TraitFunctionDecl::as_string): Likewise. (TraitItemMethod::TraitItemMethod): Likewise. (TraitItemMethod::operator=): Likewise. (TraitItemMethod::as_string): Likewise. (TraitMethodDecl::as_string): Likewise. (TraitItemFunc::accept_vis): Likewise. (TraitItemMethod::accept_vis): Likewise. * ast/rust-item.h (class TraitFunctionDecl): Likewise. (class TraitItemFunc): Likewise. (class TraitMethodDecl): Likewise. (class TraitItemMethod): Likewise. * checks/errors/rust-ast-validation.cc (ASTValidation::visit): Likewise. * checks/errors/rust-ast-validation.h: Likewise. * checks/errors/rust-feature-gate.h: Likewise. * expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_trait_function_decl): Likewise. (CfgStrip::maybe_strip_trait_method_decl): Likewise. (CfgStrip::visit): Likewise. * expand/rust-cfg-strip.h: Likewise. * expand/rust-derive.h: Likewise. * expand/rust-expand-visitor.cc (ExpandVisitor::expand_trait_function_decl): Likewise. (ExpandVisitor::expand_trait_method_decl): Likewise. (ExpandVisitor::visit): Likewise. * expand/rust-expand-visitor.h: Likewise. * hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Likewise. * hir/rust-ast-lower-base.h: Likewise. * hir/rust-ast-lower-implitem.cc (ASTLowerTraitItem::visit): Likewise. * hir/rust-ast-lower-implitem.h: Likewise. * resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Likewise. * resolve/rust-ast-resolve-base.h: Likewise. * resolve/rust-ast-resolve-implitem.h (visit): Likewise. * resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit): Likewise. * resolve/rust-ast-resolve-item.h: Likewise. * resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise. * resolve/rust-default-resolver.h: Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Likewise. * resolve/rust-toplevel-name-resolver-2.0.h: Likewise. * util/rust-attributes.cc (AttributeChecker::visit): Likewise. * util/rust-attributes.h: Likewise. Signed-off-by: Kushal Pal <kushalpal109@gmail.com>
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-base.cc8
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-base.h2
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-implitem.h40
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.cc155
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.h2
-rw-r--r--gcc/rust/resolve/rust-default-resolver.cc8
-rw-r--r--gcc/rust/resolve/rust-default-resolver.h2
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc10
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h1
9 files changed, 0 insertions, 228 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-base.cc b/gcc/rust/resolve/rust-ast-resolve-base.cc
index 1283d77..c88bd58 100644
--- a/gcc/rust/resolve/rust-ast-resolve-base.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-base.cc
@@ -403,14 +403,6 @@ ResolverBase::visit (AST::StaticItem &)
{}
void
-ResolverBase::visit (AST::TraitItemFunc &)
-{}
-
-void
-ResolverBase::visit (AST::TraitItemMethod &)
-{}
-
-void
ResolverBase::visit (AST::TraitItemConst &)
{}
diff --git a/gcc/rust/resolve/rust-ast-resolve-base.h b/gcc/rust/resolve/rust-ast-resolve-base.h
index 7883049..9bc6433 100644
--- a/gcc/rust/resolve/rust-ast-resolve-base.h
+++ b/gcc/rust/resolve/rust-ast-resolve-base.h
@@ -126,8 +126,6 @@ public:
void visit (AST::Union &);
void visit (AST::ConstantItem &);
void visit (AST::StaticItem &);
- void visit (AST::TraitItemFunc &);
- void visit (AST::TraitItemMethod &);
void visit (AST::TraitItemConst &);
void visit (AST::TraitItemType &);
void visit (AST::Trait &);
diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h
index d9c9bcb..fabc258 100644
--- a/gcc/rust/resolve/rust-ast-resolve-implitem.h
+++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h
@@ -130,46 +130,6 @@ public:
mappings->insert_canonical_path (function.get_node_id (), cpath);
}
- void visit (AST::TraitItemFunc &function) override
- {
- auto decl = CanonicalPath::new_seg (
- function.get_node_id (),
- function.get_trait_function_decl ().get_identifier ().as_string ());
- auto path = prefix.append (decl);
- auto cpath = canonical_prefix.append (decl);
-
- resolver->get_name_scope ().insert (
- path, function.get_node_id (), function.get_locus (), false,
- Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
- rich_location r (line_table, function.get_locus ());
- r.add_range (locus);
- rust_error_at (r, "redefined multiple times");
- });
-
- mappings->insert_canonical_path (function.get_node_id (), cpath);
- }
-
- void visit (AST::TraitItemMethod &method) override
- {
- auto decl = CanonicalPath::new_seg (
- method.get_node_id (),
- method.get_trait_method_decl ().get_identifier ().as_string ());
- auto path = prefix.append (decl);
- auto cpath = canonical_prefix.append (decl);
-
- resolver->get_name_scope ().insert (
- path, method.get_node_id (), method.get_locus (), false,
- Rib::ItemType::Function,
- [&] (const CanonicalPath &, NodeId, location_t locus) -> void {
- rich_location r (line_table, method.get_locus ());
- r.add_range (locus);
- rust_error_at (r, "redefined multiple times");
- });
-
- mappings->insert_canonical_path (method.get_node_id (), cpath);
- }
-
void visit (AST::TraitItemConst &constant) override
{
auto decl
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc
index 6037fe5..e69b945 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 (),
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h
index 33a78e2..0c7b752 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.h
+++ b/gcc/rust/resolve/rust-ast-resolve-item.h
@@ -37,8 +37,6 @@ public:
void visit (AST::Function &type) override;
void visit (AST::TraitItemType &type) override;
- void visit (AST::TraitItemFunc &func) override;
- void visit (AST::TraitItemMethod &func) override;
void visit (AST::TraitItemConst &constant) override;
private:
diff --git a/gcc/rust/resolve/rust-default-resolver.cc b/gcc/rust/resolve/rust-default-resolver.cc
index ab4d5e8..b116353 100644
--- a/gcc/rust/resolve/rust-default-resolver.cc
+++ b/gcc/rust/resolve/rust-default-resolver.cc
@@ -403,14 +403,6 @@ DefaultResolver::visit (AST::StaticItem &item)
}
void
-DefaultResolver::visit (AST::TraitItemFunc &)
-{}
-
-void
-DefaultResolver::visit (AST::TraitItemMethod &)
-{}
-
-void
DefaultResolver::visit (AST::TraitItemConst &)
{}
diff --git a/gcc/rust/resolve/rust-default-resolver.h b/gcc/rust/resolve/rust-default-resolver.h
index 20dbff8..d508ff3 100644
--- a/gcc/rust/resolve/rust-default-resolver.h
+++ b/gcc/rust/resolve/rust-default-resolver.h
@@ -114,8 +114,6 @@ public:
void visit (AST::EnumItemDiscriminant &);
void visit (AST::ConstantItem &);
void visit (AST::StaticItem &);
- void visit (AST::TraitItemFunc &);
- void visit (AST::TraitItemMethod &);
void visit (AST::TraitItemConst &);
void visit (AST::TraitItemType &);
void visit (AST::ExternalTypeItem &);
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 46113a8..af7766d 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -229,16 +229,6 @@ TopLevel::visit (AST::StaticItem &static_item)
}
void
-TopLevel::visit (AST::TraitItemFunc &item)
-{
- auto def_vis
- = [this, &item] () { item.get_definition ()->accept_vis (*this); };
-
- if (item.has_definition ())
- ctx.scoped (Rib::Kind::Function, item.get_node_id (), def_vis);
-}
-
-void
TopLevel::visit (AST::StructStruct &struct_item)
{
insert_or_error_out (struct_item.get_struct_name (), struct_item,
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h
index 996899b..f1943ee 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.h
@@ -65,7 +65,6 @@ private:
void visit (AST::Function &function) override;
void visit (AST::BlockExpr &expr) override;
void visit (AST::StaticItem &static_item) override;
- void visit (AST::TraitItemFunc &item) override;
void visit (AST::StructStruct &struct_item) override;
void visit (AST::TupleStruct &tuple_struct) override;
void visit (AST::EnumItem &variant) override;