diff options
author | Muhammad Mahad <mahadtxt@gmail.com> | 2023-08-14 17:09:25 +0500 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 19:00:32 +0100 |
commit | dd343c42d25d2ab2cc1549c5cf608d7d6b3f0589 (patch) | |
tree | 4fb406a57356720ac18823484d3df9d9bcaee30f /gcc/rust | |
parent | b763d736a10793420945882436d7490385c7dc2d (diff) | |
download | gcc-dd343c42d25d2ab2cc1549c5cf608d7d6b3f0589.zip gcc-dd343c42d25d2ab2cc1549c5cf608d7d6b3f0589.tar.gz gcc-dd343c42d25d2ab2cc1549c5cf608d7d6b3f0589.tar.bz2 |
gccrs: Non-allowed default type paramters
gcc/rust/ChangeLog:
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit):
Added more helpful error message.
gcc/testsuite/ChangeLog:
* rust/compile/generics10.rs: for dejagnu.
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-item.cc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-item.cc b/gcc/rust/hir/rust-ast-lower-item.cc index 6eaf75f..6d91c23 100644 --- a/gcc/rust/hir/rust-ast-lower-item.cc +++ b/gcc/rust/hir/rust-ast-lower-item.cc @@ -499,10 +499,15 @@ ASTLoweringItem::visit (AST::InherentImpl &impl_block) if (t.has_type ()) { - // see https://github.com/rust-lang/rust/issues/36887 - rust_error_at ( + rich_location rich_locus (line_table, t.get_locus ()); + rich_locus.add_fixit_replace ( t.get_locus (), - "defaults for type parameters are not allowed here"); + "for more information, see issue #36887 " + "<https://github.com/rust-lang/rust/issues/36887>"); + rust_error_at (rich_locus, + "defaults for type parameters are only " + "allowed in %<struct%>, %<enum%>, %<type%>, " + "or %<trait%> definitions"); } } break; @@ -645,10 +650,15 @@ ASTLoweringItem::visit (AST::TraitImpl &impl_block) if (t.has_type ()) { - // see https://github.com/rust-lang/rust/issues/36887 - rust_error_at ( - t.get_locus (), - "defaults for type parameters are not allowed here"); + rich_location rich_locus (line_table, t.get_locus ()); + rich_locus.add_fixit_replace ( + t.get_locus (), "for more information, see issue #36887 " + "<https://github.com/rust-lang/rust/" + "issues/36887>"); + rust_error_at (rich_locus, + "defaults for type parameters are only " + "allowed in %<struct%>, %<enum%>, %<type%>, " + "or %<trait%> definitions"); } } break; |