2017-08-13 08:46:49 +00:00
|
|
|
// Regression test for issue #27592.
|
2015-08-13 00:58:47 +00:00
|
|
|
|
|
|
|
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() {
|
2017-08-13 08:46:49 +00:00
|
|
|
write(|| format_args!("{}", String::from("Hello world")));
|
2019-04-22 07:40:08 +00:00
|
|
|
//~^ ERROR cannot return value referencing temporary value
|
2019-09-25 18:45:38 +00:00
|
|
|
//~| ERROR cannot return reference to temporary value
|
2015-08-13 00:58:47 +00:00
|
|
|
}
|