Skip to content

Commit ab71c18

Browse files
committed
rustdoc: Update for new impl syntax
1 parent 99a5715 commit ab71c18

File tree

8 files changed

+39
-37
lines changed

8 files changed

+39
-37
lines changed

src/rustdoc/attr_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,14 @@ fn fold_impl(
271271
#[test]
272272
fn should_extract_impl_docs() {
273273
let doc = test::mk_doc(
274-
~"#[doc = \"whatever\"] impl i for int { fn a() { } }");
274+
~"#[doc = \"whatever\"] impl int { fn a() { } }");
275275
assert doc.cratemod().impls()[0].desc() == some(~"whatever");
276276
}
277277

278278
#[test]
279279
fn should_extract_impl_method_docs() {
280280
let doc = test::mk_doc(
281-
~"impl i for int {\
281+
~"impl int {\
282282
#[doc = \"desc\"]\
283283
fn f(a: bool) -> bool { }\
284284
}");

src/rustdoc/desc_to_brief_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn should_promote_trait_method_desc() {
7777
#[test]
7878
fn should_promote_impl_method_desc() {
7979
let doc = test::mk_doc(
80-
~"impl i for int { #[doc = \"desc\"] fn a() { } }");
80+
~"impl int { #[doc = \"desc\"] fn a() { } }");
8181
assert doc.cratemod().impls()[0].methods[0].brief == some(~"desc");
8282
}
8383

src/rustdoc/extract.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,9 @@ fn impldoc_from_impl(
248248
}
249249
}
250250

251-
#[test]
252-
fn should_extract_impls_with_names() {
253-
let doc = test::mk_doc(~"impl i for int { fn a() { } }");
254-
assert doc.cratemod().impls()[0].name() == ~"i";
255-
}
256-
257-
#[test]
258-
fn should_extract_impls_without_names() {
259-
let doc = test::mk_doc(~"impl of i for int { fn a() { } }");
260-
assert doc.cratemod().impls()[0].name() == ~"i";
261-
}
262-
263251
#[test]
264252
fn should_extract_impl_methods() {
265-
let doc = test::mk_doc(~"impl i for int { fn f() { } }");
253+
let doc = test::mk_doc(~"impl int { fn f() { } }");
266254
assert doc.cratemod().impls()[0].methods[0].name == ~"f";
267255
}
268256

src/rustdoc/markdown_pass.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,21 @@ fn header_name(doc: doc::itemtag) -> ~str {
241241
}
242242

243243
fn header_text(doc: doc::itemtag) -> ~str {
244-
header_text_(header_kind(doc), header_name(doc))
244+
match doc {
245+
doc::impltag(impldoc) => {
246+
let header_kind = header_kind(doc);
247+
let desc = if impldoc.trait_types.is_empty() {
248+
fmt!{"for `%s`", impldoc.self_ty.get()}
249+
} else {
250+
fmt!{"of `%s` for `%s`", impldoc.trait_types[0],
251+
impldoc.self_ty.get()}
252+
};
253+
fmt!{"%s %s", header_kind, desc}
254+
}
255+
_ => {
256+
header_text_(header_kind(doc), header_name(doc))
257+
}
258+
}
245259
}
246260

247261
fn header_text_(kind: ~str, name: ~str) -> ~str {
@@ -697,34 +711,34 @@ fn write_impl(ctxt: ctxt, doc: doc::impldoc) {
697711

698712
#[test]
699713
fn should_write_impl_header() {
700-
let markdown = test::render(~"impl i for int { fn a() { } }");
701-
assert str::contains(markdown, ~"## Implementation `i for int`");
714+
let markdown = test::render(~"impl int { fn a() { } }");
715+
assert str::contains(markdown, ~"## Implementation for `int`");
702716
}
703717

704718
#[test]
705719
fn should_write_impl_header_with_trait() {
706-
let markdown = test::render(~"impl i of j for int { fn a() { } }");
707-
assert str::contains(markdown, ~"## Implementation `i of j for int`");
720+
let markdown = test::render(~"impl int: j { fn a() { } }");
721+
assert str::contains(markdown, ~"## Implementation of `j` for `int`");
708722
}
709723

710724
#[test]
711725
fn should_write_impl_desc() {
712726
let markdown = test::render(
713-
~"#[doc = \"desc\"] impl i for int { fn a() { } }");
727+
~"#[doc = \"desc\"] impl int { fn a() { } }");
714728
assert str::contains(markdown, ~"desc");
715729
}
716730

717731
#[test]
718732
fn should_write_impl_method_header() {
719733
let markdown = test::render(
720-
~"impl i for int { fn a() { } }");
734+
~"impl int { fn a() { } }");
721735
assert str::contains(markdown, ~"### Method `a`");
722736
}
723737

724738
#[test]
725739
fn should_write_impl_method_signature() {
726740
let markdown = test::render(
727-
~"impl i for int { fn a() { } }");
741+
~"impl int { fn a() { } }");
728742
assert str::contains(markdown, ~"\n fn a()");
729743
}
730744

