From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id 9C2823858C42; Tue, 16 Jan 2024 18:12:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C2823858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705428758; bh=ZbMlO1I6hYCWLr3f2y2JP4xfH9FsFN+1gfiQiZN7CE8=; h=From:To:Subject:Date:From; b=x/zRi3UJk3AL59Vs7MvSGopPldP/r85dAkNMMqhq1OEEmaxMT809CBI2VA0gOsGJG Jz4iiMl0YJLCifISM48u9SLHc/xPoa3owwf2rqRL41kJeLe3qxpHkYlOq/Ek9sqAmx aPNPRL9X+qkouCCfIAIFT8N+S6ml1FPbcnystXXM= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8003] gccrs: [E0599] Failed to resovle method implementation X-Act-Checkin: gcc X-Git-Author: Muhammad Mahad X-Git-Refname: refs/heads/trunk X-Git-Oldrev: f14cbab89d7a3678dd6c3b2f4a1102b4e6e95cf8 X-Git-Newrev: 2b560b964d60e42ea4cc99118b786acb0d96db34 Message-Id: <20240116181238.9C2823858C42@sourceware.org> Date: Tue, 16 Jan 2024 18:12:38 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2b560b964d60e42ea4cc99118b786acb0d96db34 commit r14-8003-g2b560b964d60e42ea4cc99118b786acb0d96db34 Author: Muhammad Mahad Date: Tue Aug 29 20:00:18 2023 +0500 gccrs: [E0599] Failed to resovle method implementation gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Added new error message, rich location and error code. gcc/testsuite/ChangeLog: * rust/compile/cfg2.rs: Updated according to new message. * rust/compile/issue-2139.rs: likewise. * rust/compile/issue-2190-1.rs: likewise. * rust/compile/method1.rs: likewise. Signed-off-by: Muhammad Mahad Diff: --- gcc/rust/typecheck/rust-hir-type-check-expr.cc | 6 ++++-- gcc/testsuite/rust/compile/cfg2.rs | 2 +- gcc/testsuite/rust/compile/issue-2139.rs | 2 +- gcc/testsuite/rust/compile/issue-2190-1.rs | 2 +- gcc/testsuite/rust/compile/method1.rs | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc index f0911967470..4ed84840e88 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc @@ -1077,9 +1077,11 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr) expr.get_method_name ().get_segment ()); if (candidates.empty ()) { + rich_location richloc (line_table, expr.get_method_name ().get_locus ()); + richloc.add_fixit_replace ("method not found"); rust_error_at ( - expr.get_method_name ().get_locus (), - "failed to resolve method for %<%s%>", + richloc, ErrorCode::E0599, + "no method named %qs found in the current scope", expr.get_method_name ().get_segment ().as_string ().c_str ()); return; } diff --git a/gcc/testsuite/rust/compile/cfg2.rs b/gcc/testsuite/rust/compile/cfg2.rs index e4c90d96dd4..ce1c5f96369 100644 --- a/gcc/testsuite/rust/compile/cfg2.rs +++ b/gcc/testsuite/rust/compile/cfg2.rs @@ -8,5 +8,5 @@ impl Foo { fn main() { let a = Foo; a.test(); - // { dg-error "failed to resolve method for .test." "" { target *-*-* } .-1 } + // { dg-error "no method named .test. found in the current scope" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/rust/compile/issue-2139.rs b/gcc/testsuite/rust/compile/issue-2139.rs index 3b9ad954679..65f82f39f40 100644 --- a/gcc/testsuite/rust/compile/issue-2139.rs +++ b/gcc/testsuite/rust/compile/issue-2139.rs @@ -14,5 +14,5 @@ impl Foo for u16 { fn main() { let a: u16 = 123; a.foo(); - // { dg-error "failed to resolve method for .foo." "" { target *-*-* } .-1 } + // { dg-error "no method named .foo. found in the current scope" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/rust/compile/issue-2190-1.rs b/gcc/testsuite/rust/compile/issue-2190-1.rs index 057d7c71633..927f90d6c9b 100644 --- a/gcc/testsuite/rust/compile/issue-2190-1.rs +++ b/gcc/testsuite/rust/compile/issue-2190-1.rs @@ -9,5 +9,5 @@ trait Deref { fn foo>(t: &T) -> i32 { t.max(2) - // { dg-error "failed to resolve method for .max." "" { target *-*-* } .-1 } + // { dg-error "no method named .max. found in the current scope" "" { target *-*-* } .-1 } } diff --git a/gcc/testsuite/rust/compile/method1.rs b/gcc/testsuite/rust/compile/method1.rs index d371bf271f8..3741c61b076 100644 --- a/gcc/testsuite/rust/compile/method1.rs +++ b/gcc/testsuite/rust/compile/method1.rs @@ -8,5 +8,5 @@ pub fn main() { a = Foo(123); a.test(); - // { dg-error "failed to resolve method for .test." "" { target *-*-* } .-1 } + // { dg-error "no method named .test. found in the current scope" "" { target *-*-* } .-1 } }