Skip to content

Commit 5bc9895

Browse files
committed
rustc: fix fallout of adding the 'tcx lifetime to Ty.
1 parent 92ae0c6 commit 5bc9895

Some content is hidden

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

86 files changed

+4003
-3735
lines changed

src/librustc/lint/builtin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,8 @@ declare_lint!(BOX_POINTERS, Allow,
474474
pub struct BoxPointers;
475475

476476
impl BoxPointers {
477-
fn check_heap_type(&self, cx: &Context, span: Span, ty: Ty) {
477+
fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
478+
span: Span, ty: Ty<'tcx>) {
478479
let mut n_uniq = 0i;
479480
ty::fold_ty(cx.tcx, ty, |t| {
480481
match ty::get(t).sty {

src/librustc/lint/context.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -546,30 +546,30 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
546546
impl<'a, 'tcx> AstConv<'tcx> for Context<'a, 'tcx>{
547547
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx }
548548

549-
fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
549+
fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
550550
ty::lookup_item_type(self.tcx, id)
551551
}
552552

553-
fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef> {
553+
fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
554554
ty::lookup_trait_def(self.tcx, id)
555555
}
556556

557-
fn ty_infer(&self, _span: Span) -> Ty {
557+
fn ty_infer(&self, _span: Span) -> Ty<'tcx> {
558558
infer::new_infer_ctxt(self.tcx).next_ty_var()
559559
}
560560

561-
fn associated_types_of_trait_are_valid(&self, _: Ty, _: ast::DefId)
561+
fn associated_types_of_trait_are_valid(&self, _: Ty<'tcx>, _: ast::DefId)
562562
-> bool {
563563
// FIXME(pcwalton): This is wrong.
564564
true
565565
}
566566

567567
fn associated_type_binding(&self,
568568
_: Span,
569-
_: Option<Ty>,
569+
_: Option<Ty<'tcx>>,
570570
trait_id: ast::DefId,
571571
associated_type_id: ast::DefId)
572-
-> Ty {
572+
-> Ty<'tcx> {
573573
// FIXME(pcwalton): This is wrong.
574574
let trait_def = self.get_trait_def(trait_id);
575575
let index = ty::associated_type_parameter_index(self.tcx,

src/librustc/metadata/csearch.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ pub fn get_enum_variant_defs(cstore: &cstore::CStore, enum_id: ast::DefId)
123123
decoder::get_enum_variant_defs(&*cstore.intr, &*cdata, enum_id.node)
124124
}
125125

126-
pub fn get_enum_variants(tcx: &ty::ctxt, def: ast::DefId)
127-
-> Vec<Rc<ty::VariantInfo>> {
126+
pub fn get_enum_variants<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
127+
-> Vec<Rc<ty::VariantInfo<'tcx>>> {
128128
let cstore = &tcx.sess.cstore;
129129
let cdata = cstore.get_crate_data(def.krate);
130130
decoder::get_enum_variants(cstore.intr.clone(), &*cdata, def.node, tcx)
@@ -137,8 +137,8 @@ pub fn get_impl_items(cstore: &cstore::CStore, impl_def_id: ast::DefId)
137137
decoder::get_impl_items(&*cdata, impl_def_id.node)
138138
}
139139

140-
pub fn get_impl_or_trait_item(tcx: &ty::ctxt, def: ast::DefId)
141-
-> ty::ImplOrTraitItem {
140+
pub fn get_impl_or_trait_item<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId)
141+
-> ty::ImplOrTraitItem<'tcx> {
142142
let cdata = tcx.sess.cstore.get_crate_data(def.krate);
143143
decoder::get_impl_or_trait_item(tcx.sess.cstore.intr.clone(),
144144
&*cdata,
@@ -166,15 +166,17 @@ pub fn get_item_variances(cstore: &cstore::CStore,
166166
decoder::get_item_variances(&*cdata, def.node)
167167
}
168168

169-
pub fn get_provided_trait_methods(tcx: &ty::ctxt,
170-
def: ast::DefId)
171-
-> Vec<Rc<ty::Method>> {
169+
pub fn get_provided_trait_methods<'tcx>(tcx: &ty::ctxt<'tcx>,
170+
def: ast::DefId)
171+
-> Vec<Rc<ty::Method<'tcx>>> {
172172
let cstore = &tcx.sess.cstore;
173173
let cdata = cstore.get_crate_data(def.krate);
174174
decoder::get_provided_trait_methods(cstore.intr.clone(), &*cdata, def.node, tcx)
175175
}
176176

177-
pub fn get_supertraits(tcx: &ty::ctxt, def: ast::DefId) -> Vec<Rc<ty::TraitRef>> {
177+
pub fn get_supertraits<'tcx>(tcx: &ty::ctxt<'tcx>,
178+
def: ast::DefId)
179+
-> Vec<Rc<ty::TraitRef<'tcx>>> {
178180
let cstore = &tcx.sess.cstore;
179181
let cdata = cstore.get_crate_data(def.krate);
180182
decoder::get_supertraits(&*cdata, def.node, tcx)
@@ -213,22 +215,22 @@ pub fn get_struct_field_attrs(cstore: &cstore::CStore, def: ast::DefId) -> HashM
213215
decoder::get_struct_field_attrs(&*cdata)
214216
}
215217

216-
pub fn get_type(tcx: &ty::ctxt,
217-
def: ast::DefId)
218-
-> ty::Polytype {
218+
pub fn get_type<'tcx>(tcx: &ty::ctxt<'tcx>,
219+
def: ast::DefId)
220+
-> ty::Polytype<'tcx> {
219221
let cstore = &tcx.sess.cstore;
220222
let cdata = cstore.get_crate_data(def.krate);
221223
decoder::get_type(&*cdata, def.node, tcx)
222224
}
223225

224-
pub fn get_trait_def(tcx: &ty::ctxt, def: ast::DefId) -> ty::TraitDef {
226+
pub fn get_trait_def<'tcx>(tcx: &ty::ctxt<'tcx>, def: ast::DefId) -> ty::TraitDef<'tcx> {
225227
let cstore = &tcx.sess.cstore;
226228
let cdata = cstore.get_crate_data(def.krate);
227229
decoder::get_trait_def(&*cdata, def.node, tcx)
228230
}
229231

230-
pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
231-
def: ast::DefId) -> ty::Polytype {
232+
pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
233+
def: ast::DefId) -> ty::Polytype<'tcx> {
232234
let cstore = &tcx.sess.cstore;
233235
let cdata = cstore.get_crate_data(class_id.krate);
234236
let all_items = reader::get_doc(rbml::Doc::new(cdata.data()), tag_items);
@@ -255,17 +257,18 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
255257

256258
// Given a def_id for an impl, return the trait it implements,
257259
// if there is one.
258-
pub fn get_impl_trait(tcx: &ty::ctxt,
259-
def: ast::DefId) -> Option<Rc<ty::TraitRef>> {
260+
pub fn get_impl_trait<'tcx>(tcx: &ty::ctxt<'tcx>,
261+
def: ast::DefId)
262+
-> Option<Rc<ty::TraitRef<'tcx>>> {
260263
let cstore = &tcx.sess.cstore;
261264
let cdata = cstore.get_crate_data(def.krate);
262265
decoder::get_impl_trait(&*cdata, def.node, tcx)
263266
}
264267

265268
// Given a def_id for an impl, return information about its vtables
266-
pub fn get_impl_vtables(tcx: &ty::ctxt,
267-
def: ast::DefId)
268-
-> typeck::vtable_res {
269+
pub fn get_impl_vtables<'tcx>(tcx: &ty::ctxt<'tcx>,
270+
def: ast::DefId)
271+
-> typeck::vtable_res<'tcx> {
269272
let cstore = &tcx.sess.cstore;
270273
let cdata = cstore.get_crate_data(def.krate);
271274
decoder::get_impl_vtables(&*cdata, def.node, tcx)

src/librustc/metadata/decoder.rs

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -224,39 +224,44 @@ fn variant_disr_val(d: rbml::Doc) -> Option<ty::Disr> {
224224
})
225225
}
226226

