diff options
author | Dave <dme2223@gmail.com> | 2022-12-19 10:59:00 -0600 |
---|---|---|
committer | Dave Evans <dave@dmetwo.org> | 2023-01-02 17:56:59 -0600 |
commit | 5918059fd3a28915546c08e0d3adbc62b9ca3977 (patch) | |
tree | cf506d7058b56b388fcc23bd4c51079b39fe714a /gcc/rust | |
parent | 0152926ab36ba52153f3f457f6f3bb02bb274073 (diff) | |
download | gcc-5918059fd3a28915546c08e0d3adbc62b9ca3977.zip gcc-5918059fd3a28915546c08e0d3adbc62b9ca3977.tar.gz gcc-5918059fd3a28915546c08e0d3adbc62b9ca3977.tar.bz2 |
Check for mutable references in const functions
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>
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/checks/errors/rust-const-checker.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/rust/checks/errors/rust-const-checker.cc b/gcc/rust/checks/errors/rust-const-checker.cc index 3de27ec..5f20437 100644 --- a/gcc/rust/checks/errors/rust-const-checker.cc +++ b/gcc/rust/checks/errors/rust-const-checker.cc @@ -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) |