diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2024-07-19 13:42:03 +0000 |
---|---|---|
committer | P-E-P <32375388+P-E-P@users.noreply.github.com> | 2024-07-24 11:44:33 +0000 |
commit | 8c357fd0072a29b24e10a8a1fe287f86f8c9b553 (patch) | |
tree | d789e653f2bcca412fc6210aaad36370cd9c4d98 /gcc/rust | |
parent | 34a0835087d1a451aceeccda40e6754182b25ed3 (diff) | |
download | gcc-8c357fd0072a29b24e10a8a1fe287f86f8c9b553.zip gcc-8c357fd0072a29b24e10a8a1fe287f86f8c9b553.tar.gz gcc-8c357fd0072a29b24e10a8a1fe287f86f8c9b553.tar.bz2 |
gccrs: [E0576] Associated `item` not found in given `type`
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit):
Add rich error message and error code similiar to rustc with
associaed type and trait name
gcc/testsuite/ChangeLog:
* rust/compile/unknown-associated-item.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-type.cc | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index 36f64a7..b745b52 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -220,7 +220,17 @@ TypeCheckType::visit (HIR::QualifiedPathInType &path) = specified_bound.lookup_associated_item (item_seg_identifier.as_string ()); if (item.is_error ()) { - rust_error_at (item_seg->get_locus (), "unknown associated item"); + std::string item_seg_ident_name, rich_msg; + item_seg_ident_name = qual_path_type.get_trait ()->as_string (); + rich_msg = "not found in `" + item_seg_ident_name + "`"; + + rich_location richloc (line_table, item_seg->get_locus ()); + richloc.add_fixit_replace (rich_msg.c_str ()); + + rust_error_at (richloc, ErrorCode::E0576, + "cannot find associated type %qs in trait %qs", + item_seg_identifier.as_string ().c_str (), + item_seg_ident_name.c_str ()); return; } |