Skip to content

Commit 190f0c0

Browse files
Always just use symbol name for sorting exported symbols.
1 parent 0c366cd commit 190f0c0

File tree

1 file changed

+0
-38
lines changed

1 file changed

+0
-38
lines changed

src/librustc/middle/exported_symbols.rs

-38
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::ty::subst::SubstsRef;
33
use crate::ty::{self, TyCtxt};
44
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
55
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
6-
use std::cmp;
76
use std::mem;
87

98
/// The SymbolExportLevel of a symbols specifies from which kinds of crates
@@ -43,43 +42,6 @@ impl<'tcx> ExportedSymbol<'tcx> {
4342
ExportedSymbol::NoDefId(symbol_name) => symbol_name,
4443
}
4544
}
46-
47-
pub fn compare_stable(&self, tcx: TyCtxt<'tcx>, other: &ExportedSymbol<'tcx>) -> cmp::Ordering {
48-
match *self {
49-
ExportedSymbol::NonGeneric(self_def_id) => match *other {
50-
ExportedSymbol::NonGeneric(other_def_id) => {
51-
tcx.def_path_hash(self_def_id).cmp(&tcx.def_path_hash(other_def_id))
52-
}
53-
ExportedSymbol::Generic(..) | ExportedSymbol::NoDefId(_) => cmp::Ordering::Less,
54-
},
55-
ExportedSymbol::Generic(self_def_id, self_substs) => match *other {
56-
ExportedSymbol::NonGeneric(_) => cmp::Ordering::Greater,
57-
ExportedSymbol::Generic(other_def_id, other_substs) => {
58-
// We compare the symbol names because they are cached as query
59-
// results which makes them relatively cheap to access repeatedly.
60-
//
61-
// It might be even faster to build a local cache of stable IDs
62-
// for sorting. Exported symbols are really only sorted once
63-
// in order to make the `exported_symbols` query result stable.
64-
let self_symbol_name =
65-
tcx.symbol_name(ty::Instance::new(self_def_id, self_substs));
66-
let other_symbol_name =
67-
tcx.symbol_name(ty::Instance::new(other_def_id, other_substs));
68-
69-
self_symbol_name.cmp(&other_symbol_name)
70-
}
71-
ExportedSymbol::NoDefId(_) => cmp::Ordering::Less,
72-
},
73-
ExportedSymbol::NoDefId(self_symbol_name) => match *other {
74-
ExportedSymbol::NonGeneric(_) | ExportedSymbol::Generic(..) => {
75-
cmp::Ordering::Greater
76-
}
77-
ExportedSymbol::NoDefId(ref other_symbol_name) => {
78-
self_symbol_name.cmp(other_symbol_name)
79-
}
80-
},
81-
}
82-
}
8345
}
8446

8547
pub fn metadata_symbol_name(tcx: TyCtxt<'_>) -> String {

0 commit comments

Comments
 (0)