Skip to content

Commit 141377b

Browse files
committed
---
yaml --- r: 152017 b: refs/heads/try2 c: 9181c35 h: refs/heads/master i: 152015: 514a461 v: v3
1 parent 5ed00c9 commit 141377b

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 6ee9109c8b1eb170b7fb6fac6d248801dcd42817
8+
refs/heads/try2: 9181c35ee925240fc129d77695e3f88c6d5f0f2b
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/metadata/encoder.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -774,23 +774,27 @@ fn encode_info_for_method(ecx: &EncodeContext,
774774
} else {
775775
encode_symbol(ecx, ebml_w, m.def_id.node);
776776
}
777+
encode_method_argument_names(ebml_w, &*ast_method.decl);
778+
}
777779

778-
ebml_w.start_tag(tag_method_argument_names);
779-
for arg in ast_method.decl.inputs.iter() {
780-
ebml_w.start_tag(tag_method_argument_name);
781-
match arg.pat.node {
782-
ast::PatIdent(_, ref name, _) => {
783-
let name = name.segments.last().unwrap().identifier;
784-
let name = token::get_ident(name);
785-
ebml_w.writer.write(name.get().as_bytes());
786-
}
787-
_ => {}
780+
ebml_w.end_tag();
781+
}
782+
783+
fn encode_method_argument_names(ebml_w: &mut Encoder,
784+
decl: &ast::FnDecl) {
785+
ebml_w.start_tag(tag_method_argument_names);
786+
for arg in decl.inputs.iter() {
787+
ebml_w.start_tag(tag_method_argument_name);
788+
match arg.pat.node {
789+
ast::PatIdent(_, ref name, _) => {
790+
let name = name.segments.last().unwrap().identifier;
791+
let name = token::get_ident(name);
792+
ebml_w.writer.write(name.get().as_bytes());
788793
}
789-
ebml_w.end_tag();
794+
_ => {}
790795
}
791796
ebml_w.end_tag();
792797
}
793-
794798
ebml_w.end_tag();
795799
}
796800

@@ -910,7 +914,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
910914
encode_visibility(ebml_w, vis);
911915
ebml_w.end_tag();
912916
}
913-
ItemFn(_, fn_style, _, ref generics, _) => {
917+
ItemFn(ref decl, fn_style, _, ref generics, _) => {
914918
add_to_index(item, ebml_w, index);
915919
ebml_w.start_tag(tag_items_data_item);
916920
encode_def_id(ebml_w, def_id);
@@ -926,6 +930,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
926930
encode_symbol(ecx, ebml_w, item.id);
927931
}
928932
encode_visibility(ebml_w, vis);
933+
encode_method_argument_names(ebml_w, &**decl);
929934
ebml_w.end_tag();
930935
}
931936
ItemMod(ref m) => {

branches/try2/src/librustdoc/clean.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -722,18 +722,35 @@ impl Clean<FnDecl> for ast::FnDecl {
722722
}
723723
}
724724

725-
impl Clean<FnDecl> for ty::FnSig {
725+
impl<'a> Clean<FnDecl> for (ast::DefId, &'a ty::FnSig) {
726726
fn clean(&self) -> FnDecl {
727+
let cx = super::ctxtkey.get().unwrap();
728+
let tcx = match cx.maybe_typed {
729+
core::Typed(ref tcx) => tcx,
730+
core::NotTyped(_) => fail!(),
731+
};
732+
let (did, sig) = *self;
733+
let mut names = if did.node != 0 {
734+
csearch::get_method_arg_names(&tcx.sess.cstore, did).move_iter()
735+
} else {
736+
Vec::new().move_iter()
737+
}.peekable();
738+
if names.peek().map(|s| s.as_slice()) == Some("self") {
739+
let _ = names.next();
740+
}
741+
if did.node == 0 {
742+
let _ = names.len();
743+
}
727744
FnDecl {
728-
output: self.output.clean(),
745+
output: sig.output.clean(),
729746
cf: Return,
730-
attrs: Vec::new(), // FIXME: this is likely wrong
747+
attrs: Vec::new(),
731748
inputs: Arguments {
732-
values: self.inputs.iter().map(|t| {
749+
values: sig.inputs.iter().map(|t| {
733750
Argument {
734751
type_: t.clean(),
735752
id: 0,
736-
name: "".to_strbuf(), // FIXME: where are the names?
753+
name: names.next().unwrap_or("".to_strbuf()),
737754
}
738755
}).collect(),
739756
},
@@ -868,15 +885,6 @@ impl Clean<TraitMethod> for ty::Method {
868885
(s, sig)
869886
}
870887
};
871-
let mut names = csearch::get_method_arg_names(&tcx.sess.cstore,
872-
self.def_id).move_iter();
873-
if self_ != SelfStatic {
874-
names.next();
875-
}
876-
let mut decl = sig.clean();
877-
for (name, slot) in names.zip(decl.inputs.values.mut_iter()) {
878-
slot.name = name;
879-
}
880888

881889
m(Item {
882890
name: Some(self.ident.clean()),
@@ -888,7 +896,7 @@ impl Clean<TraitMethod> for ty::Method {
888896
fn_style: self.fty.fn_style,
889897
generics: self.generics.clean(),
890898
self_: self_,
891-
decl: decl,
899+
decl: (self.def_id, &sig).clean(),
892900
})
893901
})
894902
}
@@ -1005,13 +1013,13 @@ impl Clean<Type> for ty::t {
10051013
generics: Generics {
10061014
lifetimes: Vec::new(), type_params: Vec::new()
10071015
},
1008-
decl: fty.sig.clean(),
1016+
decl: (ast_util::local_def(0), &fty.sig).clean(),
10091017
abi: fty.abi.to_str().to_strbuf(),
10101018
}),
10111019
ty::ty_closure(ref fty) => {
10121020
let decl = box ClosureDecl {
10131021
lifetimes: Vec::new(), // FIXME: this looks wrong...
1014-
decl: fty.sig.clean(),
1022+
decl: (ast_util::local_def(0), &fty.sig).clean(),
10151023
onceness: fty.onceness,
10161024
fn_style: fty.fn_style,
10171025
bounds: fty.bounds.iter().map(|i| i.clean()).collect(),
@@ -1855,7 +1863,7 @@ fn build_external_function(tcx: &ty::ctxt,
18551863
let t = ty::lookup_item_type(tcx, did);
18561864
Function {
18571865
decl: match ty::get(t.ty).sty {
1858-
ty::ty_bare_fn(ref f) => f.sig.clean(),
1866+
ty::ty_bare_fn(ref f) => (did, &f.sig).clean(),
18591867
_ => fail!("bad function"),
18601868
},
18611869
generics: t.generics.clean(),

0 commit comments

Comments
 (0)