aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-04-30 16:22:15 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-04-30 17:10:00 +0100
commit2216cab0c9f694016d6cc220cfa8f5c23ba5f465 (patch)
tree6ac4d268325bf75dfc747c12ff18122826a5c151 /gcc/rust
parentfeaafdfecf4aa0575768deaa837323c3d86f678f (diff)
downloadgcc-2216cab0c9f694016d6cc220cfa8f5c23ba5f465.zip
gcc-2216cab0c9f694016d6cc220cfa8f5c23ba5f465.tar.gz
gcc-2216cab0c9f694016d6cc220cfa8f5c23ba5f465.tar.bz2
Defaults to type params are not allowed here
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/hir/rust-ast-lower-item.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-item.h b/gcc/rust/hir/rust-ast-lower-item.h
index 18ead3c..fe0b791 100644
--- a/gcc/rust/hir/rust-ast-lower-item.h
+++ b/gcc/rust/hir/rust-ast-lower-item.h
@@ -349,6 +349,29 @@ public:
{
generic_params
= lower_generic_params (impl_block.get_generic_params ());
+
+ for (auto &generic_param : generic_params)
+ {
+ switch (generic_param->get_kind ())
+ {
+ case HIR::GenericParam::GenericKind::TYPE: {
+ const HIR::TypeParam &t
+ = static_cast<const HIR::TypeParam &> (*generic_param);
+
+ 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");
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
}
HIR::Type *trait_type