Skip to content

Commit 1589a17

Browse files
Merge branch 'main' into coderabbit/changes/b669491d
2 parents 4c8c6b7 + 9bf5a37 commit 1589a17

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

‎bots/rhodibot/src/canon/requirement.rs‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ fn split_on<'a>(text: &'a str, separators: &[&str]) -> Vec<&'a str> {
143143
// Iterated by character, not by byte: the canon's descriptions carry em
144144
// dashes, and stepping through bytes would cut them in half.
145145
while index < text.len() {
146-
let ch = text[index..]
147-
.chars()
148-
.next()
149-
.expect("index is a char boundary");
146+
let Some(ch) = text[index..].chars().next() else {
147+
break;
148+
};
150149

151150
match ch {
152151
'{' => depth += 1,

‎bots/rhodibot/src/canon/verdict.rs‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -402,13 +402,16 @@ fn classify_group(
402402
// leftover under a retired one is moving, not living in the retired one
403403
// -- calling that "deprecated location" would overstate it.
404404
let mut live: Vec<String> = Vec::new();
405-
let mut retired: Vec<String> = Vec::new();
405+
let mut retired: Vec<(String, &Deprecation)> = Vec::new();
406406
for alternative in alternatives.iter().filter(|path| !path.ends_with('/')) {
407407
let basename = basename(alternative);
408408
for file in files.iter().filter(|file| basename_of(file) == basename) {
409-
if is_retired(file, deprecations) {
410-
if !retired.contains(file) {
411-
retired.push(file.clone());
409+
if let Some(deprecation) = deprecations
410+
.iter()
411+
.find(|deprecation| deprecation.matches(file))
412+
{
413+
if !retired.iter().any(|(path, _)| path == file) {
414+
retired.push((file.clone(), deprecation));
412415
}
413416
} else if !live.contains(file) {
414417
live.push(file.clone());
@@ -420,16 +423,12 @@ fn classify_group(
420423
return GroupVerdict::Elsewhere {
421424
expected: alternatives.to_vec(),
422425
found: live,
423-
deprecated_copies: retired,
426+
deprecated_copies: retired.into_iter().map(|(path, _)| path).collect(),
424427
};
425428
}
426429

427430
// 4. Present only under a location the canon has retired.
428-
if let Some(found) = retired.first() {
429-
let deprecated = deprecations
430-
.iter()
431-
.find(|deprecated| deprecated.matches(found))
432-
.expect("a retired path came from a deprecation");
431+
if let Some((found, deprecated)) = retired.first() {
433432
return GroupVerdict::Deprecated {
434433
found: found.clone(),
435434
location: deprecated.location.clone(),

0 commit comments

Comments
 (0)