2015-10-26 10:46:11 -05:00
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
struct S;
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
fn mutate(&mut self) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn func(arg: S) {
|
2019-04-22 02:40:08 -05:00
|
|
|
arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
|
2015-10-26 10:46:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl S {
|
|
|
|
fn method(&self, arg: S) {
|
2019-04-22 02:40:08 -05:00
|
|
|
arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
|
2015-10-26 10:46:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trait T {
|
|
|
|
fn default(&self, arg: S) {
|
2019-04-22 02:40:08 -05:00
|
|
|
arg.mutate(); //~ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
|
2015-10-26 10:46:11 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl T for S {}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = S;
|
|
|
|
func(s);
|
|
|
|
s.method(s);
|
|
|
|
s.default(s);
|
2019-04-22 02:40:08 -05:00
|
|
|
(|arg: S| { arg.mutate() })(s);
|
|
|
|
//~^ ERROR: cannot borrow `arg` as mutable, as it is not declared as mutable
|
2015-10-26 10:46:11 -05:00
|
|
|
}
|