Use StackedContext instead. Fix error string
Signed-off-by: Dave Evans <dave@dmetwo.org>
(Squashed commits) Check for mutable references in const functions using StackedContext
Signed-off-by: Dave Evans <dave@dmetwo.org>
{}
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)
--- /dev/null
+const fn foo (a: &mut i32) { // { dg-error "mutable references are not allowed in constant functions" }
+ *a = 1;
+}