Skip to content

Commit e7fc786

Browse files
committed
fallout from moving def-id
1 parent b70b7c2 commit e7fc786

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1033
-980
lines changed

Diff for: src/librustc/ast_map/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use self::MapEntry::*;
1414

1515
use metadata::inline::InlinedItem;
1616
use metadata::inline::InlinedItem as II;
17+
use middle::def_id::{DefId, LOCAL_CRATE};
1718
use syntax::abi;
1819
use syntax::ast::*;
1920
use syntax::ast_util;
@@ -378,7 +379,7 @@ impl<'ast> Map<'ast> {
378379
match self.find_entry(parent) {
379380
Some(RootInlinedParent(&InlinedParent {ii: II::TraitItem(did, _), ..})) => did,
380381
Some(RootInlinedParent(&InlinedParent {ii: II::ImplItem(did, _), ..})) => did,
381-
_ => ast_util::local_def(parent)
382+
_ => DefId::local(parent)
382383
}
383384
}
384385

Diff for: src/librustc/metadata/csearch.rs

+48-47
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use metadata::common::*;
1515
use metadata::cstore;
1616
use metadata::decoder;
1717
use metadata::inline::InlinedItem;
18+
use middle::def_id::DefId;
1819
use middle::lang_items;
1920
use middle::ty;
2021

@@ -30,11 +31,11 @@ use std::collections::hash_map::HashMap;
3031
#[derive(Copy, Clone)]
3132
pub struct MethodInfo {
3233
pub name: ast::Name,
33-
pub def_id: ast::DefId,
34+
pub def_id: DefId,
3435
pub vis: ast::Visibility,
3536
}
3637

37-
pub fn get_symbol(cstore: &cstore::CStore, def: ast::DefId) -> String {
38+
pub fn get_symbol(cstore: &cstore::CStore, def: DefId) -> String {
3839
let cdata = cstore.get_crate_data(def.krate);
3940
decoder::get_symbol(cdata.data(), def.node)
4041
}
@@ -52,7 +53,7 @@ pub fn each_lang_item<F>(cstore: &cstore::CStore,
5253

5354
/// Iterates over each child of the given item.
5455
pub fn each_child_of_item<F>(cstore: &cstore::CStore,
55-
def_id: ast::DefId,
56+
def_id: DefId,
5657
callback: F) where
5758
F: FnMut(decoder::DefLike, ast::Name, ast::Visibility),
5859
{
@@ -83,7 +84,7 @@ pub fn each_top_level_item_of_crate<F>(cstore: &cstore::CStore,
8384
callback)
8485
}
8586

86-
pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem> {
87+
pub fn get_item_path(tcx: &ty::ctxt, def: DefId) -> Vec<ast_map::PathElem> {
8788
let cstore = &tcx.sess.cstore;
8889
let cdata = cstore.get_crate_data(def.krate);
8990
let path = decoder::get_item_path(&*cdata, def.node);
@@ -98,14 +99,14 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec<ast_map::PathElem>
9899

99100
pub enum FoundAst<'ast> {
100101
Found(&'ast InlinedItem),
101-
FoundParent(ast::DefId, &'ast InlinedItem),
102+
FoundParent(DefId, &'ast InlinedItem),
102103
NotFound,
103104
}
104105

105106
// Finds the AST for this item in the crate metadata, if any. If the item was
106107
// not marked for inlining, then the AST will not be present and hence none
107108
// will be returned.
108-
pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId,
109+
pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId,
109110
decode_inlined_item: decoder::DecodeInlinedItem)
110111
-> FoundAst<'tcx> {
111112
let cstore = &tcx.sess.cstore;
@@ -114,13 +115,13 @@ pub fn maybe_get_item_ast<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId,
114115
}
115116

116117
/// Returns information about the given implementation.
117-
pub fn get_impl_items(cstore: &cstore::CStore, impl_def_id: ast::DefId)
118+
pub fn get_impl_items(cstore: &cstore::CStore, impl_def_id: DefId)
118119
-> Vec<ty::ImplOrTraitItemId> {
119120
let cdata = cstore.get_crate_data(impl_def_id.krate);
120121
decoder::get_impl_items(&*cdata, impl_def_id.node)
121122
}
122123

123-
pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
124+
pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId)
124125
-> ty::ImplOrTraitItem<'tcx> {
125126
let cdata = tcx.sess.cstore.get_crate_data(def.krate);
126127
decoder::get_impl_or_trait_item(tcx.sess.cstore.intr.clone(),
@@ -129,114 +130,114 @@ pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
129130
tcx)
130131
}
131132

132-
pub fn get_trait_name(cstore: &cstore::CStore, def: ast::DefId) -> ast::Name {
133+
pub fn get_trait_name(cstore: &cstore::CStore, def: DefId) -> ast::Name {
133134
let cdata = cstore.get_crate_data(def.krate);
134135
decoder::get_trait_name(cstore.intr.clone(),
135136
&*cdata,
136137
def.node)
137138
}
138139

139-
pub fn is_static_method(cstore: &cstore::CStore, def: ast::DefId) -> bool {
140+
pub fn is_static_method(cstore: &cstore::CStore, def: DefId) -> bool {
140141
let cdata = cstore.get_crate_data(def.krate);
141142
decoder::is_static_method(&*cdata, def.node)
142143
}
143144

144-
pub fn get_trait_item_def_ids(cstore: &cstore::CStore, def: ast::DefId)
145+
pub fn get_trait_item_def_ids(cstore: &cstore::CStore, def: DefId)
145146
-> Vec<ty::ImplOrTraitItemId> {
146147
let cdata = cstore.get_crate_data(def.krate);
147148
decoder::get_trait_item_def_ids(&*cdata, def.node)
148149
}
149150

150151
pub fn get_item_variances(cstore: &cstore::CStore,
151-
def: ast::DefId) -> ty::ItemVariances {
152+
def: DefId) -> ty::ItemVariances {
152153
let cdata = cstore.get_crate_data(def.krate);
153154
decoder::get_item_variances(&*cdata, def.node)
154155
}
155156

156157
pub fn get_provided_trait_methods<'tcx>(tcx: &ty::ctxt<'tcx>,
157-
def: ast::DefId)
158+
def: DefId)
158159
-> Vec<Rc<ty::Method<'tcx>>> {
159160
let cstore = &tcx.sess.cstore;
160161
let cdata = cstore.get_crate_data(def.krate);
161162
decoder::get_provided_trait_methods(cstore.intr.clone(), &*cdata, def.node, tcx)
162163
}
163164

164-
pub fn get_associated_consts<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
165+
pub fn get_associated_consts<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId)
165166
-> Vec<Rc<ty::AssociatedConst<'tcx>>> {
166167
let cstore = &tcx.sess.cstore;
167168
let cdata = cstore.get_crate_data(def.krate);
168169
decoder::get_associated_consts(cstore.intr.clone(), &*cdata, def.node, tcx)
169170
}
170171

