summaryrefslogtreecommitdiffstats
path: root/src/test/ui/issues/issue-27592.rs
blob: 88f70f584022d39d520079b39b6fe613233fbde6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Regression test for issue #27592.

fn write<'a, F: ::std::ops::FnOnce()->::std::fmt::Arguments<'a> + 'a>(fcn: F) {
    use std::fmt::Write;
    let _ = match fcn() { a => write!(&mut Stream, "{}", a), };
}

struct Stream;
impl ::std::fmt::Write for Stream {
    fn write_str(&mut self, _s: &str) -> ::std::fmt::Result {
        Ok( () )
    }
}

fn main() {
    write(|| format_args!("{}", String::from("Hello world")));
    //~^ ERROR cannot return value referencing temporary value
    //~| ERROR cannot return reference to temporary value
}