Skip to content

Commit 1235836

Browse files
incr.comp.: Fix instability in CodegenUnitExt::items_in_deterministic_order().
1 parent 7a016c1 commit 1235836

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/librustc_trans/partitioning.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,27 @@ pub trait CodegenUnitExt<'tcx> {
163163
fn item_sort_key<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
164164
item: TransItem<'tcx>) -> ItemSortKey {
165165
ItemSortKey(match item {
166-
TransItem::Fn(instance) => {
167-
tcx.hir.as_local_node_id(instance.def_id())
166+
TransItem::Fn(ref instance) => {
167+
match instance.def {
168+
// We only want to take NodeIds of user-defined
169+
// instances into account. The others don't matter for
170+
// the codegen tests and can even make item order
171+
// unstable.
172+
InstanceDef::Item(def_id) => {
173+
tcx.hir.as_local_node_id(def_id)
174+
}
175+
InstanceDef::Intrinsic(..) |
176+
InstanceDef::FnPtrShim(..) |
177+
InstanceDef::Virtual(..) |
178+
InstanceDef::ClosureOnceShim { .. } |
179+
InstanceDef::DropGlue(..) |
180+
InstanceDef::CloneShim(..) => {
181+
None
182+
}
183+
}
168184
}
169-
TransItem::Static(node_id) | TransItem::GlobalAsm(node_id) => {
185+
TransItem::Static(node_id) |
186+
TransItem::GlobalAsm(node_id) => {
170187
Some(node_id)
171188
}
172189
}, item.symbol_name(tcx))

0 commit comments

Comments
 (0)