Skip to content

Commit 63b2b9c

Browse files
committed
rustdoc: Remove structural records
1 parent baf301c commit 63b2b9c

File tree

5 files changed

+36
-29
lines changed

5 files changed

+36
-29
lines changed

src/librustdoc/astsrv.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ use syntax::diagnostic::handler;
4040
use syntax::diagnostic;
4141
use syntax;
4242

43-
pub type Ctxt = {
43+
pub struct Ctxt {
4444
ast: @ast::crate,
4545
ast_map: ast_map::map
46-
};
46+
}
4747

4848
type SrvOwner<T> = fn(srv: Srv) -> T;
4949
pub type CtxtHandler<T> = fn~(ctxt: Ctxt) -> T;
@@ -54,9 +54,9 @@ enum Msg {
5454
Exit
5555
}
5656

57-
pub enum Srv = {
57+
pub struct Srv {
5858
ch: oldcomm::Chan<Msg>
59-
};
59+
}
6060

6161
impl Srv: Clone {
6262
fn clone(&self) -> Srv { copy *self }
@@ -72,11 +72,11 @@ pub fn from_file<T>(file: ~str, owner: SrvOwner<T>) -> T {
7272

7373
fn run<T>(owner: SrvOwner<T>, source: ~str, parse: Parser) -> T {
7474

75-
let srv_ = Srv({
75+
let srv_ = Srv {
7676
ch: do util::spawn_listener |copy source, move parse, po| {
7777
act(po, copy source, copy parse);
7878
}
79-
});
79+
};
8080

8181
let res = owner(srv_);
8282
oldcomm::send(srv_.ch, Exit);
@@ -127,7 +127,7 @@ fn build_ctxt(sess: Session,
127127
let ast = front::test::modify_for_testing(sess, ast);
128128
let ast_map = ast_map::map_crate(sess.diagnostic(), *ast);
129129

130-
{
130+
Ctxt {
131131
ast: ast,
132132
ast_map: ast_map,
133133
}

src/librustdoc/attr_parser.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ use syntax::attr;
2525
use syntax::codemap;
2626
use syntax;
2727

28-
pub type CrateAttrs = {
28+
pub struct CrateAttrs {
2929
name: Option<~str>
30-
};
30+
}
3131

3232
#[cfg(test)]
3333
mod test {
@@ -66,7 +66,7 @@ fn doc_metas(
6666
pub fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs {
6767
let link_metas = attr::find_linkage_metas(attrs);
6868

69-
{
69+
CrateAttrs {
7070
name: attr::last_meta_item_value_str_by_name(link_metas, ~"name")
7171
}
7272
}

src/librustdoc/config.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,33 @@ pub fn default_config(input_crate: &Path) -> Config {
104104
}
105105
}
106106

107-
type ProgramOutput = fn~((&str), (&[~str])) ->
108-
{status: int, out: ~str, err: ~str};
107+
struct ProcOut {
108+
status: int,
109+
out: ~str,
110+
err: ~str
111+
}
112+
113+
type ProgramOutput = fn~((&str), (&[~str])) -> ProcOut;
109114

110-
pub fn mock_program_output(_prog: &str, _args: &[~str]) -> {
111-
status: int, out: ~str, err: ~str
112-
} {
113-
{
115+
pub fn mock_program_output(_prog: &str, _args: &[~str]) -> ProcOut {
116+
ProcOut {
114117
status: 0,
115118
out: ~"",
116119
err: ~""
117120
}
118121
}
119122

123+
pub fn program_output(prog: &str, args: &[~str]) -> ProcOut {
124+
let {status, out, err} = run::program_output(prog, args);
125+
ProcOut {
126+
status: status,
127+
out: out,
128+
err: err
129+
}
130+
}
131+
120132
pub fn parse_config(args: &[~str]) -> Result<Config, ~str> {
121-
parse_config_(args, run::program_output)
133+
parse_config_(args, program_output)
122134
}
123135

124136
pub fn parse_config_(
@@ -260,10 +272,8 @@ fn should_find_pandoc() {
260272
output_format: PandocHtml,
261273
.. default_config(&Path("test"))
262274
};
263-
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
264-
status: int, out: ~str, err: ~str
265-
} {
266-
{
275+
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> ProcOut {
276+
ProcOut {
267277
status: 0, out: ~"pandoc 1.8.2.1", err: ~""
268278
}
269279
};
@@ -277,10 +287,8 @@ fn should_error_with_no_pandoc() {
277287
output_format: PandocHtml,
278288
.. default_config(&Path("test"))
279289
};
280-
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
281-
status: int, out: ~str, err: ~str
282-
} {
283-
{
290+
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> ProcOut {
291+
ProcOut {
284292
status: 1, out: ~"", err: ~""
285293
}
286294
};

src/librustdoc/markdown_pass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ fn should_write_modules_last() {
110110
assert idx_a < idx_c;
111111
}
112112

113-
type Ctxt = {
113+
struct Ctxt {
114114
w: Writer
115-
};
115+
}
116116

117117
pub fn write_markdown(
118118
doc: doc::Doc,
@@ -122,7 +122,7 @@ pub fn write_markdown(
122122
// we don't want to spawn too many pandoc processes.
123123
// (See #2484, which is closed.)
124124
do doc.pages.map |page| {
125-
let ctxt = {
125+
let ctxt = Ctxt {
126126
w: writer_factory(copy *page)
127127
};
128128
write_page(&ctxt, page)

src/librustdoc/rustdoc.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#[crate_type = "lib"];
2121

2222
#[no_core];
23-
#[legacy_records];
2423

2524
#[allow(non_implicitly_copyable_typarams)];
2625
#[allow(deprecated_self)];

0 commit comments

Comments
 (0)