171-
pub fn get_type_name_if_impl(cstore: &cstore::CStore, def: ast::DefId)
172+
pub fn get_type_name_if_impl(cstore: &cstore::CStore, def: DefId)
172173
-> Option<ast::Name> {
173174
let cdata = cstore.get_crate_data(def.krate);
174175
decoder::get_type_name_if_impl(&*cdata, def.node)
175176
}
176177

177178
pub fn get_methods_if_impl(cstore: &cstore::CStore,
178-
def: ast::DefId)
179+
def: DefId)
179180
-> Option<Vec<MethodInfo> > {
180181
let cdata = cstore.get_crate_data(def.krate);
181182
decoder::get_methods_if_impl(cstore.intr.clone(), &*cdata, def.node)
182183
}
183184

184185
pub fn get_item_attrs(cstore: &cstore::CStore,
185-
def_id: ast::DefId)
186+
def_id: DefId)
186187
-> Vec<ast::Attribute> {
187188
let cdata = cstore.get_crate_data(def_id.krate);
188189
decoder::get_item_attrs(&*cdata, def_id.node)
189190
}
190191

191-
pub fn get_struct_field_names(cstore: &cstore::CStore, def: ast::DefId) -> Vec<ast::Name> {
192+
pub fn get_struct_field_names(cstore: &cstore::CStore, def: DefId) -> Vec<ast::Name> {
192193
let cdata = cstore.get_crate_data(def.krate);
193194
decoder::get_struct_field_names(&cstore.intr, &*cdata, def.node)
194195
}
195196

196-
pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: ast::DefId) -> HashMap<ast::NodeId,
197+
pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: DefId) -> HashMap<ast::NodeId,
197198
Vec<ast::Attribute>> {
198199
let cdata = cstore.get_crate_data(def.krate);
199200
decoder::get_struct_field_attrs(&*cdata)
200201
}
201202

202203
pub fn get_type<'tcx>(tcx: &ty::ctxt<'tcx>,
203-
def: ast::DefId)
204+
def: DefId)
204205
-> ty::TypeScheme<'tcx> {
205206
let cstore = &tcx.sess.cstore;
206207
let cdata = cstore.get_crate_data(def.krate);
207208
decoder::get_type(&*cdata, def.node, tcx)
208209
}
209210

