@@ -66,7 +66,7 @@ use hir::def_id::CrateNum;
6666use session;
6767use session:: config;
6868use ty:: TyCtxt ;
69- use middle:: cstore:: DepKind ;
69+ use middle:: cstore:: { CrateStore , DepKind } ;
7070use middle:: cstore:: LinkagePreference :: { self , RequireStatic , RequireDynamic } ;
7171use util:: nodemap:: FxHashMap ;
7272use rustc_back:: PanicStrategy ;
@@ -132,12 +132,12 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
132132 if let Some ( v) = attempt_static ( tcx) {
133133 return v;
134134 }
135- for cnum in sess . cstore . crates ( ) {
136- if sess . cstore . dep_kind ( cnum) . macros_only ( ) { continue }
137- let src = sess . cstore . used_crate_source ( cnum) ;
135+ for cnum in tcx . cstore ( ) . crates ( ) {
136+ if tcx . cstore ( ) . dep_kind ( cnum) . macros_only ( ) { continue }
137+ let src = tcx . cstore ( ) . used_crate_source ( cnum) ;
138138 if src. rlib . is_some ( ) { continue }
139139 sess. err ( & format ! ( "dependency `{}` not found in rlib format" ,
140- sess . cstore. crate_name( cnum) ) ) ;
140+ tcx . cstore( ) . crate_name( cnum) ) ) ;
141141 }
142142 return Vec :: new ( ) ;
143143 }
@@ -165,24 +165,24 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
165165 // Sweep all crates for found dylibs. Add all dylibs, as well as their
166166 // dependencies, ensuring there are no conflicts. The only valid case for a
167167 // dependency to be relied upon twice is for both cases to rely on a dylib.
168- for cnum in sess . cstore . crates ( ) {
169- if sess . cstore . dep_kind ( cnum) . macros_only ( ) { continue }
170- let name = sess . cstore . crate_name ( cnum) ;
171- let src = sess . cstore . used_crate_source ( cnum) ;
168+ for cnum in tcx . cstore ( ) . crates ( ) {
169+ if tcx . cstore ( ) . dep_kind ( cnum) . macros_only ( ) { continue }
170+ let name = tcx . cstore ( ) . crate_name ( cnum) ;
171+ let src = tcx . cstore ( ) . used_crate_source ( cnum) ;
172172 if src. dylib . is_some ( ) {
173173 info ! ( "adding dylib: {}" , name) ;
174- add_library ( sess, cnum, RequireDynamic , & mut formats) ;
174+ add_library ( sess, tcx . cstore ( ) , cnum, RequireDynamic , & mut formats) ;
175175 let deps = tcx. dylib_dependency_formats ( cnum. as_def_id ( ) ) ;
176176 for & ( depnum, style) in deps. iter ( ) {
177177 info ! ( "adding {:?}: {}" , style,
178- sess . cstore. crate_name( depnum) ) ;
179- add_library ( sess, depnum, style, & mut formats) ;
178+ tcx . cstore( ) . crate_name( depnum) ) ;
179+ add_library ( sess, tcx . cstore ( ) , depnum, style, & mut formats) ;
180180 }
181181 }
182182 }
183183
184184 // Collect what we've got so far in the return vector.
185- let last_crate = sess . cstore . crates ( ) . len ( ) ;
185+ let last_crate = tcx . cstore ( ) . crates ( ) . len ( ) ;
186186 let mut ret = ( 1 ..last_crate+1 ) . map ( |cnum| {
187187 match formats. get ( & CrateNum :: new ( cnum) ) {
188188 Some ( & RequireDynamic ) => Linkage :: Dynamic ,
@@ -196,14 +196,14 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
196196 //
197197 // If the crate hasn't been included yet and it's not actually required
198198 // (e.g. it's an allocator) then we skip it here as well.
199- for cnum in sess . cstore . crates ( ) {
200- let src = sess . cstore . used_crate_source ( cnum) ;
199+ for cnum in tcx . cstore ( ) . crates ( ) {
200+ let src = tcx . cstore ( ) . used_crate_source ( cnum) ;
201201 if src. dylib . is_none ( ) &&
202202 !formats. contains_key ( & cnum) &&
203- sess . cstore . dep_kind ( cnum) == DepKind :: Explicit {
203+ tcx . cstore ( ) . dep_kind ( cnum) == DepKind :: Explicit {
204204 assert ! ( src. rlib. is_some( ) || src. rmeta. is_some( ) ) ;
205- info ! ( "adding staticlib: {}" , sess . cstore. crate_name( cnum) ) ;
206- add_library ( sess, cnum, RequireStatic , & mut formats) ;
205+ info ! ( "adding staticlib: {}" , tcx . cstore( ) . crate_name( cnum) ) ;
206+ add_library ( sess, tcx . cstore ( ) , cnum, RequireStatic , & mut formats) ;
207207 ret[ cnum. as_usize ( ) - 1 ] = Linkage :: Static ;
208208 }
209209 }
@@ -226,7 +226,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
226226 // making sure that everything is available in the requested format.
227227 for ( cnum, kind) in ret. iter ( ) . enumerate ( ) {
228228 let cnum = CrateNum :: new ( cnum + 1 ) ;
229- let src = sess . cstore . used_crate_source ( cnum) ;
229+ let src = tcx . cstore ( ) . used_crate_source ( cnum) ;
230230 match * kind {
231231 Linkage :: NotLinked |
232232 Linkage :: IncludedFromDylib => { }
@@ -237,7 +237,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
237237 Linkage :: Static => "rlib" ,
238238 _ => "dylib" ,
239239 } ;
240- let name = sess . cstore . crate_name ( cnum) ;
240+ let name = tcx . cstore ( ) . crate_name ( cnum) ;
241241 sess. err ( & format ! ( "crate `{}` required to be available in {}, \
242242 but it was not available in this form",
243243 name, kind) ) ;
@@ -249,6 +249,7 @@ fn calculate_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
249249}
250250
251251fn add_library ( sess : & session:: Session ,
252+ cstore : & CrateStore ,
252253 cnum : CrateNum ,
253254 link : LinkagePreference ,
254255 m : & mut FxHashMap < CrateNum , LinkagePreference > ) {
@@ -263,7 +264,7 @@ fn add_library(sess: &session::Session,
263264 // can be refined over time.
264265 if link2 != link || link == RequireStatic {
265266 sess. struct_err ( & format ! ( "cannot satisfy dependencies so `{}` only \
266- shows up once", sess . cstore. crate_name( cnum) ) )
267+ shows up once", cstore. crate_name( cnum) ) )
267268 . help ( "having upstream crates all available in one format \
268269 will likely make this go away")
269270 . emit ( ) ;
@@ -275,16 +276,16 @@ fn add_library(sess: &session::Session,
275276
276277fn attempt_static < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ) -> Option < DependencyList > {
277278 let sess = & tcx. sess ;
278- let crates = sess . cstore . used_crates ( RequireStatic ) ;
279+ let crates = tcx . cstore ( ) . used_crates ( RequireStatic ) ;
279280 if !crates. iter ( ) . by_ref ( ) . all ( |& ( _, ref p) | p. is_some ( ) ) {
280281 return None
281282 }
282283
283284 // All crates are available in an rlib format, so we're just going to link
284285 // everything in explicitly so long as it's actually required.
285- let last_crate = sess . cstore . crates ( ) . len ( ) ;
286+ let last_crate = tcx . cstore ( ) . crates ( ) . len ( ) ;
286287 let mut ret = ( 1 ..last_crate+1 ) . map ( |cnum| {
287- if sess . cstore . dep_kind ( CrateNum :: new ( cnum) ) == DepKind :: Explicit {
288+ if tcx . cstore ( ) . dep_kind ( CrateNum :: new ( cnum) ) == DepKind :: Explicit {
288289 Linkage :: Static
289290 } else {
290291 Linkage :: NotLinked
@@ -357,13 +358,13 @@ fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) {
357358
358359 if tcx. is_panic_runtime ( cnum. as_def_id ( ) ) {
359360 if let Some ( ( prev, _) ) = panic_runtime {
360- let prev_name = sess . cstore . crate_name ( prev) ;
361- let cur_name = sess . cstore . crate_name ( cnum) ;
361+ let prev_name = tcx . cstore ( ) . crate_name ( prev) ;
362+ let cur_name = tcx . cstore ( ) . crate_name ( cnum) ;
362363 sess. err ( & format ! ( "cannot link together two \
363364 panic runtimes: {} and {}",
364365 prev_name, cur_name) ) ;
365366 }
366- panic_runtime = Some ( ( cnum, sess . cstore . panic_strategy ( cnum) ) ) ;
367+ panic_runtime = Some ( ( cnum, tcx . cstore ( ) . panic_strategy ( cnum) ) ) ;
367368 }
368369 }
369370
@@ -379,7 +380,7 @@ fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) {
379380 sess. err ( & format ! ( "the linked panic runtime `{}` is \
380381 not compiled with this crate's \
381382 panic strategy `{}`",
382- sess . cstore. crate_name( cnum) ,
383+ tcx . cstore( ) . crate_name( cnum) ,
383384 desired_strategy. desc( ) ) ) ;
384385 }
385386
@@ -395,8 +396,8 @@ fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) {
395396 continue
396397 }
397398 let cnum = CrateNum :: new ( i + 1 ) ;
398- let found_strategy = sess . cstore . panic_strategy ( cnum) ;
399- let is_compiler_builtins = sess . cstore . is_compiler_builtins ( cnum) ;
399+ let found_strategy = tcx . cstore ( ) . panic_strategy ( cnum) ;
400+ let is_compiler_builtins = tcx . cstore ( ) . is_compiler_builtins ( cnum) ;
400401 if is_compiler_builtins || desired_strategy == found_strategy {
401402 continue
402403 }
@@ -405,7 +406,7 @@ fn verify_ok<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, list: &[Linkage]) {
405406 panic strategy `{}` which is \
406407 incompatible with this crate's \
407408 strategy of `{}`",
408- sess . cstore. crate_name( cnum) ,
409+ tcx . cstore( ) . crate_name( cnum) ,
409410 found_strategy. desc( ) ,
410411 desired_strategy. desc( ) ) ) ;
411412 }
0 commit comments