src/rustdoc/sectionalize_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ fn should_sectionalize_trait_methods() {
217217
#[test]
218218
fn should_sectionalize_impl_methods() {
219219
let doc = test::mk_doc(
220-
~"impl i for bool {
220+
~"impl bool {
221221
#[doc = \"\
222222
# Header\n\
223223
Body\"]\

src/rustdoc/sort_item_type_pass.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fn test() {
3434
fn ifn() { } \
3535
enum ienum { ivar } \
3636
trait itrait { fn a(); } \
37-
impl iimpl for int { fn a() { } } \
37+
impl int { fn a() { } } \
3838
type itype = int;";
3939
do astsrv::from_str(source) |srv| {
4040
let doc = extract::from_srv(srv, ~"");
@@ -43,7 +43,7 @@ fn test() {
4343
assert doc.cratemod().items[1].name() == ~"itype";
4444
assert doc.cratemod().items[2].name() == ~"ienum";
4545
assert doc.cratemod().items[3].name() == ~"itrait";
46-
assert doc.cratemod().items[4].name() == ~"iimpl";
46+
assert doc.cratemod().items[4].name() == ~"__extensions__";
4747
assert doc.cratemod().items[5].name() == ~"ifn";
4848
assert doc.cratemod().items[6].name() == ~"imod";
4949
assert doc.cratemod().items[7].name() == ~"inmod";

src/rustdoc/text_pass.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,28 +145,28 @@ fn should_execute_op_on_trait_method_desc() {
145145
#[test]
146146
fn should_execute_op_on_impl_brief() {
147147
let doc = test::mk_doc(
148-
~"#[doc = \" a \"] impl i for int { fn a() { } }");
148+
~"#[doc = \" a \"] impl int { fn a() { } }");
149149
assert doc.cratemod().impls()[0].brief() == some(~"a");
150150
}
151151

152152
#[test]
153153
fn should_execute_op_on_impl_desc() {
154154
let doc = test::mk_doc(
155-
~"#[doc = \" a \"] impl i for int { fn a() { } }");
155+
~"#[doc = \" a \"] impl int { fn a() { } }");
156156
assert doc.cratemod().impls()[0].desc() == some(~"a");
157157
}
158158

159159
#[test]
160160
fn should_execute_op_on_impl_method_brief() {
161161
let doc = test::mk_doc(
162-
~"impl i for int { #[doc = \" a \"] fn a() { } }");
162+
~"impl int { #[doc = \" a \"] fn a() { } }");
163163
assert doc.cratemod().impls()[0].methods[0].brief == some(~"a");
164164
}
165165

166166
#[test]
167167
fn should_execute_op_on_impl_method_desc() {
168168
let doc = test::mk_doc(
169-
~"impl i for int { #[doc = \" a \"] fn a() { } }");
169+
~"impl int { #[doc = \" a \"] fn a() { } }");
170170
assert doc.cratemod().impls()[0].methods[0].desc == some(~"a");
171171
}
172172

@@ -230,7 +230,7 @@ fn should_execute_on_trait_method_section_bodies() {
230230
#[test]
231231
fn should_execute_on_impl_method_section_headers() {
232232
let doc = test::mk_doc(
233-
~"impl i for bool {
233+
~"impl bool {
234234
#[doc = \"\
235235
# Header \n\
236236
Body\"]\
@@ -242,7 +242,7 @@ fn should_execute_on_impl_method_section_headers() {
242242
#[test]
243243
fn should_execute_on_impl_method_section_bodies() {
244244
let doc = test::mk_doc(
245-
~"impl i for bool {
245+
~"impl bool {
246246
#[doc = \"\
247247
# Header\n\
248248
Body \"]\

src/rustdoc/tystr_pass.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,25 +254,25 @@ fn fold_impl(
254254

255255
#[test]
256256
fn should_add_impl_trait_types() {
257-
let doc = test::mk_doc(~"impl i of j for int { fn a<T>() { } }");
257+
let doc = test::mk_doc(~"impl int: j { fn a<T>() { } }");
258258
assert doc.cratemod().impls()[0].trait_types[0] == ~"j";
259259
}
260260

261261
#[test]
262262
fn should_not_add_impl_trait_types_if_none() {
263-
let doc = test::mk_doc(~"impl i for int { fn a() { } }");
263+
let doc = test::mk_doc(~"impl int { fn a() { } }");
264264
assert vec::len(doc.cratemod().impls()[0].trait_types) == 0;
265265
}
266266

267267
#[test]
268268
fn should_add_impl_self_ty() {
269-
let doc = test::mk_doc(~"impl i for int { fn a() { } }");
269+
let doc = test::mk_doc(~"impl int { fn a() { } }");
270270
assert doc.cratemod().impls()[0].self_ty == some(~"int");
271271
}
272272

273273
#[test]
274274
fn should_add_impl_method_sigs() {
275-
let doc = test::mk_doc(~"impl i for int { fn a<T>() -> int { fail } }");
275+
let doc = test::mk_doc(~"impl int { fn a<T>() -> int { fail } }");
276276
assert doc.cratemod().impls()[0].methods[0].sig
277277
== some(~"fn a<T>() -> int");
278278
}

0 commit comments

Comments
 (0)