Skip to content

Commit

Permalink
simplify integer_lit
Browse files Browse the repository at this point in the history
  • Loading branch information
Centril committed Oct 13, 2019
1 parent 1721c96 commit 7effe63
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 7effe63

Please sign in to comment.