From 25d52051fc4013f4e242c4486fa361e375b10065 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Tue, 5 Mar 2024 16:05:14 +0100 Subject: [PATCH 1/3] [wip] lower: Start lolwering AST::ForLoopExprs properly --- gcc/rust/hir/rust-ast-lower.cc | 302 +++++++++++++++++++++++++++++++-- 1 file changed, 284 insertions(+), 18 deletions(-) diff --git a/gcc/rust/hir/rust-ast-lower.cc b/gcc/rust/hir/rust-ast-lower.cc index 1c2db3b81342..c10c99549f2b 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -24,6 +24,14 @@ #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-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 { @@ -327,27 +335,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 e06432f974f2b9b9807036a8ab637ebd0bf297ec Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 6 Mar 2024 16:38:38 +0100 Subject: [PATCH 2/3] [wip | split me up] --- gcc/rust/ast/rust-macro.h | 27 ++++++++++--------- gcc/rust/backend/rust-compile-expr.cc | 4 +-- 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 | 5 +++- gcc/rust/typecheck/rust-typecheck-context.cc | 3 +++ 10 files changed, 39 insertions(+), 24 deletions(-) diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index 507e595e3790..a60d093a680a 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 6a9bb73ffe0f..1bed4525bbba 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -954,8 +954,8 @@ check_match_scrutinee (HIR::MatchExpr &expr, Context *ctx) // 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); - rust_assert (adt->is_enum ()); - rust_assert (adt->number_of_variants () > 0); + if (adt->is_enum ()) + rust_assert (adt->number_of_variants () > 0); } else if (scrutinee_kind == TyTy::TypeKind::FLOAT) { diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc index bd26e7019c30..754c0be1904b 100644 --- a/gcc/rust/hir/rust-ast-lower-base.cc +++ b/gcc/rust/hir/rust-ast-lower-base.cc @@ -621,6 +621,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 c10c99549f2b..4e4c0aa512c7 100644 --- a/gcc/rust/hir/rust-ast-lower.cc +++ b/gcc/rust/hir/rust-ast-lower.cc @@ -534,11 +534,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 df1e7ee1a450..8afe7c259d4f 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 { @@ -496,10 +497,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 (); } ResolveTypeToCanonicalPath::ResolveTypeToCanonicalPath () diff --git a/gcc/rust/typecheck/rust-hir-type-check-base.cc b/gcc/rust/typecheck/rust-hir-type-check-base.cc index f3edfef4e275..d4cf940e2da4 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 3e504e5df322..f99aeca9cbd4 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-item.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-item.cc @@ -685,8 +685,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 dd6ab03a3627..83add09888e4 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-path.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc @@ -224,7 +224,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 44ebc159b23a..1f4ef4c7292c 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -331,6 +331,8 @@ TyTy::BaseType * TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset, NodeId *root_resolved_node_id) { + 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++) @@ -417,7 +419,8 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset, if (is_root) { rust_error_at (seg->get_locus (), - "failed to resolve root segment"); + "failed to resolve root segment: %s", + seg->as_string ().c_str ()); return new TyTy::ErrorType (path.get_mappings ().get_hirid ()); } return root_tyty; diff --git a/gcc/rust/typecheck/rust-typecheck-context.cc b/gcc/rust/typecheck/rust-typecheck-context.cc index ab0093a273b4..b1e29508ad44 100644 --- a/gcc/rust/typecheck/rust-typecheck-context.cc +++ b/gcc/rust/typecheck/rust-typecheck-context.cc @@ -463,18 +463,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 7c17958f4252345324c37554974a849738cbb481 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Tue, 16 Apr 2024 17:51:17 +0200 Subject: [PATCH 3/3] [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 4e4c0aa512c7..7bb2c37272ae 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" @@ -25,6 +26,7 @@ #include "rust-ast-lower-pattern.h" #include "rust-ast-lower-struct-field-expr.h" #include "rust-common.h" +#include "rust-diagnostics.h" #include "rust-hir-expr.h" #include "rust-hir-full-decls.h" #include "rust-hir-map.h" @@ -436,6 +438,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) @@ -545,15 +561,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 (); @@ -613,6 +642,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 224d2fff4b8d..1995b6c28cfb 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1117,8 +1117,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 b1e29508ad44..ab0093a273b4 100644 --- a/gcc/rust/typecheck/rust-typecheck-context.cc +++ b/gcc/rust/typecheck/rust-typecheck-context.cc @@ -463,21 +463,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 (); }