summaryrefslogtreecommitdiffstats
path: root/tests/ui/nll/issue-55850.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/nll/issue-55850.rs')
-rw-r--r--tests/ui/nll/issue-55850.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/nll/issue-55850.rs b/tests/ui/nll/issue-55850.rs
new file mode 100644
index 000000000..e6279bd02
--- /dev/null
+++ b/tests/ui/nll/issue-55850.rs
@@ -0,0 +1,35 @@
+#![allow(unused_mut)]
+#![feature(generators, generator_trait)]
+
+use std::marker::Unpin;
+use std::ops::Generator;
+use std::ops::GeneratorState::Yielded;
+use std::pin::Pin;
+
+pub struct GenIter<G>(G);
+
+impl <G> Iterator for GenIter<G>
+where
+ G: Generator + Unpin,
+{
+ type Item = G::Yield;
+
+ fn next(&mut self) -> Option<Self::Item> {
+ match Pin::new(&mut self.0).resume(()) {
+ Yielded(y) => Some(y),
+ _ => None
+ }
+ }
+}
+
+fn bug<'a>() -> impl Iterator<Item = &'a str> {
+ GenIter(move || {
+ let mut s = String::new();
+ yield &s[..] //~ ERROR cannot yield value referencing local variable `s` [E0515]
+ //~| ERROR borrow may still be in use when generator yields
+ })
+}
+
+fn main() {
+ bug();
+}