summary refs log tree commit diff
path: root/src/librustdoc/html
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-20 15:45:07 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-20 22:36:13 -0800
commit3cb9fa26ef9905c00a29ea577fb55a12a91c8e7b (patch)
treea1091c2dd4d5fc6d09be609ffc106295797a6e0a /src/librustdoc/html
parent29bd9a06efd2f8c8a7b1102e2203cc0e6ae2dcba (diff)
downloadrust-3cb9fa26ef9905c00a29ea577fb55a12a91c8e7b.tar.gz
rust-3cb9fa26ef9905c00a29ea577fb55a12a91c8e7b.zip
std: Rename Show/String to Debug/Display
This commit is an implementation of [RFC 565][rfc] which is a stabilization of
the `std::fmt` module and the implementations of various formatting traits.
Specifically, the following changes were performed:

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md

* The `Show` trait is now deprecated, it was renamed to `Debug`
* The `String` trait is now deprecated, it was renamed to `Display`
* Many `Debug` and `Display` implementations were audited in accordance with the
  RFC and audited implementations now have the `#[stable]` attribute
  * Integers and floats no longer print a suffix
  * Smart pointers no longer print details that they are a smart pointer
  * Paths with `Debug` are now quoted and escape characters
* The `unwrap` methods on `Result` now require `Display` instead of `Debug`
* The `Error` trait no longer has a `detail` method and now requires that
  `Display` must be implemented. With the loss of `String`, this has moved into
  libcore.
* `impl<E: Error> FromError<E> for Box<Error>` now exists
* `derive(Show)` has been renamed to `derive(Debug)`. This is not currently
  warned about due to warnings being emitted on stage1+

While backwards compatibility is attempted to be maintained with a blanket
implementation of `Display` for the old `String` trait (and the same for
`Show`/`Debug`) this is still a breaking change due to primitives no longer
implementing `String` as well as modifications such as `unwrap` and the `Error`
trait. Most code is fairly straightforward to update with a rename or tweaks of
method calls.

[breaking-change]
Closes #21436
Diffstat (limited to 'src/librustdoc/html')
-rw-r--r--src/librustdoc/html/escape.rs2
-rw-r--r--src/librustdoc/html/format.rs52
-rw-r--r--src/librustdoc/html/item_type.rs2
-rw-r--r--src/librustdoc/html/layout.rs2
-rw-r--r--src/librustdoc/html/markdown.rs4
-rw-r--r--src/librustdoc/html/render.rs8
-rw-r--r--src/librustdoc/html/toc.rs6
7 files changed, 38 insertions, 38 deletions
diff --git a/src/librustdoc/html/escape.rs b/src/librustdoc/html/escape.rs
index 6fb78d9a833..c2b18962192 100644
--- a/src/librustdoc/html/escape.rs
+++ b/src/librustdoc/html/escape.rs
@@ -19,7 +19,7 @@ use std::fmt;
 /// string when passed to a format string.
 pub struct Escape<'a>(pub &'a str);
 
-impl<'a> fmt::String for Escape<'a> {
+impl<'a> fmt::Display for Escape<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         // Because the internet is always right, turns out there's not that many
         // characters to escape: http://stackoverflow.com/questions/7381974
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index 57b8d666c95..27b875ee286 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -66,7 +66,7 @@ impl UnsafetySpace {
     }
 }
 
-impl<'a, T: fmt::String> fmt::String for CommaSep<'a, T> {
+impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         for (i, item) in self.0.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
@@ -76,7 +76,7 @@ impl<'a, T: fmt::String> fmt::String for CommaSep<'a, T> {
     }
 }
 
