about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-08-12 20:58:47 -0400
committerNiko Matsakis <niko@alum.mit.edu>2015-08-12 20:58:47 -0400
commite1fa00bced4c020c7765786d76e2b53c7ae803cd (patch)
tree42746fc446c6bcee6c8c7241a31a0f5ae0ad78d7 /src
parent9f3f69efab08afc14674647667f7561d669e76c3 (diff)
downloadrust-e1fa00bced4c020c7765786d76e2b53c7ae803cd.tar.gz
rust-e1fa00bced4c020c7765786d76e2b53c7ae803cd.zip
add regression test for #27592. Fixes #27592.
Diffstat (limited to 'src')
-rw-r--r--src/test/compile-fail/issue-27592.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/compile-fail/issue-27592.rs b/src/test/compile-fail/issue-27592.rs
new file mode 100644
index 00000000000..ccf5eabc111
--- /dev/null
+++ b/src/test/compile-fail/issue-27592.rs
@@ -0,0 +1,29 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Regression test for issue #27591.
+
+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!("{}", "Hello world"));
+    //~^ ERROR borrowed value does not live long enough
+    //~| ERROR borrowed value does not live long enough
+}