]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-27592.rs
Rollup merge of #62337 - Mark-Simulacrum:fix-cpu-usage-script, r=alexcrichton
[rust.git] / src / test / ui / issues / issue-27592.rs
1 // Regression test for issue #27592.
2
3 fn write<'a, F: ::std::ops::FnOnce()->::std::fmt::Arguments<'a> + 'a>(fcn: F) {
4     use std::fmt::Write;
5     let _ = match fcn() { a => write!(&mut Stream, "{}", a), };
6 }
7
8 struct Stream;
9 impl ::std::fmt::Write for Stream {
10     fn write_str(&mut self, _s: &str) -> ::std::fmt::Result {
11         Ok( () )
12     }
13 }
14
15 fn main() {
16     write(|| format_args!("{}", String::from("Hello world")));
17     //~^ ERROR cannot return value referencing temporary value
18     //~| ERROR cannot return value referencing temporary value
19 }