210-
pub fn get_trait_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> ty::TraitDef<'tcx> {
211+
pub fn get_trait_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::TraitDef<'tcx> {
211212
let cstore = &tcx.sess.cstore;
212213
let cdata = cstore.get_crate_data(def.krate);
213214
decoder::get_trait_def(&*cdata, def.node, tcx)
214215
}
215216

216-
pub fn get_adt_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> ty::AdtDefMaster<'tcx> {
217+
pub fn get_adt_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId) -> ty::AdtDefMaster<'tcx> {
217218
let cstore = &tcx.sess.cstore;
218219
let cdata = cstore.get_crate_data(def.krate);
219220
decoder::get_adt_def(&cstore.intr, &*cdata, def.node, tcx)
220221
}
221222

222-
pub fn get_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
223+
pub fn get_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId)
223224
-> ty::GenericPredicates<'tcx>
224225
{
225226
let cstore = &tcx.sess.cstore;
226227
let cdata = cstore.get_crate_data(def.krate);
227228
decoder::get_predicates(&*cdata, def.node, tcx)
228229
}
229230

230-
pub fn get_super_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
231+
pub fn get_super_predicates<'tcx>(tcx: &ty::ctxt<'tcx>, def: DefId)
231232
-> ty::GenericPredicates<'tcx>
232233
{
233234
let cstore = &tcx.sess.cstore;
234235
let cdata = cstore.get_crate_data(def.krate);
235236
decoder::get_super_predicates(&*cdata, def.node, tcx)
236237
}
237238

238-
pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
239-
def: ast::DefId) -> ty::TypeScheme<'tcx> {
239+
pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: DefId,
240+
def: DefId) -> ty::TypeScheme<'tcx> {
240241
let cstore = &tcx.sess.cstore;
241242
let cdata = cstore.get_crate_data(class_id.krate);
242243
let all_items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
@@ -261,7 +262,7 @@ pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
261262
}
262263

263264
pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
264-
def: ast::DefId)
265+
def: DefId)
265266
-> Option<ast::ImplPolarity>
266267
{
267268
let cstore = &tcx.sess.cstore;
@@ -270,7 +271,7 @@ pub fn get_impl_polarity<'tcx>(tcx: &ty::ctxt<'tcx>,
270271
}
271272

272273
pub fn get_custom_coerce_unsized_kind<'tcx>(tcx: &ty::ctxt<'tcx>,
273-
def: ast::DefId)
274+
def: DefId)
274275
-> Option<ty::CustomCoerceUnsized> {
275276
let cstore = &tcx.sess.cstore;
276277
let cdata = cstore.get_crate_data(def.krate);
@@ -280,7 +281,7 @@ pub fn get_custom_coerce_unsized_kind<'tcx>(tcx: &ty::ctxt<'tcx>,
280281
// Given a def_id for an impl, return the trait it implements,
281282
// if there is one.
282283
pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
283-
def: ast::DefId)
284+
def: DefId)
284285
-> Option<ty::TraitRef<'tcx>> {
285286
let cstore = &tcx.sess.cstore;
286287
let cdata = cstore.get_crate_data(def.krate);
@@ -294,18 +295,18 @@ pub fn get_native_libraries(cstore: &cstore::CStore, crate_num: ast::CrateNum)
294295
}
295296

296297
pub fn each_inherent_implementation_for_type<F>(cstore: &cstore::CStore,
297-
def_id: ast::DefId,
298+
def_id: DefId,
298299
callback: F) where
299-
F: FnMut(ast::DefId),
300+
F: FnMut(DefId),
300301
{
301302
let cdata = cstore.get_crate_data(def_id.krate);
302303
decoder::each_inherent_implementation_for_type(&*cdata, def_id.node, callback)
303304
}
304305

