Rollup merge of #65359 - Centril:sil, r=davidtwco
simplify integer_lit Extracted from https://github.com/rust-lang/rust/pull/65324. r? @davidtwco
This commit is contained in:
commit
af54a3e91d
2 changed files with 7 additions and 9 deletions
|
@ -17,6 +17,7 @@
|
|||
#![feature(proc_macro_internals)]
|
||||
#![feature(proc_macro_span)]
|
||||
#![feature(try_trait)]
|
||||
#![feature(slice_patterns)]
|
||||
#![feature(unicode_internals)]
|
||||
|
||||
#![recursion_limit="256"]
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue