diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-13 13:34:42 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-13 13:34:42 +0200 |
| commit | af54a3e91d9b48ff36e2be7604fb2a231dd4c131 (patch) | |
| tree | 68ed7e2db280f99b6ef81506feb74e6ea981b361 /src/libsyntax | |
| parent | 5af528a03a0731651c303b9021c15fcb6404beba (diff) | |
| parent | 7effe633b0a729b641c7b8f1f8a21b97f9154b14 (diff) | |
| download | rust-af54a3e91d9b48ff36e2be7604fb2a231dd4c131.tar.gz rust-af54a3e91d9b48ff36e2be7604fb2a231dd4c131.zip | |
Rollup merge of #65359 - Centril:sil, r=davidtwco
simplify integer_lit Extracted from https://github.com/rust-lang/rust/pull/65324. r? @davidtwco
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/lib.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/literal.rs | 15 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 03b00188e25..09a47795a82 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -17,6 +17,7 @@ #![feature(proc_macro_internals)] #![feature(proc_macro_span)] #![feature(try_trait)] +#![feature(slice_patterns)] #![feature(unicode_internals)] #![recursion_limit="256"] diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs index fcd5b2782fd..56a79bfe5d5 100644 --- a/src/libsyntax/parse/literal.rs +++ b/src/libsyntax/parse/literal.rs @@ -426,15 +426,12 @@ fn integer_lit(symbol: Symbol, suffix: Option<Symbol>) -> Result<LitKind, LitErr let symbol = strip_underscores(symbol); let s = symbol.as_str(); - let mut base = 10; - if s.len() > 1 && s.as_bytes()[0] == b'0' { - match s.as_bytes()[1] { - b'x' => base = 16, - b'o' => base = 8, - b'b' => base = 2, - _ => {} - } - } + let base = match s.as_bytes() { + [b'0', b'x', ..] => 16, + [b'0', b'o', ..] => 8, + [b'0', b'b', ..] => 2, + _ => 10, + }; let ty = match suffix { Some(suf) => match suf { |
