diff options
Diffstat (limited to 'gcc/rust/resolve')
21 files changed, 404 insertions, 422 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-base.cc b/gcc/rust/resolve/rust-ast-resolve-base.cc index 1ef162d..1939a20 100644 --- a/gcc/rust/resolve/rust-ast-resolve-base.cc +++ b/gcc/rust/resolve/rust-ast-resolve-base.cc @@ -30,7 +30,7 @@ ResolverBase::resolve_visibility (const AST::Visibility &vis) if (vis.has_path ()) { auto path = vis.get_path (); - ResolvePath::go (&path); + ResolvePath::go (path); // Do we need to lookup something here? // Is it just about resolving the names correctly so we can look them up diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc index dd1d797..d42e7fe 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.cc +++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc @@ -28,17 +28,17 @@ namespace Rust { namespace Resolver { void -ResolveExpr::go (AST::Expr *expr, const CanonicalPath &prefix, +ResolveExpr::go (AST::Expr &expr, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix, bool funny_error) { ResolveExpr resolver (prefix, canonical_prefix, funny_error); - expr->accept_vis (resolver); + expr.accept_vis (resolver); } void ResolveExpr::visit (AST::TupleIndexExpr &expr) { - ResolveExpr::go (expr.get_tuple_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_tuple_expr (), prefix, canonical_prefix); } void @@ -48,41 +48,40 @@ ResolveExpr::visit (AST::TupleExpr &expr) return; for (auto &elem : expr.get_tuple_elems ()) - ResolveExpr::go (elem.get (), prefix, canonical_prefix); + ResolveExpr::go (*elem, prefix, canonical_prefix); } void ResolveExpr::visit (AST::PathInExpression &expr) { - ResolvePath::go (&expr); + ResolvePath::go (expr); } void ResolveExpr::visit (AST::QualifiedPathInExpression &expr) { - ResolvePath::go (&expr); + ResolvePath::go (expr); } void ResolveExpr::visit (AST::ReturnExpr &expr) { if (expr.has_returned_expr ()) - ResolveExpr::go (expr.get_returned_expr ().get (), prefix, - canonical_prefix); + ResolveExpr::go (expr.get_returned_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::CallExpr &expr) { - ResolveExpr::go (expr.get_function_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_function_expr (), prefix, canonical_prefix); for (auto ¶m : expr.get_params ()) - ResolveExpr::go (param.get (), prefix, canonical_prefix); + ResolveExpr::go (*param, prefix, canonical_prefix); } void ResolveExpr::visit (AST::MethodCallExpr &expr) { - ResolveExpr::go (expr.get_receiver_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_receiver_expr (), prefix, canonical_prefix); if (expr.get_method_name ().has_generic_args ()) { @@ -92,14 +91,14 @@ ResolveExpr::visit (AST::MethodCallExpr &expr) auto const &in_params = expr.get_params (); for (auto ¶m : in_params) - ResolveExpr::go (param.get (), prefix, canonical_prefix); + ResolveExpr::go (*param, prefix, canonical_prefix); } void ResolveExpr::visit (AST::AssignmentExpr &expr) { - ResolveExpr::go (expr.get_left_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_right_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_left_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_right_expr (), prefix, canonical_prefix); } /* The "break rust" Easter egg. @@ -178,63 +177,63 @@ ResolveExpr::visit (AST::IdentifierExpr &expr) void ResolveExpr::visit (AST::ArithmeticOrLogicalExpr &expr) { - ResolveExpr::go (expr.get_left_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_right_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_left_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_right_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::CompoundAssignmentExpr &expr) { - ResolveExpr::go (expr.get_left_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_right_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_left_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_right_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::ComparisonExpr &expr) { - ResolveExpr::go (expr.get_left_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_right_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_left_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_right_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::LazyBooleanExpr &expr) { - ResolveExpr::go (expr.get_left_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_right_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_left_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_right_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::NegationExpr &expr) { - ResolveExpr::go (expr.get_negated_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_negated_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::TypeCastExpr &expr) { - ResolveType::go (expr.get_type_to_cast_to ().get ()); - ResolveExpr::go (expr.get_casted_expr ().get (), prefix, canonical_prefix); + ResolveType::go (expr.get_type_to_cast_to ()); + ResolveExpr::go (expr.get_casted_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::IfExpr &expr) { - ResolveExpr::go (expr.get_condition_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_if_block ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_condition_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_if_block (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::IfExprConseqElse &expr) { - ResolveExpr::go (expr.get_condition_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_if_block ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_else_block ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_condition_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_if_block (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_else_block (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::IfLetExpr &expr) { - ResolveExpr::go (expr.get_value_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_value_expr (), prefix, canonical_prefix); NodeId scope_node_id = expr.get_node_id (); resolver->get_name_scope ().push (scope_node_id); @@ -251,10 +250,10 @@ ResolveExpr::visit (AST::IfLetExpr &expr) for (auto &pattern : expr.get_patterns ()) { - PatternDeclaration::go (pattern.get (), Rib::ItemType::Var, bindings); + PatternDeclaration::go (*pattern, Rib::ItemType::Var, bindings); } - ResolveExpr::go (expr.get_if_block ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_if_block (), prefix, canonical_prefix); resolver->get_name_scope ().pop (); resolver->get_type_scope ().pop (); @@ -264,7 +263,7 @@ ResolveExpr::visit (AST::IfLetExpr &expr) void ResolveExpr::visit (AST::IfLetExprConseqElse &expr) { - ResolveExpr::go (expr.get_value_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_value_expr (), prefix, canonical_prefix); NodeId scope_node_id = expr.get_node_id (); resolver->get_name_scope ().push (scope_node_id); @@ -281,11 +280,11 @@ ResolveExpr::visit (AST::IfLetExprConseqElse &expr) for (auto &pattern : expr.get_patterns ()) { - PatternDeclaration::go (pattern.get (), Rib::ItemType::Var, bindings); + PatternDeclaration::go (*pattern, Rib::ItemType::Var, bindings); } - ResolveExpr::go (expr.get_if_block ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_else_block ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_if_block (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_else_block (), prefix, canonical_prefix); resolver->get_name_scope ().pop (); resolver->get_type_scope ().pop (); @@ -328,19 +327,19 @@ ResolveExpr::visit (AST::BlockExpr &expr) for (auto &s : expr.get_statements ()) { if (s->is_item ()) - ResolveStmt::go (s.get (), prefix, canonical_prefix, + ResolveStmt::go (*s, prefix, canonical_prefix, CanonicalPath::create_empty ()); } for (auto &s : expr.get_statements ()) { if (!s->is_item ()) - ResolveStmt::go (s.get (), prefix, canonical_prefix, + ResolveStmt::go (*s, prefix, canonical_prefix, CanonicalPath::create_empty ()); } if (expr.has_tail_expr ()) - ResolveExpr::go (expr.get_tail_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_tail_expr (), prefix, canonical_prefix); resolver->get_name_scope ().pop (); resolver->get_type_scope ().pop (); @@ -350,14 +349,14 @@ ResolveExpr::visit (AST::BlockExpr &expr) void ResolveExpr::visit (AST::UnsafeBlockExpr &expr) { - expr.get_block_expr ()->accept_vis (*this); + expr.get_block_expr ().accept_vis (*this); } void ResolveExpr::visit (AST::ArrayElemsValues &elems) { for (auto &elem : elems.get_values ()) - ResolveExpr::go (elem.get (), prefix, canonical_prefix); + ResolveExpr::go (*elem, prefix, canonical_prefix); } void @@ -369,55 +368,53 @@ ResolveExpr::visit (AST::ArrayExpr &expr) void ResolveExpr::visit (AST::ArrayIndexExpr &expr) { - ResolveExpr::go (expr.get_array_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_index_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_array_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_index_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::ArrayElemsCopied &expr) { - ResolveExpr::go (expr.get_num_copies ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_elem_to_copy ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_num_copies (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_elem_to_copy (), prefix, canonical_prefix); } // this this an empty struct constructor like 'S {}' void ResolveExpr::visit (AST::StructExprStruct &struct_expr) { - ResolveExpr::go (&struct_expr.get_struct_name (), prefix, canonical_prefix); + ResolveExpr::go (struct_expr.get_struct_name (), prefix, canonical_prefix); } // this this a struct constructor with fields void ResolveExpr::visit (AST::StructExprStructFields &struct_expr) { - ResolveExpr::go (&struct_expr.get_struct_name (), prefix, canonical_prefix); + ResolveExpr::go (struct_expr.get_struct_name (), prefix, canonical_prefix); if (struct_expr.has_struct_base ()) { AST::StructBase &base = struct_expr.get_struct_base (); - ResolveExpr::go (base.get_base_struct ().get (), prefix, - canonical_prefix); + ResolveExpr::go (base.get_base_struct (), prefix, canonical_prefix); } auto const &struct_fields = struct_expr.get_fields (); for (auto &struct_field : struct_fields) { - ResolveStructExprField::go (struct_field.get (), prefix, - canonical_prefix); + ResolveStructExprField::go (*struct_field, prefix, canonical_prefix); } } void ResolveExpr::visit (AST::GroupedExpr &expr) { - ResolveExpr::go (expr.get_expr_in_parens ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_expr_in_parens (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::FieldAccessExpr &expr) { - ResolveExpr::go (expr.get_receiver_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_receiver_expr (), prefix, canonical_prefix); } void @@ -444,7 +441,7 @@ ResolveExpr::visit (AST::LoopExpr &expr) rust_error_at (locus, "was defined here"); }); } - ResolveExpr::go (expr.get_loop_block ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_loop_block (), prefix, canonical_prefix); } void @@ -477,7 +474,7 @@ ResolveExpr::visit (AST::BreakExpr &expr) if (expr.has_break_expr ()) { bool funny_error = false; - AST::Expr &break_expr = *expr.get_break_expr ().get (); + auto &break_expr = expr.get_break_expr (); if (break_expr.get_ast_kind () == AST::Kind::IDENTIFIER) { /* This is a break with an expression, and the expression is just a @@ -491,7 +488,7 @@ ResolveExpr::visit (AST::BreakExpr &expr) if (ident == "rust" || ident == "gcc") funny_error = true; } - ResolveExpr::go (&break_expr, prefix, canonical_prefix, funny_error); + ResolveExpr::go (break_expr, prefix, canonical_prefix, funny_error); } } @@ -520,8 +517,8 @@ ResolveExpr::visit (AST::WhileLoopExpr &expr) }); } - ResolveExpr::go (expr.get_predicate_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_loop_block ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_predicate_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_loop_block (), prefix, canonical_prefix); } void @@ -559,9 +556,9 @@ ResolveExpr::visit (AST::ForLoopExpr &expr) resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); // resolve the expression - PatternDeclaration::go (expr.get_pattern ().get (), Rib::ItemType::Var); - ResolveExpr::go (expr.get_iterator_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_loop_block ().get (), prefix, canonical_prefix); + PatternDeclaration::go (expr.get_pattern (), Rib::ItemType::Var); + ResolveExpr::go (expr.get_iterator_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_loop_block (), prefix, canonical_prefix); // done resolver->get_name_scope ().pop (); @@ -600,20 +597,19 @@ ResolveExpr::visit (AST::ContinueExpr &expr) void ResolveExpr::visit (AST::BorrowExpr &expr) { - ResolveExpr::go (expr.get_borrowed_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_borrowed_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::DereferenceExpr &expr) { - ResolveExpr::go (expr.get_dereferenced_expr ().get (), prefix, - canonical_prefix); + ResolveExpr::go (expr.get_dereferenced_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::MatchExpr &expr) { - ResolveExpr::go (expr.get_scrutinee_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_scrutinee_expr (), prefix, canonical_prefix); for (auto &match_case : expr.get_match_cases ()) { // each arm is in its own scope @@ -628,8 +624,7 @@ ResolveExpr::visit (AST::MatchExpr &expr) // resolve AST::MatchArm &arm = match_case.get_arm (); if (arm.has_match_arm_guard ()) - ResolveExpr::go (arm.get_guard_expr ().get (), prefix, - canonical_prefix); + ResolveExpr::go (arm.get_guard_expr (), prefix, canonical_prefix); // We know expr.get_patterns () has one pattern at most // so there's no reason to handle it like an AltPattern. @@ -639,11 +634,11 @@ ResolveExpr::visit (AST::MatchExpr &expr) // insert any possible new patterns for (auto &pattern : arm.get_patterns ()) { - PatternDeclaration::go (pattern.get (), Rib::ItemType::Var, bindings); + PatternDeclaration::go (*pattern, Rib::ItemType::Var, bindings); } // resolve the body - ResolveExpr::go (match_case.get_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (match_case.get_expr (), prefix, canonical_prefix); // done resolver->get_name_scope ().pop (); @@ -655,20 +650,20 @@ ResolveExpr::visit (AST::MatchExpr &expr) void ResolveExpr::visit (AST::RangeFromToExpr &expr) { - ResolveExpr::go (expr.get_from_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_to_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_from_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_to_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::RangeFromExpr &expr) { - ResolveExpr::go (expr.get_from_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_from_expr (), prefix, canonical_prefix); } void ResolveExpr::visit (AST::RangeToExpr &expr) { - ResolveExpr::go (expr.get_to_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_to_expr (), prefix, canonical_prefix); } void @@ -680,8 +675,8 @@ ResolveExpr::visit (AST::RangeFullExpr &) void ResolveExpr::visit (AST::RangeFromToInclExpr &expr) { - ResolveExpr::go (expr.get_from_expr ().get (), prefix, canonical_prefix); - ResolveExpr::go (expr.get_to_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_from_expr (), prefix, canonical_prefix); + ResolveExpr::go (expr.get_to_expr (), prefix, canonical_prefix); } void @@ -705,8 +700,7 @@ ResolveExpr::visit (AST::ClosureExprInner &expr) resolver->push_closure_context (expr.get_node_id ()); - ResolveExpr::go (expr.get_definition_expr ().get (), prefix, - canonical_prefix); + ResolveExpr::go (expr.get_definition_expr (), prefix, canonical_prefix); resolver->pop_closure_context (); @@ -734,12 +728,11 @@ ResolveExpr::visit (AST::ClosureExprInnerTyped &expr) resolve_closure_param (p, bindings); } - ResolveType::go (expr.get_return_type ().get ()); + ResolveType::go (expr.get_return_type ()); resolver->push_closure_context (expr.get_node_id ()); - ResolveExpr::go (expr.get_definition_block ().get (), prefix, - canonical_prefix); + ResolveExpr::go (expr.get_definition_block (), prefix, canonical_prefix); resolver->pop_closure_context (); @@ -752,11 +745,10 @@ void ResolveExpr::resolve_closure_param (AST::ClosureParam ¶m, std::vector<PatternBinding> &bindings) { - PatternDeclaration::go (param.get_pattern ().get (), Rib::ItemType::Param, - bindings); + PatternDeclaration::go (param.get_pattern (), Rib::ItemType::Param, bindings); if (param.has_type_given ()) - ResolveType::go (param.get_type ().get ()); + ResolveType::go (param.get_type ()); } ResolveExpr::ResolveExpr (const CanonicalPath &prefix, diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.h b/gcc/rust/resolve/rust-ast-resolve-expr.h index 86ae70f..4897650 100644 --- a/gcc/rust/resolve/rust-ast-resolve-expr.h +++ b/gcc/rust/resolve/rust-ast-resolve-expr.h @@ -30,7 +30,7 @@ class ResolveExpr : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::Expr *expr, const CanonicalPath &prefix, + static void go (AST::Expr &expr, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix, bool funny_error = false); diff --git a/gcc/rust/resolve/rust-ast-resolve-implitem.h b/gcc/rust/resolve/rust-ast-resolve-implitem.h index fa344ef..641a6cf 100644 --- a/gcc/rust/resolve/rust-ast-resolve-implitem.h +++ b/gcc/rust/resolve/rust-ast-resolve-implitem.h @@ -31,13 +31,13 @@ class ResolveToplevelImplItem : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::AssociatedItem *item, const CanonicalPath &prefix) + static void go (AST::AssociatedItem &item, const CanonicalPath &prefix) { - if (item->is_marked_for_strip ()) + if (item.is_marked_for_strip ()) return; ResolveToplevelImplItem resolver (prefix); - item->accept_vis (resolver); + item.accept_vis (resolver); } void visit (AST::TypeAlias &type) override @@ -183,10 +183,10 @@ class ResolveToplevelExternItem : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::ExternalItem *item, const CanonicalPath &prefix) + static void go (AST::ExternalItem &item, const CanonicalPath &prefix) { ResolveToplevelExternItem resolver (prefix); - item->accept_vis (resolver); + item.accept_vis (resolver); }; void visit (AST::Function &function) override diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc b/gcc/rust/resolve/rust-ast-resolve-item.cc index c65f112..d11a788 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.cc +++ b/gcc/rust/resolve/rust-ast-resolve-item.cc @@ -65,10 +65,10 @@ ResolveTraitItems::visit (AST::Function &function) if (function.has_generics ()) for (auto &generic : function.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); if (function.has_return_type ()) - ResolveType::go (function.get_return_type ().get ()); + ResolveType::go (function.get_return_type ()); // self turns into (self: Self) as a function param std::vector<PatternBinding> bindings @@ -80,45 +80,45 @@ ResolveTraitItems::visit (AST::Function &function) { if (p->is_variadic ()) { - auto param = static_cast<AST::VariadicParam *> (p.get ()); - PatternDeclaration::go (param->get_pattern ().get (), - Rib::ItemType::Param, bindings); + auto param = static_cast<AST::VariadicParam &> (*p); + PatternDeclaration::go (param.get_pattern (), Rib::ItemType::Param, + bindings); } else if (p->is_self ()) { - auto param = static_cast<AST::SelfParam *> (p.get ()); + auto ¶m = static_cast<AST::SelfParam &> (*p); // 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 (), + 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); + PatternDeclaration::go (self_pattern, Rib::ItemType::Param); - if (param->has_type ()) + 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 ()); + rust_assert (!param.get_has_ref ()); + ResolveType::go (param.get_type ()); } 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 ()))); + new AST::TypePathSegment ("Self", false, param.get_locus ()))); AST::TypePath self_type_path (std::move (segments), - param->get_locus ()); - ResolveType::go (&self_type_path); + 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); + auto ¶m = static_cast<AST::FunctionParam &> (*p); + ResolveType::go (param.get_type ()); + PatternDeclaration::go (param.get_pattern (), Rib::ItemType::Param, + bindings); } } @@ -127,7 +127,7 @@ ResolveTraitItems::visit (AST::Function &function) // trait items have an optional body if (function.has_body ()) - ResolveExpr::go (function.get_definition ()->get (), path, cpath); + ResolveExpr::go (*function.get_definition ().value (), path, cpath); resolver->get_name_scope ().pop (); resolver->get_type_scope ().pop (); @@ -143,7 +143,7 @@ ResolveTraitItems::visit (AST::TraitItemType &type) mappings->insert_canonical_path (type.get_node_id (), cpath); for (auto &bound : type.get_type_param_bounds ()) - ResolveTypeBound::go (bound.get ()); + ResolveTypeBound::go (*bound); } void @@ -155,10 +155,10 @@ ResolveTraitItems::visit (AST::TraitItemConst &constant) auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (constant.get_node_id (), cpath); - ResolveType::go (constant.get_type ().get ()); + ResolveType::go (constant.get_type ()); if (constant.has_expr ()) - ResolveExpr::go (constant.get_expr ().get (), path, cpath); + ResolveExpr::go (constant.get_expr (), path, cpath); } ResolveItem::ResolveItem (const CanonicalPath &prefix, @@ -167,11 +167,11 @@ ResolveItem::ResolveItem (const CanonicalPath &prefix, {} void -ResolveItem::go (AST::Item *item, const CanonicalPath &prefix, +ResolveItem::go (AST::Item &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix) { ResolveItem resolver (prefix, canonical_prefix); - item->accept_vis (resolver); + item.accept_vis (resolver); } void @@ -189,12 +189,12 @@ ResolveItem::visit (AST::TypeAlias &alias) if (alias.has_generics ()) for (auto &generic : alias.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); if (alias.has_where_clause ()) ResolveWhereClause::Resolve (alias.get_where_clause ()); - ResolveType::go (alias.get_type_aliased ().get ()); + ResolveType::go (alias.get_type_aliased ()); resolver->get_type_scope ().pop (); } @@ -221,11 +221,11 @@ ResolveItem::visit (AST::Module &module) // FIXME: Should we reinsert a child here? Any reason we ResolveTopLevel::go // in ResolveTopLevel::visit (AST::Module) as well as here? for (auto &item : module.get_items ()) - ResolveTopLevel::go (item.get (), CanonicalPath::create_empty (), cpath); + ResolveTopLevel::go (*item, CanonicalPath::create_empty (), cpath); resolver->push_new_module_scope (module.get_node_id ()); for (auto &item : module.get_items ()) - ResolveItem::go (item.get (), path, cpath); + ResolveItem::go (*item, path, cpath); resolver->pop_module_scope (); @@ -251,19 +251,19 @@ ResolveItem::visit (AST::TupleStruct &struct_decl) if (struct_decl.has_generics ()) for (auto &generic : struct_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); if (struct_decl.has_where_clause ()) ResolveWhereClause::Resolve (struct_decl.get_where_clause ()); for (AST::TupleField &field : struct_decl.get_fields ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; resolve_visibility (field.get_visibility ()); - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } resolver->get_type_scope ().pop (); @@ -285,14 +285,14 @@ ResolveItem::visit (AST::Enum &enum_decl) if (enum_decl.has_generics ()) for (auto &generic : enum_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, cpath); + ResolveGenericParam::go (*generic, prefix, cpath); if (enum_decl.has_where_clause ()) ResolveWhereClause::Resolve (enum_decl.get_where_clause ()); /* The actual fields are inside the variants. */ for (auto &variant : enum_decl.get_variants ()) - ResolveItem::go (variant.get (), path, cpath); + ResolveItem::go (*variant, path, cpath); resolver->get_type_scope ().pop (); } @@ -322,10 +322,10 @@ ResolveItem::visit (AST::EnumItemTuple &item) for (auto &field : item.get_tuple_fields ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } } @@ -340,10 +340,10 @@ ResolveItem::visit (AST::EnumItemStruct &item) for (auto &field : item.get_struct_fields ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } } @@ -375,19 +375,19 @@ ResolveItem::visit (AST::StructStruct &struct_decl) if (struct_decl.has_generics ()) for (auto &generic : struct_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); if (struct_decl.has_where_clause ()) ResolveWhereClause::Resolve (struct_decl.get_where_clause ()); for (AST::StructField &field : struct_decl.get_fields ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; resolve_visibility (field.get_visibility ()); - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } resolver->get_type_scope ().pop (); @@ -410,17 +410,17 @@ ResolveItem::visit (AST::Union &union_decl) if (union_decl.has_generics ()) for (auto &generic : union_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); if (union_decl.has_where_clause ()) ResolveWhereClause::Resolve (union_decl.get_where_clause ()); for (AST::StructField &field : union_decl.get_variants ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } resolver->get_type_scope ().pop (); @@ -435,8 +435,8 @@ ResolveItem::visit (AST::StaticItem &var) auto cpath = canonical_prefix.append (decl); mappings->insert_canonical_path (var.get_node_id (), cpath); - ResolveType::go (var.get_type ().get ()); - ResolveExpr::go (var.get_expr ().get (), path, cpath); + ResolveType::go (var.get_type ()); + ResolveExpr::go (var.get_expr (), path, cpath); } void @@ -450,8 +450,8 @@ ResolveItem::visit (AST::ConstantItem &constant) resolve_visibility (constant.get_visibility ()); - ResolveType::go (constant.get_type ().get ()); - ResolveExpr::go (constant.get_expr ().get (), path, cpath); + ResolveType::go (constant.get_type ()); + ResolveExpr::go (constant.get_expr (), path, cpath); } void @@ -477,14 +477,14 @@ ResolveItem::visit (AST::Function &function) if (function.has_generics ()) for (auto &generic : function.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); // resolve any where clause items if (function.has_where_clause ()) ResolveWhereClause::Resolve (function.get_where_clause ()); if (function.has_return_type ()) - ResolveType::go (function.get_return_type ().get ()); + ResolveType::go (function.get_return_type ()); if (function.has_self_param ()) { @@ -497,13 +497,13 @@ ResolveItem::visit (AST::Function &function) self_param.get_node_id (), {"self"}, self_param.get_locus (), self_param.get_has_ref (), self_param.get_is_mut (), std::unique_ptr<AST::Pattern> (nullptr)); - PatternDeclaration::go (&self_pattern, Rib::ItemType::Param); + PatternDeclaration::go (self_pattern, Rib::ItemType::Param); if (self_param.has_type ()) { // This shouldn't happen the parser should already error for this rust_assert (!self_param.get_has_ref ()); - ResolveType::go (self_param.get_type ().get ()); + ResolveType::go (self_param.get_type ()); } else { @@ -514,7 +514,7 @@ ResolveItem::visit (AST::Function &function) AST::TypePath self_type_path (std::move (segments), self_param.get_locus ()); - ResolveType::go (&self_type_path); + ResolveType::go (self_type_path); } } @@ -527,28 +527,28 @@ ResolveItem::visit (AST::Function &function) { if (p->is_variadic ()) { - auto param = static_cast<AST::VariadicParam *> (p.get ()); - if (param->has_pattern ()) - PatternDeclaration::go (param->get_pattern ().get (), - Rib::ItemType::Param, bindings); + auto ¶m = static_cast<AST::VariadicParam &> (*p); + if (param.has_pattern ()) + PatternDeclaration::go (param.get_pattern (), Rib::ItemType::Param, + bindings); } else if (p->is_self ()) { - auto param = static_cast<AST::SelfParam *> (p.get ()); - if (param->has_type ()) - ResolveType::go (param->get_type ().get ()); + auto ¶m = static_cast<AST::SelfParam &> (*p); + if (param.has_type ()) + ResolveType::go (param.get_type ()); } 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); + auto ¶m = static_cast<AST::FunctionParam &> (*p); + ResolveType::go (param.get_type ()); + PatternDeclaration::go (param.get_pattern (), Rib::ItemType::Param, + bindings); } } // resolve the function body - ResolveExpr::go (function.get_definition ()->get (), path, cpath); + ResolveExpr::go (*function.get_definition ().value (), path, cpath); resolver->get_name_scope ().pop (); resolver->get_type_scope ().pop (); @@ -568,7 +568,7 @@ ResolveItem::visit (AST::InherentImpl &impl_block) if (impl_block.has_generics ()) for (auto &generic : impl_block.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); // resolve any where clause items if (impl_block.has_where_clause ()) @@ -577,12 +577,11 @@ ResolveItem::visit (AST::InherentImpl &impl_block) // FIXME this needs to be protected behind nominal type-checks see: // rustc --explain E0118 // issue #2634 - ResolveType::go (impl_block.get_type ().get ()); + ResolveType::go (impl_block.get_type ()); // Setup paths CanonicalPath self_cpath = CanonicalPath::create_empty (); - bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_type ().get (), - self_cpath); + bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_type (), self_cpath); rust_assert (ok); rust_debug ("AST::InherentImpl resolve Self: {%s}", self_cpath.get ().c_str ()); @@ -609,22 +608,22 @@ ResolveItem::visit (AST::InherentImpl &impl_block) // done setup paths auto Self - = CanonicalPath::get_big_self (impl_block.get_type ()->get_node_id ()); + = CanonicalPath::get_big_self (impl_block.get_type ().get_node_id ()); resolver->get_type_scope ().insert (Self, - impl_block.get_type ()->get_node_id (), - impl_block.get_type ()->get_locus ()); + impl_block.get_type ().get_node_id (), + impl_block.get_type ().get_locus ()); for (auto &impl_item : impl_block.get_impl_items ()) { rust_debug ( "AST::InherentImpl resolve_impl_item: impl_prefix={%s} cpath={%s}", impl_prefix.get ().c_str (), cpath.get ().c_str ()); - resolve_impl_item (impl_item.get (), impl_prefix, cpath); + resolve_impl_item (*impl_item, impl_prefix, cpath); } resolver->get_type_scope ().peek ()->clear_name ( - Self, impl_block.get_type ()->get_node_id ()); + Self, impl_block.get_type ().get_node_id ()); resolver->get_type_scope ().pop (); resolver->get_name_scope ().pop (); @@ -646,14 +645,14 @@ ResolveItem::visit (AST::TraitImpl &impl_block) if (impl_block.has_generics ()) for (auto &generic : impl_block.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); // resolve any where clause items if (impl_block.has_where_clause ()) ResolveWhereClause::Resolve (impl_block.get_where_clause ()); // CanonicalPath canonical_trait_type = CanonicalPath::create_empty (); - NodeId trait_resolved_node = ResolveType::go (&impl_block.get_trait_path ()); + NodeId trait_resolved_node = ResolveType::go (impl_block.get_trait_path ()); if (trait_resolved_node == UNKNOWN_NODEID) { resolver->get_name_scope ().pop (); @@ -663,7 +662,7 @@ ResolveItem::visit (AST::TraitImpl &impl_block) } // CanonicalPath canonical_impl_type = CanonicalPath::create_empty (); - NodeId type_resolved_node = ResolveType::go (impl_block.get_type ().get ()); + NodeId type_resolved_node = ResolveType::go (impl_block.get_type ()); if (type_resolved_node == UNKNOWN_NODEID) { resolver->get_name_scope ().pop (); @@ -675,7 +674,7 @@ ResolveItem::visit (AST::TraitImpl &impl_block) bool ok; // setup paths CanonicalPath canonical_trait_type = CanonicalPath::create_empty (); - ok = ResolveTypeToCanonicalPath::go (&impl_block.get_trait_path (), + ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path (), canonical_trait_type); rust_assert (ok); @@ -683,7 +682,7 @@ ResolveItem::visit (AST::TraitImpl &impl_block) canonical_trait_type.get ().c_str ()); CanonicalPath canonical_impl_type = CanonicalPath::create_empty (); - ok = ResolveTypeToCanonicalPath::go (impl_block.get_type ().get (), + ok = ResolveTypeToCanonicalPath::go (impl_block.get_type (), canonical_impl_type); rust_assert (ok); @@ -722,22 +721,22 @@ ResolveItem::visit (AST::TraitImpl &impl_block) // DONE setup canonical-path auto Self - = CanonicalPath::get_big_self (impl_block.get_type ()->get_node_id ()); + = CanonicalPath::get_big_self (impl_block.get_type ().get_node_id ()); resolver->get_type_scope ().insert (Self, - impl_block.get_type ()->get_node_id (), - impl_block.get_type ()->get_locus ()); + impl_block.get_type ().get_node_id (), + impl_block.get_type ().get_locus ()); for (auto &impl_item : impl_block.get_impl_items ()) { rust_debug ( "AST::TraitImpl resolve_impl_item: impl_prefix={%s} cpath={%s}", impl_prefix.get ().c_str (), cpath.get ().c_str ()); - resolve_impl_item (impl_item.get (), impl_prefix, cpath); + resolve_impl_item (*impl_item, impl_prefix, cpath); } Rib *r = resolver->get_type_scope ().peek (); - r->clear_name (Self, impl_block.get_type ()->get_node_id ()); + r->clear_name (Self, impl_block.get_type ().get_node_id ()); resolver->get_name_scope ().pop (); resolver->get_type_scope ().pop (); @@ -765,7 +764,7 @@ ResolveItem::visit (AST::Trait &trait) CanonicalPath Self = CanonicalPath::get_big_self (trait.get_node_id ()); for (auto &generic : trait.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); // Self is an implicit TypeParam so lets mark it as such resolver->get_type_scope ().append_reference_for_def ( @@ -775,7 +774,7 @@ ResolveItem::visit (AST::Trait &trait) { for (auto &bound : trait.get_type_param_bounds ()) { - ResolveTypeBound::go (bound.get ()); + ResolveTypeBound::go (*bound); } } @@ -804,12 +803,12 @@ ResolveItem::visit (AST::ExternBlock &extern_block) for (auto &item : extern_block.get_extern_items ()) { - resolve_extern_item (item.get ()); + resolve_extern_item (*item); } } void -ResolveItem::resolve_impl_item (AST::AssociatedItem *item, +ResolveItem::resolve_impl_item (AST::AssociatedItem &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix) { @@ -817,7 +816,7 @@ ResolveItem::resolve_impl_item (AST::AssociatedItem *item, } void -ResolveItem::resolve_extern_item (AST::ExternalItem *item) +ResolveItem::resolve_extern_item (AST::ExternalItem &item) { ResolveExternItem::go (item, prefix, canonical_prefix); } @@ -953,7 +952,7 @@ ResolveItem::visit (AST::UseDeclaration &use_item) auto &path = import.get_path (); rust_debug ("resolving use-decl path: [%s]", path.as_string ().c_str ()); - NodeId resolved_node_id = ResolvePath::go (&path); + NodeId resolved_node_id = ResolvePath::go (path); bool ok = resolved_node_id != UNKNOWN_NODEID; if (!ok) continue; @@ -977,14 +976,14 @@ ResolveImplItems::ResolveImplItems (const CanonicalPath &prefix, {} void -ResolveImplItems::go (AST::AssociatedItem *item, const CanonicalPath &prefix, +ResolveImplItems::go (AST::AssociatedItem &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix) { - if (item->is_marked_for_strip ()) + if (item.is_marked_for_strip ()) return; ResolveImplItems resolver (prefix, canonical_prefix); - item->accept_vis (resolver); + item.accept_vis (resolver); } void @@ -1000,11 +999,11 @@ ResolveImplItems::visit (AST::TypeAlias &alias) } void -ResolveExternItem::go (AST::ExternalItem *item, const CanonicalPath &prefix, +ResolveExternItem::go (AST::ExternalItem &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix) { ResolveExternItem resolver (prefix, canonical_prefix); - item->accept_vis (resolver); + item.accept_vis (resolver); } void @@ -1031,18 +1030,18 @@ ResolveExternItem::visit (AST::Function &function) // resolve the generics if (function.has_generics ()) for (auto &generic : function.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); if (function.has_return_type ()) - ResolveType::go (function.get_return_type ().get ()); + ResolveType::go (function.get_return_type ()); // we make a new scope so the names of parameters are resolved and shadowed // correctly - for (auto &it : function.get_function_params ()) - if (!it->is_variadic ()) + for (auto ¶m : function.get_function_params ()) + if (!param->is_variadic ()) { - auto param = static_cast<AST::FunctionParam *> (it.get ()); - ResolveType::go (param->get_type ().get ()); + auto &p = static_cast<AST::FunctionParam &> (*param); + ResolveType::go (p.get_type ()); } // done @@ -1056,7 +1055,7 @@ ResolveExternItem::visit (AST::ExternalStaticItem &item) { resolve_visibility (item.get_visibility ()); - ResolveType::go (item.get_type ().get ()); + ResolveType::go (item.get_type ()); } } // namespace Resolver diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h index 0133d2c..1fd2647 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.h +++ b/gcc/rust/resolve/rust-ast-resolve-item.h @@ -52,7 +52,7 @@ class ResolveItem : public ResolverBase public: using Rust::Resolver::ResolverBase::visit; - static void go (AST::Item *item, const CanonicalPath &prefix, + static void go (AST::Item &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix); void visit (AST::TypeAlias &alias) override; @@ -76,10 +76,10 @@ public: void visit (AST::UseDeclaration &) override; protected: - void resolve_impl_item (AST::AssociatedItem *item, + void resolve_impl_item (AST::AssociatedItem &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix); - void resolve_extern_item (AST::ExternalItem *item); + void resolve_extern_item (AST::ExternalItem &item); ResolveItem (const CanonicalPath &prefix, const CanonicalPath &canonical_prefix); @@ -93,7 +93,7 @@ class ResolveImplItems : public ResolveItem using Rust::Resolver::ResolveItem::visit; public: - static void go (AST::AssociatedItem *item, const CanonicalPath &prefix, + static void go (AST::AssociatedItem &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix); void visit (AST::TypeAlias &alias) override; @@ -108,7 +108,7 @@ class ResolveExternItem : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::ExternalItem *item, const CanonicalPath &prefix, + static void go (AST::ExternalItem &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix); void visit (AST::Function &function) override; diff --git a/gcc/rust/resolve/rust-ast-resolve-path.cc b/gcc/rust/resolve/rust-ast-resolve-path.cc index 56c352e..ec59030 100644 --- a/gcc/rust/resolve/rust-ast-resolve-path.cc +++ b/gcc/rust/resolve/rust-ast-resolve-path.cc @@ -26,35 +26,35 @@ namespace Resolver { ResolvePath::ResolvePath () : ResolverBase () {} NodeId -ResolvePath::go (AST::PathInExpression *expr) +ResolvePath::go (AST::PathInExpression &expr) { ResolvePath resolver; return resolver.resolve_path (expr); } NodeId -ResolvePath::go (AST::QualifiedPathInExpression *expr) +ResolvePath::go (AST::QualifiedPathInExpression &expr) { ResolvePath resolver; return resolver.resolve_path (expr); } NodeId -ResolvePath::go (AST::SimplePath *expr) +ResolvePath::go (AST::SimplePath &expr) { ResolvePath resolver; return resolver.resolve_path (expr); } NodeId -ResolvePath::resolve_path (AST::PathInExpression *expr) +ResolvePath::resolve_path (AST::PathInExpression &expr) { NodeId resolved_node_id = UNKNOWN_NODEID; NodeId module_scope_id = resolver->peek_current_module_scope (); NodeId previous_resolved_node_id = module_scope_id; - for (size_t i = 0; i < expr->get_segments ().size (); i++) + for (size_t i = 0; i < expr.get_segments ().size (); i++) { - auto &segment = expr->get_segments ().at (i); + auto &segment = expr.get_segments ().at (i); const AST::PathIdentSegment &ident_seg = segment.get_ident_segment (); bool is_first_segment = i == 0; resolved_node_id = UNKNOWN_NODEID; @@ -219,14 +219,14 @@ ResolvePath::resolve_path (AST::PathInExpression *expr) // name scope first if (resolver->get_name_scope ().decl_was_declared_here (resolved_node_id)) { - resolver->insert_resolved_name (expr->get_node_id (), + resolver->insert_resolved_name (expr.get_node_id (), resolved_node_id); } // check the type scope else if (resolver->get_type_scope ().decl_was_declared_here ( resolved_node_id)) { - resolver->insert_resolved_type (expr->get_node_id (), + resolver->insert_resolved_type (expr.get_node_id (), resolved_node_id); } else @@ -238,14 +238,14 @@ ResolvePath::resolve_path (AST::PathInExpression *expr) } NodeId -ResolvePath::resolve_path (AST::QualifiedPathInExpression *expr) +ResolvePath::resolve_path (AST::QualifiedPathInExpression &expr) { - AST::QualifiedPathType &root_segment = expr->get_qualified_path_type (); - ResolveType::go (root_segment.get_type ().get ()); + auto &root_segment = expr.get_qualified_path_type (); + ResolveType::go (root_segment.get_type ()); if (root_segment.has_as_clause ()) - ResolveType::go (&root_segment.get_as_type_path ()); + ResolveType::go (root_segment.get_as_type_path ()); - for (auto &segment : expr->get_segments ()) + for (auto &segment : expr.get_segments ()) { // we cant actually do anything with the segment itself since this is all // the job of the type system to figure it out but we can resolve any @@ -260,18 +260,18 @@ ResolvePath::resolve_path (AST::QualifiedPathInExpression *expr) } NodeId -ResolvePath::resolve_path (AST::SimplePath *expr) +ResolvePath::resolve_path (AST::SimplePath &expr) { NodeId crate_scope_id = resolver->peek_crate_module_scope (); NodeId module_scope_id = resolver->peek_current_module_scope (); NodeId previous_resolved_node_id = UNKNOWN_NODEID; NodeId resolved_node_id = UNKNOWN_NODEID; - for (size_t i = 0; i < expr->get_segments ().size (); i++) + for (size_t i = 0; i < expr.get_segments ().size (); i++) { - AST::SimplePathSegment &segment = expr->get_segments ().at (i); + AST::SimplePathSegment &segment = expr.get_segments ().at (i); bool is_first_segment = i == 0; - bool is_final_segment = i >= (expr->get_segments ().size () - 1); + bool is_final_segment = i >= (expr.get_segments ().size () - 1); resolved_node_id = UNKNOWN_NODEID; if (segment.is_crate_path_seg ()) @@ -393,14 +393,14 @@ ResolvePath::resolve_path (AST::SimplePath *expr) // name scope first if (resolver->get_name_scope ().decl_was_declared_here (resolved_node_id)) { - resolver->insert_resolved_name (expr->get_node_id (), + resolver->insert_resolved_name (expr.get_node_id (), resolved_node_id); } // check the type scope else if (resolver->get_type_scope ().decl_was_declared_here ( resolved_node_id)) { - resolver->insert_resolved_type (expr->get_node_id (), + resolver->insert_resolved_type (expr.get_node_id (), resolved_node_id); } else diff --git a/gcc/rust/resolve/rust-ast-resolve-path.h b/gcc/rust/resolve/rust-ast-resolve-path.h index 7aae19b..08ce750 100644 --- a/gcc/rust/resolve/rust-ast-resolve-path.h +++ b/gcc/rust/resolve/rust-ast-resolve-path.h @@ -29,16 +29,16 @@ class ResolvePath : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static NodeId go (AST::PathInExpression *expr); - static NodeId go (AST::QualifiedPathInExpression *expr); - static NodeId go (AST::SimplePath *expr); + static NodeId go (AST::PathInExpression &expr); + static NodeId go (AST::QualifiedPathInExpression &expr); + static NodeId go (AST::SimplePath &expr); private: ResolvePath (); - NodeId resolve_path (AST::PathInExpression *expr); - NodeId resolve_path (AST::QualifiedPathInExpression *expr); - NodeId resolve_path (AST::SimplePath *expr); + NodeId resolve_path (AST::PathInExpression &expr); + NodeId resolve_path (AST::QualifiedPathInExpression &expr); + NodeId resolve_path (AST::SimplePath &expr); void resolve_simple_path_segments (CanonicalPath prefix, size_t offs, diff --git a/gcc/rust/resolve/rust-ast-resolve-pattern.cc b/gcc/rust/resolve/rust-ast-resolve-pattern.cc index 545fcf8..bfa6e3c 100644 --- a/gcc/rust/resolve/rust-ast-resolve-pattern.cc +++ b/gcc/rust/resolve/rust-ast-resolve-pattern.cc @@ -23,7 +23,7 @@ namespace Rust { namespace Resolver { void -PatternDeclaration::go (AST::Pattern *pattern, Rib::ItemType type) +PatternDeclaration::go (AST::Pattern &pattern, Rib::ItemType type) { std::vector<PatternBinding> bindings = {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())}; @@ -31,11 +31,11 @@ PatternDeclaration::go (AST::Pattern *pattern, Rib::ItemType type) } void -PatternDeclaration::go (AST::Pattern *pattern, Rib::ItemType type, +PatternDeclaration::go (AST::Pattern &pattern, Rib::ItemType type, std::vector<PatternBinding> &bindings) { PatternDeclaration resolver (bindings, type); - pattern->accept_vis (resolver); + pattern.accept_vis (resolver); for (auto &map_entry : resolver.missing_bindings) { @@ -71,28 +71,28 @@ PatternDeclaration::visit (AST::IdentifierPattern &pattern) void PatternDeclaration::visit (AST::GroupedPattern &pattern) { - pattern.get_pattern_in_parens ()->accept_vis (*this); + pattern.get_pattern_in_parens ().accept_vis (*this); } void PatternDeclaration::visit (AST::ReferencePattern &pattern) { - pattern.get_referenced_pattern ()->accept_vis (*this); + pattern.get_referenced_pattern ().accept_vis (*this); } void PatternDeclaration::visit (AST::PathInExpression &pattern) { - ResolvePath::go (&pattern); + ResolvePath::go (pattern); } void PatternDeclaration::visit (AST::TupleStructPattern &pattern) { - ResolvePath::go (&pattern.get_path ()); + ResolvePath::go (pattern.get_path ()); - std::unique_ptr<AST::TupleStructItems> &items = pattern.get_items (); - switch (items->get_item_type ()) + AST::TupleStructItems &items = pattern.get_items (); + switch (items.get_item_type ()) { case AST::TupleStructItems::RANGE: { // TODO @@ -101,12 +101,12 @@ PatternDeclaration::visit (AST::TupleStructPattern &pattern) break; case AST::TupleStructItems::NO_RANGE: { - AST::TupleStructItemsNoRange &items_no_range - = static_cast<AST::TupleStructItemsNoRange &> (*items.get ()); + auto &items_no_range + = static_cast<AST::TupleStructItemsNoRange &> (items); for (auto &inner_pattern : items_no_range.get_patterns ()) { - inner_pattern.get ()->accept_vis (*this); + inner_pattern->accept_vis (*this); } } break; @@ -116,7 +116,7 @@ PatternDeclaration::visit (AST::TupleStructPattern &pattern) void PatternDeclaration::visit (AST::StructPattern &pattern) { - ResolvePath::go (&pattern.get_path ()); + ResolvePath::go (pattern.get_path ()); auto &struct_pattern_elems = pattern.get_struct_pattern_elems (); for (auto &field : struct_pattern_elems.get_struct_pattern_fields ()) @@ -127,7 +127,7 @@ PatternDeclaration::visit (AST::StructPattern &pattern) AST::StructPatternFieldTuplePat &tuple = static_cast<AST::StructPatternFieldTuplePat &> (*field); - tuple.get_index_pattern ()->accept_vis (*this); + tuple.get_index_pattern ().accept_vis (*this); } break; @@ -135,13 +135,12 @@ PatternDeclaration::visit (AST::StructPattern &pattern) AST::StructPatternFieldIdentPat &ident = static_cast<AST::StructPatternFieldIdentPat &> (*field); - ident.get_ident_pattern ()->accept_vis (*this); + ident.get_ident_pattern ().accept_vis (*this); } break; case AST::StructPatternField::ItemType::IDENT: { - AST::StructPatternFieldIdent &ident - = static_cast<AST::StructPatternFieldIdent &> (*field.get ()); + auto &ident = static_cast<AST::StructPatternFieldIdent &> (*field); Mutability mut = ident.is_mut () ? Mutability::Mut : Mutability::Imm; @@ -158,13 +157,12 @@ PatternDeclaration::visit (AST::StructPattern &pattern) void PatternDeclaration::visit (AST::TuplePattern &pattern) { - std::unique_ptr<AST::TuplePatternItems> &items = pattern.get_items (); - switch (items->get_pattern_type ()) + auto &items = pattern.get_items (); + switch (items.get_pattern_type ()) { case AST::TuplePatternItems::TuplePatternItemType::MULTIPLE: { - AST::TuplePatternItemsMultiple &ref - = *static_cast<AST::TuplePatternItemsMultiple *> ( - pattern.get_items ().get ()); + auto &ref = static_cast<AST::TuplePatternItemsMultiple &> ( + pattern.get_items ()); for (auto &p : ref.get_patterns ()) p->accept_vis (*this); @@ -172,9 +170,8 @@ PatternDeclaration::visit (AST::TuplePattern &pattern) break; case AST::TuplePatternItems::TuplePatternItemType::RANGED: { - AST::TuplePatternItemsRanged &ref - = *static_cast<AST::TuplePatternItemsRanged *> ( - pattern.get_items ().get ()); + auto &ref + = static_cast<AST::TuplePatternItemsRanged &> (pattern.get_items ()); for (auto &p : ref.get_lower_patterns ()) p->accept_vis (*this); @@ -342,27 +339,25 @@ PatternDeclaration::check_bindings_consistency ( } static void -resolve_range_pattern_bound (AST::RangePatternBound *bound) +resolve_range_pattern_bound (AST::RangePatternBound &bound) { - switch (bound->get_bound_type ()) + switch (bound.get_bound_type ()) { case AST::RangePatternBound::RangePatternBoundType::LITERAL: // Nothing to resolve for a literal. break; case AST::RangePatternBound::RangePatternBoundType::PATH: { - AST::RangePatternBoundPath &ref - = *static_cast<AST::RangePatternBoundPath *> (bound); + auto &ref = static_cast<AST::RangePatternBoundPath &> (bound); - ResolvePath::go (&ref.get_path ()); + ResolvePath::go (ref.get_path ()); } break; case AST::RangePatternBound::RangePatternBoundType::QUALPATH: { - AST::RangePatternBoundQualPath &ref - = *static_cast<AST::RangePatternBoundQualPath *> (bound); + auto &ref = static_cast<AST::RangePatternBoundQualPath &> (bound); - ResolvePath::go (&ref.get_qualified_path ()); + ResolvePath::go (ref.get_qualified_path ()); } break; } @@ -371,8 +366,8 @@ resolve_range_pattern_bound (AST::RangePatternBound *bound) void PatternDeclaration::visit (AST::RangePattern &pattern) { - resolve_range_pattern_bound (pattern.get_upper_bound ().get ()); - resolve_range_pattern_bound (pattern.get_lower_bound ().get ()); + resolve_range_pattern_bound (pattern.get_upper_bound ()); + resolve_range_pattern_bound (pattern.get_lower_bound ()); } void diff --git a/gcc/rust/resolve/rust-ast-resolve-pattern.h b/gcc/rust/resolve/rust-ast-resolve-pattern.h index 5974b50..83607e54 100644 --- a/gcc/rust/resolve/rust-ast-resolve-pattern.h +++ b/gcc/rust/resolve/rust-ast-resolve-pattern.h @@ -95,8 +95,8 @@ class PatternDeclaration : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::Pattern *pattern, Rib::ItemType type); - static void go (AST::Pattern *pattern, Rib::ItemType type, + static void go (AST::Pattern &pattern, Rib::ItemType type); + static void go (AST::Pattern &pattern, Rib::ItemType type, std::vector<PatternBinding> &bindings); void visit (AST::IdentifierPattern &pattern) override; diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.cc b/gcc/rust/resolve/rust-ast-resolve-stmt.cc index 04dfdfe..7b62d1f 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.cc +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.cc @@ -30,31 +30,30 @@ ResolveStmt::visit (AST::ExternBlock &extern_block) resolve_visibility (extern_block.get_visibility ()); for (auto &item : extern_block.get_extern_items ()) { - ResolveToplevelExternItem::go (item.get (), - CanonicalPath::create_empty ()); - ResolveExternItem::go (item.get (), prefix, canonical_prefix); + ResolveToplevelExternItem::go (*item, CanonicalPath::create_empty ()); + ResolveExternItem::go (*item, prefix, canonical_prefix); } } void ResolveStmt::visit (AST::Trait &trait) { - ResolveTopLevel::go (&trait, prefix, canonical_prefix); - ResolveItem::go (&trait, prefix, canonical_prefix); + ResolveTopLevel::go (trait, prefix, canonical_prefix); + ResolveItem::go (trait, prefix, canonical_prefix); } void ResolveStmt::visit (AST::InherentImpl &impl_block) { - ResolveTopLevel::go (&impl_block, prefix, canonical_prefix); - ResolveItem::go (&impl_block, prefix, canonical_prefix); + ResolveTopLevel::go (impl_block, prefix, canonical_prefix); + ResolveItem::go (impl_block, prefix, canonical_prefix); } void ResolveStmt::visit (AST::TraitImpl &impl_block) { - ResolveTopLevel::go (&impl_block, prefix, canonical_prefix); - ResolveItem::go (&impl_block, prefix, canonical_prefix); + ResolveTopLevel::go (impl_block, prefix, canonical_prefix); + ResolveItem::go (impl_block, prefix, canonical_prefix); } } // namespace Resolver diff --git a/gcc/rust/resolve/rust-ast-resolve-stmt.h b/gcc/rust/resolve/rust-ast-resolve-stmt.h index f9aa93b..d699bde 100644 --- a/gcc/rust/resolve/rust-ast-resolve-stmt.h +++ b/gcc/rust/resolve/rust-ast-resolve-stmt.h @@ -33,20 +33,20 @@ class ResolveStmt : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::Stmt *stmt, const CanonicalPath &prefix, + static void go (AST::Stmt &stmt, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix, const CanonicalPath &enum_prefix) { - if (stmt->is_marked_for_strip ()) + if (stmt.is_marked_for_strip ()) return; ResolveStmt resolver (prefix, canonical_prefix, enum_prefix); - stmt->accept_vis (resolver); + stmt.accept_vis (resolver); } void visit (AST::ExprStmt &stmt) override { - ResolveExpr::go (stmt.get_expr ().get (), prefix, canonical_prefix); + ResolveExpr::go (stmt.get_expr (), prefix, canonical_prefix); } void visit (AST::ConstantItem &constant) override @@ -66,21 +66,20 @@ public: rust_error_at (r, "redefined multiple times"); }); - ResolveType::go (constant.get_type ().get ()); - ResolveExpr::go (constant.get_expr ().get (), prefix, canonical_prefix); + ResolveType::go (constant.get_type ()); + ResolveExpr::go (constant.get_expr (), prefix, canonical_prefix); } void visit (AST::LetStmt &stmt) override { if (stmt.has_init_expr ()) { - ResolveExpr::go (stmt.get_init_expr ().get (), prefix, - canonical_prefix); + ResolveExpr::go (stmt.get_init_expr (), prefix, canonical_prefix); } - PatternDeclaration::go (stmt.get_pattern ().get (), Rib::ItemType::Var); + PatternDeclaration::go (stmt.get_pattern (), Rib::ItemType::Var); if (stmt.has_type ()) - ResolveType::go (stmt.get_type ().get ()); + ResolveType::go (stmt.get_type ()); } void visit (AST::TupleStruct &struct_decl) override @@ -107,11 +106,11 @@ public: if (struct_decl.has_generics ()) { for (auto &generic : struct_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); } for (AST::TupleField &field : struct_decl.get_fields ()) - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); resolver->get_type_scope ().pop (); } @@ -140,11 +139,11 @@ public: if (enum_decl.has_generics ()) { for (auto &generic : enum_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); } for (auto &variant : enum_decl.get_variants ()) - ResolveStmt::go (variant.get (), path, canonical_prefix, path); + ResolveStmt::go (*variant, path, canonical_prefix, path); resolver->get_type_scope ().pop (); } @@ -188,10 +187,10 @@ public: for (auto &field : item.get_tuple_fields ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } } @@ -214,10 +213,10 @@ public: for (auto &field : item.get_struct_fields ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } } @@ -265,15 +264,15 @@ public: if (struct_decl.has_generics ()) { for (auto &generic : struct_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); } for (AST::StructField &field : struct_decl.get_fields ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } resolver->get_type_scope ().pop (); @@ -302,14 +301,14 @@ public: if (union_decl.has_generics ()) for (auto &generic : union_decl.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); for (AST::StructField &field : union_decl.get_variants ()) { - if (field.get_field_type ()->is_marked_for_strip ()) + if (field.get_field_type ().is_marked_for_strip ()) continue; - ResolveType::go (field.get_field_type ().get ()); + ResolveType::go (field.get_field_type ()); } resolver->get_type_scope ().pop (); @@ -343,10 +342,10 @@ public: if (function.has_generics ()) for (auto &generic : function.get_generic_params ()) - ResolveGenericParam::go (generic.get (), prefix, canonical_prefix); + ResolveGenericParam::go (*generic, prefix, canonical_prefix); if (function.has_return_type ()) - ResolveType::go (function.get_return_type ().get ()); + ResolveType::go (function.get_return_type ()); std::vector<PatternBinding> bindings = {PatternBinding (PatternBoundCtx::Product, std::set<Identifier> ())}; @@ -357,28 +356,28 @@ public: { if (p->is_variadic ()) { - auto param = static_cast<AST::VariadicParam *> (p.get ()); - PatternDeclaration::go (param->get_pattern ().get (), - Rib::ItemType::Param, bindings); + auto ¶m = static_cast<AST::VariadicParam &> (*p); + PatternDeclaration::go (param.get_pattern (), Rib::ItemType::Param, + bindings); } else if (p->is_self ()) { - auto param = static_cast<AST::SelfParam *> (p.get ()); - ResolveType::go (param->get_type ().get ()); + auto ¶m = static_cast<AST::SelfParam &> (*p); + ResolveType::go (param.get_type ()); } else { - auto param = static_cast<AST::FunctionParam *> (p.get ()); + auto ¶m = static_cast<AST::FunctionParam &> (*p); - ResolveType::go (param->get_type ().get ()); - PatternDeclaration::go (param->get_pattern ().get (), - Rib::ItemType::Param, bindings); + ResolveType::go (param.get_type ()); + PatternDeclaration::go (param.get_pattern (), Rib::ItemType::Param, + bindings); } } // resolve the function body - ResolveExpr::go (function.get_definition ()->get (), path, cpath); + ResolveExpr::go (*function.get_definition ().value (), path, cpath); resolver->get_name_scope ().pop (); resolver->get_type_scope ().pop (); diff --git a/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.cc b/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.cc index b707343..c63da236 100644 --- a/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.cc +++ b/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.cc @@ -23,12 +23,12 @@ namespace Rust { namespace Resolver { void -ResolveStructExprField::go (AST::StructExprField *field, +ResolveStructExprField::go (AST::StructExprField &field, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix) { ResolveStructExprField resolver (prefix, canonical_prefix); - field->accept_vis (resolver); + field.accept_vis (resolver); } ResolveStructExprField::ResolveStructExprField ( @@ -39,13 +39,13 @@ ResolveStructExprField::ResolveStructExprField ( void ResolveStructExprField::visit (AST::StructExprFieldIdentifierValue &field) { - ResolveExpr::go (field.get_value ().get (), prefix, canonical_prefix); + ResolveExpr::go (field.get_value (), prefix, canonical_prefix); } void ResolveStructExprField::visit (AST::StructExprFieldIndexValue &field) { - ResolveExpr::go (field.get_value ().get (), prefix, canonical_prefix); + ResolveExpr::go (field.get_value (), prefix, canonical_prefix); } void @@ -54,7 +54,7 @@ ResolveStructExprField::visit (AST::StructExprFieldIdentifier &field) AST::IdentifierExpr expr (field.get_field_name (), {}, field.get_locus ()); expr.set_node_id (field.get_node_id ()); - ResolveExpr::go (&expr, prefix, canonical_prefix); + ResolveExpr::go (expr, prefix, canonical_prefix); } } // namespace Resolver diff --git a/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.h b/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.h index 67bb955..3291c56 100644 --- a/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.h +++ b/gcc/rust/resolve/rust-ast-resolve-struct-expr-field.h @@ -31,7 +31,7 @@ class ResolveStructExprField : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::StructExprField *field, const CanonicalPath &prefix, + static void go (AST::StructExprField &field, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix); void visit (AST::StructExprFieldIdentifierValue &field) override; diff --git a/gcc/rust/resolve/rust-ast-resolve-toplevel.h b/gcc/rust/resolve/rust-ast-resolve-toplevel.h index 73b4d29..7576928 100644 --- a/gcc/rust/resolve/rust-ast-resolve-toplevel.h +++ b/gcc/rust/resolve/rust-ast-resolve-toplevel.h @@ -31,18 +31,18 @@ class ResolveTopLevel : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static void go (AST::Item *item, const CanonicalPath &prefix, + static void go (AST::Item &item, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix) { - if (item->is_marked_for_strip ()) + if (item.is_marked_for_strip ()) return; ResolveTopLevel resolver (prefix, canonical_prefix); - item->accept_vis (resolver); + item.accept_vis (resolver); NodeId current_module = resolver.resolver->peek_current_module_scope (); resolver.mappings->insert_child_item_to_parent_module_mapping ( - item->get_node_id (), current_module); + item.get_node_id (), current_module); } void visit (AST::Module &module) override @@ -67,7 +67,7 @@ public: resolver->push_new_module_scope (module.get_node_id ()); for (auto &item : module.get_items ()) - ResolveTopLevel::go (item.get (), path, cpath); + ResolveTopLevel::go (*item, path, cpath); resolver->pop_module_scope (); @@ -137,7 +137,7 @@ public: resolver->push_new_module_scope (enum_decl.get_node_id ()); for (auto &variant : enum_decl.get_variants ()) - ResolveTopLevel::go (variant.get (), path, cpath); + ResolveTopLevel::go (*variant, path, cpath); resolver->pop_module_scope (); @@ -343,9 +343,9 @@ public: void visit (AST::InherentImpl &impl_block) override { - std::string raw_impl_type_path = impl_block.get_type ()->as_string (); + std::string raw_impl_type_path = impl_block.get_type ().as_string (); CanonicalPath impl_type_seg - = CanonicalPath::new_seg (impl_block.get_type ()->get_node_id (), + = CanonicalPath::new_seg (impl_block.get_type ().get_node_id (), raw_impl_type_path); CanonicalPath impl_type @@ -354,14 +354,14 @@ public: CanonicalPath impl_prefix = prefix.append (impl_type_seg); for (auto &impl_item : impl_block.get_impl_items ()) - ResolveToplevelImplItem::go (impl_item.get (), impl_prefix); + ResolveToplevelImplItem::go (*impl_item, impl_prefix); } void visit (AST::TraitImpl &impl_block) override { - std::string raw_impl_type_path = impl_block.get_type ()->as_string (); + std::string raw_impl_type_path = impl_block.get_type ().as_string (); CanonicalPath impl_type_seg - = CanonicalPath::new_seg (impl_block.get_type ()->get_node_id (), + = CanonicalPath::new_seg (impl_block.get_type ().get_node_id (), raw_impl_type_path); std::string raw_trait_type_path = impl_block.get_trait_path ().as_string (); @@ -385,7 +385,7 @@ public: }); for (auto &impl_item : impl_block.get_impl_items ()) - ResolveToplevelImplItem::go (impl_item.get (), impl_prefix); + ResolveToplevelImplItem::go (*impl_item, impl_prefix); } void visit (AST::Trait &trait) override @@ -416,7 +416,7 @@ public: { for (auto &item : extern_block.get_extern_items ()) { - ResolveToplevelExternItem::go (item.get (), prefix); + ResolveToplevelExternItem::go (*item, prefix); } } diff --git a/gcc/rust/resolve/rust-ast-resolve-type.cc b/gcc/rust/resolve/rust-ast-resolve-type.cc index bbb0538..df1e7ee 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.cc +++ b/gcc/rust/resolve/rust-ast-resolve-type.cc @@ -27,15 +27,15 @@ namespace Resolver { void ResolveType::visit (AST::ArrayType &type) { - type.get_elem_type ()->accept_vis (*this); - ResolveExpr::go (type.get_size_expr ().get (), CanonicalPath::create_empty (), + type.get_elem_type ().accept_vis (*this); + ResolveExpr::go (type.get_size_expr (), CanonicalPath::create_empty (), CanonicalPath::create_empty ()); } void ResolveType::visit (AST::TraitObjectTypeOneBound &type) { - ResolveTypeBound::go (&type.get_trait_bound ()); + ResolveTypeBound::go (type.get_trait_bound ()); } void @@ -44,20 +44,20 @@ ResolveType::visit (AST::TraitObjectType &type) for (auto &bound : type.get_type_param_bounds ()) { /* NodeId bound_resolved_id = */ - ResolveTypeBound::go (bound.get ()); + ResolveTypeBound::go (*bound); } } void ResolveType::visit (AST::ReferenceType &type) { - resolved_node = ResolveType::go (type.get_type_referenced ().get ()); + resolved_node = ResolveType::go (type.get_type_referenced ()); } void ResolveType::visit (AST::RawPointerType &type) { - resolved_node = ResolveType::go (type.get_type_pointed_to ().get ()); + resolved_node = ResolveType::go (type.get_type_pointed_to ()); } void @@ -75,7 +75,7 @@ ResolveType::visit (AST::NeverType &) void ResolveType::visit (AST::SliceType &type) { - resolved_node = ResolveType::go (type.get_elem_type ().get ()); + resolved_node = ResolveType::go (type.get_elem_type ()); } // resolve relative type-paths @@ -153,12 +153,12 @@ ResolveRelativeTypePath::go (AST::TypePath &path, NodeId &resolved_node_id) AST::TypePathFunction &fn = fnseg->get_type_path_function (); for (auto ¶m : fn.get_params ()) { - ResolveType::go (param.get ()); + ResolveType::go (*param); } if (fn.has_return_type ()) { - ResolveType::go (fn.get_return_type ().get ()); + ResolveType::go (fn.get_return_type ()); } break; @@ -318,11 +318,11 @@ ResolveRelativeQualTypePath::resolve_qual_seg (AST::QualifiedPathType &seg) return false; } - auto type = seg.get_type ().get (); + auto &type = seg.get_type (); ResolveType::go (type); if (seg.has_as_clause ()) - ResolveType::go (&seg.get_as_type_path ()); + ResolveType::go (seg.get_as_type_path ()); return true; } @@ -356,10 +356,10 @@ ResolveRelativeQualTypePath::visit (AST::TypePathSegment &seg) // resolve to canonical path bool -ResolveTypeToCanonicalPath::go (AST::Type *type, CanonicalPath &result) +ResolveTypeToCanonicalPath::go (AST::Type &type, CanonicalPath &result) { ResolveTypeToCanonicalPath resolver; - type->accept_vis (resolver); + type.accept_vis (resolver); result = resolver.result; return !resolver.result.is_empty (); } @@ -402,8 +402,9 @@ ResolveTypeToCanonicalPath::visit (AST::TypePath &path) if (generic.get_kind () == AST::GenericArg::Kind::Type) { CanonicalPath arg = CanonicalPath::create_empty (); - bool ok = ResolveTypeToCanonicalPath::go ( - generic.get_type ().get (), arg); + bool ok + = ResolveTypeToCanonicalPath::go (generic.get_type (), + arg); if (ok) args.push_back (std::move (arg)); } @@ -444,8 +445,7 @@ void ResolveTypeToCanonicalPath::visit (AST::ReferenceType &type) { CanonicalPath path = CanonicalPath::create_empty (); - bool ok - = ResolveTypeToCanonicalPath::go (type.get_type_referenced ().get (), path); + bool ok = ResolveTypeToCanonicalPath::go (type.get_type_referenced (), path); if (ok) { std::string ref_type_str = type.is_mut () ? "mut" : ""; @@ -458,8 +458,7 @@ void ResolveTypeToCanonicalPath::visit (AST::RawPointerType &type) { CanonicalPath path = CanonicalPath::create_empty (); - bool ok - = ResolveTypeToCanonicalPath::go (type.get_type_pointed_to ().get (), path); + bool ok = ResolveTypeToCanonicalPath::go (type.get_type_pointed_to (), path); if (ok) { std::string ptr_type_str @@ -474,7 +473,7 @@ void ResolveTypeToCanonicalPath::visit (AST::SliceType &type) { CanonicalPath path = CanonicalPath::create_empty (); - bool ok = ResolveTypeToCanonicalPath::go (type.get_elem_type ().get (), path); + bool ok = ResolveTypeToCanonicalPath::go (type.get_elem_type (), path); if (ok) { std::string slice_path = "[" + path.get () + "]"; @@ -487,7 +486,7 @@ ResolveTypeToCanonicalPath::visit (AST::TraitObjectTypeOneBound &type) { CanonicalPath path = CanonicalPath::create_empty (); bool ok - = ResolveTypeToCanonicalPath::go (&type.get_trait_bound ().get_type_path (), + = ResolveTypeToCanonicalPath::go (type.get_trait_bound ().get_type_path (), path); if (ok) { @@ -550,10 +549,10 @@ ResolveGenericArgs::resolve_disambiguated_generic (AST::GenericArg &arg) switch (arg.get_kind ()) { case AST::GenericArg::Kind::Const: - ResolveExpr::go (arg.get_expression ().get (), prefix, canonical_prefix); + ResolveExpr::go (arg.get_expression (), prefix, canonical_prefix); break; case AST::GenericArg::Kind::Type: - ResolveType::go (arg.get_type ().get ()); + ResolveType::go (arg.get_type ()); break; default: rust_unreachable (); @@ -584,7 +583,7 @@ ResolveGenericArgs::go (AST::GenericArgs &generic_args, for (auto &binding : generic_args.get_binding_args ()) { - ResolveType::go (binding.get_type ().get ()); + ResolveType::go (binding.get_type ()); } } diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h index c69a828..f1031e9 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.h +++ b/gcc/rust/resolve/rust-ast-resolve-type.h @@ -56,20 +56,20 @@ class ResolveType : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static NodeId go (AST::Type *type) + static NodeId go (AST::Type &type) { ResolveType resolver; - type->accept_vis (resolver); + type.accept_vis (resolver); return resolver.resolved_node; } void visit (AST::BareFunctionType &fntype) override { for (auto ¶m : fntype.get_function_params ()) - ResolveType::go (param.get_type ().get ()); + ResolveType::go (param.get_type ()); if (fntype.has_return_type ()) - ResolveType::go (fntype.get_return_type ().get ()); + ResolveType::go (fntype.get_return_type ()); } void visit (AST::TupleType &tuple) override @@ -81,7 +81,7 @@ public: } for (auto &elem : tuple.get_elems ()) - ResolveType::go (elem.get ()); + ResolveType::go (*elem); } void visit (AST::TypePath &path) override @@ -119,16 +119,16 @@ class ResolveTypeBound : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static NodeId go (AST::TypeParamBound *type) + static NodeId go (AST::TypeParamBound &type) { ResolveTypeBound resolver; - type->accept_vis (resolver); + type.accept_vis (resolver); return resolver.resolved_node; }; void visit (AST::TraitBound &bound) override { - resolved_node = ResolveType::go (&bound.get_type_path ()); + resolved_node = ResolveType::go (bound.get_type_path ()); } private: @@ -140,21 +140,21 @@ class ResolveGenericParam : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static NodeId go (AST::GenericParam *param, const CanonicalPath &prefix, + static NodeId go (AST::GenericParam ¶m, const CanonicalPath &prefix, const CanonicalPath &canonical_prefix) { ResolveGenericParam resolver (prefix, canonical_prefix); - param->accept_vis (resolver); + param.accept_vis (resolver); return resolver.resolved_node; } void visit (AST::ConstGenericParam ¶m) override { - ResolveType::go (param.get_type ().get ()); + ResolveType::go (param.get_type ()); if (param.has_default_value ()) - ResolveExpr::go (param.get_default_value ().get_expression ().get (), - prefix, canonical_prefix); + ResolveExpr::go (param.get_default_value ().get_expression (), prefix, + canonical_prefix); ok = true; } @@ -163,13 +163,13 @@ public: { // if it has a type lets resolve it if (param.has_type ()) - ResolveType::go (param.get_type ().get ()); + ResolveType::go (param.get_type ()); if (param.has_type_param_bounds ()) { for (auto &bound : param.get_type_param_bounds ()) { - ResolveTypeBound::go (bound.get ()); + ResolveTypeBound::go (*bound); } } @@ -213,12 +213,12 @@ public: void visit (AST::TypeBoundWhereClauseItem &item) override { - ResolveType::go (item.get_type ().get ()); + ResolveType::go (item.get_type ()); if (item.has_type_param_bounds ()) { for (auto &bound : item.get_type_param_bounds ()) { - ResolveTypeBound::go (bound.get ()); + ResolveTypeBound::go (*bound); } } } @@ -232,7 +232,7 @@ class ResolveTypeToCanonicalPath : public ResolverBase using Rust::Resolver::ResolverBase::visit; public: - static bool go (AST::Type *type, CanonicalPath &result); + static bool go (AST::Type &type, CanonicalPath &result); void visit (AST::TypePath &path) override; diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc index 401434c..4273ae3 100644 --- a/gcc/rust/resolve/rust-ast-resolve.cc +++ b/gcc/rust/resolve/rust-ast-resolve.cc @@ -92,9 +92,8 @@ NameResolution::go (AST::Crate &crate) // first gather the top-level namespace names then we drill down so this // allows for resolving forward declarations since an impl block might have // a Self type Foo which is defined after the impl block for example. - for (auto it = crate.items.begin (); it != crate.items.end (); it++) - ResolveTopLevel::go (it->get (), CanonicalPath::create_empty (), - crate_prefix); + for (auto &item : crate.items) + ResolveTopLevel::go (*item, CanonicalPath::create_empty (), crate_prefix); // FIXME remove this if (saw_errors ()) @@ -104,8 +103,8 @@ NameResolution::go (AST::Crate &crate) } // next we can drill down into the items and their scopes - for (auto it = crate.items.begin (); it != crate.items.end (); it++) - ResolveItem::go (it->get (), CanonicalPath::create_empty (), crate_prefix); + for (auto &item : crate.items) + ResolveItem::go (*item, CanonicalPath::create_empty (), crate_prefix); // done resolver->pop_module_scope (); diff --git a/gcc/rust/resolve/rust-default-resolver.cc b/gcc/rust/resolve/rust-default-resolver.cc index 789cc4e..e2609d1 100644 --- a/gcc/rust/resolve/rust-default-resolver.cc +++ b/gcc/rust/resolve/rust-default-resolver.cc @@ -35,7 +35,7 @@ DefaultResolver::visit (AST::BlockExpr &expr) stmt->accept_vis (*this); if (expr.has_tail_expr ()) - expr.get_tail_expr ()->accept_vis (*this); + expr.get_tail_expr ().accept_vis (*this); }; ctx.scoped (Rib::Kind::Normal, expr.get_node_id (), inner_fn); @@ -61,21 +61,21 @@ DefaultResolver::visit (AST::Function &function) { if (p->is_variadic ()) { - auto param = static_cast<AST::VariadicParam *> (p.get ()); - if (param->has_pattern ()) - param->get_pattern ()->accept_vis (*this); + auto ¶m = static_cast<AST::VariadicParam &> (*p); + if (param.has_pattern ()) + param.get_pattern ().accept_vis (*this); } else if (p->is_self ()) { - auto param = static_cast<AST::SelfParam *> (p.get ()); - param->get_type ()->accept_vis (*this); - param->get_lifetime ().accept_vis (*this); + auto ¶m = static_cast<AST::SelfParam &> (*p); + param.get_type ().accept_vis (*this); + param.get_lifetime ().accept_vis (*this); } else { - auto param = static_cast<AST::FunctionParam *> (p.get ()); - param->get_pattern ()->accept_vis (*this); - param->get_type ()->accept_vis (*this); + auto ¶m = static_cast<AST::FunctionParam &> (*p); + param.get_pattern ().accept_vis (*this); + param.get_type ().accept_vis (*this); } } @@ -90,9 +90,9 @@ void DefaultResolver::visit (AST::ForLoopExpr &expr) { ctx.scoped (Rib::Kind::Normal, expr.get_node_id (), [this, &expr] () { - expr.get_pattern ()->accept_vis (*this); - expr.get_iterator_expr ()->accept_vis (*this); - expr.get_loop_block ()->accept_vis (*this); + expr.get_pattern ().accept_vis (*this); + expr.get_iterator_expr ().accept_vis (*this); + expr.get_loop_block ().accept_vis (*this); }); } @@ -188,12 +188,12 @@ DefaultResolver::visit (AST::ClosureExprInner &expr) if (param.is_error ()) continue; - param.get_pattern ()->accept_vis (*this); + param.get_pattern ().accept_vis (*this); if (param.has_type_given ()) - param.get_type ()->accept_vis (*this); + param.get_type ().accept_vis (*this); } - expr.get_definition_expr ()->accept_vis (*this); + expr.get_definition_expr ().accept_vis (*this); } void @@ -207,13 +207,13 @@ DefaultResolver::visit (AST::ClosureExprInnerTyped &expr) if (param.is_error ()) continue; - param.get_pattern ()->accept_vis (*this); + param.get_pattern ().accept_vis (*this); if (param.has_type_given ()) - param.get_type ()->accept_vis (*this); + param.get_type ().accept_vis (*this); } - expr.get_definition_block ()->accept_vis (*this); - expr.get_return_type ()->accept_vis (*this); + expr.get_definition_block ().accept_vis (*this); + expr.get_return_type ().accept_vis (*this); } void @@ -263,16 +263,16 @@ DefaultResolver::visit (AST::WhileLetLoopExpr &expr) void DefaultResolver::visit (AST::IfExpr &expr) { - expr.get_condition_expr ()->accept_vis (*this); - expr.get_if_block ()->accept_vis (*this); + expr.get_condition_expr ().accept_vis (*this); + expr.get_if_block ().accept_vis (*this); } void DefaultResolver::visit (AST::IfExprConseqElse &expr) { - expr.get_condition_expr ()->accept_vis (*this); - expr.get_if_block ()->accept_vis (*this); - expr.get_else_block ()->accept_vis (*this); + expr.get_condition_expr ().accept_vis (*this); + expr.get_if_block ().accept_vis (*this); + expr.get_else_block ().accept_vis (*this); } void @@ -289,14 +289,14 @@ DefaultResolver::visit (AST::MatchExpr &expr) if (expr.is_marked_for_strip ()) return; - expr.get_scrutinee_expr ()->accept_vis (*this); + expr.get_scrutinee_expr ().accept_vis (*this); for (auto &arm : expr.get_match_cases ()) { - arm.get_expr ()->accept_vis (*this); + arm.get_expr ().accept_vis (*this); for (auto &pat : arm.get_arm ().get_patterns ()) pat->accept_vis (*this); if (arm.get_arm ().has_match_arm_guard ()) - arm.get_arm ().get_guard_expr ()->accept_vis (*this); + arm.get_arm ().get_guard_expr ().accept_vis (*this); } } @@ -339,7 +339,7 @@ DefaultResolver::visit (AST::PathInExpression &expr) arg.accept_vis (*this); for (auto &arg : args.get_binding_args ()) if (!arg.is_error ()) - arg.get_type ()->accept_vis (*this); + arg.get_type ().accept_vis (*this); for (auto &arg : args.get_lifetime_args ()) arg.accept_vis (*this); } @@ -441,27 +441,27 @@ void DefaultResolver::visit (AST::EnumItemTuple &item) { for (auto &field : item.get_tuple_fields ()) - field.get_field_type ()->accept_vis (*this); + field.get_field_type ().accept_vis (*this); } void DefaultResolver::visit (AST::EnumItemStruct &item) { for (auto &field : item.get_struct_fields ()) - field.get_field_type ()->accept_vis (*this); + field.get_field_type ().accept_vis (*this); } void DefaultResolver::visit (AST::EnumItemDiscriminant &item) { if (item.has_expr ()) - item.get_expr ()->accept_vis (*this); + item.get_expr ().accept_vis (*this); } void DefaultResolver::visit (AST::ConstantItem &item) { - auto expr_vis = [this, &item] () { item.get_expr ()->accept_vis (*this); }; + auto expr_vis = [this, &item] () { item.get_expr ().accept_vis (*this); }; // FIXME: Why do we need a Rib here? ctx.scoped (Rib::Kind::Item, item.get_node_id (), expr_vis); @@ -470,7 +470,7 @@ DefaultResolver::visit (AST::ConstantItem &item) void DefaultResolver::visit (AST::StaticItem &item) { - auto expr_vis = [this, &item] () { item.get_expr ()->accept_vis (*this); }; + auto expr_vis = [this, &item] () { item.get_expr ().accept_vis (*this); }; // FIXME: Why do we need a Rib here? ctx.scoped (Rib::Kind::ConstantItem, item.get_node_id (), expr_vis); diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc index 5447084..af44439 100644 --- a/gcc/rust/resolve/rust-early-name-resolver.cc +++ b/gcc/rust/resolve/rust-early-name-resolver.cc @@ -90,13 +90,13 @@ EarlyNameResolver::resolve_generic_args (AST::GenericArgs &generic_args) arg.accept_vis (*this); for (auto &arg : generic_args.get_binding_args ()) - arg.get_type ()->accept_vis (*this); + arg.get_type ().accept_vis (*this); } void EarlyNameResolver::resolve_qualified_path_type (AST::QualifiedPathType &path) { - path.get_type ()->accept_vis (*this); + path.get_type ().accept_vis (*this); if (path.has_as_clause ()) path.get_as_type_path ().accept_vis (*this); @@ -227,7 +227,7 @@ EarlyNameResolver::visit (AST::BlockExpr &expr) stmt->accept_vis (*this); if (expr.has_tail_expr ()) - expr.get_tail_expr ()->accept_vis (*this); + expr.get_tail_expr ().accept_vis (*this); }); } @@ -243,37 +243,37 @@ void EarlyNameResolver::visit (AST::ForLoopExpr &expr) { scoped (expr.get_node_id (), [&expr, this] () { - expr.get_pattern ()->accept_vis (*this); - expr.get_iterator_expr ()->accept_vis (*this); - expr.get_loop_block ()->accept_vis (*this); + expr.get_pattern ().accept_vis (*this); + expr.get_iterator_expr ().accept_vis (*this); + expr.get_loop_block ().accept_vis (*this); }); } void EarlyNameResolver::visit (AST::IfLetExpr &expr) { - expr.get_value_expr ()->accept_vis (*this); + expr.get_value_expr ().accept_vis (*this); scoped (expr.get_node_id (), - [&expr, this] () { expr.get_if_block ()->accept_vis (*this); }); + [&expr, this] () { expr.get_if_block ().accept_vis (*this); }); } void EarlyNameResolver::visit (AST::MatchExpr &expr) { - expr.get_scrutinee_expr ()->accept_vis (*this); + expr.get_scrutinee_expr ().accept_vis (*this); scoped (expr.get_node_id (), [&expr, this] () { for (auto &arm : expr.get_match_cases ()) { scoped (arm.get_node_id (), [&arm, this] () { if (arm.get_arm ().has_match_arm_guard ()) - arm.get_arm ().get_guard_expr ()->accept_vis (*this); + arm.get_arm ().get_guard_expr ().accept_vis (*this); for (auto &pattern : arm.get_arm ().get_patterns ()) pattern->accept_vis (*this); - arm.get_expr ()->accept_vis (*this); + arm.get_expr ().accept_vis (*this); }); } }); @@ -365,7 +365,7 @@ EarlyNameResolver::visit (AST::Trait &trait) void EarlyNameResolver::visit (AST::InherentImpl &impl) { - impl.get_type ()->accept_vis (*this); + impl.get_type ().accept_vis (*this); for (auto &generic : impl.get_generic_params ()) generic->accept_vis (*this); @@ -379,7 +379,7 @@ EarlyNameResolver::visit (AST::InherentImpl &impl) void EarlyNameResolver::visit (AST::TraitImpl &impl) { - impl.get_type ()->accept_vis (*this); + impl.get_type ().accept_vis (*this); for (auto &generic : impl.get_generic_params ()) generic->accept_vis (*this); @@ -558,7 +558,7 @@ EarlyNameResolver::visit (AST::StructPattern &) void EarlyNameResolver::visit (AST::TupleStructPattern &pattern) { - pattern.get_items ()->accept_vis (*this); + pattern.get_items ().accept_vis (*this); } void 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 6470a63..446a1c6 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -213,7 +213,7 @@ TopLevel::visit (AST::BlockExpr &expr) stmt->accept_vis (*this); if (expr.has_tail_expr ()) - expr.get_tail_expr ()->accept_vis (*this); + expr.get_tail_expr ().accept_vis (*this); }; ctx.scoped (Rib::Kind::Normal, expr.get_node_id (), sub_vis); @@ -223,7 +223,7 @@ void TopLevel::visit (AST::StaticItem &static_item) { auto sub_vis - = [this, &static_item] () { static_item.get_expr ()->accept_vis (*this); }; + = [this, &static_item] () { static_item.get_expr ().accept_vis (*this); }; ctx.scoped (Rib::Kind::Item, static_item.get_node_id (), sub_vis); } @@ -299,7 +299,7 @@ void TopLevel::visit (AST::ConstantItem &const_item) { auto expr_vis - = [this, &const_item] () { const_item.get_expr ()->accept_vis (*this); }; + = [this, &const_item] () { const_item.get_expr ().accept_vis (*this); }; ctx.scoped (Rib::Kind::ConstantItem, const_item.get_node_id (), expr_vis); } |