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