2017-10-04 11:29:55 +00:00
|
|
|
// revisions: ast mir
|
2017-11-19 22:37:59 +00:00
|
|
|
//[mir]compile-flags: -Z borrowck=mir
|
2017-10-04 11:29:55 +00:00
|
|
|
|
2013-09-20 00:59:06 +00:00
|
|
|
// Issue 4691: Ensure that functional-struct-update can only copy, not
|
|
|
|
// move, when the struct implements Drop.
|
|
|
|
|
2015-08-12 00:27:05 +00:00
|
|
|
struct B;
|
|
|
|
struct S { a: isize, b: B }
|
2013-09-20 00:59:06 +00:00
|
|
|
impl Drop for S { fn drop(&mut self) { } }
|
|
|
|
|
2015-01-08 10:54:35 +00:00
|
|
|
struct T { a: isize, mv: Box<isize> }
|
2013-09-20 00:59:06 +00:00
|
|
|
impl Drop for T { fn drop(&mut self) { } }
|
|
|
|
|
|
|
|
fn f(s0:S) {
|
2016-05-16 22:40:27 +00:00
|
|
|
let _s2 = S{a: 2, ..s0};
|
2017-10-04 11:29:55 +00:00
|
|
|
//[ast]~^ error: cannot move out of type `S`, which implements the `Drop` trait
|
2017-11-19 22:37:59 +00:00
|
|
|
//[mir]~^^ ERROR [E0509]
|
2013-09-20 00:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn g(s0:T) {
|
2016-05-16 22:40:27 +00:00
|
|
|
let _s2 = T{a: 2, ..s0};
|
2017-10-04 11:29:55 +00:00
|
|
|
//[ast]~^ error: cannot move out of type `T`, which implements the `Drop` trait
|
2017-11-19 22:37:59 +00:00
|
|
|
//[mir]~^^ ERROR [E0509]
|
2013-09-20 00:59:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() { }
|