Rollup merge of #22747 - krdln:fix-parsing-minus, r=alexcrichton
Makes Rust less amusing by fixing [#22745](https://github.com/rust-lang/rust/issues/22745)
This commit is contained in:
commit
ad73cb0e18
@ -1672,6 +1672,7 @@ macro_rules! from_str_radix_int_impl {
|
||||
let is_signed_ty = (0 as $T) > Int::min_value();
|
||||
|
||||
match src.slice_shift_char() {
|
||||
Some(('-', "")) => Err(PIE { kind: Empty }),
|
||||
Some(('-', src)) if is_signed_ty => {
|
||||
// The number is negative
|
||||
let mut result = 0;
|
||||
|
@ -122,4 +122,9 @@ mod test {
|
||||
assert_eq!("-9223372036854775808".parse::<i64>().ok(), Some(i64_val));
|
||||
assert_eq!("-9223372036854775809".parse::<i64>().ok(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_int_from_minus_sign() {
|
||||
assert_eq!("-".parse::<i32>().ok(), None);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user