]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: improve mutability checks
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 16 Dec 2024 14:51:17 +0000 (14:51 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:56:56 +0000 (12:56 +0100)
commit770ca551cf9c591ba195e6c12c8a24948d5b289b
tree91e55b4d1a85f822ce72749920c7a9d9a8b895ba
parent76565cabf2842b7dff20f4a3cbe2808fec7d15da
gccrs: improve mutability checks

This ensures that we handle var decls readonly checks much better

Addresses: Rust-GCC#807 Rust-GCC#3287

gcc/rust/ChangeLog:

* checks/errors/rust-readonly-check.cc (check_decl): improve mut check
(emit_error): helper
(check_modify_expr): likewise
(readonly_walk_fn): reuse helper
(ReadonlyCheck::Lint): cleanup context each run

gcc/testsuite/ChangeLog:

* rust/execute/torture/builtin_macro_include_bytes.rs: needs mut
* rust/compile/mutability_checks1.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/checks/errors/rust-readonly-check.cc
gcc/testsuite/rust/compile/mutability_checks1.rs [new file with mode: 0644]
gcc/testsuite/rust/execute/torture/builtin_macro_include_bytes.rs