Skip to content

Commit 4190dce

Browse files
author
Ariel Ben-Yehuda
committed
fix tidy
1 parent 52dd2b4 commit 4190dce

File tree

7 files changed

+32
-27
lines changed

7 files changed

+32
-27
lines changed

src/librustc/middle/cstore.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use syntax::codemap::Span;
4242
use syntax::ptr::P;
4343
use rustc_back::target::Target;
4444
use rustc_front::hir;
45-
use rustc_front::visit::Visitor;
45+
use rustc_front::intravisit::Visitor;
4646
use rustc_front::util::IdVisitor;
4747

4848
pub use self::DefLike::{DlDef, DlField, DlImpl};
@@ -123,6 +123,13 @@ pub enum FoundAst<'ast> {
123123
NotFound,
124124
}
125125

126+
/// A store of Rust crates, through with their metadata
127+
/// can be accessed.
128+
///
129+
/// The `: Any` bound is a temporary measure that allows access
130+
/// to the backing `rustc_metadata::cstore::CStore` object. It
131+
/// will be removed in the near future - if you need to access
132+
/// internal APIs, please tell us.
126133
pub trait CrateStore<'tcx> : Any {
127134
// item info
128135
fn stability(&self, def: DefId) -> Option<attr::Stability>;
@@ -244,11 +251,7 @@ impl InlinedItem {
244251
}
245252

246253
pub fn visit_ids<O: IdVisitingOperation>(&self, operation: &mut O) {
247-
let mut id_visitor = IdVisitor {
248-
operation: operation,
249-
pass_through_items: true,
250-
visited_outermost: false,
251-
};
254+
let mut id_visitor = IdVisitor::new(operation);
252255
self.visit(&mut id_visitor);
253256
}
254257
}

src/librustc_driver/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ pub mod target_features;
106106
const BUG_REPORT_URL: &'static str = "https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.\
107107
md#bug-reports";
108108