305306
pub fn each_implementation_for_trait<F>(cstore: &cstore::CStore,
306-
def_id: ast::DefId,
307+
def_id: DefId,
307308
mut callback: F) where
308-
F: FnMut(ast::DefId),
309+
F: FnMut(DefId),
309310
{
310311
cstore.iter_crate_data(|_, cdata| {
311312
decoder::each_implementation_for_trait(cdata, def_id, &mut callback)
@@ -316,16 +317,16 @@ pub fn each_implementation_for_trait<F>(cstore: &cstore::CStore,
316317
/// default method or an implementation of a trait method), returns the ID of
317318
/// the trait that the method belongs to. Otherwise, returns `None`.
318319
pub fn get_trait_of_item(cstore: &cstore::CStore,
319-
def_id: ast::DefId,
320+
def_id: DefId,
320321
tcx: &ty::ctxt)
321-
-> Option<ast::DefId> {
322+
-> Option<DefId> {
322323
let cdata = cstore.get_crate_data(def_id.krate);
323324
decoder::get_trait_of_item(&*cdata, def_id.node, tcx)
324325
}
325326

326327
pub fn get_tuple_struct_definition_if_ctor(cstore: &cstore::CStore,
327-
def_id: ast::DefId)
328-
-> Option<ast::DefId>
328+
def_id: DefId)
329+
-> Option<DefId>
329330
{
330331
let cdata = cstore.get_crate_data(def_id.krate);
331332
decoder::get_tuple_struct_definition_if_ctor(&*cdata, def_id.node)
@@ -346,37 +347,37 @@ pub fn get_missing_lang_items(cstore: &cstore::CStore, cnum: ast::CrateNum)
346347
decoder::get_missing_lang_items(&*cdata)
347348
}
348349

349-
pub fn get_method_arg_names(cstore: &cstore::CStore, did: ast::DefId)
350+
pub fn get_method_arg_names(cstore: &cstore::CStore, did: DefId)
350351
-> Vec<String>
351352
{
352353
let cdata = cstore.get_crate_data(did.krate);
353354
decoder::get_method_arg_names(&*cdata, did.node)
354355
}
355356

356357
pub fn get_reachable_ids(cstore: &cstore::CStore, cnum: ast::CrateNum)
357-
-> Vec<ast::DefId>
358+
-> Vec<DefId>
358359
{
359360
let cdata = cstore.get_crate_data(cnum);
360361
decoder::get_reachable_ids(&*cdata)
361362
}
362363

363-
pub fn is_typedef(cstore: &cstore::CStore, did: ast::DefId) -> bool {
364+
pub fn is_typedef(cstore: &cstore::CStore, did: DefId) -> bool {
364365
let cdata = cstore.get_crate_data(did.krate);
365366
decoder::is_typedef(&*cdata, did.node)
366367
}
367368

368-
pub fn is_const_fn(cstore: &cstore::CStore, did: ast::DefId) -> bool {
369+
pub fn is_const_fn(cstore: &cstore::CStore, did: DefId) -> bool {
369370
let cdata = cstore.get_crate_data(did.krate);
370371
decoder::is_const_fn(&*cdata, did.node)
371372
}
372373

373-
pub fn is_impl(cstore: &cstore::CStore, did: ast::DefId) -> bool {
374+
pub fn is_impl(cstore: &cstore::CStore, did: DefId) -> bool {
374375
let cdata = cstore.get_crate_data(did.krate);
375376
decoder::is_impl(&*cdata, did.node)
376377
}
377378

378379
pub fn get_stability(cstore: &cstore::CStore,
379-
def: ast::DefId)
380+
def: DefId)
380381
-> Option<attr::Stability> {
381382
let cdata = cstore.get_crate_data(def.krate);
382383
decoder::get_stability(&*cdata, def.node)
@@ -386,23 +387,23 @@ pub fn is_staged_api(cstore: &cstore::CStore, krate: ast::CrateNum) -> bool {
386387
cstore.get_crate_data(krate).staged_api
387388
}
388389

389-
pub fn get_repr_attrs(cstore: &cstore::CStore, def: ast::DefId)
390+
pub fn get_repr_attrs(cstore: &cstore::CStore, def: DefId)
390391
-> Vec<attr::ReprAttr> {
391392
let cdata = cstore.get_crate_data(def.krate);
392393
decoder::get_repr_attrs(&*cdata, def.node)
393394
}
394395

395-
pub fn is_defaulted_trait(cstore: &cstore::CStore, trait_def_id: ast::DefId) -> bool {
396+
pub fn is_defaulted_trait(cstore: &cstore::CStore, trait_def_id: DefId) -> bool {
396397
let cdata = cstore.get_crate_data(trait_def_id.krate);
397398
decoder::is_defaulted_trait(&*cdata, trait_def_id.node)
398399
}
399400

400-
pub fn is_default_impl(cstore: &cstore::CStore, impl_did: ast::DefId) -> bool {
401+
pub fn is_default_impl(cstore: &cstore::CStore, impl_did: DefId) -> bool {
401402
let cdata = cstore.get_crate_data(impl_did.krate);
402403
decoder::is_default_impl(&*cdata, impl_did.node)
403404
}
404405

405-
pub fn is_extern_fn(cstore: &cstore::CStore, did: ast::DefId,
406+
pub fn is_extern_fn(cstore: &cstore::CStore, did: DefId,
406407
tcx: &ty::ctxt) -> bool {
407408
let cdata = cstore.get_crate_data(did.krate);
408409
decoder::is_extern_fn(&*cdata, did.node, tcx)

0 commit comments

Comments
 (0)