-impl<'a> fmt::String for TyParamBounds<'a> {
+impl<'a> fmt::Display for TyParamBounds<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let &TyParamBounds(bounds) = self;
         for (i, bound) in bounds.iter().enumerate() {
@@ -89,7 +89,7 @@ impl<'a> fmt::String for TyParamBounds<'a> {
     }
 }
 
-impl fmt::String for clean::Generics {
+impl fmt::Display for clean::Generics {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         if self.lifetimes.len() == 0 && self.type_params.len() == 0 { return Ok(()) }
         try!(f.write_str("&lt;"));
@@ -126,7 +126,7 @@ impl fmt::String for clean::Generics {
     }
 }
 
-impl<'a> fmt::String for WhereClause<'a> {
+impl<'a> fmt::Display for WhereClause<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let &WhereClause(gens) = self;
         if gens.where_predicates.len() == 0 {
@@ -163,14 +163,14 @@ impl<'a> fmt::String for WhereClause<'a> {
     }
 }
 
-impl fmt::String for clean::Lifetime {
+impl fmt::Display for clean::Lifetime {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         try!(f.write_str(self.get_ref()));
         Ok(())
     }
 }
 
-impl fmt::String for clean::PolyTrait {
+impl fmt::Display for clean::PolyTrait {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         if self.lifetimes.len() > 0 {
             try!(f.write_str("for&lt;"));
@@ -186,7 +186,7 @@ impl fmt::String for clean::PolyTrait {
     }
 }
 
-impl fmt::String for clean::TyParamBound {
+impl fmt::Display for clean::TyParamBound {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::RegionBound(ref lt) => {
@@ -203,7 +203,7 @@ impl fmt::String for clean::TyParamBound {
     }
 }
 
-impl fmt::String for clean::PathParameters {
+impl fmt::Display for clean::PathParameters {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::PathParameters::AngleBracketed {
@@ -257,14 +257,14 @@ impl fmt::String for clean::PathParameters {
     }
 }
 
-impl fmt::String for clean::PathSegment {
+impl fmt::Display for clean::PathSegment {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         try!(f.write_str(self.name.as_slice()));
         write!(f, "{}", self.params)
     }
 }
 
-impl fmt::String for clean::Path {
+impl fmt::Display for clean::Path {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         if self.global {
             try!(f.write_str("::"))
@@ -450,7 +450,7 @@ fn tybounds(w: &mut fmt::Formatter,
     }
 }
 
-impl fmt::String for clean::Type {
+impl fmt::Display for clean::Type {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::TyParamBinder(id) => {
@@ -539,7 +539,7 @@ impl fmt::String for clean::Type {
     }
 }
 
-impl fmt::String for clean::Arguments {
+impl fmt::Display for clean::Arguments {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         for (i, input) in self.values.iter().enumerate() {
             if i > 0 { try!(write!(f, ", ")); }
@@ -552,7 +552,7 @@ impl fmt::String for clean::Arguments {
     }
 }
 
-impl fmt::String for clean::FunctionRetTy {
+impl fmt::Display for clean::FunctionRetTy {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()),
@@ -563,13 +563,13 @@ impl fmt::String for clean::FunctionRetTy {
     }
 }
 
-impl fmt::String for clean::FnDecl {
+impl fmt::Display for clean::FnDecl {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
     }
 }
 
-impl<'a> fmt::String for Method<'a> {
+impl<'a> fmt::Display for Method<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Method(selfty, d) = *self;
         let mut args = String::new();
@@ -599,7 +599,7 @@ impl<'a> fmt::String for Method<'a> {
     }
 }
 
-impl fmt::String for VisSpace {
+impl fmt::Display for VisSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
             Some(ast::Public) => write!(f, "pub "),
@@ -608,7 +608,7 @@ impl fmt::String for VisSpace {
     }
 }
 
-impl fmt::String for UnsafetySpace {
+impl fmt::Display for UnsafetySpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
             ast::Unsafety::Unsafe => write!(f, "unsafe "),
@@ -617,7 +617,7 @@ impl fmt::String for UnsafetySpace {
     }
 }
 
-impl fmt::String for clean::ViewPath {
+impl fmt::Display for clean::ViewPath {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::SimpleImport(ref name, ref src) => {
@@ -644,7 +644,7 @@ impl fmt::String for clean::ViewPath {
     }
 }
 
-impl fmt::String for clean::ImportSource {
+impl fmt::Display for clean::ImportSource {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.did {
             Some(did) => resolved_path(f, did, &self.path, true),
@@ -661,7 +661,7 @@ impl fmt::String for clean::ImportSource {
     }
 }
 
-impl fmt::String for clean::ViewListIdent {
+impl fmt::Display for clean::ViewListIdent {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.source {
             Some(did) => {
@@ -683,13 +683,13 @@ impl fmt::String for clean::ViewListIdent {
     }
 }
 
-impl fmt::String for clean::TypeBinding {
+impl fmt::Display for clean::TypeBinding {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}={}", self.name, self.ty)
     }
 }
 
-impl fmt::String for MutableSpace {
+impl fmt::Display for MutableSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             MutableSpace(clean::Immutable) => Ok(()),
@@ -698,7 +698,7 @@ impl fmt::String for MutableSpace {
     }
 }
 
-impl fmt::String for RawMutableSpace {
+impl fmt::Display for RawMutableSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             RawMutableSpace(clean::Immutable) => write!(f, "const "),
@@ -707,7 +707,7 @@ impl fmt::String for RawMutableSpace {
     }
 }
 
-impl<'a> fmt::String for Stability<'a> {
+impl<'a> fmt::Display for Stability<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Stability(stab) = *self;
         match *stab {
@@ -721,7 +721,7 @@ impl<'a> fmt::String for Stability<'a> {
     }
 }
 
-impl<'a> fmt::String for ConciseStability<'a> {
+impl<'a> fmt::Display for ConciseStability<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let ConciseStability(stab) = *self;
         match *stab {
@@ -738,7 +738,7 @@ impl<'a> fmt::String for ConciseStability<'a> {
     }
 }
 
-impl fmt::String for ModuleSummary {
+impl fmt::Display for ModuleSummary {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         fn fmt_inner<'a>(f: &mut fmt::Formatter,
                          context: &mut Vec<&'a str>,
diff --git a/src/librustdoc/html/item_type.rs b/src/librustdoc/html/item_type.rs
index db3319eb765..fbc8ae2c0b4 100644
--- a/src/librustdoc/html/item_type.rs
+++ b/src/librustdoc/html/item_type.rs
@@ -103,7 +103,7 @@ impl ItemType {
     }
 }
 
-impl fmt::String for ItemType {
+impl fmt::Display for ItemType {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         self.to_static_str().fmt(f)
     }
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs
index f75ab3f431c..e3bd2b4e27f 100644
--- a/src/librustdoc/html/layout.rs
+++ b/src/librustdoc/html/layout.rs
@@ -30,7 +30,7 @@ pub struct Page<'a> {
     pub keywords: &'a str
 }
 
-pub fn render<T: fmt::String, S: fmt::String>(
+pub fn render<T: fmt::Display, S: fmt::Display>(
     dst: &mut io::Writer, layout: &Layout, page: &Page, sidebar: &S, t: &T)
     -> io::IoResult<()>
 {
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 0dbd13b4616..4bdc2a16482 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -426,7 +426,7 @@ pub fn reset_headers() {
     USED_HEADER_MAP.with(|s| s.borrow_mut().clear());
 }
 
-impl<'a> fmt::String for Markdown<'a> {
+impl<'a> fmt::Display for Markdown<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let Markdown(md) = *self;
         // This is actually common enough to special-case
@@ -435,7 +435,7 @@ impl<'a> fmt::String for Markdown<'a> {
     }
 }
 
-impl<'a> fmt::String for MarkdownWithToc<'a> {
+impl<'a> fmt::Display for MarkdownWithToc<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let MarkdownWithToc(md) = *self;
         render(fmt, md.as_slice(), true)
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index ab9700d966a..bd2213910be 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1351,7 +1351,7 @@ impl<'a> Item<'a> {
 }
 
 
-impl<'a> fmt::String for Item<'a> {
+impl<'a> fmt::Display for Item<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         // Write the breadcrumb trail header for the top
         try!(write!(fmt, "\n<h1 class='fqn'><span class='in-band'>"));
@@ -1626,7 +1626,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
 
 struct Initializer<'a>(&'a str);
 
-impl<'a> fmt::String for Initializer<'a> {
+impl<'a> fmt::Display for Initializer<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Initializer(s) = *self;
         if s.len() == 0 { return Ok(()); }
@@ -2188,7 +2188,7 @@ fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
     document(w, it)
 }
 
-impl<'a> fmt::String for Sidebar<'a> {
+impl<'a> fmt::Display for Sidebar<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let cx = self.cx;
         let it = self.item;
@@ -2243,7 +2243,7 @@ impl<'a> fmt::String for Sidebar<'a> {
     }
 }
 
-impl<'a> fmt::String for Source<'a> {
+impl<'a> fmt::Display for Source<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let Source(s) = *self;
         let lines = s.lines().count();
diff --git a/src/librustdoc/html/toc.rs b/src/librustdoc/html/toc.rs
index 8d94e1857c4..aca6e5bb10e 100644
--- a/src/librustdoc/html/toc.rs
+++ b/src/librustdoc/html/toc.rs
@@ -176,13 +176,13 @@ impl TocBuilder {
     }
 }
 
-impl fmt::Show for Toc {
+impl fmt::Debug for Toc {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        fmt::String::fmt(self, f)
+        fmt::Display::fmt(self, f)
     }
 }
 
-impl fmt::String for Toc {
+impl fmt::Display for Toc {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         try!(write!(fmt, "<ul>"));
         for entry in self.entries.iter() {