Skip to content

Commit 4097858

Browse files
committed
Avoid using kw::Empty when comparing names.
1 parent 5fb0f57 commit 4097858

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: src/librustdoc/html/render/print_item.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::def_id::DefId;
1111
use rustc_index::IndexVec;
1212
use rustc_middle::ty::{self, TyCtxt};
1313
use rustc_span::hygiene::MacroKind;
14-
use rustc_span::symbol::{Symbol, kw, sym};
14+
use rustc_span::symbol::{Symbol, sym};
1515
use tracing::{debug, info};
1616

1717
use super::type_layout::document_type_layout;
@@ -347,9 +347,12 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
347347
// but we actually want stable items to come first
348348
return is_stable2.cmp(&is_stable1);
349349
}
350-
let lhs = i1.name.unwrap_or(kw::Empty);
351-
let rhs = i2.name.unwrap_or(kw::Empty);
352-
compare_names(lhs.as_str(), rhs.as_str())
350+
match (i1.name, i2.name) {
351+
(Some(name1), Some(name2)) => compare_names(name1.as_str(), name2.as_str()),
352+
(Some(_), None) => Ordering::Greater,
353+
(None, Some(_)) => Ordering::Less,
354+
(None, None) => Ordering::Equal,
355+
}
353356
}
354357

355358
let tcx = cx.tcx();

0 commit comments

Comments
 (0)