1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // All the possible mutability error cases.
15 type MakeRef = fn() -> &'static (i32,);
16 type MakePtr = fn() -> *const (i32,);
18 fn named_ref(x: &(i32,)) {
25 fn unnamed_ref(f: MakeRef) {
26 *f() = (1,); //~ ERROR
32 unsafe fn named_ptr(x: *const (i32,)) {
36 &mut (*x).0; //~ ERROR
39 unsafe fn unnamed_ptr(f: MakePtr) {
40 *f() = (1,); //~ ERROR
41 (*f()).0 = 1; //~ ERROR
43 &mut (*f()).0; //~ ERROR
46 fn fn_ref<F: Fn()>(f: F) -> F { f }
48 fn ref_closure(mut x: (i32,)) {
63 fn imm_local(x: (i32,)) {
68 fn imm_capture(x: (i32,)) {
83 static X: (i32,) = (0,);