@@ -97,7 +97,7 @@ pub fn calculate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
97
97
let mut fmts = sess. dependency_formats . borrow_mut ( ) ;
98
98
for & ty in sess. crate_types . borrow ( ) . iter ( ) {
99
99
let linkage = calculate_type ( tcx, ty) ;
100
- verify_ok ( sess , & linkage) ;
100
+ verify_ok ( tcx , & linkage) ;
101
101
fmts. insert ( ty, linkage) ;
102
102
}
103
103
sess. abort_if_errors ( ) ;
@@ -116,7 +116,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
116
116
// If the global prefer_dynamic switch is turned off, first attempt
117
117
// static linkage (this can fail).
118
118
config:: CrateTypeExecutable if !sess. opts . cg . prefer_dynamic => {
119
- if let Some ( v) = attempt_static ( sess ) {
119
+ if let Some ( v) = attempt_static ( tcx ) {
120
120
return v;
121
121
}
122
122
}
@@ -129,7 +129,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
129
129
// to be found, we generate some nice pretty errors.
130
130
config:: CrateTypeStaticlib |
131
131
config:: CrateTypeCdylib => {
132
- if let Some ( v) = attempt_static ( sess ) {
132
+ if let Some ( v) = attempt_static ( tcx ) {
133
133
return v;
134
134
}
135
135
for cnum in sess. cstore . crates ( ) {
@@ -146,7 +146,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
146
146
// to try to eagerly statically link all dependencies. This is normally
147
147
// done for end-product dylibs, not intermediate products.
148
148
config:: CrateTypeDylib if !sess. opts . cg . prefer_dynamic => {
149
- if let Some ( v) = attempt_static ( sess ) {
149
+ if let Some ( v) = attempt_static ( tcx ) {
150
150
return v;
151
151
}
152
152
}
@@ -215,9 +215,9 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
215
215
// Things like allocators and panic runtimes may not have been activated
216
216
// quite yet, so do so here.
217
217
activate_injected_dep ( sess. injected_allocator . get ( ) , & mut ret,
218
- & |cnum| sess . cstore . is_allocator ( cnum) ) ;
218
+ & |cnum| tcx . is_allocator ( cnum) ) ;
219
219
activate_injected_dep ( sess. injected_panic_runtime . get ( ) , & mut ret,
220
- & |cnum| sess . cstore . is_panic_runtime ( cnum) ) ;
220
+ & |cnum| tcx . is_panic_runtime ( cnum) ) ;
221
221
222
222
// When dylib B links to dylib A, then when using B we must also link to A.
223
223
// It could be the case, however, that the rlib for A is present (hence we
@@ -274,7 +274,8 @@ fn add_library(sess: &session::Session,
274
274
}
275
275
}
276
276
277
- fn attempt_static ( sess : & session:: Session ) -> Option < DependencyList > {
277
+ fn attempt_static < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> Option < DependencyList > {
278
+ let sess = & tcx. sess ;
278
279
let crates = sess. cstore . used_crates ( RequireStatic ) ;
279
280
if !crates. iter ( ) . by_ref ( ) . all ( |& ( _, ref p) | p. is_some ( ) ) {
280
281
return None
@@ -295,9 +296,9 @@ fn attempt_static(sess: &session::Session) -> Option<DependencyList> {
295
296
// explicitly linked, which is the case for any injected dependency. Handle
296
297
// that here and activate them.
297
298
activate_injected_dep ( sess. injected_allocator . get ( ) , & mut ret,
298
- & |cnum| sess . cstore . is_allocator ( cnum) ) ;
299
+ & |cnum| tcx . is_allocator ( cnum) ) ;
299
300
activate_injected_dep ( sess. injected_panic_runtime . get ( ) , & mut ret,
300
- & |cnum| sess . cstore . is_panic_runtime ( cnum) ) ;
301
+ & |cnum| tcx . is_panic_runtime ( cnum) ) ;
301
302
302
303
Some ( ret)
303
304
}
@@ -332,7 +333,8 @@ fn activate_injected_dep(injected: Option<CrateNum>,
332
333
333
334
// After the linkage for a crate has been determined we need to verify that
334
335
// there's only going to be one allocator in the output.
335
- fn verify_ok ( sess : & session:: Session , list : & [ Linkage ] ) {
336
+ fn verify_ok < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , list : & [ Linkage ] ) {
337
+ let sess = & tcx. sess ;
336
338
if list. len ( ) == 0 {
337
339
return
338
340
}
@@ -343,7 +345,7 @@ fn verify_ok(sess: &session::Session, list: &[Linkage]) {
343
345
continue
344
346
}
345
347
let cnum = CrateNum :: new ( i + 1 ) ;
346
- if sess . cstore . is_allocator ( cnum) {
348
+ if tcx . is_allocator ( cnum) {
347
349
if let Some ( prev) = allocator {
348
350
let prev_name = sess. cstore . crate_name ( prev) ;
349
351
let cur_name = sess. cstore . crate_name ( cnum) ;
@@ -354,7 +356,7 @@ fn verify_ok(sess: &session::Session, list: &[Linkage]) {
354
356
allocator = Some ( cnum) ;
355
357
}
356
358
357
- if sess . cstore . is_panic_runtime ( cnum) {
359
+ if tcx . is_panic_runtime ( cnum) {
358
360
if let Some ( ( prev, _) ) = panic_runtime {
359
361
let prev_name = sess. cstore . crate_name ( prev) ;
360
362
let cur_name = sess. cstore . crate_name ( cnum) ;
0 commit comments