aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorMuhammad Mahad <mahadtxt@gmail.com>2023-07-18 18:55:32 +0500
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 18:55:59 +0100
commit5141707b5b5dcacde76dd0760f6604451f06ef85 (patch)
tree80aea6c80c4417848809b73c9f339b0dd383d86a /gcc/rust
parent973f4088efa74e3c181169b77c22358ae179d4d6 (diff)
downloadgcc-5141707b5b5dcacde76dd0760f6604451f06ef85.zip
gcc-5141707b5b5dcacde76dd0760f6604451f06ef85.tar.gz
gcc-5141707b5b5dcacde76dd0760f6604451f06ef85.tar.bz2
gccrs: [E0323] Implemented associated const, expected another trait
Refactored Error message similiar to rustc. gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-implitem.cc (TypeCheckImplItemWithTrait::visit): called error function. gcc/testsuite/ChangeLog: * rust/compile/non_member_const.rs: New test. Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-implitem.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
index b8a73a7..189dd87 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-implitem.cc
@@ -389,12 +389,14 @@ TypeCheckImplItemWithTrait::visit (HIR::ConstantItem &constant)
TraitItemReference::TraitItemType::CONST,
&raw_trait_item);
- // unknown trait item
+ // unknown trait item - https://doc.rust-lang.org/error_codes/E0323.html
if (!found || raw_trait_item->is_error ())
{
rich_location r (line_table, constant.get_locus ());
r.add_range (trait_reference.get_locus ());
- rust_error_at (r, "constant %<%s%> is not a member of trait %<%s%>",
+ rust_error_at (r, ErrorCode ("E0323"),
+ "item %qs is an associated const, which does not match "
+ "its trait %qs",
constant.get_identifier ().as_string ().c_str (),
trait_reference.get_name ().c_str ());
return;