diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-08-12 20:58:47 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-08-12 20:58:47 -0400 |
| commit | e1fa00bced4c020c7765786d76e2b53c7ae803cd (patch) | |
| tree | 42746fc446c6bcee6c8c7241a31a0f5ae0ad78d7 /src | |
| parent | 9f3f69efab08afc14674647667f7561d669e76c3 (diff) | |
| download | rust-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.rs | 29 |
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 +} |
