diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs
index b1f1e69c5a187..695c0420e2b10 100644
--- a/src/compiletest/common.rs
+++ b/src/compiletest/common.rs
@@ -41,15 +41,15 @@ impl FromStr for Mode {
impl fmt::Show for Mode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let msg = match *self {
- CompileFail => "compile-fail",
- RunFail => "run-fail",
- RunPass => "run-pass",
- Pretty => "pretty",
- DebugInfoGdb => "debuginfo-gdb",
- DebugInfoLldb => "debuginfo-lldb",
- Codegen => "codegen",
+ CompileFail => "compile-fail",
+ RunFail => "run-fail",
+ RunPass => "run-pass",
+ Pretty => "pretty",
+ DebugInfoGdb => "debuginfo-gdb",
+ DebugInfoLldb => "debuginfo-lldb",
+ Codegen => "codegen",
};
- write!(f.buf, "{}", msg)
+ msg.fmt(f)
}
}
diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs
index 245040d791cff..ba83ad8d37c9a 100644
--- a/src/libcollections/btree.rs
+++ b/src/libcollections/btree.rs
@@ -425,8 +425,8 @@ impl "));
+ try!(write!(fmt, " "));
let len = cx.current.len() - if it.is_mod() {1} else {0};
for (i, name) in cx.current.iter().take(len).enumerate() {
if i > 0 {
- try!(write!(fmt.buf, "&\\#8203;::"));
+ try!(write!(fmt, "&\\#8203;::"));
}
- try!(write!(fmt.buf, "{}",
+ try!(write!(fmt, "{}",
cx.root_path
.as_slice()
.slice_to((cx.current.len() - i - 1) * 3),
*name));
}
- try!(write!(fmt.buf, "> Eq for HashMap> Show for HashMap> HashSet> fmt::Show for HashSet"));
+ try!(write!(fmt, "\n
\n"));
match self.item.inner {
clean::ModuleItem(ref m) => {
- item_module(fmt.buf, self.cx, self.item, m.items.as_slice())
+ item_module(fmt, self.cx, self.item, m.items.as_slice())
}
clean::FunctionItem(ref f) | clean::ForeignFunctionItem(ref f) =>
- item_function(fmt.buf, self.item, f),
- clean::TraitItem(ref t) => item_trait(fmt.buf, self.item, t),
- clean::StructItem(ref s) => item_struct(fmt.buf, self.item, s),
- clean::EnumItem(ref e) => item_enum(fmt.buf, self.item, e),
- clean::TypedefItem(ref t) => item_typedef(fmt.buf, self.item, t),
- clean::MacroItem(ref m) => item_macro(fmt.buf, self.item, m),
+ item_function(fmt, self.item, f),
+ clean::TraitItem(ref t) => item_trait(fmt, self.item, t),
+ clean::StructItem(ref s) => item_struct(fmt, self.item, s),
+ clean::EnumItem(ref e) => item_enum(fmt, self.item, e),
+ clean::TypedefItem(ref t) => item_typedef(fmt, self.item, t),
+ clean::MacroItem(ref m) => item_macro(fmt, self.item, m),
_ => Ok(())
}
}
@@ -1097,7 +1097,7 @@ fn shorter<'a>(s: Option<&'a str>) -> &'a str {
}
}
-fn document(w: &mut Writer, item: &clean::Item) -> fmt::Result {
+fn document(w: &mut fmt::Formatter, item: &clean::Item) -> fmt::Result {
match item.doc_value() {
Some(s) => {
try!(write!(w, ""));
match self.item.inner {
clean::ModuleItem(ref m) => if m.is_crate {
- try!(write!(fmt.buf, "Crate "));
+ try!(write!(fmt, "Crate "));
} else {
- try!(write!(fmt.buf, "Module "));
+ try!(write!(fmt, "Module "));
},
- clean::FunctionItem(..) => try!(write!(fmt.buf, "Function ")),
- clean::TraitItem(..) => try!(write!(fmt.buf, "Trait ")),
- clean::StructItem(..) => try!(write!(fmt.buf, "Struct ")),
- clean::EnumItem(..) => try!(write!(fmt.buf, "Enum ")),
+ clean::FunctionItem(..) => try!(write!(fmt, "Function ")),
+ clean::TraitItem(..) => try!(write!(fmt, "Trait ")),
+ clean::StructItem(..) => try!(write!(fmt, "Struct ")),
+ clean::EnumItem(..) => try!(write!(fmt, "Enum ")),
_ => {}
}
let cur = self.cx.current.as_slice();
@@ -1017,16 +1017,16 @@ impl<'a> fmt::Show for Item<'a> {
for _ in range(0, cur.len() - i - 1) {
trail.push_str("../");
}
- try!(write!(fmt.buf, "{}::",
- trail, component.as_slice()));
+ try!(write!(fmt, "{}::",
+ trail, component.as_slice()));
}
- try!(write!(fmt.buf, "{}",
- shortty(self.item), self.item.name.get_ref().as_slice()));
+ try!(write!(fmt, "{}",
+ shortty(self.item), self.item.name.get_ref().as_slice()));
// Write stability attributes
match attr::find_stability(self.item.attrs.iter()) {
Some(ref stability) => {
- try!(write!(fmt.buf,
+ try!(write!(fmt,
"{lvl}",
lvl = stability.level.to_str(),
reason = match stability.text {
@@ -1039,22 +1039,22 @@ impl<'a> fmt::Show for Item<'a> {
// Write `src` tag
if self.cx.include_sources {
- try!(write!(fmt.buf, "[src]",
+ try!(write!(fmt, "[src]",
self.link()));
}
- try!(write!(fmt.buf, "
\n"));
+ try!(write!(fmt, " =
"));
+ try!(write!(f, " =
"));
if s.contains("\n") {
- write!(f.buf,
- "[definition]",
+ write!(f, "[definition]",
item.link())
} else {
- write!(f.buf, "{}
", s.as_slice())
+ write!(f, "{}
", s.as_slice())
}
}
}
@@ -1262,7 +1261,7 @@ fn item_module(w: &mut Writer, cx: &Context,
write!(w, "")
}
-fn item_function(w: &mut Writer, it: &clean::Item,
+fn item_function(w: &mut fmt::Formatter, it: &clean::Item,
f: &clean::Function) -> fmt::Result {
try!(write!(w, "{vis}{fn_style}fn \
{name}{generics}{decl}
",
@@ -1274,7 +1273,7 @@ fn item_function(w: &mut Writer, it: &clean::Item,
document(w, it)
}
-fn item_trait(w: &mut Writer, it: &clean::Item,
+fn item_trait(w: &mut fmt::Formatter, it: &clean::Item,
t: &clean::Trait) -> fmt::Result {
let mut parents = StrBuf::new();
if t.parents.len() > 0 {
@@ -1318,7 +1317,7 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
// Trait documentation
try!(document(w, it));
- fn meth(w: &mut Writer, m: &clean::TraitMethod) -> fmt::Result {
+ fn meth(w: &mut fmt::Formatter, m: &clean::TraitMethod) -> fmt::Result {
try!(write!(w, "",
shortty(m.item()),
*m.item().name.get_ref()));
@@ -1374,8 +1373,8 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
Ok(())
}
-fn render_method(w: &mut Writer, meth: &clean::Item) -> fmt::Result {
- fn fun(w: &mut Writer, it: &clean::Item, fn_style: ast::FnStyle,
+fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result {
+ fn fun(w: &mut fmt::Formatter, it: &clean::Item, fn_style: ast::FnStyle,
g: &clean::Generics, selfty: &clean::SelfTy,
d: &clean::FnDecl) -> fmt::Result {
write!(w, "{}fn {name}\
@@ -1400,7 +1399,7 @@ fn render_method(w: &mut Writer, meth: &clean::Item) -> fmt::Result {
}
}
-fn item_struct(w: &mut Writer, it: &clean::Item,
+fn item_struct(w: &mut fmt::Formatter, it: &clean::Item,
s: &clean::Struct) -> fmt::Result {
try!(write!(w, "
"));
try!(render_struct(w,
@@ -1437,7 +1436,8 @@ fn item_struct(w: &mut Writer, it: &clean::Item,
render_methods(w, it)
}
-fn item_enum(w: &mut Writer, it: &clean::Item, e: &clean::Enum) -> fmt::Result {
+fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
+ e: &clean::Enum) -> fmt::Result {
try!(write!(w, "
{}enum {}{}",
VisSpace(it.visibility),
it.name.get_ref().as_slice(),
@@ -1533,7 +1533,7 @@ fn item_enum(w: &mut Writer, it: &clean::Item, e: &clean::Enum) -> fmt::Result {
Ok(())
}
-fn render_struct(w: &mut Writer, it: &clean::Item,
+fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
g: Option<&clean::Generics>,
ty: doctree::StructType,
fields: &[clean::Item],
@@ -1597,7 +1597,7 @@ fn render_struct(w: &mut Writer, it: &clean::Item,
Ok(())
}
-fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
+fn render_methods(w: &mut fmt::Formatter, it: &clean::Item) -> fmt::Result {
match cache_key.get().unwrap().impls.find(&it.id) {
Some(v) => {
let mut non_trait = v.iter().filter(|p| {
@@ -1642,7 +1642,7 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
Ok(())
}
-fn render_impl(w: &mut Writer, i: &clean::Impl,
+fn render_impl(w: &mut fmt::Formatter, i: &clean::Impl,
dox: &Option
impl{} ", i.generics));
let trait_id = match i.trait_ {
@@ -1664,8 +1664,8 @@ fn render_impl(w: &mut Writer, i: &clean::Impl,
None => {}
}
- fn docmeth(w: &mut Writer, item: &clean::Item,
- dox: bool) -> io::IoResult<()> {
+ fn docmeth(w: &mut fmt::Formatter, item: &clean::Item,
+ dox: bool) -> fmt::Result {
try!(write!(w, "
",
*item.name.get_ref()));
try!(render_method(w, item));
@@ -1714,7 +1714,7 @@ fn render_impl(w: &mut Writer, i: &clean::Impl,
Ok(())
}
-fn item_typedef(w: &mut Writer, it: &clean::Item,
+fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
t: &clean::Typedef) -> fmt::Result {
try!(write!(w, "
type {}{} = {};
",
it.name.get_ref().as_slice(),
@@ -1728,21 +1728,21 @@ impl<'a> fmt::Show for Sidebar<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let cx = self.cx;
let it = self.item;
- try!(write!(fmt.buf, "
")); + try!(write!(fmt, "")); + try!(write!(fmt, "{}", highlight::highlight(s.as_slice(), None))); Ok(()) } } -fn item_macro(w: &mut Writer, it: &clean::Item, +fn item_macro(w: &mut fmt::Formatter, it: &clean::Item, t: &clean::Macro) -> fmt::Result { - try!(w.write_str(highlight::highlight(t.source.as_slice(), - Some("macro")).as_slice())); + try!(w.write(highlight::highlight(t.source.as_slice(), Some("macro")).as_bytes())); document(w, it) } diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs index 893214dc9c9c7..4dabdf64f8102 100644 --- a/src/librustdoc/html/toc.rs +++ b/src/librustdoc/html/toc.rs @@ -174,17 +174,17 @@ impl TocBuilder { impl fmt::Show for Toc { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(write!(fmt.buf, "")); for i in range(1, lines + 1) { - try!(write!(fmt.buf, "{0:1$u}\n", i, cols)); + try!(write!(fmt, "{0:1$u}\n", i, cols)); } - try!(write!(fmt.buf, "")); - try!(write!(fmt.buf, "{}", highlight::highlight(s.as_slice(), None))); + try!(write!(fmt, "