Skip to content

Commit f636322

Browse files
committed
Use the local_span method.
1 parent a2627f7 commit f636322

File tree

1 file changed

+2
-35
lines changed
  • compiler/rustc_middle/src/mir

1 file changed

+2
-35
lines changed

compiler/rustc_middle/src/mir/mono.rs

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -525,45 +525,12 @@ impl<'tcx> CodegenUnit<'tcx> {
525525
tcx: TyCtxt<'tcx>,
526526
) -> Vec<(MonoItem<'tcx>, MonoItemData)> {
527527
// The codegen tests rely on items being process in the same order as
528-
// they appear in the file, so for local items, we sort by node_id first
528+
// they appear in the file, so for local items, we sort by span first
529529
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)]
530530
struct ItemSortKey<'tcx>(Option<Span>, SymbolName<'tcx>);
531531

532532
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<'tcx> {
533-
ItemSortKey(
534-
match item {
535-
MonoItem::Fn(ref instance) => {
536-
match instance.def {
537-
// We only want to take HirIds of user-defined
538-
// instances into account. The others don't matter for
539-
// the codegen tests and can even make item order
540-
// unstable.
541-
InstanceKind::Item(def) => {
542-
def.as_local().map(|def_id| tcx.def_span(def_id))
543-
}
544-
InstanceKind::VTableShim(..)
545-
| InstanceKind::ReifyShim(..)
546-
| InstanceKind::Intrinsic(..)
547-
| InstanceKind::FnPtrShim(..)
548-
| InstanceKind::Virtual(..)
549-
| InstanceKind::ClosureOnceShim { .. }
550-
| InstanceKind::ConstructCoroutineInClosureShim { .. }
551-
| InstanceKind::DropGlue(..)
552-
| InstanceKind::CloneShim(..)
553-
| InstanceKind::ThreadLocalShim(..)
554-
| InstanceKind::FnPtrAddrShim(..)
555-
| InstanceKind::AsyncDropGlue(..)
556-
| InstanceKind::FutureDropPollShim(..)
557-
| InstanceKind::AsyncDropGlueCtorShim(..) => None,
558-
}
559-
}
560-
MonoItem::Static(def_id) => {
561-
def_id.as_local().map(|def_id| tcx.def_span(def_id))
562-
}
563-
MonoItem::GlobalAsm(item_id) => Some(tcx.def_span(item_id.owner_id.def_id)),
564-
},
565-
item.symbol_name(tcx),
566-
)
533+
ItemSortKey(item.local_span(tcx), item.symbol_name(tcx))
567534
}
568535

569536
let mut items: Vec<_> = self.items().iter().map(|(&i, &data)| (i, data)).collect();

0 commit comments

Comments
 (0)