Skip to content

Commit 34bd169

Browse files
committed
auto merge of #15091 : nikomatsakis/rust/issue-5527-rename-types, r=pcwalton
Some cleanups I'm sick of rebasing. r? @pcwalton (do you agree with new names?)
2 parents c9f3c68 + 8a4bb8a commit 34bd169

File tree

16 files changed

+177
-180
lines changed

16 files changed

+177
-180
lines changed

src/librustc/metadata/csearch.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub fn get_struct_fields(cstore: &cstore::CStore,
193193

194194
pub fn get_type(tcx: &ty::ctxt,
195195
def: ast::DefId)
196-
-> ty::ty_param_bounds_and_ty {
196+
-> ty::Polytype {
197197
let cstore = &tcx.sess.cstore;
198198
let cdata = cstore.get_crate_data(def.krate);
199199
decoder::get_type(&*cdata, def.node, tcx)
@@ -206,7 +206,7 @@ pub fn get_trait_def(tcx: &ty::ctxt, def: ast::DefId) -> ty::TraitDef {
206206
}
207207

208208
pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
209-
def: ast::DefId) -> ty::ty_param_bounds_and_ty {
209+
def: ast::DefId) -> ty::Polytype {
210210
let cstore = &tcx.sess.cstore;
211211
let cdata = cstore.get_crate_data(class_id.krate);
212212
let all_items = reader::get_doc(ebml::Doc::new(cdata.data()), tag_items);
@@ -224,7 +224,7 @@ pub fn get_field_type(tcx: &ty::ctxt, class_id: ast::DefId,
224224
def)).to_string()
225225
});
226226
let ty = decoder::item_type(def, the_field, tcx, &*cdata);
227-
ty::ty_param_bounds_and_ty {
227+
ty::Polytype {
228228
generics: ty::Generics {types: VecPerParamSpace::empty(),
229229
regions: VecPerParamSpace::empty()},
230230
ty: ty

src/librustc/metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ pub fn get_trait_def(cdata: Cmd,
422422
}
423423

424424
pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
425-
-> ty::ty_param_bounds_and_ty {
425+
-> ty::Polytype {
426426

427427
let item = lookup_item(id, cdata.data());
428428

@@ -432,7 +432,7 @@ pub fn get_type(cdata: Cmd, id: ast::NodeId, tcx: &ty::ctxt)
432432
let tp_defs = item_ty_param_defs(item, tcx, cdata, tag_items_data_item_ty_param_bounds);
433433
let rp_defs = item_region_param_defs(item, cdata);
434434

435-
ty::ty_param_bounds_and_ty {
435+
ty::Polytype {
436436
generics: ty::Generics {types: tp_defs,
437437
regions: rp_defs},
438438
ty: t

src/librustc/metadata/encoder.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,11 @@ fn encode_item_variances(ebml_w: &mut Encoder,
196196

197197
fn encode_bounds_and_type(ebml_w: &mut Encoder,
198198
ecx: &EncodeContext,
199-
tpt: &ty::ty_param_bounds_and_ty) {
200-
encode_ty_type_param_defs(ebml_w, ecx, &tpt.generics.types,
199+
pty: &ty::Polytype) {
200+
encode_ty_type_param_defs(ebml_w, ecx, &pty.generics.types,
201201
tag_items_data_item_ty_param_bounds);
202-
encode_region_param_defs(ebml_w, &tpt.generics.regions);
203-
encode_type(ecx, ebml_w, tpt.ty);
202+
encode_region_param_defs(ebml_w, &pty.generics.regions);
203+
encode_type(ecx, ebml_w, pty.ty);
204204
}
205205

206206
fn encode_variant_id(ebml_w: &mut Encoder, vid: DefId) {
@@ -772,8 +772,8 @@ fn encode_info_for_method(ecx: &EncodeContext,
772772
encode_stability(ebml_w, stab);
773773

774774
// The type for methods gets encoded twice, which is unfortunate.
775-
let tpt = lookup_item_type(ecx.tcx, m.def_id);
776-
encode_bounds_and_type(ebml_w, ecx, &tpt);
775+
let pty = lookup_item_type(ecx.tcx, m.def_id);
776+
encode_bounds_and_type(ebml_w, ecx, &pty);
777777

778778
let elem = ast_map::PathName(m.ident.name);
779779
encode_path(ebml_w, impl_path.chain(Some(elem).move_iter()));
@@ -785,7 +785,7 @@ fn encode_info_for_method(ecx: &EncodeContext,
785785
}
786786

787787
for &ast_method in ast_method_opt.iter() {
788-
let any_types = !tpt.generics.types.is_empty();
788+
let any_types = !pty.generics.types.is_empty();
789789
if any_types || is_default_impl || should_inline(ast_method.attrs.as_slice()) {
790790
encode_inlined_item(ecx, ebml_w,
791791
IIMethodRef(local_def(parent_id), false,
@@ -1218,8 +1218,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
12181218
fn_style_static_method_family(
12191219
method_ty.fty.fn_style));
12201220

1221-
let tpt = ty::lookup_item_type(tcx, method_def_id);
1222-
encode_bounds_and_type(ebml_w, ecx, &tpt);
1221+
let pty = ty::lookup_item_type(tcx, method_def_id);
1222+
encode_bounds_and_type(ebml_w, ecx, &pty);
12231223
}
12241224

12251225
_ => {
@@ -1242,8 +1242,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
12421242
// this.
12431243
if method_ty.explicit_self != SelfStatic {
12441244
// FIXME: I feel like there is something funny going on.
1245-
let tpt = ty::lookup_item_type(tcx, method_def_id);
1246-
encode_bounds_and_type(ebml_w, ecx, &tpt);
1245+
let pty = ty::lookup_item_type(tcx, method_def_id);
1246+
encode_bounds_and_type(ebml_w, ecx, &pty);
12471247
}
12481248
encode_method_sort(ebml_w, 'p');
12491249
encode_inlined_item(ecx, ebml_w,

src/librustc/middle/astencode.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,9 @@ trait ebml_writer_helpers {
839839
fn emit_type_param_def(&mut self,
840840
ecx: &e::EncodeContext,
841841
type_param_def: &ty::TypeParameterDef);
842-
fn emit_tpbt(&mut self,
843-
ecx: &e::EncodeContext,
844-
tpbt: ty::ty_param_bounds_and_ty);
842+
fn emit_polytype(&mut self,
843+
ecx: &e::EncodeContext,
844+
pty: ty::Polytype);
845845
fn emit_substs(&mut self, ecx: &e::EncodeContext, substs: &subst::Substs);
846846
fn emit_auto_adjustment(&mut self, ecx: &e::EncodeContext, adj: &ty::AutoAdjustment);
847847
}
@@ -865,26 +865,26 @@ impl<'a> ebml_writer_helpers for Encoder<'a> {
865865
});
866866
}
867867

868-
fn emit_tpbt(&mut self,
868+
fn emit_polytype(&mut self,
869869
ecx: &e::EncodeContext,
870-
tpbt: ty::ty_param_bounds_and_ty) {
871-
self.emit_struct("ty_param_bounds_and_ty", 2, |this| {
870+
pty: ty::Polytype) {
871+
self.emit_struct("Polytype", 2, |this| {
872872
this.emit_struct_field("generics", 0, |this| {
873873
this.emit_struct("Generics", 2, |this| {
874874
this.emit_struct_field("types", 0, |this| {
875875
Ok(encode_vec_per_param_space(
876-
this, &tpbt.generics.types,
876+
this, &pty.generics.types,
877877
|this, def| this.emit_type_param_def(ecx, def)))
878878
});
879879
this.emit_struct_field("regions", 1, |this| {
880880
Ok(encode_vec_per_param_space(
881-
this, &tpbt.generics.regions,
881+
this, &pty.generics.regions,
882882
|this, def| def.encode(this).unwrap()))
883883
})
884884
})
885885
});
886886
this.emit_struct_field("ty", 1, |this| {
887-
Ok(this.emit_ty(ecx, tpbt.ty))
887+
Ok(this.emit_ty(ecx, pty.ty))
888888
})
889889
});
890890
}
@@ -1030,11 +1030,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
10301030
}
10311031

10321032
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
1033-
for &tpbt in tcx.tcache.borrow().find(&lid).iter() {
1033+
for &pty in tcx.tcache.borrow().find(&lid).iter() {
10341034
ebml_w.tag(c::tag_table_tcache, |ebml_w| {
10351035
ebml_w.id(id);
10361036
ebml_w.tag(c::tag_table_val, |ebml_w| {
1037-
ebml_w.emit_tpbt(ecx, tpbt.clone());
1037+
ebml_w.emit_polytype(ecx, pty.clone());
10381038
})
10391039
})
10401040
}
@@ -1142,8 +1142,8 @@ trait ebml_decoder_decoder_helpers {
11421142
fn read_tys(&mut self, xcx: &ExtendedDecodeContext) -> Vec<ty::t>;
11431143
fn read_type_param_def(&mut self, xcx: &ExtendedDecodeContext)
11441144
-> ty::TypeParameterDef;
1145-
fn read_ty_param_bounds_and_ty(&mut self, xcx: &ExtendedDecodeContext)
1146-
-> ty::ty_param_bounds_and_ty;
1145+
fn read_polytype(&mut self, xcx: &ExtendedDecodeContext)
1146+
-> ty::Polytype;
11471147
fn read_substs(&mut self, xcx: &ExtendedDecodeContext) -> subst::Substs;
11481148
fn read_auto_adjustment(&mut self, xcx: &ExtendedDecodeContext) -> ty::AutoAdjustment;
11491149
fn convert_def_id(&mut self,
@@ -1245,10 +1245,10 @@ impl<'a> ebml_decoder_decoder_helpers for reader::Decoder<'a> {
12451245
}).unwrap()
12461246
}
12471247

1248-
fn read_ty_param_bounds_and_ty(&mut self, xcx: &ExtendedDecodeContext)
1249-
-> ty::ty_param_bounds_and_ty {
1250-
self.read_struct("ty_param_bounds_and_ty", 2, |this| {
1251-
Ok(ty::ty_param_bounds_and_ty {
1248+
fn read_polytype(&mut self, xcx: &ExtendedDecodeContext)
1249+
-> ty::Polytype {
1250+
self.read_struct("Polytype", 2, |this| {
1251+
Ok(ty::Polytype {
12521252
generics: this.read_struct_field("generics", 0, |this| {
12531253
this.read_struct("Generics", 2, |this| {
12541254
Ok(ty::Generics {
@@ -1408,9 +1408,9 @@ fn decode_side_tables(xcx: &ExtendedDecodeContext,
14081408
dcx.tcx.freevars.borrow_mut().insert(id, fv_info);
14091409
}
14101410
c::tag_table_tcache => {
1411-
let tpbt = val_dsr.read_ty_param_bounds_and_ty(xcx);
1411+
let pty = val_dsr.read_polytype(xcx);
14121412
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
1413-
dcx.tcx.tcache.borrow_mut().insert(lid, tpbt);
1413+
dcx.tcx.tcache.borrow_mut().insert(lid, pty);
14141414
}
14151415
c::tag_table_param_defs => {
14161416
let bounds = val_dsr.read_type_param_def(xcx);

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ fn check_while_true_expr(cx: &Context, e: &ast::Expr) {
721721
impl<'a> AstConv for Context<'a>{
722722
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }
723723

724-
fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty {
724+
fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
725725
ty::lookup_item_type(self.tcx, id)
726726
}
727727

src/librustc/middle/ty.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,21 +1026,16 @@ pub struct ParameterEnvironment {
10261026

10271027
/// A polytype.
10281028
///
1029-
/// - `bounds`: The list of bounds for each type parameter. The length of the
1030-
/// list also tells you how many type parameters there are.
1031-
///
1032-
/// - `rp`: true if the type is region-parameterized. Types can have at
1033-
/// most one region parameter, always called `&self`.
1034-
///
1035-
/// - `ty`: the base type. May have reference to the (unsubstituted) bound
1036-
/// region `&self` or to (unsubstituted) ty_param types
1029+
/// - `generics`: the set of type parameters and their bounds
1030+
/// - `ty`: the base types, which may reference the parameters defined
1031+
/// in `generics`
10371032
#[deriving(Clone)]
1038-
pub struct ty_param_bounds_and_ty {
1033+
pub struct Polytype {
10391034
pub generics: Generics,
10401035
pub ty: t
10411036
}
10421037

1043-
/// As `ty_param_bounds_and_ty` but for a trait ref.
1038+
/// As `Polytype` but for a trait ref.
10441039
pub struct TraitDef {
10451040
pub generics: Generics,
10461041
pub bounds: BuiltinBounds,
@@ -1054,12 +1049,7 @@ pub struct ItemSubsts {
10541049
pub substs: Substs,
10551050
}
10561051

1057-
pub struct ty_param_substs_and_ty {
1058-
pub substs: Substs,
1059-
pub ty: ty::t
1060-
}
1061-
1062-
pub type type_cache = RefCell<DefIdMap<ty_param_bounds_and_ty>>;
1052+
pub type type_cache = RefCell<DefIdMap<Polytype>>;
10631053

10641054
pub type node_type_table = RefCell<HashMap<uint,t>>;
10651055

@@ -3848,7 +3838,7 @@ pub fn enum_variant_with_id(cx: &ctxt,
38483838
// the type cache. Returns the type parameters and type.
38493839
pub fn lookup_item_type(cx: &ctxt,
38503840
did: ast::DefId)
3851-
-> ty_param_bounds_and_ty {
3841+
-> Polytype {
38523842
lookup_locally_or_in_crate_store(
38533843
"tcache", did, &mut *cx.tcache.borrow_mut(),
38543844
|| csearch::get_type(cx, did))
@@ -3946,7 +3936,7 @@ pub fn lookup_field_type(tcx: &ctxt,
39463936
} else {
39473937
let mut tcache = tcx.tcache.borrow_mut();
39483938
match tcache.find(&id) {
3949-
Some(&ty_param_bounds_and_ty {ty, ..}) => ty,
3939+
Some(&Polytype {ty, ..}) => ty,
39503940
None => {
39513941
let tpt = csearch::get_field_type(tcx, struct_id, id);
39523942
tcache.insert(id, tpt.clone());

src/librustc/middle/typeck/astconv.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ use middle::const_eval;
5353
use middle::def;
5454
use middle::lang_items::FnMutTraitLangItem;
5555
use rl = middle::resolve_lifetime;
56-
use middle::subst::{Subst, Substs};
57-
use middle::subst;
58-
use middle::ty::ty_param_substs_and_ty;
56+
use middle::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs};
5957
use middle::ty;
58+
use middle::typeck::TypeAndSubsts;
6059
use middle::typeck::lookup_def_tcx;
6160
use middle::typeck::rscope::RegionScope;
6261
use middle::typeck::rscope;
@@ -71,7 +70,7 @@ use syntax::print::pprust::{lifetime_to_str, path_to_str};
7170

7271
pub trait AstConv {
7372
fn tcx<'a>(&'a self) -> &'a ty::ctxt;
74-
fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty;
73+
fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype;
7574
fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef>;
7675

7776
// what type should we use when a type is omitted?
@@ -154,7 +153,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
154153
rscope: &RS,
155154
decl_generics: &ty::Generics,
156155
self_ty: Option<ty::t>,
157-
path: &ast::Path) -> subst::Substs
156+
path: &ast::Path) -> Substs
158157
{
159158
/*!
160159
* Given a path `path` that refers to an item `I` with the
@@ -172,13 +171,13 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
172171
// Note: in the case of traits, the self parameter is also
173172
// defined, but we don't currently create a `type_param_def` for
174173
// `Self` because it is implicit.
175-
assert!(decl_generics.regions.all(|d| d.space == subst::TypeSpace));
176-
assert!(decl_generics.types.all(|d| d.space != subst::FnSpace));
174+
assert!(decl_generics.regions.all(|d| d.space == TypeSpace));
175+
assert!(decl_generics.types.all(|d| d.space != FnSpace));
177176

178177
// If the type is parameterized by the this region, then replace this
179178
// region with the current anon region binding (in other words,
180179
// whatever & would get replaced with).
181-
let expected_num_region_params = decl_generics.regions.len(subst::TypeSpace);
180+
let expected_num_region_params = decl_generics.regions.len(TypeSpace);
182181
let supplied_num_region_params = path.segments.last().unwrap().lifetimes.len();
183182
let regions = if expected_num_region_params == supplied_num_region_params {
184183
path.segments.last().unwrap().lifetimes.iter().map(
@@ -204,7 +203,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
204203
};
205204

206205
// Convert the type parameters supplied by the user.
207-
let ty_param_defs = decl_generics.types.get_vec(subst::TypeSpace);
206+
let ty_param_defs = decl_generics.types.get_vec(TypeSpace);
208207
let supplied_ty_param_count = path.segments.iter().flat_map(|s| s.types.iter()).count();
209208
let formal_ty_param_count = ty_param_defs.len();
210209
let required_ty_param_count = ty_param_defs.iter()
@@ -246,7 +245,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
246245
.map(|a_t| ast_ty_to_ty(this, rscope, &**a_t))
247246
.collect();
248247

249-
let mut substs = subst::Substs::new_type(tps, regions);
248+
let mut substs = Substs::new_type(tps, regions);
250249

251250
match self_ty {
252251
None => {
@@ -258,14 +257,14 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
258257
// "declared" (in other words, this should be a
259258
// trait-ref).
260259
assert!(decl_generics.types.get_self().is_some());
261-
substs.types.push(subst::SelfSpace, ty);
260+
substs.types.push(SelfSpace, ty);
262261
}
263262
}
264263

265264
for param in ty_param_defs.slice_from(supplied_ty_param_count).iter() {
266265
let default = param.default.unwrap();
267266
let default = default.subst_spanned(tcx, &substs, Some(path.span));
268-
substs.types.push(subst::TypeSpace, default);
267+
substs.types.push(TypeSpace, default);
269268
}
270269

271270
substs
@@ -289,17 +288,17 @@ pub fn ast_path_to_ty<AC:AstConv,RS:RegionScope>(
289288
rscope: &RS,
290289
did: ast::DefId,
291290
path: &ast::Path)
292-
-> ty_param_substs_and_ty
291+
-> TypeAndSubsts
293292
{
294293
let tcx = this.tcx();
295-
let ty::ty_param_bounds_and_ty {
294+
let ty::Polytype {
296295
generics: generics,
297296
ty: decl_ty
298297
} = this.get_item_ty(did);
299298

300299
let substs = ast_path_substs(this, rscope, &generics, None, path);
301300
let ty = decl_ty.subst(tcx, &substs);
302-
ty_param_substs_and_ty { substs: substs, ty: ty }
301+
TypeAndSubsts { substs: substs, ty: ty }
303302
}
304303

305304
pub static NO_REGIONS: uint = 1;
@@ -547,11 +546,11 @@ pub fn trait_ref_for_unboxed_function<AC:AstConv,
547546
let output_type = ast_ty_to_ty(this,
548547
rscope,
549548
&*unboxed_function.decl.output);
550-
let mut substs = subst::Substs::new_type(vec!(input_tuple, output_type),
549+
let mut substs = Substs::new_type(vec!(input_tuple, output_type),
551550
Vec::new());
552551

553552
match self_ty {
554-
Some(s) => substs.types.push(subst::SelfSpace, s),
553+
Some(s) => substs.types.push(SelfSpace, s),
555554
None => ()
556555
}
557556

0 commit comments

Comments
 (0)