rustdoc: Remove structural records

This commit is contained in:
Brian Anderson 2013-01-30 19:45:39 -08:00
parent baf301cd3e
commit 63b2b9c4a8
5 changed files with 36 additions and 29 deletions

View File

@ -40,10 +40,10 @@ use syntax::diagnostic::handler;
use syntax::diagnostic;
use syntax;
pub type Ctxt = {
pub struct Ctxt {
ast: @ast::crate,
ast_map: ast_map::map
};
}
type SrvOwner<T> = fn(srv: Srv) -> T;
pub type CtxtHandler<T> = fn~(ctxt: Ctxt) -> T;
@ -54,9 +54,9 @@ enum Msg {
Exit
}
pub enum Srv = {
pub struct Srv {
ch: oldcomm::Chan<Msg>
};
}
impl Srv: Clone {
fn clone(&self) -> Srv { copy *self }
@ -72,11 +72,11 @@ pub fn from_file<T>(file: ~str, owner: SrvOwner<T>) -> T {
fn run<T>(owner: SrvOwner<T>, source: ~str, parse: Parser) -> T {
let srv_ = Srv({
let srv_ = Srv {
ch: do util::spawn_listener |copy source, move parse, po| {
act(po, copy source, copy parse);
}
});
};
let res = owner(srv_);
oldcomm::send(srv_.ch, Exit);
@ -127,7 +127,7 @@ fn build_ctxt(sess: Session,
let ast = front::test::modify_for_testing(sess, ast);
let ast_map = ast_map::map_crate(sess.diagnostic(), *ast);
{
Ctxt {
ast: ast,
ast_map: ast_map,
}

View File

@ -25,9 +25,9 @@ use syntax::attr;
use syntax::codemap;
use syntax;
pub type CrateAttrs = {
pub struct CrateAttrs {
name: Option<~str>
};
}
#[cfg(test)]
mod test {
@ -66,7 +66,7 @@ fn doc_metas(
pub fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs {
let link_metas = attr::find_linkage_metas(attrs);
{
CrateAttrs {
name: attr::last_meta_item_value_str_by_name(link_metas, ~"name")
}
}

View File

@ -104,21 +104,33 @@ pub fn default_config(input_crate: &Path) -> Config {
}
}
type ProgramOutput = fn~((&str), (&[~str])) ->
{status: int, out: ~str, err: ~str};
struct ProcOut {
status: int,
out: ~str,
err: ~str
}
pub fn mock_program_output(_prog: &str, _args: &[~str]) -> {
status: int, out: ~str, err: ~str
} {
{
type ProgramOutput = fn~((&str), (&[~str])) -> ProcOut;
pub fn mock_program_output(_prog: &str, _args: &[~str]) -> ProcOut {
ProcOut {
status: 0,
out: ~"",
err: ~""
}
}
pub fn program_output(prog: &str, args: &[~str]) -> ProcOut {
let {status, out, err} = run::program_output(prog, args);
ProcOut {
status: status,
out: out,
err: err
}
}
pub fn parse_config(args: &[~str]) -> Result<Config, ~str> {
parse_config_(args, run::program_output)
parse_config_(args, program_output)
}
pub fn parse_config_(
@ -260,10 +272,8 @@ fn should_find_pandoc() {
output_format: PandocHtml,
.. default_config(&Path("test"))
};
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
status: int, out: ~str, err: ~str
} {
{
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> ProcOut {
ProcOut {
status: 0, out: ~"pandoc 1.8.2.1", err: ~""
}
};
@ -277,10 +287,8 @@ fn should_error_with_no_pandoc() {
output_format: PandocHtml,
.. default_config(&Path("test"))
};
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> {
status: int, out: ~str, err: ~str
} {
{
let mock_program_output = fn~(_prog: &str, _args: &[~str]) -> ProcOut {
ProcOut {
status: 1, out: ~"", err: ~""
}
};

View File

@ -110,9 +110,9 @@ fn should_write_modules_last() {
assert idx_a < idx_c;
}
type Ctxt = {
struct Ctxt {
w: Writer
};
}
pub fn write_markdown(
doc: doc::Doc,
@ -122,7 +122,7 @@ pub fn write_markdown(
// we don't want to spawn too many pandoc processes.
// (See #2484, which is closed.)
do doc.pages.map |page| {
let ctxt = {
let ctxt = Ctxt {
w: writer_factory(copy *page)
};
write_page(&ctxt, page)

View File

@ -20,7 +20,6 @@
#[crate_type = "lib"];
#[no_core];
#[legacy_records];
#[allow(non_implicitly_copyable_typarams)];
#[allow(deprecated_self)];