Skip to content

Commit ad73cb0

Browse files
committed
Rollup merge of rust-lang#22747 - krdln:fix-parsing-minus, r=alexcrichton
Makes Rust less amusing by fixing [rust-lang#22745](rust-lang#22745)
2 parents 5af3d66 + a9f6f4b commit ad73cb0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/libcore/num/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1672,6 +1672,7 @@ macro_rules! from_str_radix_int_impl {
16721672
let is_signed_ty = (0 as $T) > Int::min_value();
16731673

16741674
match src.slice_shift_char() {
1675+
Some(('-', "")) => Err(PIE { kind: Empty }),
16751676
Some(('-', src)) if is_signed_ty => {
16761677
// The number is negative
16771678
let mut result = 0;

src/libcoretest/num/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,9 @@ mod test {
122122
assert_eq!("-9223372036854775808".parse::<i64>().ok(), Some(i64_val));
123123
assert_eq!("-9223372036854775809".parse::<i64>().ok(), None);
124124
}
125+
126+
#[test]
127+
fn test_int_from_minus_sign() {
128+
assert_eq!("-".parse::<i32>().ok(), None);
129+
}
125130
}

0 commit comments

Comments
 (0)