Skip to content

Commit 217f963

Browse files
committed
auto merge of #6224 : erickt/rust/rustc-cleanup, r=erickt
Just a couple minor cleanups and renames of librustc
2 parents 31cedf6 + 729708d commit 217f963

Some content is hidden

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

56 files changed

+605
-588
lines changed

src/librustc/metadata/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub static tag_mod_impl_trait: uint = 0x47u;
100100
different tags.
101101
*/
102102
pub static tag_item_impl_method: uint = 0x48u;
103-
pub static tag_item_trait_method_self_ty: uint = 0x4b;
103+
pub static tag_item_trait_method_explicit_self: uint = 0x4b;
104104
pub static tag_item_trait_method_self_ty_region: uint = 0x4c;
105105

106106

src/librustc/metadata/csearch.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use syntax::ast_map;
2222
use syntax::diagnostic::expect;
2323

2424
pub struct ProvidedTraitMethodInfo {
25-
ty: ty::method,
25+
ty: ty::Method,
2626
def_id: ast::def_id
2727
}
2828

@@ -129,17 +129,18 @@ pub fn get_impls_for_mod(cstore: @mut cstore::CStore, def: ast::def_id,
129129
}
130130

131131
pub fn get_method(tcx: ty::ctxt,
132-
def: ast::def_id) -> ty::method
132+
def: ast::def_id) -> ty::Method
133133
{
134134
let cdata = cstore::get_crate_data(tcx.cstore, def.crate);
135135
decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx)
136136
}
137137

138-
pub fn get_method_name_and_self_ty(cstore: @mut cstore::CStore,
139-
def: ast::def_id) -> (ast::ident, ast::self_ty_)
138+
pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore,
139+
def: ast::def_id)
140+
-> (ast::ident, ast::explicit_self_)
140141
{
141142
let cdata = cstore::get_crate_data(cstore, def.crate);
142-
decoder::get_method_name_and_self_ty(cstore.intr, cdata, def.node)
143+
decoder::get_method_name_and_explicit_self(cstore.intr, cdata, def.node)
143144
}
144145

145146
pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore,

src/librustc/metadata/decoder.rs

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id,
653653
item, tcx, cdata);
654654
let name = item_name(intr, item);
655655
let arg_tys = match ty::get(ctor_ty).sty {
656-
ty::ty_bare_fn(ref f) => f.sig.inputs.map(|a| a.ty),
656+
ty::ty_bare_fn(ref f) => copy f.sig.inputs,
657657
_ => ~[], // Nullary enum variant.
658658
};
659659
match variant_disr_val(item) {
@@ -670,7 +670,7 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id,
670670
return infos;
671671
}
672672

673-
fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
673+
fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
674674
fn get_mutability(ch: u8) -> ast::mutability {
675675
match ch as char {
676676
'i' => { ast::m_imm }
@@ -682,11 +682,11 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
682682
}
683683
}
684684

685-
let self_type_doc = reader::get_doc(item, tag_item_trait_method_self_ty);
686-
let string = reader::doc_as_str(self_type_doc);
685+
let explicit_self_doc = reader::get_doc(item, tag_item_trait_method_explicit_self);
686+
let string = reader::doc_as_str(explicit_self_doc);
687687

688-
let self_ty_kind = string[0];
689-
match self_ty_kind as char {
688+
let explicit_self_kind = string[0];
689+
match explicit_self_kind as char {
690690
's' => { return ast::sty_static; }
691691
'v' => { return ast::sty_value; }
692692
'@' => { return ast::sty_box(get_mutability(string[1])); }
@@ -696,7 +696,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
696696
return ast::sty_region(None, get_mutability(string[1]));
697697
}
698698
_ => {
699-
fail!("unknown self type code: `%c`", self_ty_kind as char);
699+
fail!("unknown self type code: `%c`", explicit_self_kind as char);
700700
}
701701
}
702702
}
@@ -707,12 +707,12 @@ fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc,
707707
for reader::tagged_docs(item, tag_item_impl_method) |doc| {
708708
let m_did = reader::with_doc_data(doc, |d| parse_def_id(d));
709709
let mth_item = lookup_item(m_did.node, cdata.data);
710-
let self_ty = get_self_ty(mth_item);
710+
let explicit_self = get_explicit_self(mth_item);
711711
rslt.push(@resolve::MethodInfo {
712712
did: translate_def_id(cdata, m_did),
713713
n_tps: item_ty_param_count(mth_item) - base_tps,
714714
ident: item_name(intr, mth_item),
715-
self_type: self_ty});
715+
explicit_self: explicit_self});
716716
}
717717
rslt
718718
}
@@ -748,19 +748,19 @@ pub fn get_impls_for_mod(intr: @ident_interner,
748748
@result
749749
}
750750