109-
// [stage0]: kill this
109+
// SNAP 1af31d4
110+
// This is a terrible hack. Our stage0 is older than 1.4 and does not
111+
// support DST coercions, so this function performs the corecion
112+
// manually. This should go away.
110113
pub fn cstore_to_cratestore(a: Rc<CStore>) -> Rc<for<'s> CrateStore<'s>>
111114
{
112115
use std::mem;

src/librustc_metadata/creader.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use loader::{self, CratePaths};
2020
use rustc::back::svh::Svh;
2121
use rustc::session::{config, Session};
2222
use rustc::session::search_paths::PathKind;
23-
use rustc::middle::cstore::validate_crate_name;
23+
use rustc::middle::cstore::{CrateStore, validate_crate_name};
2424
use rustc::util::nodemap::FnvHashMap;
2525
use rustc::front::map as hir_map;
2626

@@ -223,7 +223,7 @@ impl<'a> CrateReader<'a> {
223223
// We're also sure to compare *paths*, not actual byte slices. The
224224
// `source` stores paths which are normalized which may be different
225225
// from the strings on the command line.
226-
let source = self.cstore.do_get_used_crate_source(cnum).unwrap();
226+
let source = self.cstore.used_crate_source(cnum);
227227
if let Some(locs) = self.sess.opts.externs.get(name) {
228228
let found = locs.iter().any(|l| {
229229
let l = fs::canonicalize(l).ok();
@@ -395,7 +395,7 @@ impl<'a> CrateReader<'a> {
395395
if explicitly_linked && !data.explicitly_linked.get() {
396396
data.explicitly_linked.set(explicitly_linked);
397397
}
398-
(cnum, data, self.cstore.do_get_used_crate_source(cnum).unwrap())
398+
(cnum, data, self.cstore.used_crate_source(cnum))
399399
}
400400
LookupResult::Loaded(library) => {
401401
self.register_crate(root, ident, name, span, library,
@@ -707,7 +707,8 @@ impl<'a> CrateReader<'a> {
707707
}
708708

709709
impl<'a, 'b> LocalCrateReader<'a, 'b> {
710-
pub fn new(sess: &'a Session, cstore: &'a CStore, map: &'a hir_map::Map<'b>) -> LocalCrateReader<'a, 'b> {
710+
pub fn new(sess: &'a Session, cstore: &'a CStore,
711+
map: &'a hir_map::Map<'b>) -> LocalCrateReader<'a, 'b> {
711712
LocalCrateReader {
712713
sess: sess,
713714
cstore: cstore,

src/librustc_metadata/csearch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,12 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
447447

448448
fn used_crate_source(&self, cnum: ast::CrateNum) -> CrateSource
449449
{
450-
self.do_get_used_crate_source(cnum).unwrap()
450+
self.opt_used_crate_source(cnum).unwrap()
451451
}
452452

453453
fn extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>
454454
{
455-
self.find_extern_mod_stmt_cnum(emod_id)
455+
self.do_extern_mod_stmt_cnum(emod_id)
456456
}
457457

458458
fn encode_metadata(&self,

src/librustc_metadata/cstore.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl CStore {
136136
I: FnMut(ast::CrateNum, &crate_metadata, Option<CrateSource>),
137137
{
138138
for (&k, v) in self.metas.borrow().iter() {
139-
let origin = self.do_get_used_crate_source(k);
139+
let origin = self.opt_used_crate_source(k);
140140
origin.as_ref().map(|cs| { assert!(k == cs.cnum); });
141141
i(k, &**v, origin);
142142
}
@@ -149,9 +149,8 @@ impl CStore {
149149
}
150150
}
151151

152-
// TODO: killdo
153-
pub fn do_get_used_crate_source(&self, cnum: ast::CrateNum)
154-
-> Option<CrateSource> {
152+
pub fn opt_used_crate_source(&self, cnum: ast::CrateNum)
153+
-> Option<CrateSource> {
155154
self.used_crate_sources.borrow_mut()
156155
.iter().find(|source| source.cnum == cnum).cloned()
157156
}
@@ -174,7 +173,6 @@ impl CStore {
174173
// In order to get this left-to-right dependency ordering, we perform a
175174
// topological sort of all crates putting the leaves at the right-most
176175
// positions.
177-
// TODO: killdo
178176
pub fn do_get_used_crates(&self, prefer: LinkagePreference)
179177
-> Vec<(ast::CrateNum, Option<PathBuf>)> {
180178
let mut ordering = Vec::new();
@@ -234,18 +232,18 @@ impl CStore {
234232
self.extern_mod_crate_map.borrow_mut().insert(emod_id, cnum);
235233
}
236234

237-
pub fn find_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId)
238-
-> Option<ast::CrateNum> {
239-
self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
240-
}
241-
242235
pub fn add_statically_included_foreign_item(&self, id: ast::NodeId) {
243236
self.statically_included_foreign_items.borrow_mut().insert(id);
244237
}
245238

246239
pub fn do_is_statically_included_foreign_item(&self, id: ast::NodeId) -> bool {
247240
self.statically_included_foreign_items.borrow().contains(&id)
248241
}
242+
243+
pub fn do_extern_mod_stmt_cnum(&self, emod_id: ast::NodeId) -> Option<ast::CrateNum>
244+
{
245+
self.extern_mod_crate_map.borrow().get(&emod_id).cloned()
246+
}
249247
}
250248

251249
impl crate_metadata {

src/librustdoc/clean/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn build_external_function(cx: &DocContext, tcx: &ty::ctxt, did: DefId) -> clean
169169
_ => panic!("bad function"),
170170
};
171171

172-
let constness = if csearch::is_const_fn(&tcx.sess.cstore, did) {
172+
let constness = if tcx.sess.cstore.is_const_fn(did) {
173173
hir::Constness::Const
174174
} else {
175175
hir::Constness::NotConst
@@ -346,7 +346,7 @@ pub fn build_impl(cx: &DocContext,
346346
clean::TyMethodItem(clean::TyMethod {
347347
unsafety, decl, self_, generics, abi
348348
}) => {
349-
let constness = if csearch::is_const_fn(&tcx.sess.cstore, did) {
349+
let constness = if tcx.sess.cstore.is_const_fn(did) {
350350
hir::Constness::Const
351351
} else {
352352
hir::Constness::NotConst

src/test/compile-fail/use-from-trait-xc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ use use_from_trait_xc::Trait::CONST;
2222
//~^ ERROR `CONST` is not directly importable
2323

2424
use use_from_trait_xc::Foo::new;
25-
//~^ ERROR `new` is not directly importable
25+
//~^ ERROR unresolved import `use_from_trait_xc::Foo::new`
2626

2727
use use_from_trait_xc::Foo::C;
2828
//~^ ERROR unresolved import `use_from_trait_xc::Foo::C`
2929

3030
use use_from_trait_xc::Bar::new as bnew;
31-
//~^ ERROR `bnew` is not directly importable
31+
//~^ ERROR unresolved import `use_from_trait_xc::Bar::new`
3232

3333
use use_from_trait_xc::Baz::new as baznew;
3434
//~^ ERROR `baznew` is not directly importable

0 commit comments

Comments
 (0)