227-
fn doc_type(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> Ty {
227+
fn doc_type<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
228228
let tp = reader::get_doc(doc, tag_items_data_item_type);
229229
parse_ty_data(tp.data, cdata.cnum, tp.start, tcx,
230230
|_, did| translate_def_id(cdata, did))
231231
}
232232

233-
fn doc_method_fty(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::BareFnTy {
233+
fn doc_method_fty<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>,
234+
cdata: Cmd) -> ty::BareFnTy<'tcx> {
234235
let tp = reader::get_doc(doc, tag_item_method_fty);
235236
parse_bare_fn_ty_data(tp.data, cdata.cnum, tp.start, tcx,
236237
|_, did| translate_def_id(cdata, did))
237238
}
238239

239-
pub fn item_type(_item_id: ast::DefId, item: rbml::Doc,
240-
tcx: &ty::ctxt, cdata: Cmd) -> Ty {
240+
pub fn item_type<'tcx>(_item_id: ast::DefId, item: rbml::Doc,
241+
tcx: &ty::ctxt<'tcx>, cdata: Cmd) -> Ty<'tcx> {
241242
doc_type(item, tcx, cdata)
242243
}
243244

244-
fn doc_trait_ref(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::TraitRef {
245+
fn doc_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
246+
-> ty::TraitRef<'tcx> {
245247
parse_trait_ref_data(doc.data, cdata.cnum, doc.start, tcx,
246248
|_, did| translate_def_id(cdata, did))
247249
}
248250

249-
fn item_trait_ref(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::TraitRef {
251+
fn item_trait_ref<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
252+
-> ty::TraitRef<'tcx> {
250253
let tp = reader::get_doc(doc, tag_item_trait_ref);
251254
doc_trait_ref(tp, tcx, cdata)
252255
}
253256

254-
fn doc_bounds(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::ParamBounds {
257+
fn doc_bounds<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
258+
-> ty::ParamBounds<'tcx> {
255259
parse_bounds_data(doc.data, cdata.cnum, doc.start, tcx,
256260
|_, did| translate_def_id(cdata, did))
257261
}
258262

259-
fn trait_def_bounds(doc: rbml::Doc, tcx: &ty::ctxt, cdata: Cmd) -> ty::ParamBounds {
263+
fn trait_def_bounds<'tcx>(doc: rbml::Doc, tcx: &ty::ctxt<'tcx>, cdata: Cmd)
264+
-> ty::ParamBounds<'tcx> {
260265
let d = reader::get_doc(doc, tag_trait_def_bounds);
261266
doc_bounds(d, tcx, cdata)
262267
}
@@ -353,9 +358,9 @@ fn item_to_def_like(item: rbml::Doc, did: ast::DefId, cnum: ast::CrateNum)
353358
}
354359
}
355360

356-
pub fn get_trait_def(cdata: Cmd,
357-
item_id: ast::NodeId,
358-
tcx: &ty::ctxt) -> ty::TraitDef
361+
pub fn get_trait_def<'tcx>(cdata: Cmd,
362+
item_id: ast::NodeId,
363+
tcx: &ty::ctxt<'tcx>) -> ty::TraitDef<'tcx>
359364
{
360365
let item_doc = lookup_item(item_id, cdata.data());
361366
let generics = doc_generics(item_doc, tcx, cdata, tag_item_generics);
@@ -368,8 +373,8 @@ pub fn get_trait_def(cdata: Cmd,
368373
}
369374
}
370375

371-
pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
372-
-> ty::Polytype {
376+
pub fn get_type<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
377+
-> ty::Polytype<'tcx> {
373378

374379
let item = lookup_item(id, cdata.data());
375380

@@ -403,20 +408,21 @@ pub fn get_repr_attrs(cdata: Cmd, id: ast::NodeId) -> Vec<attr::ReprAttr> {
403408
}
404409
}
405410

406-
pub fn get_impl_trait(cdata: Cmd,
407-
id: ast::NodeId,
408-
tcx: &ty::ctxt) -> Option<Rc<ty::TraitRef>>
411+
pub fn get_impl_trait<'tcx>(cdata: Cmd,
412+
id: ast::NodeId,
413+
tcx: &ty::ctxt<'tcx>)
414+
-> Option<Rc<ty::TraitRef<'tcx>>>
409415
{
410416
let item_doc = lookup_item(id, cdata.data());
411417
reader::maybe_get_doc(item_doc, tag_item_trait_ref).map(|tp| {
412418
Rc::new(doc_trait_ref(tp, tcx, cdata))
413419
})
414420
}
415421

416-
pub fn get_impl_vtables(cdata: Cmd,
417-
id: ast::NodeId,
418-
tcx: &ty::ctxt)
419-
-> typeck::vtable_res
422+
pub fn get_impl_vtables<'tcx>(cdata: Cmd,
423+
id: ast::NodeId,
424+
tcx: &ty::ctxt<'tcx>)
425+
-> typeck::vtable_res<'tcx>
420426
{
421427
let item_doc = lookup_item(id, cdata.data());
422428
let vtables_doc = reader::get_doc(item_doc, tag_item_impl_vtables);
@@ -682,8 +688,8 @@ pub fn get_enum_variant_defs(intr: &IdentInterner,
682688
}).collect()
683689
}
684690

685-
pub fn get_enum_variants(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId,
686-
tcx: &ty::ctxt) -> Vec<Rc<ty::VariantInfo>> {
691+
pub fn get_enum_variants<'tcx>(intr: Rc<IdentInterner>, cdata: Cmd, id: ast::NodeId,
692+
tcx: &ty::ctxt<'tcx>) -> Vec<Rc<ty::VariantInfo<'tcx>>> {
687693
let data = cdata.data();
688694
let items = reader::get_doc(rbml::Doc::new(data), tag_items);
689695
let item = find_item(id, items);
@@ -786,11 +792,11 @@ pub fn get_trait_item_name_and_kind(intr: Rc<IdentInterner>,
786792
}
787793
}
788794

789-
pub fn get_impl_or_trait_item(intr: Rc<IdentInterner>,
790-
cdata: Cmd,
791-
id: ast::NodeId,
792-
tcx: &ty::ctxt)
793-
-> ty::ImplOrTraitItem {
795+
pub fn get_impl_or_trait_item<'tcx>(intr: Rc<IdentInterner>,
796+
cdata: Cmd,
797+
id: ast::NodeId,
798+
tcx: &ty::ctxt<'tcx>)
799+
-> ty::ImplOrTraitItem<'tcx> {
794800
let method_doc = lookup_item(id, cdata.data());
795801

796802
let def_id = item_def_id(method_doc, cdata);
@@ -860,11 +866,11 @@ pub fn get_item_variances(cdata: Cmd, id: ast::NodeId) -> ty::ItemVariances {
860866
Decodable::decode(&mut decoder).unwrap()
861867
}
862868

863-
pub fn get_provided_trait_methods(intr: Rc<IdentInterner>,
864-
cdata: Cmd,
865-
id: ast::NodeId,
866-
tcx: &ty::ctxt)
867-
-> Vec<Rc<ty::Method>> {
869+
pub fn get_provided_trait_methods<'tcx>(intr: Rc<IdentInterner>,
870+
cdata: Cmd,
871+
id: ast::NodeId,
872+
tcx: &ty::ctxt<'tcx>)
873+
-> Vec<Rc<ty::Method<'tcx>>> {
868874
let data = cdata.data();
869875
let item = lookup_item(id, data);
870876
let mut result = Vec::new();
@@ -892,8 +898,8 @@ pub fn get_provided_trait_methods(intr: Rc<IdentInterner>,
892898
}
893899

894900
/// Returns the supertraits of the given trait.
895-
pub fn get_supertraits(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
896-
-> Vec<Rc<ty::TraitRef>> {
901+
pub fn get_supertraits<'tcx>(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt<'tcx>)
902+
-> Vec<Rc<ty::TraitRef<'tcx>>> {
897903
let mut results = Vec::new();
898904
let item_doc = lookup_item(id, cdata.data());
899905
reader::tagged_docs(item_doc, tag_item_super_trait_ref, |trait_doc| {
@@ -1388,11 +1394,11 @@ pub fn is_typedef(cdata: Cmd, id: ast::NodeId) -> bool {
13881394
}
13891395
}
13901396

1391-
fn doc_generics(base_doc: rbml::Doc,
1392-
tcx: &ty::ctxt,
1393-
cdata: Cmd,
1394-
tag: uint)
1395-
-> ty::Generics
1397+
fn doc_generics<'tcx>(base_doc: rbml::Doc,
1398+
tcx: &ty::ctxt<'tcx>,
1399+
cdata: Cmd,
1400+
tag: uint)
1401+
-> ty::Generics<'tcx>
13961402
{
13971403
let doc = reader::get_doc(base_doc, tag);
13981404

0 commit comments

Comments
 (0)