Skip to content
Permalink
Browse files

Add a test for #26619

  • Loading branch information...
varkor committed Feb 25, 2019
1 parent 651c1ab commit d49f4f86d91c41b6908140347045dbfa9d35d213
Showing with 36 additions and 0 deletions.
  1. +24 −0 src/test/ui/issues/issue-26619.rs
  2. +12 −0 src/test/ui/issues/issue-26619.stderr
@@ -0,0 +1,24 @@
#![feature(slice_patterns)]

pub struct History<'a> { pub _s: &'a str }

impl<'a> History<'a> {
pub fn get_page(&self) {
for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) {
//~^ ERROR borrowed value does not live long enough
println!("{:?}", s);
}
}

fn make_entry(&self, s: &'a String) -> Option<&str> {
let parts: Vec<_> = s.split('|').collect();
println!("{:?} -> {:?}", s, parts);

if let [commit, ..] = &parts[..] { Some(commit) } else { None }
}
}

fn main() {
let h = History{ _s: "" };
h.get_page();
}
@@ -0,0 +1,12 @@
error[E0597]: borrowed value does not live long enough
--> $DIR/issue-26619.rs:7:66
|
LL | for s in vec!["1|2".to_string()].into_iter().filter_map(|ref line| self.make_entry(line)) {
| ^^^^^^^^ -- temporary value needs to live until here
| | |
| | temporary value dropped here while still borrowed
| temporary value does not live long enough

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.

0 comments on commit d49f4f8

Please sign in to comment.
You can’t perform that action at this time.