summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/issue-82462.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/borrowck/issue-82462.rs')
-rw-r--r--tests/ui/borrowck/issue-82462.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/borrowck/issue-82462.rs b/tests/ui/borrowck/issue-82462.rs
new file mode 100644
index 000000000..5a3c64255
--- /dev/null
+++ b/tests/ui/borrowck/issue-82462.rs
@@ -0,0 +1,21 @@
+struct DroppingSlice<'a>(&'a [i32]);
+
+impl Drop for DroppingSlice<'_> {
+ fn drop(&mut self) {
+ println!("hi from slice");
+ }
+}
+
+impl DroppingSlice<'_> {
+ fn iter(&self) -> std::slice::Iter<'_, i32> {
+ self.0.iter()
+ }
+}
+
+fn main() {
+ let mut v = vec![1, 2, 3, 4];
+ for x in DroppingSlice(&*v).iter() {
+ v.push(*x); //~ERROR
+ break;
+ }
+}