Skip to content

Commit bd45311

Browse files
Improve code
1 parent dd42a9f commit bd45311

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/librustdoc/html/render/write_shared.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,15 @@ impl Hierarchy {
511511
.filter(|component| matches!(component, Component::Normal(_) | Component::ParentDir))
512512
.peekable();
513513

514+
assert!(components.peek().is_some(), "empty file path");
514515
while let Some(component) = components.next() {
515516
match component {
516517
Component::Normal(s) => {
517518
if components.peek().is_none() {
518519
h.elems.borrow_mut().insert(s.to_owned());
519520
break;
520521
}
521-
let next_h = {
522+
h = {
522523
let mut children = h.children.borrow_mut();
523524

524525
if let Some(existing) = children.get(s) {
@@ -529,12 +530,9 @@ impl Hierarchy {
529530
new_node
530531
}
531532
};
532-
h = next_h;
533533
}
534-
Component::ParentDir => {
535-
if let Some(parent) = h.parent.upgrade() {
536-
h = parent;
537-
}
534+
Component::ParentDir if let Some(parent) = h.parent.upgrade() => {
535+
h = parent;
538536
}
539537
_ => {}
540538
}

0 commit comments

Comments
 (0)