]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-assign-to-andmut-in-aliasable-loc.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-assign-to-andmut-in-aliasable-loc.rs
1 // Test that assignments to an `&mut` pointer which is found in a
2 // borrowed (but otherwise non-aliasable) location is illegal.
3
4 struct S<'a> {
5     pointer: &'a mut isize
6 }
7
8 fn a(s: &S) {
9     *s.pointer += 1; //~ ERROR cannot assign
10 }
11
12 fn b(s: &mut S) {
13     *s.pointer += 1;
14 }
15
16 fn c(s: & &mut S) {
17     *s.pointer += 1; //~ ERROR cannot assign
18 }
19
20 fn main() {}