mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Strip base prefix in layout_scalar_valid_range
This commit is contained in:
parent
0840038f02
commit
084ee934b8
1 changed files with 6 additions and 6 deletions
|
@ -120,14 +120,14 @@ fn layout_scalar_valid_range(db: &dyn HirDatabase, def: AdtId) -> (Bound<u128>,
|
||||||
for tree in attr {
|
for tree in attr {
|
||||||
if let Some(it) = tree.token_trees.first() {
|
if let Some(it) = tree.token_trees.first() {
|
||||||
let text = it.to_string().replace('_', "");
|
let text = it.to_string().replace('_', "");
|
||||||
let base = match text.as_bytes() {
|
let (text, base) = match text.as_bytes() {
|
||||||
[b'0', b'x', ..] => 16,
|
[b'0', b'x', ..] => (&text[2..], 16),
|
||||||
[b'0', b'o', ..] => 8,
|
[b'0', b'o', ..] => (&text[2..], 8),
|
||||||
[b'0', b'b', ..] => 2,
|
[b'0', b'b', ..] => (&text[2..], 2),
|
||||||
_ => 10,
|
_ => (&*text, 10),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(it) = u128::from_str_radix(&text, base) {
|
if let Ok(it) = u128::from_str_radix(text, base) {
|
||||||
return Bound::Included(it);
|
return Bound::Included(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue