-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This ensures that we handle var decls readonly checks much better Addresses: #807 #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 <[email protected]>
- Loading branch information
Showing
3 changed files
with
61 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pub fn test() { | ||
let a; | ||
a = 1; | ||
a = 2 + 1; | ||
// { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 } | ||
|
||
struct Foo(i32); | ||
let a = Foo(1); | ||
a.0 = 2; | ||
// { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 } | ||
|
||
let a = [1, 2, 3, 4]; | ||
a[0] = 1 + 2; | ||
// { dg-error "assignment of read-only variable" "" { target *-*-* } .-1 } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters