We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 681af62 commit 241ceedCopy full SHA for 241ceed
src/test/run-pass/borrowck/issue-62007-assign-box.rs
@@ -0,0 +1,27 @@
1
+// run-pass
2
+
3
+// Issue #62007: assigning over a deref projection of a box (in this
4
+// case, `*list = n;`) should be able to kill all borrows of `*list`,
5
+// so that `*list` can be borrowed on the next iteration through the
6
+// loop.
7
8
+#![allow(dead_code)]
9
10
+struct List<T> {
11
+ value: T,
12
+ next: Option<Box<List<T>>>,
13
+}
14
15
+fn to_refs<T>(mut list: Box<&mut List<T>>) -> Vec<&mut T> {
16
+ let mut result = vec![];
17
+ loop {
18
+ result.push(&mut list.value);
19
+ if let Some(n) = list.next.as_mut() {
20
+ *list = n;
21
+ } else {
22
+ return result;
23
+ }
24
25
26
27
+fn main() {}
0 commit comments