Skip to content

Commit 87acde8

Browse files
committed
rustdoc: Remove structural records from tests. Fixes build breakage
1 parent 0aef28d commit 87acde8

14 files changed

+75
-83
lines changed

src/librustdoc/attr_pass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ fn fold_crate(
7070
};
7171

7272
doc::CrateDoc {
73-
topmod: doc::ModDoc_(doc::ModDoc_ {
73+
topmod: doc::ModDoc {
7474
item: doc::ItemDoc {
7575
name: option::get_or_default(attrs.name, doc.topmod.name()),
7676
.. doc.topmod.item
7777
},
78-
.. *doc.topmod
79-
})
78+
.. doc.topmod
79+
}
8080
}
8181
}
8282

src/librustdoc/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ fn maybe_find_pandoc(
256256

257257
#[test]
258258
fn should_find_pandoc() {
259-
let config = {
259+
let config = Config {
260260
output_format: PandocHtml,
261261
.. default_config(&Path("test"))
262262
};
@@ -273,7 +273,7 @@ fn should_find_pandoc() {
273273

274274
#[test]
275275
fn should_error_with_no_pandoc() {
276-
let config = {
276+
let config = Config {
277277
output_format: PandocHtml,
278278
.. default_config(&Path("test"))
279279
};

src/librustdoc/doc.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@ use core::vec;
2222
pub type AstId = int;
2323

2424
#[deriving_eq]
25-
pub struct Doc_ {
25+
pub struct Doc {
2626
pages: ~[Page]
2727
}
2828

29-
#[deriving_eq]
30-
pub enum Doc {
31-
Doc_(Doc_)
32-
}
33-
3429
#[deriving_eq]
3530
pub enum Page {
3631
CratePage(CrateDoc),
@@ -93,17 +88,12 @@ pub struct SimpleItemDoc {
9388
}
9489

9590
#[deriving_eq]
96-
pub struct ModDoc_ {
91+
pub struct ModDoc {
9792
item: ItemDoc,
9893
items: ~[ItemTag],
9994
index: Option<Index>
10095
}
10196

102-
#[deriving_eq]
103-
pub enum ModDoc {
104-
ModDoc_(ModDoc_)
105-
}
106-
10797
#[deriving_eq]
10898
pub struct NmodDoc {
10999
item: ItemDoc,

src/librustdoc/extract.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ pub fn extract(
5757
crate: @ast::crate,
5858
+default_name: ~str
5959
) -> doc::Doc {
60-
doc::Doc_(doc::Doc_ {
60+
doc::Doc {
6161
pages: ~[
6262
doc::CratePage(doc::CrateDoc {
6363
topmod: top_moddoc_from_crate(crate, default_name),
6464
})
6565
]
66-
})
66+
}
6767
}
6868

6969
fn top_moddoc_from_crate(
@@ -90,7 +90,7 @@ fn moddoc_from_mod(
9090
+itemdoc: doc::ItemDoc,
9191
module_: ast::_mod
9292
) -> doc::ModDoc {
93-
doc::ModDoc_(doc::ModDoc_ {
93+
doc::ModDoc {
9494
item: itemdoc,
9595
items: do vec::filter_map(module_.items) |item| {
9696
let ItemDoc = mk_itemdoc(item.id, to_str(item.ident));
@@ -144,7 +144,7 @@ fn moddoc_from_mod(
144144
}
145145
},
146146
index: None
147-
})
147+
}
148148
}
149149

150150
fn nmoddoc_from_mod(

src/librustdoc/fold.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub fn default_par_fold<T:Owned Clone>(+ctxt: T) -> Fold<T> {
158158
}
159159

160160
pub fn default_seq_fold_doc<T>(fold: &Fold<T>, +doc: doc::Doc) -> doc::Doc {
161-
doc::Doc_(doc::Doc_ {
161+
doc::Doc {
162162
pages: do vec::map(doc.pages) |page| {
163163
match *page {
164164
doc::CratePage(doc) => {
@@ -169,8 +169,8 @@ pub fn default_seq_fold_doc<T>(fold: &Fold<T>, +doc: doc::Doc) -> doc::Doc {
169169
}
170170
}
171171
},
172-
.. *doc
173-
})
172+
.. doc
173+
}
174174
}
175175

176176
pub fn default_seq_fold_crate<T>(
@@ -194,40 +194,40 @@ pub fn default_any_fold_mod<T:Owned Clone>(
194194
+doc: doc::ModDoc
195195
) -> doc::ModDoc {
196196
let fold_copy = fold.clone();
197-
doc::ModDoc_(doc::ModDoc_ {
197+
doc::ModDoc {
198198
item: (fold.fold_item)(fold, doc.item),
199199
items: par::map(doc.items, |ItemTag, move fold_copy| {
200200
fold_ItemTag(&fold_copy, *ItemTag)
201201
}),
202-
.. *doc
203-
})
202+
.. doc
203+
}
204204
}
205205

206206
pub fn default_seq_fold_mod<T>(
207207
fold: &Fold<T>,
208208
+doc: doc::ModDoc
209209
) -> doc::ModDoc {
210-
doc::ModDoc_(doc::ModDoc_ {
210+
doc::ModDoc {
211211
item: (fold.fold_item)(fold, doc.item),
212212
items: vec::map(doc.items, |ItemTag| {
213213
fold_ItemTag(fold, *ItemTag)
214214
}),
215-
.. *doc
216-
})
215+
.. doc
216+
}
217217
}
218218

219219
pub fn default_par_fold_mod<T:Owned Clone>(
220220
fold: &Fold<T>,
221221
+doc: doc::ModDoc
222222
) -> doc::ModDoc {
223223
let fold_copy = fold.clone();
224-
doc::ModDoc_(doc::ModDoc_ {
224+
doc::ModDoc {
225225
item: (fold.fold_item)(fold, doc.item),
226226
items: par::map(doc.items, |ItemTag, move fold_copy| {
227227
fold_ItemTag(&fold_copy, *ItemTag)
228228
}),
229-
.. *doc
230-
})
229+
.. doc
230+
}
231231
}
232232

233233
pub fn default_any_fold_nmod<T:Owned Clone>(

src/librustdoc/markdown_index_pass.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ fn fold_mod(
5454

5555
let doc = fold::default_any_fold_mod(fold, doc);
5656

57-
doc::ModDoc_(doc::ModDoc_ {
57+
doc::ModDoc {
5858
index: Some(build_mod_index(doc, fold.ctxt)),
59-
.. *doc
60-
})
59+
.. doc
60+
}
6161
}
6262

6363
fn fold_nmod(
@@ -180,13 +180,13 @@ fn should_index_mod_contents() {
180180
config::DocPerCrate,
181181
~"mod a { } fn b() { }"
182182
);
183-
assert doc.cratemod().index.get().entries[0] == {
183+
assert doc.cratemod().index.get().entries[0] == doc::IndexEntry {
184184
kind: ~"Module",
185185
name: ~"a",
186186
brief: None,
187187
link: ~"#module-a"
188188
};
189-
assert doc.cratemod().index.get().entries[1] == {
189+
assert doc.cratemod().index.get().entries[1] == doc::IndexEntry {
190190
kind: ~"Function",
191191
name: ~"b",
192192
brief: None,
@@ -200,13 +200,13 @@ fn should_index_mod_contents_multi_page() {
200200
config::DocPerMod,
201201
~"mod a { } fn b() { }"
202202
);
203-
assert doc.cratemod().index.get().entries[0] == {
203+
assert doc.cratemod().index.get().entries[0] == doc::IndexEntry {
204204
kind: ~"Module",
205205
name: ~"a",
206206
brief: None,
207207
link: ~"a.html"
208208
};
209-
assert doc.cratemod().index.get().entries[1] == {
209+
assert doc.cratemod().index.get().entries[1] == doc::IndexEntry {
210210
kind: ~"Function",
211211
name: ~"b",
212212
brief: None,
@@ -220,7 +220,7 @@ fn should_index_foreign_mod_pages() {
220220
config::DocPerMod,
221221
~"extern mod a { }"
222222
);
223-
assert doc.cratemod().index.get().entries[0] == {
223+
assert doc.cratemod().index.get().entries[0] == doc::IndexEntry {
224224
kind: ~"Foreign module",
225225
name: ~"a",
226226
brief: None,
@@ -244,7 +244,8 @@ fn should_index_foreign_mod_contents() {
244244
config::DocPerCrate,
245245
~"extern mod a { fn b(); }"
246246
);
247-
assert doc.cratemod().nmods()[0].index.get().entries[0] == {
247+
assert doc.cratemod().nmods()[0].index.get().entries[0]
248+
== doc::IndexEntry {
248249
kind: ~"Function",
249250
name: ~"b",
250251
brief: None,
@@ -268,7 +269,7 @@ mod test {
268269
pub fn mk_doc(output_style: config::OutputStyle, +source: ~str)
269270
-> doc::Doc {
270271
do astsrv::from_str(source) |srv| {
271-
let config = {
272+
let config = config::Config {
272273
output_style: output_style,
273274
.. config::default_config(&Path("whatever"))
274275
};

src/librustdoc/markdown_pass.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -573,20 +573,20 @@ fn should_insert_blank_line_after_fn_signature() {
573573
#[test]
574574
fn should_correctly_indent_fn_signature() {
575575
let doc = test::create_doc(~"fn a() { }");
576-
let doc = doc::Doc_({
576+
let doc = doc::Doc{
577577
pages: ~[
578-
doc::CratePage({
579-
topmod: doc::ModDoc_({
580-
items: ~[doc::FnTag({
578+
doc::CratePage(doc::CrateDoc{
579+
topmod: doc::ModDoc{
580+
items: ~[doc::FnTag(doc::SimpleItemDoc{
581581
sig: Some(~"line 1\nline 2"),
582582
.. doc.cratemod().fns()[0]
583583
})],
584-
.. *doc.cratemod()
585-
}),
584+
.. doc.cratemod()
585+
},
586586
.. doc.CrateDoc()
587587
})
588588
]
589-
});
589+
};
590590
let markdown = test::write_markdown_str(doc);
591591
assert str::contains(markdown, ~" line 1\n line 2");
592592
}
@@ -863,7 +863,7 @@ mod test {
863863
fn create_doc_srv(+source: ~str) -> (astsrv::Srv, doc::Doc) {
864864
do astsrv::from_str(source) |srv| {
865865

866-
let config = {
866+
let config = config::Config {
867867
output_style: config::DocPerCrate,
868868
.. config::default_config(&Path("whatever"))
869869
};

src/librustdoc/markdown_writer.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use core::prelude::*;
1212

1313
use config;
14+
use config::Config;
1415
use doc::ItemUtils;
1516
use doc;
1617
use pass::Pass;
@@ -228,7 +229,7 @@ pub fn make_filename(
228229
229230
#[test]
230231
fn should_use_markdown_file_name_based_off_crate() {
231-
let config = {
232+
let config = Config {
232233
output_dir: Path("output/dir"),
233234
output_format: config::Markdown,
234235
output_style: config::DocPerCrate,
@@ -242,7 +243,7 @@ fn should_use_markdown_file_name_based_off_crate() {
242243
243244
#[test]
244245
fn should_name_html_crate_file_name_index_html_when_doc_per_mod() {
245-
let config = {
246+
let config = Config {
246247
output_dir: Path("output/dir"),
247248
output_format: config::PandocHtml,
248249
output_style: config::DocPerMod,
@@ -256,7 +257,7 @@ fn should_name_html_crate_file_name_index_html_when_doc_per_mod() {
256257
257258
#[test]
258259
fn should_name_mod_file_names_by_path() {
259-
let config = {
260+
let config = Config {
260261
output_dir: Path("output/dir"),
261262
output_format: config::PandocHtml,
262263
output_style: config::DocPerMod,

src/librustdoc/page_pass.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ fn make_doc_from_pages(page_port: PagePort) -> doc::Doc {
7676
break;
7777
}
7878
}
79-
doc::Doc_(doc::Doc_ {
79+
doc::Doc {
8080
pages: pages
81-
})
81+
}
8282
}
8383

8484
fn find_pages(doc: doc::Doc, page_chan: PageChan) {
@@ -128,16 +128,16 @@ fn fold_mod(
128128
}
129129

130130
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
131-
doc::ModDoc_(doc::ModDoc_ {
131+
doc::ModDoc {
132132
items: do doc.items.filtered |item| {
133133
match *item {
134134
doc::ModTag(_) => false,
135135
doc::NmodTag(_) => false,
136136
_ => true
137137
}
138138
},
139-
.. *doc
140-
})
139+
.. doc
140+
}
141141
}
142142

143143
fn fold_nmod(

0 commit comments

Comments
 (0)