mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
Add a test for #26619
This commit is contained in:
parent
651c1abfb7
commit
d49f4f86d9
24
src/test/ui/issues/issue-26619.rs
Normal file
24
src/test/ui/issues/issue-26619.rs
Normal file
@ -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();
|
||||
}
|
12
src/test/ui/issues/issue-26619.stderr
Normal file
12
src/test/ui/issues/issue-26619.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user