Use try blocks in rustc_codegen_ssa
This commit is contained in:
parent
2a8f6a7806
commit
ab19e5870e
@ -382,20 +382,19 @@ impl<'a> Linker for GccLinker<'a> {
|
|||||||
|
|
||||||
if self.sess.target.target.options.is_like_osx {
|
if self.sess.target.target.options.is_like_osx {
|
||||||
// Write a plain, newline-separated list of symbols
|
// 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)?);
|
let mut f = BufWriter::new(File::create(&path)?);
|
||||||
for sym in self.info.exports[&crate_type].iter() {
|
for sym in self.info.exports[&crate_type].iter() {
|
||||||
debug!(" _{}", sym);
|
debug!(" _{}", sym);
|
||||||
writeln!(f, "_{}", sym)?;
|
writeln!(f, "_{}", sym)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
};
|
||||||
})();
|
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
self.sess.fatal(&format!("failed to write lib.def file: {}", e));
|
self.sess.fatal(&format!("failed to write lib.def file: {}", e));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Write an LD version script
|
// Write an LD version script
|
||||||
let res = (|| -> io::Result<()> {
|
let res: io::Result<()> = try {
|
||||||
let mut f = BufWriter::new(File::create(&path)?);
|
let mut f = BufWriter::new(File::create(&path)?);
|
||||||
writeln!(f, "{{\n global:")?;
|
writeln!(f, "{{\n global:")?;
|
||||||
for sym in self.info.exports[&crate_type].iter() {
|
for sym in self.info.exports[&crate_type].iter() {
|
||||||
@ -403,8 +402,7 @@ impl<'a> Linker for GccLinker<'a> {
|
|||||||
writeln!(f, " {};", sym)?;
|
writeln!(f, " {};", sym)?;
|
||||||
}
|
}
|
||||||
writeln!(f, "\n local:\n *;\n}};")?;
|
writeln!(f, "\n local:\n *;\n}};")?;
|
||||||
Ok(())
|
};
|
||||||
})();
|
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
self.sess.fatal(&format!("failed to write version script: {}", e));
|
self.sess.fatal(&format!("failed to write version script: {}", e));
|
||||||
}
|
}
|
||||||
@ -644,7 +642,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||||||
tmpdir: &Path,
|
tmpdir: &Path,
|
||||||
crate_type: CrateType) {
|
crate_type: CrateType) {
|
||||||
let path = tmpdir.join("lib.def");
|
let path = tmpdir.join("lib.def");
|
||||||
let res = (|| -> io::Result<()> {
|
let res: io::Result<()> = try {
|
||||||
let mut f = BufWriter::new(File::create(&path)?);
|
let mut f = BufWriter::new(File::create(&path)?);
|
||||||
|
|
||||||
// Start off with the standard module name header and then go
|
// Start off with the standard module name header and then go
|
||||||
@ -655,8 +653,7 @@ impl<'a> Linker for MsvcLinker<'a> {
|
|||||||
debug!(" _{}", symbol);
|
debug!(" _{}", symbol);
|
||||||
writeln!(f, " {}", symbol)?;
|
writeln!(f, " {}", symbol)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
};
|
||||||
})();
|
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
self.sess.fatal(&format!("failed to write lib.def file: {}", e));
|
self.sess.fatal(&format!("failed to write lib.def file: {}", e));
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#![feature(libc)]
|
#![feature(libc)]
|
||||||
#![feature(rustc_diagnostic_macros)]
|
#![feature(rustc_diagnostic_macros)]
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
#![feature(try_blocks)]
|
||||||
#![feature(in_band_lifetimes)]
|
#![feature(in_band_lifetimes)]
|
||||||
#![feature(nll)]
|
#![feature(nll)]
|
||||||
#![allow(unused_attributes)]
|
#![allow(unused_attributes)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user