751-
pub fn get_method_name_and_self_ty(
751+
pub fn get_method_name_and_explicit_self(
752752
intr: @ident_interner,
753753
cdata: cmd,
754-
id: ast::node_id) -> (ast::ident, ast::self_ty_)
754+
id: ast::node_id) -> (ast::ident, ast::explicit_self_)
755755
{
756756
let method_doc = lookup_item(id, cdata.data);
757757
let name = item_name(intr, method_doc);
758-
let self_ty = get_self_ty(method_doc);
759-
(name, self_ty)
758+
let explicit_self = get_explicit_self(method_doc);
759+
(name, explicit_self)
760760
}
761761

762762
pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
763-
tcx: ty::ctxt) -> ty::method
763+
tcx: ty::ctxt) -> ty::Method
764764
{
765765
let method_doc = lookup_item(id, cdata.data);
766766
let def_id = item_def_id(method_doc, cdata);
@@ -770,19 +770,20 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
770770
let transformed_self_ty = doc_transformed_self_ty(method_doc, tcx, cdata);
771771
let fty = doc_method_fty(method_doc, tcx, cdata);
772772
let vis = item_visibility(method_doc);
773-
let self_ty = get_self_ty(method_doc);
774-
ty::method {
775-
ident: name,
776-
generics: ty::Generics {
773+
let explicit_self = get_explicit_self(method_doc);
774+
775+
ty::Method::new(
776+
name,
777+
ty::Generics {
777778
type_param_defs: type_param_defs,
778779
region_param: None
779780
},
780-
transformed_self_ty: transformed_self_ty,
781-
fty: fty,
782-
self_ty: self_ty,
783-
vis: vis,
784-
def_id: def_id
785-
}
781+
transformed_self_ty,
782+
fty,
783+
explicit_self,
784+
vis,
785+
def_id
786+
)
786787
}
787788

788789
pub fn get_trait_method_def_ids(cdata: cmd,
@@ -823,19 +824,20 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
823824
};
824825

825826
let transformed_self_ty = doc_transformed_self_ty(mth, tcx, cdata);
826-
let self_ty = get_self_ty(mth);
827-
let ty_method = ty::method {
828-
ident: name,
829-
generics: ty::Generics {
827+
let explicit_self = get_explicit_self(mth);
828+
829+
let ty_method = ty::Method::new(
830+
name,
831+
ty::Generics {
830832
type_param_defs: type_param_defs,
831833
region_param: None
832834
},
833-
transformed_self_ty: transformed_self_ty,
834-
fty: fty,
835-
self_ty: self_ty,
836-
vis: ast::public,
837-
def_id: did
838-
};
835+
transformed_self_ty,
836+
fty,
837+
explicit_self,
838+
ast::public,
839+
did
840+
);
839841
let provided_trait_method_info = ProvidedTraitMethodInfo {
840842
ty: ty_method,
841843
def_id: did

src/librustc/metadata/encoder.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ fn encode_path(ecx: @EncodeContext,
366366
fn encode_reexported_static_method(ecx: @EncodeContext,
367367
ebml_w: &mut writer::Encoder,
368368
exp: &middle::resolve::Export2,
369-
m: @ty::method) {
369+
m: @ty::Method) {
370370
debug!("(encode static trait method) reexport '%s::%s'",
371371
*exp.name, *ecx.tcx.sess.str_of(m.ident));
372372
ebml_w.start_tag(tag_items_data_item_reexport);
@@ -389,7 +389,7 @@ fn encode_reexported_static_methods(ecx: @EncodeContext,
389389
Some(&ast_map::node_item(_, path)) => {
390390
if mod_path != *path {
391391
for methods.each |&m| {
392-
if m.self_ty == ast::sty_static {
392+
if m.explicit_self == ast::sty_static {
393393
encode_reexported_static_method(ecx,
394394
ebml_w,
395395
exp, m);
@@ -486,11 +486,11 @@ fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) {
486486
ebml_w.end_tag();
487487
}
488488

489-
fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) {
490-
ebml_w.start_tag(tag_item_trait_method_self_ty);
489+
fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explicit_self_) {
490+
ebml_w.start_tag(tag_item_trait_method_explicit_self);
491491

492492
// Encode the base self type.
493-
match self_type {
493+
match explicit_self {
494494
sty_static => {
495495
ebml_w.writer.write(&[ 's' as u8 ]);
496496
}
@@ -625,7 +625,7 @@ fn encode_info_for_struct_ctor(ecx: @EncodeContext,
625625

626626
fn encode_method_ty_fields(ecx: @EncodeContext,
627627
ebml_w: &mut writer::Encoder,
628-
method_ty: &ty::method) {
628+
method_ty: &ty::Method) {
629629
encode_def_id(ebml_w, method_ty.def_id);
630630
encode_name(ecx, ebml_w, method_ty.ident);
631631
encode_ty_type_param_defs(ebml_w, ecx,
@@ -634,7 +634,7 @@ fn encode_method_ty_fields(ecx: @EncodeContext,
634634
encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty);
635635
encode_method_fty(ecx, ebml_w, &method_ty.fty);
636636
encode_visibility(ebml_w, method_ty.vis);
637-
encode_self_type(ebml_w, method_ty.self_ty);
637+
encode_explicit_self(ebml_w, method_ty.explicit_self);
638638
}
639639

640640
fn encode_info_for_method(ecx: @EncodeContext,
@@ -652,10 +652,10 @@ fn encode_info_for_method(ecx: @EncodeContext,
652652
ebml_w.start_tag(tag_items_data_item);
653653

654654
let method_def_id = local_def(m.id);
655-
let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id);
655+
let method_ty = ty::method(ecx.tcx, method_def_id);
656656
encode_method_ty_fields(ecx, ebml_w, method_ty);
657657

658-
match m.self_ty.node {
658+
match m.explicit_self.node {
659659
ast::sty_static => {
660660
encode_family(ebml_w, purity_static_method_family(m.purity));
661661
}
@@ -948,7 +948,7 @@ fn encode_info_for_item(ecx: @EncodeContext,
948948
for ty::trait_method_def_ids(tcx, local_def(item.id)).eachi |i, &method_def_id| {
949949
assert!(method_def_id.crate == ast::local_crate);
950950

951-
let method_ty: @ty::method = ty::method(tcx, method_def_id);
951+
let method_ty = ty::method(tcx, method_def_id);
952952

953953
index.push(entry {val: method_def_id.node, pos: ebml_w.writer.tell()});
954954

@@ -962,7 +962,7 @@ fn encode_info_for_item(ecx: @EncodeContext,
962962
trait_path.push(ast_map::path_name(item.ident));
963963
encode_path(ecx, ebml_w, trait_path, ast_map::path_name(method_ty.ident));
964964

965-
match method_ty.self_ty {
965+
match method_ty.explicit_self {
966966
sty_static => {
967967
encode_family(ebml_w,
968968
purity_static_method_family(
@@ -991,7 +991,7 @@ fn encode_info_for_item(ecx: @EncodeContext,
991991
// This is obviously a bogus assert but I don't think this
992992
// ever worked before anyhow...near as I can tell, before
993993
// we would emit two items.
994-
if method_ty.self_ty == sty_static {
994+
if method_ty.explicit_self == sty_static {
995995
tcx.sess.span_unimpl(
996996
item.span,
997997
fmt!("Method %s is both provided and static",

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ pub fn parse_trait_ref_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ct
126126
parse_trait_ref(st, conv)
127127
}
128128

129-
pub fn parse_arg_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
130-
conv: conv_did) -> ty::arg {
131-
let st = parse_state_from_data(data, crate_num, pos, tcx);
132-
parse_arg(st, conv)
133-
}
134-
135129
fn parse_path(st: @mut PState) -> @ast::Path {
136130
let mut idents: ~[ast::ident] = ~[];
137131
fn is_last(c: char) -> bool { return c == '(' || c == ':'; }
@@ -471,12 +465,6 @@ fn parse_onceness(c: char) -> ast::Onceness {
471465
}
472466
}
473467

474-
fn parse_arg(st: @mut PState, conv: conv_did) -> ty::arg {
475-
ty::arg {
476-
ty: parse_ty(st, conv)
477-
}
478-
}
479-
480468
fn parse_closure_ty(st: @mut PState, conv: conv_did) -> ty::ClosureTy {
481469
let sigil = parse_sigil(st);
482470
let purity = parse_purity(next(st));
@@ -505,9 +493,9 @@ fn parse_bare_fn_ty(st: @mut PState, conv: conv_did) -> ty::BareFnTy {
505493

506494
fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
507495
assert!((next(st) == '['));
508-
let mut inputs: ~[ty::arg] = ~[];
496+
let mut inputs = ~[];
509497
while peek(st) != ']' {
510-
inputs.push(ty::arg { ty: parse_ty(st, conv) });
498+
inputs.push(parse_ty(st, conv));
511499
}
512500
st.pos += 1u; // eat the ']'
513501
let ret_ty = parse_ty(st, conv);

src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,6 @@ fn enc_sigil(w: @io::Writer, sigil: Sigil) {
344344
}
345345
}
346346

347-
pub fn enc_arg(w: @io::Writer, cx: @ctxt, arg: ty::arg) {
348-
enc_ty(w, cx, arg.ty);
349-
}
350-
351347
fn enc_purity(w: @io::Writer, p: purity) {
352348
match p {
353349
pure_fn => w.write_char('p'),
@@ -389,8 +385,8 @@ fn enc_closure_ty(w: @io::Writer, cx: @ctxt, ft: &ty::ClosureTy) {
389385

390386
fn enc_fn_sig(w: @io::Writer, cx: @ctxt, fsig: &ty::FnSig) {
391387
w.write_char('[');
392-
for fsig.inputs.each |arg| {
393-
enc_arg(w, cx, *arg);
388+
for fsig.inputs.each |ty| {
389+
enc_ty(w, cx, *ty);
394390
}
395391
w.write_char(']');
396392
enc_ty(w, cx, fsig.output);

0 commit comments

Comments
 (0)