diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc index cdb506dacbe..b0e52c454e9 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-path.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc @@ -266,8 +266,10 @@ TypeCheckExpr::resolve_root_path (HIR::PathInExpression &expr, size_t *offset, { if (is_root) { - rust_error_at (seg.get_locus (), - "failed to resolve root segment"); + rust_error_at (expr.get_locus (), ErrorCode::E0425, + "cannot find value %qs in this scope", + expr.as_simple_path ().as_string ().c_str ()); + return new TyTy::ErrorType (expr.get_mappings ().get_hirid ()); } return root_tyty;