From 05c8831903b511eaec7b2601f49a1208410f76de Mon Sep 17 00:00:00 2001 From: robobun <117481402+robobun@users.noreply.github.com> Date: Mon, 20 Jul 2026 08:42:28 +0000 Subject: [PATCH] semver: drop redundant store and dead guards in parser List::and_range assigned tail.range a second time right after the Box::new struct literal set it. Range is Copy and the parameter is &Range, so the second store is a no-op. In query::parse, the i < input.len() half of the hyphen-lookahead final check is always true: length_of_leading_whitespace_ascii returns at most the slice length, and the preceding i == input.len() check already broke out. In Version::parse, the b'-' | b'+' arm had a leading-space skip loop that can never iterate because input[i] is known to be '-' or '+' at the match dispatch and i is not advanced before the loop. --- src/semver/SemverQuery.rs | 3 +-- src/semver/Version.rs | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/semver/SemverQuery.rs b/src/semver/SemverQuery.rs index d1eefe83f801..7731d493aa1f 100644 --- a/src/semver/SemverQuery.rs +++ b/src/semver/SemverQuery.rs @@ -329,7 +329,6 @@ impl List { range: *range, next: None, }); - tail.range = *range; let tail_ptr = NonNull::from(&mut *tail); @@ -988,7 +987,7 @@ pub fn parse(input: &[u8], sliced: SlicedString) -> Result { break 'possibly_hyphenate false; } - if !(i < input.len() && matches!(input[i], b'0'..=b'9' | b'X' | b'x' | b'*')) { + if !matches!(input[i], b'0'..=b'9' | b'X' | b'x' | b'*') { break 'possibly_hyphenate false; } diff --git a/src/semver/Version.rs b/src/semver/Version.rs index 4ab302f02375..e9f824ff249a 100644 --- a/src/semver/Version.rs +++ b/src/semver/Version.rs @@ -579,9 +579,6 @@ impl VersionType { } part_start_i = i; - while i < input.len() && matches!(input[i], b' ') { - i += 1; - } let tag_result = Tag::parse(sliced_string.sub(&input[part_start_i..])); result.version.tag = tag_result.tag; i += tag_result.len as usize;