Skip to content

Commit f54adca

Browse files
committed
auto merge of #5374 : z0w0/rust/rustdoc-explicit-self, r=z0w0
2 parents 6307d24 + 246573d commit f54adca

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/librustdoc/markdown_pass.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,8 @@ fn should_write_trait_method_header() {
734734
#[test]
735735
fn should_write_trait_method_signature() {
736736
let markdown = test::render(
737-
~"trait i { fn a(); }");
738-
fail_unless!(str::contains(markdown, ~"\n fn a()"));
737+
~"trait i { fn a(&self); }");
738+
fail_unless!(str::contains(markdown, ~"\n fn a(&self)"));
739739
}
740740
741741
fn write_impl(ctxt: &Ctxt, doc: doc::ImplDoc) {
@@ -773,8 +773,8 @@ fn should_write_impl_method_header() {
773773
#[test]
774774
fn should_write_impl_method_signature() {
775775
let markdown = test::render(
776-
~"impl int { fn a() { } }");
777-
fail_unless!(str::contains(markdown, ~"\n fn a()"));
776+
~"impl int { fn a(&mut self) { } }");
777+
fail_unless!(str::contains(markdown, ~"\n fn a(&mut self)"));
778778
}
779779
780780
fn write_type(

src/librustdoc/tystr_pass.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
7575
ident: ident,
7676
node: ast::foreign_item_fn(ref decl, _, ref tys), _
7777
}, _, _) => {
78-
Some(pprust::fun_to_str(decl, ident, tys,
78+
Some(pprust::fun_to_str(decl, ident, None, tys,
7979
extract::interner()))
8080
}
8181
_ => fail!(~"get_fn_sig: fn_id not bound to a fn item")
@@ -215,6 +215,7 @@ fn get_method_sig(
215215
Some(pprust::fun_to_str(
216216
&ty_m.decl,
217217
ty_m.ident,
218+
Some(ty_m.self_ty.node),
218219
&ty_m.generics,
219220
extract::interner()
220221
))
@@ -223,6 +224,7 @@ fn get_method_sig(
223224
Some(pprust::fun_to_str(
224225
&m.decl,
225226
m.ident,
227+
Some(m.self_ty.node),
226228
&m.generics,
227229
extract::interner()
228230
))
@@ -242,6 +244,7 @@ fn get_method_sig(
242244
Some(pprust::fun_to_str(
243245
&method.decl,
244246
method.ident,
247+
Some(method.self_ty.node),
245248
&method.generics,
246249
extract::interner()
247250
))
@@ -256,9 +259,9 @@ fn get_method_sig(
256259
257260
#[test]
258261
fn should_add_trait_method_sigs() {
259-
let doc = test::mk_doc(~"trait i { fn a<T>() -> int; }");
262+
let doc = test::mk_doc(~"trait i { fn a<T>(&mut self) -> int; }");
260263
fail_unless!(doc.cratemod().traits()[0].methods[0].sig
261-
== Some(~"fn a<T>() -> int"));
264+
== Some(~"fn a<T>(&mut self) -> int"));
262265
}
263266
264267
fn fold_impl(
@@ -315,9 +318,9 @@ fn should_add_impl_self_ty() {
315318
316319
#[test]
317320
fn should_add_impl_method_sigs() {
318-
let doc = test::mk_doc(~"impl int { fn a<T>() -> int { fail!() } }");
321+
let doc = test::mk_doc(~"impl int { fn a<T>(&self) -> int { fail!() } }");
319322
fail_unless!(doc.cratemod().impls()[0].methods[0].sig
320-
== Some(~"fn a<T>() -> int"));
323+
== Some(~"fn a<T>(&self) -> int"));
321324
}
322325
323326
fn fold_type(

src/libsyntax/print/pprust.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ pub fn path_to_str(&&p: @ast::path, intr: @ident_interner) -> ~str {
181181
}
182182

183183
pub fn fun_to_str(decl: &ast::fn_decl, name: ast::ident,
184+
opt_self_ty: Option<ast::self_ty_>,
184185
generics: &ast::Generics, intr: @ident_interner) -> ~str {
185186
do io::with_str_writer |wr| {
186187
let s = rust_printer(wr, intr);
187-
print_fn(s, decl, None, name, generics, None, ast::inherited);
188+
print_fn(s, decl, None, name, generics, opt_self_ty, ast::inherited);
188189
end(s); // Close the head box
189190
end(s); // Close the outer box
190191
eof(s.s);
@@ -2274,7 +2275,7 @@ pub mod test {
22742275
cf: ast::return_val
22752276
};
22762277
let generics = ast_util::empty_generics();
2277-
check_equal (&fun_to_str(&decl, abba_ident, &generics, mock_interner),
2278+
check_equal (&fun_to_str(&decl, abba_ident, None, &generics, mock_interner),
22782279
&~"fn abba()");
22792280
}
22802281

0 commit comments

Comments
 (0)