cargo fmt

This commit is contained in:
elipeter 2026-06-02 13:49:39 -05:00
parent 9c99f6c6a9
commit 321d0a61ab
3 changed files with 42 additions and 15 deletions

View file

@ -4075,7 +4075,10 @@ class C {
"#;
let (cfg, _entry) = parse_and_build(src, "java", ts_lang);
let ifs = if_nodes(&cfg);
let arith: Vec<_> = ifs.iter().filter_map(|&n| cfg[n].cond_arith.clone()).collect();
let arith: Vec<_> = ifs
.iter()
.filter_map(|&n| cfg[n].cond_arith.clone())
.collect();
// Exactly one If condition is a pure int-arith comparison; the
// `s.length() > 200` one must NOT be captured (it contains a call).

View file

@ -1202,9 +1202,17 @@ pub(super) fn is_syntactic_literal(node: Node, code: &[u8]) -> bool {
// (`decimal_integer_literal`, `hex_integer_literal`, …) rather than a
// bare `integer`, so `int num = 86;` would otherwise miss this arm and
// lower to `Const(None)` (Varying) instead of `Const("86")`.
"integer" | "integer_literal" | "int_literal" | "float" | "float_literal" | "number"
| "decimal_integer_literal" | "hex_integer_literal" | "octal_integer_literal"
| "binary_integer_literal" | "decimal_floating_point_literal"
"integer"
| "integer_literal"
| "int_literal"
| "float"
| "float_literal"
| "number"
| "decimal_integer_literal"
| "hex_integer_literal"
| "octal_integer_literal"
| "binary_integer_literal"
| "decimal_floating_point_literal"
| "hex_floating_point_literal" => true,
// Booleans / null / nil / none

View file

@ -510,12 +510,14 @@ impl CondArith {
BinOp::BitAnd => arith(Some(lhs & rhs)),
BinOp::BitOr => arith(Some(lhs | rhs)),
BinOp::BitXor => arith(Some(lhs ^ rhs)),
BinOp::LeftShift => {
u32::try_from(rhs).ok().and_then(|s| lhs.checked_shl(s)).map(CondVal::Int)
}
BinOp::RightShift => {
u32::try_from(rhs).ok().and_then(|s| lhs.checked_shr(s)).map(CondVal::Int)
}
BinOp::LeftShift => u32::try_from(rhs)
.ok()
.and_then(|s| lhs.checked_shl(s))
.map(CondVal::Int),
BinOp::RightShift => u32::try_from(rhs)
.ok()
.and_then(|s| lhs.checked_shr(s))
.map(CondVal::Int),
BinOp::Eq => Some(CondVal::Bool(lhs == rhs)),
BinOp::NotEq => Some(CondVal::Bool(lhs != rhs)),
BinOp::Lt => Some(CondVal::Bool(lhs < rhs)),
@ -1418,13 +1420,22 @@ fn parse_int_literal(node: Node, code: &[u8]) -> Option<i64> {
if let Ok(v) = cleaned.parse::<i64>() {
return Some(v);
}
if let Some(h) = cleaned.strip_prefix("0x").or_else(|| cleaned.strip_prefix("0X")) {
if let Some(h) = cleaned
.strip_prefix("0x")
.or_else(|| cleaned.strip_prefix("0X"))
{
return i64::from_str_radix(h, 16).ok();
}
if let Some(o) = cleaned.strip_prefix("0o").or_else(|| cleaned.strip_prefix("0O")) {
if let Some(o) = cleaned
.strip_prefix("0o")
.or_else(|| cleaned.strip_prefix("0O"))
{
return i64::from_str_radix(o, 8).ok();
}
if let Some(b) = cleaned.strip_prefix("0b").or_else(|| cleaned.strip_prefix("0B")) {
if let Some(b) = cleaned
.strip_prefix("0b")
.or_else(|| cleaned.strip_prefix("0B"))
{
return i64::from_str_radix(b, 2).ok();
}
None
@ -1479,7 +1490,10 @@ fn build_cond_arith(node: Node, lang: &str, code: &[u8], depth: u32) -> Option<C
let kind = node.kind();
// Unwrap parentheses (transparent to value).
if matches!(kind, "parenthesized_expression" | "parenthesized" | "parenthesized_statement") {
if matches!(
kind,
"parenthesized_expression" | "parenthesized" | "parenthesized_statement"
) {
let inner = node.named_child(0)?;
return build_cond_arith(inner, lang, code, depth + 1);
}
@ -1493,7 +1507,9 @@ fn build_cond_arith(node: Node, lang: &str, code: &[u8], depth: u32) -> Option<C
if matches!(kind, "identifier" | "simple_identifier") {
let name = text_of(node, code)?;
if !name.is_empty()
&& name.chars().all(|c| c.is_alphanumeric() || c == '_' || c == '$')
&& name
.chars()
.all(|c| c.is_alphanumeric() || c == '_' || c == '$')
{
return Some(CondArith::Var(name));
}