File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
compiler/rustc_middle/src/middle Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -207,23 +207,19 @@ pub type CrateStoreDyn = dyn CrateStore + sync::Sync;
207
207
// around. For more info, see some comments in the add_used_library function
208
208
// below.
209
209
//
210
- // In order to get this left-to-right dependency ordering, we perform a
211
- // topological sort of all crates putting the leaves at the right-most
212
- // positions.
210
+ // In order to get this left-to-right dependency ordering, we use the reverse
211
+ // postorder of all crates putting the leaves at the right-most positions.
213
212
pub fn used_crates ( tcx : TyCtxt < ' _ > ) -> Vec < CrateNum > {
214
- let mut libs = tcx
215
- . crates ( ( ) )
213
+ tcx
214
+ . postorder_cnums ( ( ) )
216
215
. iter ( )
216
+ . rev ( )
217
217
. cloned ( )
218
218
. filter_map ( |cnum| {
219
219
if tcx. dep_kind ( cnum) . macros_only ( ) {
220
220
return None ;
221
221
}
222
222
Some ( cnum)
223
223
} )
224
- . collect :: < Vec < _ > > ( ) ;
225
- let mut ordering = tcx. postorder_cnums ( ( ) ) . to_owned ( ) ;
226
- ordering. reverse ( ) ;
227
- libs. sort_by_cached_key ( |& a| ordering. iter ( ) . position ( |x| * x == a) ) ;
228
- libs
224
+ . collect :: < Vec < _ > > ( )
229
225
}
You can’t perform that action at this time.
0 commit comments