Skip to content

Commit 555a239

Browse files
committed
De-@ CStore uses.
1 parent f77c744 commit 555a239

File tree

14 files changed

+109
-122
lines changed

14 files changed

+109
-122
lines changed

src/librustc/back/link.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
10001000
}
10011001
};
10021002
a.add_rlib(&p, name, sess.lto()).unwrap();
1003-
let native_libs = csearch::get_native_libraries(sess.cstore, cnum);
1003+
let native_libs = csearch::get_native_libraries(&sess.cstore, cnum);
10041004
for &(kind, ref lib) in native_libs.iter() {
10051005
let name = match kind {
10061006
cstore::NativeStatic => "static library",
@@ -1302,8 +1302,8 @@ fn add_upstream_rust_crates(args: &mut Vec<~str>, sess: &Session,
13021302
// * If one form of linking fails, the second is also attempted
13031303
// * If both forms fail, then we emit an error message
13041304

1305-
let dynamic = get_deps(sess.cstore, cstore::RequireDynamic);
1306-
let statik = get_deps(sess.cstore, cstore::RequireStatic);
1305+
let dynamic = get_deps(&sess.cstore, cstore::RequireDynamic);
1306+
let statik = get_deps(&sess.cstore, cstore::RequireStatic);
13071307
match (dynamic, statik, sess.opts.cg.prefer_dynamic, dylib) {
13081308
(_, Some(deps), false, false) => {
13091309
add_static_crates(args, sess, tmpdir, deps)
@@ -1459,7 +1459,7 @@ fn add_upstream_rust_crates(args: &mut Vec<~str>, sess: &Session,
14591459
// be instantiated in the target crate, meaning that the native symbol must
14601460
// also be resolved in the target crate.
14611461
fn add_upstream_native_libraries(args: &mut Vec<~str>, sess: &Session) {
1462-
let cstore = sess.cstore;
1462+
let cstore = &sess.cstore;
14631463
cstore.iter_crate_data(|cnum, _| {
14641464
let libs = csearch::get_native_libraries(cstore, cnum);
14651465
for &(kind, ref lib) in libs.iter() {

src/librustc/driver/driver.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,6 @@ pub fn build_session_(sopts: @session::Options,
10041004
-> Session {
10051005
let target_cfg = build_target_config(sopts);
10061006
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler, codemap);
1007-
let cstore = @CStore::new(token::get_ident_interner());
10081007
let default_sysroot = match sopts.maybe_sysroot {
10091008
Some(_) => None,
10101009
None => Some(filesearch::get_or_default_sysroot())
@@ -1022,7 +1021,7 @@ pub fn build_session_(sopts: @session::Options,
10221021
Session {
10231022
targ_cfg: target_cfg,
10241023
opts: sopts,
1025-
cstore: cstore,
1024+
cstore: CStore::new(token::get_ident_interner()),
10261025
parse_sess: p_s,
10271026
codemap: codemap,
10281027
// For a library crate, this is always none

src/librustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub enum CrateType {
176176
pub struct Session {
177177
targ_cfg: @Config,
178178
opts: @Options,
179-
cstore: @metadata::cstore::CStore,
179+
cstore: metadata::cstore::CStore,
180180
parse_sess: @ParseSess,
181181
codemap: @codemap::CodeMap,
182182
// For a library crate, this is always none

src/librustc/metadata/creader.rs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,10 @@ struct Env<'a> {
120120
}
121121

122122
fn visit_crate(e: &Env, c: &ast::Crate) {
123-
let cstore = e.sess.cstore;
124-
125123
for a in c.attrs.iter().filter(|m| m.name().equiv(&("link_args"))) {
126124
match a.value_str() {
127-
Some(ref linkarg) => cstore.add_used_link_args(linkarg.get()),
128-
None => { /* fallthrough */ }
125+
Some(ref linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()),
126+
None => { /* fallthrough */ }
129127
}
130128
}
131129
}
@@ -195,7 +193,6 @@ fn visit_item(e: &Env, i: &ast::Item) {
195193
}
196194

197195
// First, add all of the custom link_args attributes
198-
let cstore = e.sess.cstore;
199196
let link_args = i.attrs.iter()
200197
.filter_map(|at| if at.name().equiv(&("link_args")) {
201198
Some(at)
@@ -205,13 +202,12 @@ fn visit_item(e: &Env, i: &ast::Item) {
205202
.to_owned_vec();
206203
for m in link_args.iter() {
207204
match m.value_str() {
208-
Some(linkarg) => cstore.add_used_link_args(linkarg.get()),
205+
Some(linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()),
209206
None => { /* fallthrough */ }
210207
}
211208
}
212209

213210
// Next, process all of the #[link(..)]-style arguments
214-
let cstore = e.sess.cstore;
215211
let link_args = i.attrs.iter()
216212
.filter_map(|at| if at.name().equiv(&("link")) {
217213
Some(at)
@@ -260,7 +256,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
260256
if n.get().is_empty() {
261257
e.sess.span_err(m.span, "#[link(name = \"\")] given with empty name");
262258
} else {
263-
cstore.add_used_library(n.get().to_owned(), kind);
259+
e.sess.cstore.add_used_library(n.get().to_owned(), kind);
264260
}
265261
}
266262
None => {}
@@ -344,18 +340,15 @@ fn resolve_crate(e: &mut Env,
344340
cnum: cnum
345341
};
346342

347-
let cstore = e.sess.cstore;
348-
cstore.set_crate_data(cnum, cmeta);
349-
cstore.add_used_crate_source(cstore::CrateSource {
343+
e.sess.cstore.set_crate_data(cnum, cmeta);
344+
e.sess.cstore.add_used_crate_source(cstore::CrateSource {
350345
dylib: dylib,
351346
rlib: rlib,
352347
cnum: cnum,
353348
});
354-
return cnum;
355-
}
356-
Some(cnum) => {
357-
return cnum;
349+
cnum
358350
}
351+
Some(cnum) => cnum
359352
}
360353
}
361354

@@ -415,12 +408,12 @@ impl<'a> CrateLoader for Loader<'a> {
415408
}
416409

417410
fn get_exported_macros(&mut self, cnum: ast::CrateNum) -> Vec<~str> {
418-
csearch::get_exported_macros(self.env.sess.cstore, cnum).move_iter()
419-
.collect()
411+
csearch::get_exported_macros(&self.env.sess.cstore, cnum).move_iter()
412+
.collect()
420413
}
421414

422415
fn get_registrar_symbol(&mut self, cnum: ast::CrateNum) -> Option<~str> {
423-
let cstore = self.env.sess.cstore;
416+
let cstore = &self.env.sess.cstore;
424417
csearch::get_macro_registrar_fn(cstore, cnum)
425418
.map(|did| csearch::get_symbol(cstore, did))
426419
}

0 commit comments

Comments
 (0)