Converts all try! macros to ? syntax.

Fixes #46
This commit is contained in:
rep-nop
2017-02-25 22:12:33 -05:00
committed by Jakob Stoklund Olesen
parent c8be39fa9d
commit 7459fee71a
22 changed files with 270 additions and 270 deletions

View File

@@ -42,9 +42,9 @@ fn needs_quotes(name: &str) -> bool {
impl fmt::Display for FunctionName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if needs_quotes(&self.0) {
try!(f.write_char('"'));
f.write_char('"')?;
for c in self.0.chars().flat_map(char::escape_default) {
try!(f.write_char(c));
f.write_char(c)?;
}
f.write_char('"')
} else {

View File

@@ -49,10 +49,10 @@ impl Display for Imm64 {
// 0xffff_ffff_fff8_4400
//
let mut pos = (64 - x.leading_zeros() - 1) & 0xf0;
try!(write!(f, "0x{:04x}", (x >> pos) & 0xffff));
write!(f, "0x{:04x}", (x >> pos) & 0xffff)?;
while pos > 0 {
pos -= 16;
try!(write!(f, "_{:04x}", (x >> pos) & 0xffff));
write!(f, "_{:04x}", (x >> pos) & 0xffff)?;
}
Ok(())
}
@@ -178,7 +178,7 @@ fn format_float(bits: u64, w: u8, t: u8, f: &mut Formatter) -> fmt::Result {
// All formats share the leading sign.
if sign_bit != 0 {
try!(write!(f, "-"));
write!(f, "-")?;
}
if e_bits == 0 {

View File

@@ -265,9 +265,9 @@ impl Display for VariableArgs {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
for (i, val) in self.0.iter().enumerate() {
if i == 0 {
try!(write!(fmt, "{}", val));
write!(fmt, "{}", val)?;
} else {
try!(write!(fmt, ", {}", val));
write!(fmt, ", {}", val)?;
}
}
Ok(())
@@ -289,9 +289,9 @@ pub struct UnaryImmVectorData {
impl Display for UnaryImmVectorData {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
try!(write!(f, "#"));
write!(f, "#")?;
for b in &self.imm {
try!(write!(f, "{:02x}", b));
write!(f, "{:02x}", b)?;
}
Ok(())
}
@@ -356,9 +356,9 @@ impl BranchData {
impl Display for BranchData {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
try!(write!(f, "{}, {}", self.arg, self.destination));
write!(f, "{}, {}", self.arg, self.destination)?;
if !self.varargs.is_empty() {
try!(write!(f, "({})", self.varargs));
write!(f, "({})", self.varargs)?;
}
Ok(())
}

View File

@@ -97,14 +97,14 @@ impl<'a> Iterator for Entries<'a> {
impl Display for JumpTableData {
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
match self.table.first().and_then(|e| e.expand()) {
None => try!(write!(fmt, "jump_table 0")),
Some(first) => try!(write!(fmt, "jump_table {}", first)),
None => write!(fmt, "jump_table 0")?,
Some(first) => write!(fmt, "jump_table {}", first)?,
}
for dest in self.table.iter().skip(1).map(|e| e.expand()) {
match dest {
None => try!(write!(fmt, ", 0")),
Some(ebb) => try!(write!(fmt, ", {}", ebb)),
None => write!(fmt, ", 0")?,
Some(ebb) => write!(fmt, ", {}", ebb)?,
}
}
Ok(())