Update rustfmt to 0.9.0.

This commit is contained in:
Dan Gohman
2017-08-31 10:44:59 -07:00
parent 46fb64cbb4
commit 2efdc0ed37
111 changed files with 4692 additions and 3379 deletions

View File

@@ -192,10 +192,10 @@ impl FromStr for Uimm32 {
// Parse a decimal or hexadecimal `Uimm32`, formatted as above.
fn from_str(s: &str) -> Result<Uimm32, &'static str> {
parse_i64(s).and_then(|x| if 0 <= x && x <= u32::MAX as i64 {
Ok(Uimm32(x as u32))
} else {
Err("Uimm32 out of range")
})
Ok(Uimm32(x as u32))
} else {
Err("Uimm32 out of range")
})
}
}
@@ -260,10 +260,10 @@ impl FromStr for Offset32 {
return Err("Offset must begin with sign");
}
parse_i64(s).and_then(|x| if i32::MIN as i64 <= x && x <= i32::MAX as i64 {
Ok(Offset32::new(x as i32))
} else {
Err("Offset out of range")
})
Ok(Offset32::new(x as i32))
} else {
Err("Offset out of range")
})
}
}
@@ -325,10 +325,10 @@ impl FromStr for Uoffset32 {
return Err("Unsigned offset must begin with '+' sign");
}
parse_i64(s).and_then(|x| if 0 <= x && x <= u32::MAX as i64 {
Ok(Uoffset32::new(x as u32))
} else {
Err("Offset out of range")
})
Ok(Uoffset32::new(x as u32))
} else {
Err("Offset out of range")
})
}
}
@@ -458,20 +458,20 @@ fn parse_float(s: &str, w: u8, t: u8) -> Result<u64, &'static str> {
if s2.starts_with("NaN:0x") {
// Quiet NaN with payload.
return match u64::from_str_radix(&s2[6..], 16) {
Ok(payload) if payload < quiet_bit => {
Ok(sign_bit | max_e_bits | quiet_bit | payload)
}
_ => Err("Invalid NaN payload"),
};
Ok(payload) if payload < quiet_bit => {
Ok(sign_bit | max_e_bits | quiet_bit | payload)
}
_ => Err("Invalid NaN payload"),
};
}
if s2.starts_with("sNaN:0x") {
// Signaling NaN with payload.
return match u64::from_str_radix(&s2[7..], 16) {
Ok(payload) if 0 < payload && payload < quiet_bit => {
Ok(sign_bit | max_e_bits | payload)
}
_ => Err("Invalid sNaN payload"),
};
Ok(payload) if 0 < payload && payload < quiet_bit => {
Ok(sign_bit | max_e_bits | payload)
}
_ => Err("Invalid sNaN payload"),
};
}
return Err("Float must be hexadecimal");
@@ -662,7 +662,8 @@ mod tests {
// Verify that `text` can be parsed as a `T` into a value that displays as `want`.
fn parse_ok<T: FromStr + Display>(text: &str, want: &str)
where <T as FromStr>::Err: Display
where
<T as FromStr>::Err: Display,
{
match text.parse::<T>() {
Err(s) => panic!("\"{}\".parse() error: {}", text, s),
@@ -672,7 +673,8 @@ mod tests {
// Verify that `text` fails to parse as `T` with the error `msg`.
fn parse_err<T: FromStr + Display>(text: &str, msg: &str)
where <T as FromStr>::Err: Display
where
<T as FromStr>::Err: Display,
{
match text.parse::<T>() {
Err(s) => assert_eq!(s.to_string(), msg),
@@ -781,18 +783,26 @@ mod tests {
assert_eq!(Ieee32::with_float(1.0).to_string(), "0x1.000000p0");
assert_eq!(Ieee32::with_float(1.5).to_string(), "0x1.800000p0");
assert_eq!(Ieee32::with_float(0.5).to_string(), "0x1.000000p-1");
assert_eq!(Ieee32::with_float(f32::EPSILON).to_string(),
"0x1.000000p-23");
assert_eq!(
Ieee32::with_float(f32::EPSILON).to_string(),
"0x1.000000p-23"
);
assert_eq!(Ieee32::with_float(f32::MIN).to_string(), "-0x1.fffffep127");
assert_eq!(Ieee32::with_float(f32::MAX).to_string(), "0x1.fffffep127");
// Smallest positive normal number.
assert_eq!(Ieee32::with_float(f32::MIN_POSITIVE).to_string(),
"0x1.000000p-126");
assert_eq!(
Ieee32::with_float(f32::MIN_POSITIVE).to_string(),
"0x1.000000p-126"
);
// Subnormals.
assert_eq!(Ieee32::with_float(f32::MIN_POSITIVE / 2.0).to_string(),
"0x0.800000p-126");
assert_eq!(Ieee32::with_float(f32::MIN_POSITIVE * f32::EPSILON).to_string(),
"0x0.000002p-126");
assert_eq!(
Ieee32::with_float(f32::MIN_POSITIVE / 2.0).to_string(),
"0x0.800000p-126"
);
assert_eq!(
Ieee32::with_float(f32::MIN_POSITIVE * f32::EPSILON).to_string(),
"0x0.000002p-126"
);
assert_eq!(Ieee32::with_float(f32::INFINITY).to_string(), "+Inf");
assert_eq!(Ieee32::with_float(f32::NEG_INFINITY).to_string(), "-Inf");
assert_eq!(Ieee32::with_float(f32::NAN).to_string(), "+NaN");
@@ -883,32 +893,48 @@ mod tests {
assert_eq!(Ieee64::with_float(1.0).to_string(), "0x1.0000000000000p0");
assert_eq!(Ieee64::with_float(1.5).to_string(), "0x1.8000000000000p0");
assert_eq!(Ieee64::with_float(0.5).to_string(), "0x1.0000000000000p-1");
assert_eq!(Ieee64::with_float(f64::EPSILON).to_string(),
"0x1.0000000000000p-52");
assert_eq!(Ieee64::with_float(f64::MIN).to_string(),
"-0x1.fffffffffffffp1023");
assert_eq!(Ieee64::with_float(f64::MAX).to_string(),
"0x1.fffffffffffffp1023");
assert_eq!(
Ieee64::with_float(f64::EPSILON).to_string(),
"0x1.0000000000000p-52"
);
assert_eq!(
Ieee64::with_float(f64::MIN).to_string(),
"-0x1.fffffffffffffp1023"
);
assert_eq!(
Ieee64::with_float(f64::MAX).to_string(),
"0x1.fffffffffffffp1023"
);
// Smallest positive normal number.
assert_eq!(Ieee64::with_float(f64::MIN_POSITIVE).to_string(),
"0x1.0000000000000p-1022");
assert_eq!(
Ieee64::with_float(f64::MIN_POSITIVE).to_string(),
"0x1.0000000000000p-1022"
);
// Subnormals.
assert_eq!(Ieee64::with_float(f64::MIN_POSITIVE / 2.0).to_string(),
"0x0.8000000000000p-1022");
assert_eq!(Ieee64::with_float(f64::MIN_POSITIVE * f64::EPSILON).to_string(),
"0x0.0000000000001p-1022");
assert_eq!(
Ieee64::with_float(f64::MIN_POSITIVE / 2.0).to_string(),
"0x0.8000000000000p-1022"
);
assert_eq!(
Ieee64::with_float(f64::MIN_POSITIVE * f64::EPSILON).to_string(),
"0x0.0000000000001p-1022"
);
assert_eq!(Ieee64::with_float(f64::INFINITY).to_string(), "+Inf");
assert_eq!(Ieee64::with_float(f64::NEG_INFINITY).to_string(), "-Inf");
assert_eq!(Ieee64::with_float(f64::NAN).to_string(), "+NaN");
assert_eq!(Ieee64::with_float(-f64::NAN).to_string(), "-NaN");
// Construct some qNaNs with payloads.
assert_eq!(Ieee64(0x7ff8000000000001).to_string(), "+NaN:0x1");
assert_eq!(Ieee64(0x7ffc000000000001).to_string(),
"+NaN:0x4000000000001");
assert_eq!(
Ieee64(0x7ffc000000000001).to_string(),
"+NaN:0x4000000000001"
);
// Signaling NaNs.
assert_eq!(Ieee64(0x7ff0000000000001).to_string(), "+sNaN:0x1");
assert_eq!(Ieee64(0x7ff4000000000001).to_string(),
"+sNaN:0x4000000000001");
assert_eq!(
Ieee64(0x7ff4000000000001).to_string(),
"+sNaN:0x4000000000001"
);
}
#[test]