diff options
Diffstat (limited to 'tests/ui/regions/regions-adjusted-lvalue-op.rs')
-rw-r--r-- | tests/ui/regions/regions-adjusted-lvalue-op.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/regions/regions-adjusted-lvalue-op.rs b/tests/ui/regions/regions-adjusted-lvalue-op.rs new file mode 100644 index 000000000..5aa5a3ecb --- /dev/null +++ b/tests/ui/regions/regions-adjusted-lvalue-op.rs @@ -0,0 +1,16 @@ +// check that we link regions in mutable place ops correctly - issue #41774 + +struct Data(i32); + +trait OhNo { + fn oh_no(&mut self, other: &Vec<Data>) { loop {} } +} + +impl OhNo for Data {} +impl OhNo for [Data] {} + +fn main() { + let mut v = vec![Data(0)]; + v[0].oh_no(&v); //~ ERROR cannot borrow `v` as immutable because + (*v).oh_no(&v); //~ ERROR cannot borrow `v` as immutable because +} |