Skip to content

Commit

Permalink
Rollup merge of rust-lang#65359 - Centril:sil, r=davidtwco
Browse files Browse the repository at this point in the history
simplify integer_lit

Extracted from rust-lang#65324.

r? @davidtwco
  • Loading branch information
Centril authored Oct 13, 2019
2 parents 5af528a + 7effe63 commit af54a3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#![feature(proc_macro_internals)]
#![feature(proc_macro_span)]
#![feature(try_trait)]
#![feature(slice_patterns)]
#![feature(unicode_internals)]

#![recursion_limit="256"]
Expand Down
15 changes: 6 additions & 9 deletions src/libsyntax/parse/literal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit af54a3e

Please sign in to comment.