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 ();
}