diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2023-08-18 16:28:34 +0500 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-08-22 12:42:59 +0000 |
commit | 8fcbb07fa702ab817fa3dd8cff3a0086e70a6ab7 (patch) | |
tree | 9aaf367c959b640e2f278132affe4c45e64983c2 /gcc | |
parent | 3196ca35261f475c92b655dd943c2fc3f9c6d42e (diff) | |
download | gcc-8fcbb07fa702ab817fa3dd8cff3a0086e70a6ab7.zip gcc-8fcbb07fa702ab817fa3dd8cff3a0086e70a6ab7.tar.gz gcc-8fcbb07fa702ab817fa3dd8cff3a0086e70a6ab7.tar.bz2 |
gccrs: [E0573] Something other than type was used
gcc/rust/ChangeLog:
* typecheck/rust-hir-type-check-type.cc:
Added last variant name, errorcode & rich location. for enum candidates.
gcc/testsuite/ChangeLog:
* rust/compile/issue-2479.rs: Updated comment.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-hir-type-check-type.cc | 14 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/issue-2479.rs | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index d03fcec..ecfc1dd 100644 --- a/gcc/rust/typecheck/rust-hir-type-check-type.cc +++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc @@ -510,9 +510,17 @@ TypeCheckType::resolve_segments ( if (candidate.is_enum_candidate ()) { - rust_error_at (seg->get_locus (), - "expected type, found variant of %s", - tyseg->get_name ().c_str ()); + TyTy::ADTType *adt = static_cast<TyTy::ADTType *> (tyseg); + auto last_variant = adt->get_variants (); + TyTy::VariantDef *variant = last_variant.back (); + + rich_location richloc (line_table, seg->get_locus ()); + richloc.add_fixit_replace ("not a type"); + + rust_error_at (richloc, ErrorCode::E0573, + "expected type, found variant of %<%s::%s%>", + adt->get_name ().c_str (), + variant->get_identifier ().c_str ()); return new TyTy::ErrorType (expr_id); } diff --git a/gcc/testsuite/rust/compile/issue-2479.rs b/gcc/testsuite/rust/compile/issue-2479.rs index 4a0d354..5cc403e 100644 --- a/gcc/testsuite/rust/compile/issue-2479.rs +++ b/gcc/testsuite/rust/compile/issue-2479.rs @@ -5,7 +5,7 @@ enum Dragon { } fn oblivion() -> Dragon::Born { -// { dg-error "expected type, found variant of Dragon" "" { target *-*-* } .-1 } +// { dg-error "expected type, found variant of .Dragon::Born." "" { target *-*-* } .-1 } // { dg-error "failed to resolve return type" "" { target *-*-* } .-2 } Dragon::Born } @@ -17,6 +17,6 @@ enum Wizard { trait Isengard { fn wizard(_: Wizard::Saruman); - // { dg-error "expected type, found variant of Wizard" "" { target *-*-* } .-1 } + // { dg-error "expected type, found variant of .Wizard::Saruman." "" { target *-*-* } .-1 } } } |