summaryrefslogtreecommitdiffstats
path: root/src/test/ui/nll/polonius/call-kills-loans.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/nll/polonius/call-kills-loans.rs')
-rw-r--r--src/test/ui/nll/polonius/call-kills-loans.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/ui/nll/polonius/call-kills-loans.rs b/src/test/ui/nll/polonius/call-kills-loans.rs
new file mode 100644
index 000000000..f430e9211
--- /dev/null
+++ b/src/test/ui/nll/polonius/call-kills-loans.rs
@@ -0,0 +1,23 @@
+// `Call` terminators can write to a local which has existing loans
+// and those need to be killed like a regular assignment to a local.
+// This is a simplified version of issue 47680, is correctly accepted
+// by NLL but was incorrectly rejected by Polonius because of these
+// missing `killed` facts.
+
+// check-pass
+// compile-flags: -Z polonius
+
+struct Thing;
+
+impl Thing {
+ fn next(&mut self) -> &mut Self { unimplemented!() }
+}
+
+fn main() {
+ let mut temp = &mut Thing;
+
+ loop {
+ let v = temp.next();
+ temp = v; // accepted by NLL, was incorrectly rejected by Polonius
+ }
+}