Register new snapshots

Closes #15544
This commit is contained in:
Alex Crichton
2014-07-09 10:57:01 -07:00
parent 3f3291e0c7
commit 0c71e0c596
44 changed files with 13 additions and 242 deletions

View File

@@ -245,146 +245,6 @@ pub fn arg_to_string(arg: &ast::Arg) -> String {
to_string(|s| s.print_arg(arg))
}
#[cfg(stage0)]
pub fn to_str(f: |&mut State| -> IoResult<()>) -> String {
let mut s = rust_printer(box MemWriter::new());
f(&mut s).unwrap();
eof(&mut s.s).unwrap();
unsafe {
// FIXME(pcwalton): A nasty function to extract the string from an `io::Writer`
// that we "know" to be a `MemWriter` that works around the lack of checked
// downcasts.
let (_, wr): (uint, Box<MemWriter>) = mem::transmute_copy(&s.s.out);
let result =
str::from_utf8_owned(Vec::from_slice(wr.get_ref())).unwrap();
mem::forget(wr);
result.to_string()
}
}
#[cfg(stage0)]
pub fn ty_to_str(ty: &ast::Ty) -> String {
to_str(|s| s.print_type(ty))
}
#[cfg(stage0)]
pub fn pat_to_str(pat: &ast::Pat) -> String {
to_str(|s| s.print_pat(pat))
}
#[cfg(stage0)]
pub fn expr_to_str(e: &ast::Expr) -> String {
to_str(|s| s.print_expr(e))
}
#[cfg(stage0)]
pub fn lifetime_to_str(e: &ast::Lifetime) -> String {
to_str(|s| s.print_lifetime(e))
}
#[cfg(stage0)]
pub fn tt_to_str(tt: &ast::TokenTree) -> String {
to_str(|s| s.print_tt(tt))
}
#[cfg(stage0)]
pub fn tts_to_str(tts: &[ast::TokenTree]) -> String {
to_str(|s| s.print_tts(tts))
}
#[cfg(stage0)]
pub fn stmt_to_str(stmt: &ast::Stmt) -> String {
to_str(|s| s.print_stmt(stmt))
}
#[cfg(stage0)]
pub fn item_to_str(i: &ast::Item) -> String {
to_str(|s| s.print_item(i))
}
#[cfg(stage0)]
pub fn generics_to_str(generics: &ast::Generics) -> String {
to_str(|s| s.print_generics(generics))
}
#[cfg(stage0)]
pub fn ty_method_to_str(p: &ast::TypeMethod) -> String {
to_str(|s| s.print_ty_method(p))
}
#[cfg(stage0)]
pub fn method_to_str(p: &ast::Method) -> String {
to_str(|s| s.print_method(p))
}
#[cfg(stage0)]
pub fn fn_block_to_str(p: &ast::FnDecl) -> String {
to_str(|s| s.print_fn_block_args(p))
}
#[cfg(stage0)]
pub fn path_to_str(p: &ast::Path) -> String {
to_str(|s| s.print_path(p, false))
}
#[cfg(stage0)]
pub fn fun_to_str(decl: &ast::FnDecl, fn_style: ast::FnStyle, name: ast::Ident,
opt_explicit_self: Option<ast::ExplicitSelf_>,
generics: &ast::Generics) -> String {
to_str(|s| {
try!(s.print_fn(decl, Some(fn_style), abi::Rust,
name, generics, opt_explicit_self, ast::Inherited));
try!(s.end()); // Close the head box
s.end() // Close the outer box
})
}
#[cfg(stage0)]
pub fn block_to_str(blk: &ast::Block) -> String {
to_str(|s| {
// containing cbox, will be closed by print-block at }
try!(s.cbox(indent_unit));
// head-ibox, will be closed by print-block after {
try!(s.ibox(0u));
s.print_block(blk)
})
}
#[cfg(stage0)]
pub fn meta_item_to_str(mi: &ast::MetaItem) -> String {
to_str(|s| s.print_meta_item(mi))
}
#[cfg(stage0)]
pub fn attribute_to_str(attr: &ast::Attribute) -> String {
to_str(|s| s.print_attribute(attr))
}
#[cfg(stage0)]
pub fn lit_to_str(l: &ast::Lit) -> String {
to_str(|s| s.print_literal(l))
}
#[cfg(stage0)]
pub fn explicit_self_to_str(explicit_self: ast::ExplicitSelf_) -> String {
to_str(|s| s.print_explicit_self(explicit_self, ast::MutImmutable).map(|_| {}))
}
#[cfg(stage0)]
pub fn variant_to_str(var: &ast::Variant) -> String {
to_str(|s| s.print_variant(var))
}
#[cfg(stage0)]
pub fn arg_to_str(arg: &ast::Arg) -> String {
to_str(|s| s.print_arg(arg))
}
pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
match vis {
ast::Public => format!("pub {}", s),