@@ -898,8 +898,12 @@ ConstChecker::visit (RawPointerType &)
{}
void
-ConstChecker::visit (ReferenceType &)
-{}
+ConstChecker::visit (ReferenceType &type)
+{
+ if (const_context.is_in_context () && type.is_mut ())
+ rust_error_at (type.get_locus (),
+ "mutable references are not allowed in constant functions");
+}
void
ConstChecker::visit (ArrayType &type)
new file mode 100644
@@ -0,0 +1,3 @@
+const fn foo (a: &mut i32) { // { dg-error "mutable references are not allowed in constant functions" }
+ *a = 1;
+}