diff options
| author | kennytm <kennytm@gmail.com> | 2019-03-16 14:56:58 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2019-03-16 22:40:43 +0800 |
| commit | 10fe829b6052c94ea9e8b78987699f9d494fdc55 (patch) | |
| tree | 89189f4a6bc5eaad96293416ceb04937ed9a9179 /src/librustc_codegen_ssa | |
| parent | 08959313bebd77a02db2d036a5b39714cba930bc (diff) | |
| parent | ab19e5870ea28584ecf3ff4885e29afbbcaf0854 (diff) | |
| download | rust-10fe829b6052c94ea9e8b78987699f9d494fdc55.tar.gz rust-10fe829b6052c94ea9e8b78987699f9d494fdc55.zip | |
Rollup merge of #59180 - taiki-e:try_blocks, r=scottmcm
Use try blocks in rustc_codegen_ssa r? @scottmcm
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/back/linker.rs | 15 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/lib.rs | 1 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 1f4c5543fa9..e6470dbb61c 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -382,20 +382,19 @@ impl<'a> Linker for GccLinker<'a> { if self.sess.target.target.options.is_like_osx { // Write a plain, newline-separated list of symbols - let res = (|| -> io::Result<()> { + let res: io::Result<()> = try { let mut f = BufWriter::new(File::create(&path)?); for sym in self.info.exports[&crate_type].iter() { debug!(" _{}", sym); writeln!(f, "_{}", sym)?; } - Ok(()) - })(); + }; if let Err(e) = res { self.sess.fatal(&format!("failed to write lib.def file: {}", e)); } } else { // Write an LD version script - let res = (|| -> io::Result<()> { + let res: io::Result<()> = try { let mut f = BufWriter::new(File::create(&path)?); writeln!(f, "{{\n global:")?; for sym in self.info.exports[&crate_type].iter() { @@ -403,8 +402,7 @@ impl<'a> Linker for GccLinker<'a> { writeln!(f, " {};", sym)?; } writeln!(f, "\n local:\n *;\n}};")?; - Ok(()) - })(); + }; if let Err(e) = res { self.sess.fatal(&format!("failed to write version script: {}", e)); } @@ -644,7 +642,7 @@ impl<'a> Linker for MsvcLinker<'a> { tmpdir: &Path, crate_type: CrateType) { let path = tmpdir.join("lib.def"); - let res = (|| -> io::Result<()> { + let res: io::Result<()> = try { let mut f = BufWriter::new(File::create(&path)?); // Start off with the standard module name header and then go @@ -655,8 +653,7 @@ impl<'a> Linker for MsvcLinker<'a> { debug!(" _{}", symbol); writeln!(f, " {}", symbol)?; } - Ok(()) - })(); + }; if let Err(e) = res { self.sess.fatal(&format!("failed to write lib.def file: {}", e)); } diff --git a/src/librustc_codegen_ssa/lib.rs b/src/librustc_codegen_ssa/lib.rs index fec41936a23..fe9b88c85f0 100644 --- a/src/librustc_codegen_ssa/lib.rs +++ b/src/librustc_codegen_ssa/lib.rs @@ -7,6 +7,7 @@ #![feature(libc)] #![feature(rustc_diagnostic_macros)] #![feature(stmt_expr_attributes)] +#![feature(try_blocks)] #![feature(in_band_lifetimes)] #![feature(nll)] #![allow(unused_attributes)] |
