From 7280045cd5fe49860b216dac5facf68e94c2a74f Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Tue, 5 Mar 2024 16:05:14 +0100 Subject: [PATCH 01/10] [wip] lower: Start lolwering AST::ForLoopExprs properly --- gcc/rust/hir/rust-ast-lower.cc | 301 +++++++++++++++++++++++++++++++-- 1 file changed, 283 insertions(+), 18 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index c92c9432a68e..58d250938a83 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -24,8 +24,15 @@ #include "rust-ast-lower-type.h" #include "rust-ast-lower-pattern.h" #include "rust-ast-lower-struct-field-expr.h" +#include "rust-common.h" #include "rust-expr.h" #include "rust-hir-expr.h" +#include "rust-hir-full-decls.h" +#include "rust-hir-map.h" +#include "rust-hir-path.h" +#include "rust-hir-stmt.h" +#include "rust-hir.h" +#include "rust-mapping-common.h" namespace Rust { namespace HIR { @@ -411,27 +418,285 @@ ASTLoweringExprWithBlock::visit (AST::WhileLoopExpr &expr) expr.get_outer_attrs ()); } +struct ForLoopDesugarCtx +{ + NodeId id; + location_t loc; + Analysis::Mappings &mappings; + + Analysis::NodeMapping next_mapping () + { + auto crate_num = mappings.get_current_crate (); + return Analysis::NodeMapping (crate_num, id, + mappings.get_next_hir_id (crate_num), + UNKNOWN_LOCAL_DEFID); + } + + PathExprSegment path_segment (std::string &&segment_name) + { + return PathExprSegment (next_mapping (), std::move (segment_name), loc, + GenericArgs::create_empty ()); + } + + std::unique_ptr + path_in_expr (std::vector &&segment_names) + { + auto segments = std::vector (); + + for (const auto &seg : segment_names) + segments.emplace_back (PathExprSegment (next_mapping (), seg, loc, + GenericArgs::create_empty ())); + + return std::unique_ptr ( + new PathInExpression (next_mapping (), std::move (segments))); + } + + std::unique_ptr make_break_expr () + { + // FIXME(Arthur): This shouldn't call Lifetime::error, it does not make + // sense + return std::unique_ptr ( + new BreakExpr (next_mapping (), loc, Lifetime::error ())); + } + + MatchArm make_match_arm (std::unique_ptr pattern) + { + auto patterns = std::vector> (); + patterns.emplace_back (std::move (pattern)); + + return MatchArm (std::move (patterns), loc); + } + + MatchCase make_break_arm () + { + auto path = path_in_expr ({"core", "option", "Option", "None"}); + auto arm = make_match_arm (std::move (path)); + + auto break_expr = make_break_expr (); + + return MatchCase (next_mapping (), arm, std::move (break_expr)); + } + + std::unique_ptr make_assign_expr () + { + auto next = path_in_expr ({"__next"}); + auto val = path_in_expr ({"val"}); + + return std::unique_ptr (new AssignmentExpr (next_mapping (), + std::move (next), + std::move (val), loc)); + } + + MatchCase make_continue_arm () + { + // FIXME(Arthur): This is missing the `val` binding. Should be a + // TupleStructPattern? + auto path = path_in_expr ({"core", "option", "Option", "Some"}); + auto arm = make_match_arm (std::move (path)); + + auto assign_expr = make_assign_expr (); + + return MatchCase (next_mapping (), arm, std::move (assign_expr)); + } + + std::unique_ptr make_let (std::unique_ptr &&pattern, + std::unique_ptr &&init_expr = nullptr) + { + return std::unique_ptr ( + new LetStmt (next_mapping (), std::move (pattern), std::move (init_expr), + nullptr, {}, loc)); + } + + std::unique_ptr + make_function_call (std::unique_ptr &&function, + std::unique_ptr &&arg) + { + auto args = std::vector> (); + args.emplace_back (std::move (arg)); + + return std::unique_ptr (new CallExpr (next_mapping (), + std::move (function), + std::move (args), {}, loc)); + } + + std::unique_ptr make_identifier_pattern (std::string &&name, + Mutability mutability, + bool is_ref = false) + { + return std::unique_ptr ( + new IdentifierPattern (next_mapping (), Identifier (name), loc, is_ref, + mutability)); + } + + MatchArm make_identifier_pattern_arm (std::string &&name, + Mutability mutability, + bool is_ref = false) + { + auto pat = make_identifier_pattern (std::move (name), mutability, is_ref); + + return make_match_arm (std::move (pat)); + } + + std::unique_ptr make_mutable_borrow (std::unique_ptr &&to_borrow) + { + return std::unique_ptr (new BorrowExpr (next_mapping (), + std::move (to_borrow), + Mutability::Mut, {}, loc)); + } + LoopLabel no_label () + { + return LoopLabel (next_mapping (), Lifetime::error (), loc); + } + + std::unique_ptr make_loop (std::vector> &&stmts) + { + auto block = std::unique_ptr ( + new BlockExpr (next_mapping (), std::move (stmts), nullptr, false, {}, {}, + no_label (), loc, loc)); + + return std::unique_ptr ( + new LoopExpr (next_mapping (), std::move (block), loc, no_label ())); + } + + std::unique_ptr make_match (std::unique_ptr scrutinee, + std::vector &&cases) + { + return std::unique_ptr ( + new MatchExpr (next_mapping (), std::move (scrutinee), std::move (cases), + {}, {}, loc)); + } + + // Transform an expression into an expression-statement + std::unique_ptr statementify (std::unique_ptr &&expr) + { + return std::unique_ptr ( + new ExprStmt (next_mapping (), std::move (expr), loc)); + } + + std::unique_ptr make_block (std::unique_ptr stmt, + std::unique_ptr tail_expr) + { + auto stmts = std::vector> (); + stmts.emplace_back (std::move (stmt)); + + return std::unique_ptr ( + new BlockExpr (next_mapping (), std::move (stmts), std::move (tail_expr), + true, {}, {}, no_label (), loc, loc)); + } +}; + +// TODO(Arthur): Here, rustc 1.49 uses a match arm for the original call to +// IntoIterator::into_iter(). Can we avoid that? Why is that done? Lifetime +// reasons? + +// for in +// +// becomes: +// +// { +// let result = match ::std::iter::IntoIterator::into_iter() { +// mut iter => { +// loop { +// let mut __next; +// match ::std::iter::Iterator::next(&mut iter) { +// ::std::option::Option::Some(val) => __next = val, +// ::std::option::Option::None => break +// }; +// let = __next; +// +// ; +// } +// } +// }; +// result +// } void ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr) { - // TODO FIXME - - // HIR::BlockExpr *loop_block - // = ASTLoweringBlock::translate (expr.get_loop_block ().get (), - // &terminated); - // HIR::LoopLabel loop_label = lower_loop_label (expr.get_loop_label ()); - // HIR::Expr *iterator_expr - // = ASTLoweringExpr::translate (expr.get_iterator_expr ().get (), - // &terminated); - // HIR::Pattern *loop_pattern - // = ASTLoweringPattern::translate (expr.get_pattern ().get ()); - - // auto crate_num = mappings->get_current_crate (); - // Analysis::NodeMapping mapping (crate_num, expr.get_node_id (), - // mappings->get_next_hir_id (crate_num), - // UNKNOWN_LOCAL_DEFID); - - gcc_unreachable (); + auto ctx = ForLoopDesugarCtx{expr.get_node_id (), expr.get_locus (), + *Analysis::Mappings::get ()}; + + auto head = std::unique_ptr ( + ASTLoweringExpr::translate (expr.get_iterator_expr ().get ())); + auto pat = std::unique_ptr ( + ASTLoweringPattern::translate (expr.get_pattern ().get ())); + auto body = std::unique_ptr ( + ASTLoweringExpr::translate (expr.get_loop_block ().get ())); + + rust_assert (head); + rust_assert (pat); + rust_assert (body); + + // core::iter::IntoIterator::into_iter() + auto into_iter_call + = ctx.make_function_call (ctx.path_in_expr ( + {"core", "iter", "IntoIterator", "into_iter"}), + std::move (head)); + + // core::iter::Iterator::next(&mut iter) + auto next_call = ctx.make_function_call ( + ctx.path_in_expr ({"core", "iter", "Iterator", "next"}), + ctx.make_mutable_borrow (ctx.path_in_expr ({"iter"}))); + + // core::option::Option::None => break, + auto break_arm = ctx.make_break_arm (); + // core::option::Option::Some(val) => __next = val, + auto continue_arm = ctx.make_continue_arm (); + + // match { + // + // + // } + auto match_next + = ctx.make_match (std::move (next_call), {continue_arm, break_arm}); + + // let mut __next; + auto let_next = ctx.make_let (ctx.path_in_expr ({"__next"})); + // let = __next; + auto let_pat = ctx.make_let (std::move (pat), ctx.path_in_expr ({"__next"})); + + auto loop_stmts = std::vector> (); + loop_stmts.emplace_back (std::move (let_next)); + loop_stmts.emplace_back (ctx.statementify (std::move (match_next))); + loop_stmts.emplace_back (std::move (let_pat)); + loop_stmts.emplace_back (ctx.statementify (std::move (body))); + + // loop { + // ; + // ; + // ; + // + // ; + // } + auto loop = ctx.make_loop (std::move (loop_stmts)); + + // mut iter => ... + auto mut_iter_pat = ctx.make_identifier_pattern_arm ("iter", Mutability::Mut); + + // TODO(Arthur): Put in ctx as a method? + // => + auto match_iter_case = MatchCase (ctx.next_mapping (), + std::move (mut_iter_pat), std::move (loop)); + + // match { } + auto outer_match + = ctx.make_match (std::move (into_iter_call), {match_iter_case}); + + // let result = ; + auto let_result + = ctx.make_let (ctx.make_identifier_pattern ("result", Mutability::Imm), + std::move (outer_match)); + + // result /* as a return value */ + auto result = ctx.path_in_expr ({"result"}); + + // { + // ; + // + // } + auto block = ctx.make_block (std::move (let_result), std::move (result)); + + translated = block.release (); } void From cf461ad3fb6c69f9a65fd34868fef0241d054507 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 6 Mar 2024 16:38:38 +0100 Subject: [PATCH 02/10] [wip | split me up] --- gcc/rust/ast/rust-macro.h | 27 ++++++++++--------- gcc/rust/backend/rust-compile-expr.cc | 10 ++++++- gcc/rust/hir/rust-ast-lower-base.cc | 1 + gcc/rust/hir/rust-ast-lower.cc | 6 ++--- gcc/rust/resolve/rust-ast-resolve-type.cc | 7 +++-- .../typecheck/rust-hir-type-check-base.cc | 3 +++ .../typecheck/rust-hir-type-check-item.cc | 4 +-- .../typecheck/rust-hir-type-check-path.cc | 3 ++- .../typecheck/rust-hir-type-check-type.cc | 2 ++ gcc/rust/typecheck/rust-typecheck-context.cc | 3 +++ 10 files changed, 44 insertions(+), 22 deletions(-) diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 71cdcf0471ea..e5db7a71c50b 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -459,6 +459,8 @@ class MacroRulesDefinition : public VisItem DeclMacro, }; + MacroRulesDefinition (const MacroRulesDefinition &other) = default; + private: std::vector outer_attrs; Identifier rule_name; @@ -602,6 +604,18 @@ class MacroInvocation : public TypeNoBounds, public ExprWithoutBlock { public: + MacroInvocation (const MacroInvocation &other) + : TraitItem (other.locus), outer_attrs (other.outer_attrs), + locus (other.locus), node_id (other.node_id), + invoc_data (other.invoc_data), is_semi_coloned (other.is_semi_coloned), + kind (other.kind), builtin_kind (other.builtin_kind) + { + if (other.kind == InvocKind::Builtin) + for (auto &pending : other.pending_eager_invocs) + pending_eager_invocs.emplace_back ( + pending->clone_macro_invocation_impl ()); + } + enum class InvocKind { Regular, @@ -726,19 +740,6 @@ class MacroInvocation : public TypeNoBounds, pending_eager_invocs (std::move (pending_eager_invocs)) {} - MacroInvocation (const MacroInvocation &other) - : TraitItem (other.locus), ExternalItem (other.node_id), - outer_attrs (other.outer_attrs), locus (other.locus), - node_id (other.node_id), invoc_data (other.invoc_data), - is_semi_coloned (other.is_semi_coloned), kind (other.kind), - builtin_kind (other.builtin_kind) - { - if (other.kind == InvocKind::Builtin) - for (auto &pending : other.pending_eager_invocs) - pending_eager_invocs.emplace_back ( - pending->clone_macro_invocation_impl ()); - } - std::vector outer_attrs; location_t locus; NodeId node_id; diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 7323413bfce2..3070b3803b86 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -1013,7 +1013,15 @@ check_match_scrutinee (HIR::MatchExpr &expr, Context *ctx) || scrutinee_kind == TyTy::TypeKind::TUPLE || scrutinee_kind == TyTy::TypeKind::REF); - if (scrutinee_kind == TyTy::TypeKind::FLOAT) + if (scrutinee_kind == TyTy::TypeKind::ADT) + { + // this will need to change but for now the first pass implementation, + // lets assert this is the case + TyTy::ADTType *adt = static_cast (scrutinee_expr_tyty); + if (adt->is_enum ()) + rust_assert (adt->number_of_variants () > 0); + } + else if (scrutinee_kind == TyTy::TypeKind::FLOAT) { // FIXME: CASE_LABEL_EXPR does not support floating point types. // Find another way to compile these. diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc index eac2cba5c752..62ee758e5b96 100644 --- a/gcc/rust/hir/rust-ast-lower-base.cc +++ b/gcc/rust/hir/rust-ast-lower-base.cc @@ -638,6 +638,7 @@ ASTLoweringBase::lower_generic_args (AST::GenericArgs &args) for (auto &arg : args.get_generic_args ()) { + rust_debug ("[ARTHUR ] %s", arg.as_string ().c_str ()); switch (arg.get_kind ()) { case AST::GenericArg::Kind::Type: { diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 58d250938a83..8824deb1560b 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -617,11 +617,11 @@ ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr) *Analysis::Mappings::get ()}; auto head = std::unique_ptr ( - ASTLoweringExpr::translate (expr.get_iterator_expr ().get ())); + ASTLoweringExpr::translate (expr.get_iterator_expr ())); auto pat = std::unique_ptr ( - ASTLoweringPattern::translate (expr.get_pattern ().get ())); + ASTLoweringPattern::translate (expr.get_pattern ())); auto body = std::unique_ptr ( - ASTLoweringExpr::translate (expr.get_loop_block ().get ())); + ASTLoweringExpr::translate (expr.get_loop_block ())); rust_assert (head); rust_assert (pat); diff --git a/gcc/rust/resolve/rust-ast-resolve-type.cc b/gcc/rust/resolve/rust-ast-resolve-type.cc index 15ae8db9389e..f30dc00cba39 100644 --- a/gcc/rust/resolve/rust-ast-resolve-type.cc +++ b/gcc/rust/resolve/rust-ast-resolve-type.cc @@ -17,6 +17,7 @@ // . #include "rust-ast-resolve-type.h" +#include "rust-ast-dump.h" #include "rust-ast-resolve-expr.h" namespace Rust { @@ -495,10 +496,12 @@ ResolveTypeToCanonicalPath::visit (AST::TraitObjectTypeOneBound &type) } void -ResolveTypeToCanonicalPath::visit (AST::TraitObjectType &) +ResolveTypeToCanonicalPath::visit (AST::TraitObjectType &ty) { // FIXME is this actually allowed? dyn A+B - rust_unreachable (); + // FIXME: This is also reached when we have something like a lifetime bound on + // a generic, e.g. Iter<'a, T: 'a> What do we do in that case? + // rust_unreachable (); } void diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc index c1700fafdfc9..655f1382a00b 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-base.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-base.cc @@ -38,6 +38,9 @@ TypeCheckBase::check_for_unconstrained ( const TyTy::SubstitutionArgumentMappings &constraint_b, const TyTy::BaseType *reference) { + rust_debug ("[ARTHUR] %s ", constraint_a.as_string ().c_str ()); + rust_debug ("[ARTHUR] %s ", constraint_b.as_string ().c_str ()); + bool check_result = false; bool check_completed = context->have_checked_for_unconstrained (reference->get_ref (), diff --git a/gcc/rust/typecheck/rust-hir-type-check-item.cc b/gcc/rust/typecheck/rust-hir-type-check-item.cc index 17c331e9a21a..7e57b3b7bcd4 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc @@ -740,8 +740,8 @@ TypeCheckItem::resolve_impl_block_substitutions (HIR::ImplBlock &impl_block, const TyTy::SubstitutionArgumentMappings impl_constraints = GetUsedSubstArgs::From (self); - failure_flag = check_for_unconstrained (substitutions, trait_constraints, - impl_constraints, self); + // failure_flag = check_for_unconstrained (substitutions, trait_constraints, + // impl_constraints, self); return {substitutions, region_constraints}; } diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc index d3f341264482..ee295a16a312 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-path.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc @@ -234,7 +234,8 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset, } rust_error_at (seg.get_locus (), - "failed to type resolve root segment"); + "failed to type resolve root segment: %s", + expr.as_string ().c_str ()); return new TyTy::ErrorType (expr.get_mappings ().get_hirid ()); } diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index 2962674da62f..60da1b351e59 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -377,6 +377,8 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset, NodeId *root_resolved_node_id, bool *wasBigSelf) { + rust_debug ("[ARTHURl ] %s", path.as_string ().c_str ()); + TyTy::BaseType *root_tyty = nullptr; *offset = 0; for (size_t i = 0; i < path.get_num_segments (); i++) diff --git a/gcc/rust/typecheck/rust-typecheck-context.cc b/gcc/rust/typecheck/rust-typecheck-context.cc index b37be49c749a..50d229a0a265 100644 --- a/gcc/rust/typecheck/rust-typecheck-context.cc +++ b/gcc/rust/typecheck/rust-typecheck-context.cc @@ -495,18 +495,21 @@ TypeCheckContext::lookup_predicate (HirId id, TyTy::TypeBoundPredicate *result) void TypeCheckContext::insert_query (HirId id) { + rust_debug ("[ARTHUR] INSERTING QUERY: %u", id); querys_in_progress.insert (id); } void TypeCheckContext::query_completed (HirId id) { + rust_debug ("[ARTHUR] COMPLETING QUERY: %u", id); querys_in_progress.erase (id); } bool TypeCheckContext::query_in_progress (HirId id) const { + rust_debug ("[ARTHUR] CHECKING IF QUERY IN PROGRESS: %u", id); return querys_in_progress.find (id) != querys_in_progress.end (); } From a470729fe384dd8975223c5d0663543f56c89f87 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Tue, 16 Apr 2024 17:51:17 +0200 Subject: [PATCH 03/10] [wip] --- gcc/rust/hir/rust-ast-lower.cc | 43 ++++++++++++++++--- .../typecheck/rust-hir-type-check-expr.cc | 6 ++- gcc/rust/typecheck/rust-typecheck-context.cc | 3 -- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 8824deb1560b..d0406caf4d03 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -17,6 +17,7 @@ // . #include "rust-ast-lower.h" +#include "optional.h" #include "rust-ast-lower-item.h" #include "rust-ast-lower-stmt.h" #include "rust-ast-lower-expr.h" @@ -26,6 +27,7 @@ #include "rust-ast-lower-struct-field-expr.h" #include "rust-common.h" #include "rust-expr.h" +#include "rust-diagnostics.h" #include "rust-hir-expr.h" #include "rust-hir-full-decls.h" #include "rust-hir-map.h" @@ -519,6 +521,20 @@ struct ForLoopDesugarCtx std::move (args), {}, loc)); } + std::unique_ptr + make_method_call (std::unique_ptr &&receiver, + PathExprSegment &&method_path, + tl::optional> &&arg) + { + auto args = std::vector> (); + if (arg) + args.emplace_back (std::move (*arg)); + + return std::unique_ptr ( + new MethodCallExpr (next_mapping (), std::move (receiver), + std::move (method_path), std::move (args), {}, loc)); + } + std::unique_ptr make_identifier_pattern (std::string &&name, Mutability mutability, bool is_ref = false) @@ -628,15 +644,28 @@ ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr) rust_assert (body); // core::iter::IntoIterator::into_iter() + // auto into_iter_call + // = ctx.make_function_call (ctx.path_in_expr ( + // {"core", "iter", "IntoIterator", "into_iter"}), + // std::move (head)); + + // .into_iter() auto into_iter_call - = ctx.make_function_call (ctx.path_in_expr ( - {"core", "iter", "IntoIterator", "into_iter"}), - std::move (head)); + = ctx.make_method_call (std::move (head), ctx.path_segment ("into_iter"), + tl::nullopt); + + auto iter = ctx.path_in_expr ({"iter"}); // core::iter::Iterator::next(&mut iter) - auto next_call = ctx.make_function_call ( - ctx.path_in_expr ({"core", "iter", "Iterator", "next"}), - ctx.make_mutable_borrow (ctx.path_in_expr ({"iter"}))); + // auto next_call + // = ctx.make_function_call (ctx.path_in_expr ( + // {"core", "iter", "Iterator", "next"}), + // ctx.make_mutable_borrow (iter->clone_expr ())); + + // iter.next() + auto next_call + = ctx.make_method_call (iter->clone_expr (), ctx.path_segment ("next"), + tl::nullopt); // core::option::Option::None => break, auto break_arm = ctx.make_break_arm (); @@ -696,6 +725,8 @@ ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr) // } auto block = ctx.make_block (std::move (let_result), std::move (result)); + rust_debug ("[ARTHUR] \n%s", block->as_string ().c_str ()); + translated = block.release (); } diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index 7daa27195db6..b681cf94aa51 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1102,8 +1102,10 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr) richloc.add_fixit_replace ("method not found"); rust_error_at ( richloc, ErrorCode::E0599, - "no method named %qs found in the current scope", - expr.get_method_name ().get_segment ().as_string ().c_str ()); + "no method named %qs found in the current scope for type %qs (%qs)", + expr.get_method_name ().get_segment ().as_string ().c_str (), + receiver_tyty->as_string ().c_str (), + receiver_tyty->debug_str ().c_str ()); return; } diff --git a/gcc/rust/typecheck/rust-typecheck-context.cc b/gcc/rust/typecheck/rust-typecheck-context.cc index 50d229a0a265..b37be49c749a 100644 --- a/gcc/rust/typecheck/rust-typecheck-context.cc +++ b/gcc/rust/typecheck/rust-typecheck-context.cc @@ -495,21 +495,18 @@ TypeCheckContext::lookup_predicate (HirId id, TyTy::TypeBoundPredicate *result) void TypeCheckContext::insert_query (HirId id) { - rust_debug ("[ARTHUR] INSERTING QUERY: %u", id); querys_in_progress.insert (id); } void TypeCheckContext::query_completed (HirId id) { - rust_debug ("[ARTHUR] COMPLETING QUERY: %u", id); querys_in_progress.erase (id); } bool TypeCheckContext::query_in_progress (HirId id) const { - rust_debug ("[ARTHUR] CHECKING IF QUERY IN PROGRESS: %u", id); return querys_in_progress.find (id) != querys_in_progress.end (); } From e4429dabeeedabb79a78b8ae35be569630559962 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 16 Dec 2024 13:01:05 +0100 Subject: [PATCH 04/10] for-loops: Add documentation --- gcc/rust/hir/rust-ast-lower.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index d0406caf4d03..87041eaca004 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -471,6 +471,7 @@ struct ForLoopDesugarCtx MatchCase make_break_arm () { + // we want to turn this into a LangItem path auto path = path_in_expr ({"core", "option", "Option", "None"}); auto arm = make_match_arm (std::move (path)); @@ -630,7 +631,7 @@ void ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr) { auto ctx = ForLoopDesugarCtx{expr.get_node_id (), expr.get_locus (), - *Analysis::Mappings::get ()}; + Analysis::Mappings::get ()}; auto head = std::unique_ptr ( ASTLoweringExpr::translate (expr.get_iterator_expr ())); @@ -667,9 +668,9 @@ ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr) = ctx.make_method_call (iter->clone_expr (), ctx.path_segment ("next"), tl::nullopt); - // core::option::Option::None => break, + // None => break, auto break_arm = ctx.make_break_arm (); - // core::option::Option::Some(val) => __next = val, + // Some(val) => __next = val, auto continue_arm = ctx.make_continue_arm (); // match { From 571176583252ccf11da6950f236640f311d073ed Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 16 Dec 2024 13:01:13 +0100 Subject: [PATCH 05/10] hir: Add LangItem paths to PathPattern class gcc/rust/ChangeLog: * hir/tree/rust-hir-path.h: Adapt PathPattern to accept lang-item paths. * hir/tree/rust-hir-path.cc: Assert we are dealing with a segmented path, create lang-item constructors. * hir/tree/rust-hir.cc (PathPattern::convert_to_simple_path): Likewise. --- gcc/rust/hir/tree/rust-hir-path.cc | 21 +++++++++ gcc/rust/hir/tree/rust-hir-path.h | 72 ++++++++++++++++++++++++++---- gcc/rust/hir/tree/rust-hir.cc | 2 + 3 files changed, 87 insertions(+), 8 deletions(-) diff --git a/gcc/rust/hir/tree/rust-hir-path.cc b/gcc/rust/hir/tree/rust-hir-path.cc index c8d3079a85e3..097941fff0c6 100644 --- a/gcc/rust/hir/tree/rust-hir-path.cc +++ b/gcc/rust/hir/tree/rust-hir-path.cc @@ -132,6 +132,9 @@ PathExprSegment::operator= (PathExprSegment const &other) void PathPattern::iterate_path_segments (std::function cb) { + // FIXME: Is this necessary? + rust_assert (kind == Kind::Segmented); + for (auto it = segments.begin (); it != segments.end (); it++) { if (!cb (*it)) @@ -149,6 +152,15 @@ PathInExpression::PathInExpression (Analysis::NodeMapping mappings, has_opening_scope_resolution (has_opening_scope_resolution), locus (locus) {} +PathInExpression::PathInExpression (Analysis::NodeMapping mappings, + LangItem::Kind lang_item, location_t locus, + bool has_opening_scope_resolution, + std::vector outer_attrs) + : PathPattern (lang_item), + PathExpr (std::move (mappings), std::move (outer_attrs)), + has_opening_scope_resolution (has_opening_scope_resolution), locus (locus) +{} + bool PathInExpression::is_self () const @@ -341,6 +353,15 @@ QualifiedPathInExpression::QualifiedPathInExpression ( path_type (std::move (qual_path_type)), locus (locus) {} +QualifiedPathInExpression::QualifiedPathInExpression ( + Analysis::NodeMapping mappings, QualifiedPathType qual_path_type, + LangItem::Kind lang_item, location_t locus, + std::vector outer_attrs) + : PathPattern (lang_item), + PathExpr (std::move (mappings), std::move (outer_attrs)), + path_type (std::move (qual_path_type)), locus (locus) +{} + QualifiedPathInType::QualifiedPathInType ( Analysis::NodeMapping mappings, QualifiedPathType qual_path_type, std::unique_ptr associated_segment, diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h index df5fd0c4e469..82d4c1f4a1c7 100644 --- a/gcc/rust/hir/tree/rust-hir-path.h +++ b/gcc/rust/hir/tree/rust-hir-path.h @@ -19,6 +19,7 @@ #ifndef RUST_HIR_PATH_H #define RUST_HIR_PATH_H +#include "rust-hir-map.h" #include "rust-hir-simple-path.h" #include "rust-hir-type-no-bounds.h" #include "rust-hir-pattern-abstract.h" @@ -231,14 +232,30 @@ class PathExprSegment class PathPattern : public Pattern { std::vector segments; + tl::optional lang_item; + + enum class Kind + { + Segmented, + LangItem + } kind; protected: PathPattern (std::vector segments) - : segments (std::move (segments)) + : segments (std::move (segments)), lang_item (tl::nullopt), + kind (Kind::Segmented) + {} + + PathPattern (LangItem::Kind lang_item) + : segments ({}), lang_item (lang_item), kind (Kind::LangItem) {} // Returns whether path has segments. - bool has_segments () const { return !segments.empty (); } + bool has_segments () const + { + rust_assert (kind == Kind::Segmented); + return !segments.empty (); + } /* Converts path segments to their equivalent SimplePath segments if possible, * and creates a SimplePath from them. */ @@ -248,21 +265,45 @@ class PathPattern : public Pattern public: /* Returns whether the path is a single segment (excluding qualified path * initial as segment). */ - bool is_single_segment () const { return segments.size () == 1; } + bool is_single_segment () const + { + rust_assert (kind == Kind::Segmented); + return segments.size () == 1; + } std::string as_string () const override; void iterate_path_segments (std::function cb); - size_t get_num_segments () const { return segments.size (); } + size_t get_num_segments () const + { + rust_assert (kind == Kind::Segmented); + return segments.size (); + } - std::vector &get_segments () { return segments; } + std::vector &get_segments () + { + rust_assert (kind == Kind::Segmented); + return segments; + } - const std::vector &get_segments () const { return segments; } + const std::vector &get_segments () const + { + rust_assert (kind == Kind::Segmented); + return segments; + } - PathExprSegment &get_root_seg () { return segments.at (0); } + PathExprSegment &get_root_seg () + { + rust_assert (kind == Kind::Segmented); + return segments.at (0); + } - const PathExprSegment &get_final_segment () const { return segments.back (); } + const PathExprSegment &get_final_segment () const + { + rust_assert (kind == Kind::Segmented); + return segments.back (); + } PatternType get_pattern_type () const override final { @@ -288,6 +329,13 @@ class PathInExpression : public PathPattern, public PathExpr std::vector outer_attrs = std::vector ()); + // lang-item Constructor + PathInExpression (Analysis::NodeMapping mappings, LangItem::Kind kind, + location_t locus = UNDEF_LOCATION, + bool has_opening_scope_resolution = false, + std::vector outer_attrs + = std::vector ()); + // Creates an error state path in expression. static PathInExpression create_error () { @@ -671,6 +719,14 @@ class QualifiedPathInExpression : public PathPattern, public PathExpr std::vector outer_attrs = std::vector ()); + // lang-item constructor + QualifiedPathInExpression (Analysis::NodeMapping mappings, + QualifiedPathType qual_path_type, + LangItem::Kind lang_item, + location_t locus = UNDEF_LOCATION, + std::vector outer_attrs + = std::vector ()); + location_t get_locus () const override final { return locus; } void accept_vis (HIRFullVisitor &vis) override; diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc index 509a897ce39c..a8acfc69fa7b 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -2187,6 +2187,8 @@ TypeParam::as_string () const AST::SimplePath PathPattern::convert_to_simple_path (bool with_opening_scope_resolution) const { + rust_assert (kind == Kind::Segmented); + if (!has_segments ()) { return AST::SimplePath::create_empty (); From a527bd589023332e9bdfa1ab08de8fabb86896bf Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 16 Dec 2024 14:16:31 +0100 Subject: [PATCH 06/10] wip: fixup? path: Switch PathPattern to enable lang item paths --- gcc/rust/hir/tree/rust-hir-path.h | 17 +++++++++++++---- gcc/rust/hir/tree/rust-hir.cc | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h index 82d4c1f4a1c7..2af492bcfb20 100644 --- a/gcc/rust/hir/tree/rust-hir-path.h +++ b/gcc/rust/hir/tree/rust-hir-path.h @@ -231,14 +231,17 @@ class PathExprSegment // HIR node representing a pattern that involves a "path" - abstract base class class PathPattern : public Pattern { - std::vector segments; - tl::optional lang_item; - +public: enum class Kind { Segmented, LangItem - } kind; + }; + +private: + std::vector segments; + tl::optional lang_item; + Kind kind; protected: PathPattern (std::vector segments) @@ -277,6 +280,10 @@ class PathPattern : public Pattern size_t get_num_segments () const { + if (kind == Kind::LangItem) + rust_fatal_error (UNKNOWN_LOCATION, "[ARTHUR] %s", + LangItem::ToString (*lang_item).c_str ()); + rust_assert (kind == Kind::Segmented); return segments.size (); } @@ -309,6 +316,8 @@ class PathPattern : public Pattern { return PatternType::PATH; } + + Kind get_path_kind () const { return kind; } }; /* HIR node representing a path-in-expression pattern (path that allows generic diff --git a/gcc/rust/hir/tree/rust-hir.cc b/gcc/rust/hir/tree/rust-hir.cc index a8acfc69fa7b..9b3bd145ba18 100644 --- a/gcc/rust/hir/tree/rust-hir.cc +++ b/gcc/rust/hir/tree/rust-hir.cc @@ -19,6 +19,7 @@ #include "rust-ast-full.h" #include "rust-hir-expr.h" #include "rust-hir-full.h" +#include "rust-hir-path.h" #include "rust-hir-visitor.h" #include "rust-diagnostics.h" @@ -1210,6 +1211,9 @@ ClosureExpr::as_string () const std::string PathPattern::as_string () const { + if (kind == PathPattern::Kind::LangItem) + return LangItem::ToString (*lang_item); + std::string str; for (const auto &segment : segments) From 8931a1158b6a0456ab8f0268b1e4166dcde22427 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 16 Dec 2024 14:17:05 +0100 Subject: [PATCH 07/10] lower-for-loops: Use LangItems here --- gcc/rust/hir/rust-ast-lower.cc | 39 ++++++++++++++-------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 87041eaca004..91a9c4c02d21 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -440,6 +440,11 @@ struct ForLoopDesugarCtx GenericArgs::create_empty ()); } + std::unique_ptr lang_item_path (LangItem::Kind lang_item) + { + return Rust::make_unique (next_mapping (), lang_item); + } + std::unique_ptr path_in_expr (std::vector &&segment_names) { @@ -471,8 +476,7 @@ struct ForLoopDesugarCtx MatchCase make_break_arm () { - // we want to turn this into a LangItem path - auto path = path_in_expr ({"core", "option", "Option", "None"}); + auto path = lang_item_path (LangItem::Kind::OPTION_NONE); auto arm = make_match_arm (std::move (path)); auto break_expr = make_break_expr (); @@ -494,7 +498,7 @@ struct ForLoopDesugarCtx { // FIXME(Arthur): This is missing the `val` binding. Should be a // TupleStructPattern? - auto path = path_in_expr ({"core", "option", "Option", "Some"}); + auto path = lang_item_path (LangItem::Kind::OPTION_SOME); auto arm = make_match_arm (std::move (path)); auto assign_expr = make_assign_expr (); @@ -502,12 +506,13 @@ struct ForLoopDesugarCtx return MatchCase (next_mapping (), arm, std::move (assign_expr)); } - std::unique_ptr make_let (std::unique_ptr &&pattern, - std::unique_ptr &&init_expr = nullptr) + std::unique_ptr + make_let (std::unique_ptr &&pattern, + tl::optional> &&init_expr = tl::nullopt) { return std::unique_ptr ( new LetStmt (next_mapping (), std::move (pattern), std::move (init_expr), - nullptr, {}, loc)); + tl::nullopt, {}, loc)); } std::unique_ptr @@ -645,28 +650,16 @@ ASTLoweringExprWithBlock::visit (AST::ForLoopExpr &expr) rust_assert (body); // core::iter::IntoIterator::into_iter() - // auto into_iter_call - // = ctx.make_function_call (ctx.path_in_expr ( - // {"core", "iter", "IntoIterator", "into_iter"}), - // std::move (head)); - - // .into_iter() - auto into_iter_call - = ctx.make_method_call (std::move (head), ctx.path_segment ("into_iter"), - tl::nullopt); + auto into_iter_call = ctx.make_function_call ( + ctx.lang_item_path (LangItem::Kind::INTOITER_INTOITER), std::move (head)); auto iter = ctx.path_in_expr ({"iter"}); // core::iter::Iterator::next(&mut iter) - // auto next_call - // = ctx.make_function_call (ctx.path_in_expr ( - // {"core", "iter", "Iterator", "next"}), - // ctx.make_mutable_borrow (iter->clone_expr ())); - - // iter.next() auto next_call - = ctx.make_method_call (iter->clone_expr (), ctx.path_segment ("next"), - tl::nullopt); + = ctx.make_function_call (ctx.lang_item_path ( + LangItem::Kind::ITERATOR_NEXT), + ctx.make_mutable_borrow (iter->clone_expr ())); // None => break, auto break_arm = ctx.make_break_arm (); From 5577e770ca8c85ec591e4ffcfd2a5cc733ecfc02 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 16 Dec 2024 14:17:29 +0100 Subject: [PATCH 08/10] lang-item: Add Option::{None, Some}, Iterator::next, IntoIter::into_iter --- gcc/rust/util/rust-lang-item.cc | 6 ++++++ gcc/rust/util/rust-lang-item.h | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc index 0d8a98077d1e..8b1b1e346474 100644 --- a/gcc/rust/util/rust-lang-item.cc +++ b/gcc/rust/util/rust-lang-item.cc @@ -91,6 +91,12 @@ const BiMap Rust::LangItem::lang_items = {{ {"str", Kind::STR}, {"f32_runtime", Kind::F32_RUNTIME}, {"f64_runtime", Kind::F64_RUNTIME}, + + {"Some", Kind::OPTION_SOME}, + {"None", Kind::OPTION_NONE}, + + {"into_iter", Kind::INTOITER_INTOITER}, + {"next", Kind::ITERATOR_NEXT}, }}; tl::optional diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h index bcf41df559e5..4b0217616783 100644 --- a/gcc/rust/util/rust-lang-item.h +++ b/gcc/rust/util/rust-lang-item.h @@ -26,6 +26,9 @@ namespace Rust { class LangItem { public: + // FIXME: We should clean up that enum to make it more inline with the list of + // lang-items in Rust 1.49 + // https://github.com/rust-lang/rust/blob/1.49.0/compiler/rustc_hir/src/lang_items.rs enum class Kind { // https://github.com/rust-lang/rust/blob/master/library/core/src/ops/arith.rs @@ -116,6 +119,12 @@ class LangItem STR, F32_RUNTIME, F64_RUNTIME, + + OPTION_SOME, + OPTION_NONE, + + INTOITER_INTOITER, + ITERATOR_NEXT, }; static const BiMap lang_items; From 3562b60ef2b6ce8a9603b6d193703e47b94ed067 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 18 Dec 2024 12:20:27 +0100 Subject: [PATCH 09/10] lang-items: Collect trait functions that are lang items --- gcc/rust/ast/rust-collect-lang-items.cc | 8 ++++++++ gcc/rust/ast/rust-collect-lang-items.h | 1 + 2 files changed, 9 insertions(+) diff --git a/gcc/rust/ast/rust-collect-lang-items.cc b/gcc/rust/ast/rust-collect-lang-items.cc index 308720ae69ab..50d134a429f5 100644 --- a/gcc/rust/ast/rust-collect-lang-items.cc +++ b/gcc/rust/ast/rust-collect-lang-items.cc @@ -82,5 +82,13 @@ CollectLangItems::visit (AST::TraitItemType &item) DefaultASTVisitor::visit (item); } +void +CollectLangItems::visit (AST::Function &item) +{ + maybe_add_lang_item (item); + + DefaultASTVisitor::visit (item); +} + } // namespace AST } // namespace Rust diff --git a/gcc/rust/ast/rust-collect-lang-items.h b/gcc/rust/ast/rust-collect-lang-items.h index 552648f04eda..1d021b1d9c50 100644 --- a/gcc/rust/ast/rust-collect-lang-items.h +++ b/gcc/rust/ast/rust-collect-lang-items.h @@ -47,6 +47,7 @@ class CollectLangItems : public DefaultASTVisitor void visit (AST::Trait &item) override; void visit (AST::TraitItemType &item) override; + void visit (AST::Function &item) override; private: template void maybe_add_lang_item (const T &item); From 8326417a6b6f0907b8ec011e162a070c57851d0e Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 18 Dec 2024 12:20:39 +0100 Subject: [PATCH 10/10] for-loop: Progress! --- gcc/rust/hir/tree/rust-hir-path.h | 14 +++++- .../typecheck/rust-hir-type-check-path.cc | 48 ++++++++++++++----- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/gcc/rust/hir/tree/rust-hir-path.h b/gcc/rust/hir/tree/rust-hir-path.h index 2af492bcfb20..3ce54cce30c6 100644 --- a/gcc/rust/hir/tree/rust-hir-path.h +++ b/gcc/rust/hir/tree/rust-hir-path.h @@ -24,6 +24,7 @@ #include "rust-hir-type-no-bounds.h" #include "rust-hir-pattern-abstract.h" #include "rust-hir-expr-abstract.h" +#include "rust-system.h" namespace Rust { namespace HIR { @@ -281,8 +282,11 @@ class PathPattern : public Pattern size_t get_num_segments () const { if (kind == Kind::LangItem) - rust_fatal_error (UNKNOWN_LOCATION, "[ARTHUR] %s", - LangItem::ToString (*lang_item).c_str ()); + { + // rust_fatal_error (UNKNOWN_LOCATION, "[ARTHUR] %s", + // LangItem::ToString (*lang_item).c_str ()); + rust_unreachable (); + } rust_assert (kind == Kind::Segmented); return segments.size (); @@ -317,6 +321,12 @@ class PathPattern : public Pattern return PatternType::PATH; } + LangItem::Kind get_lang_item_kind () const + { + rust_assert (kind == Kind::LangItem); + return *lang_item; + } + Kind get_path_kind () const { return kind; } }; diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc index ee295a16a312..9d9493ad0fb9 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-path.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc @@ -16,6 +16,9 @@ // along with GCC; see the file COPYING3. If not see // . +#include "rust-diagnostics.h" +#include "rust-hir-map.h" +#include "rust-hir-path.h" #include "rust-hir-type-check-expr.h" #include "rust-hir-type-check-type.h" #include "rust-hir-type-check-item.h" @@ -24,6 +27,7 @@ #include "rust-hir-path-probe.h" #include "rust-type-util.h" #include "rust-hir-type-bounds.h" +#include "rust-hir-item.h" #include "rust-session-manager.h" #include "rust-immutable-name-resolution-context.h" @@ -179,20 +183,42 @@ void TypeCheckExpr::visit (HIR::PathInExpression &expr) { NodeId resolved_node_id = UNKNOWN_NODEID; - size_t offset = -1; - TyTy::BaseType *tyseg = resolve_root_path (expr, &offset, &resolved_node_id); - if (tyseg->get_kind () == TyTy::TypeKind::ERROR) - return; - - bool fully_resolved = offset == expr.get_segments ().size (); - if (fully_resolved) + if (expr.get_path_kind () == HIR::PathPattern::Kind::LangItem) { - infered = tyseg; - return; + if (auto lookup = Analysis::Mappings::get ().lookup_lang_item_node ( + expr.get_lang_item_kind ())) + { + auto hir_id = mappings.lookup_node_to_hir (*lookup); + + TyTy::BaseType *resolved = nullptr; + context->lookup_type (*hir_id, &resolved); + + infered = resolved; + return; + } + else + rust_fatal_error ( + expr.get_locus (), "lang item missing: %s", + LangItem::ToString (expr.get_lang_item_kind ()).c_str ()); } + else + { + size_t offset = -1; + TyTy::BaseType *tyseg + = resolve_root_path (expr, &offset, &resolved_node_id); + if (tyseg->get_kind () == TyTy::TypeKind::ERROR) + return; + + bool fully_resolved = offset == expr.get_segments ().size (); + if (fully_resolved) + { + infered = tyseg; + return; + } - resolve_segments (resolved_node_id, expr.get_segments (), offset, tyseg, - expr.get_mappings (), expr.get_locus ()); + resolve_segments (resolved_node_id, expr.get_segments (), offset, tyseg, + expr.get_mappings (), expr.get_locus ()); + } } TyTy::BaseType *