rollup merge of #20481: seanmonstar/fmt-show-string

Conflicts:
	src/compiletest/runtest.rs
	src/libcore/fmt/mod.rs
	src/libfmt_macros/lib.rs
	src/libregex/parse.rs
	src/librustc/middle/cfg/construct.rs
	src/librustc/middle/dataflow.rs
	src/librustc/middle/infer/higher_ranked/mod.rs
	src/librustc/middle/ty.rs
	src/librustc_back/archive.rs
	src/librustc_borrowck/borrowck/fragments.rs
	src/librustc_borrowck/borrowck/gather_loans/mod.rs
	src/librustc_resolve/lib.rs
	src/librustc_trans/back/link.rs
	src/librustc_trans/save/mod.rs
	src/librustc_trans/trans/base.rs
	src/librustc_trans/trans/callee.rs
	src/librustc_trans/trans/common.rs
	src/librustc_trans/trans/consts.rs
	src/librustc_trans/trans/controlflow.rs
	src/librustc_trans/trans/debuginfo.rs
	src/librustc_trans/trans/expr.rs
	src/librustc_trans/trans/monomorphize.rs
	src/librustc_typeck/astconv.rs
	src/librustc_typeck/check/method/mod.rs
	src/librustc_typeck/check/mod.rs
	src/librustc_typeck/check/regionck.rs
	src/librustc_typeck/collect.rs
	src/libsyntax/ext/format.rs
	src/libsyntax/ext/source_util.rs
	src/libsyntax/ext/tt/transcribe.rs
	src/libsyntax/parse/mod.rs
	src/libsyntax/parse/token.rs
	src/test/run-pass/issue-8898.rs
This commit is contained in:
Alex Crichton
2015-01-06 15:22:24 -08:00
252 changed files with 2703 additions and 2072 deletions

View File

@@ -10,7 +10,7 @@
//! HTML formatting module
//!
//! This module contains a large number of `fmt::Show` implementations for
//! This module contains a large number of `fmt::String` implementations for
//! various types in `rustdoc::clean`. These implementations all currently
//! assume that HTML output is desired, although it may be possible to redesign
//! them in the future to instead emit any format desired.
@@ -64,7 +64,15 @@ impl UnsafetySpace {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl<'a> fmt::Show for TyParamBounds<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl<'a> fmt::String for TyParamBounds<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let &TyParamBounds(bounds) = self;
for (i, bound) in bounds.iter().enumerate() {
@@ -77,7 +85,15 @@ impl<'a> fmt::Show for TyParamBounds<'a> {
}
}
impl fmt::Show for clean::Generics {
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::Generic {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String 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;"));
@@ -114,7 +130,15 @@ impl fmt::Show for clean::Generics {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl<'a> fmt::Show for WhereClause<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl<'a> fmt::String for WhereClause<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let &WhereClause(gens) = self;
if gens.where_predicates.len() == 0 {
@@ -151,14 +175,30 @@ impl<'a> fmt::Show for WhereClause<'a> {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::Lifetime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::Lifetime {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(f.write_str(self.get_ref()));
Ok(())
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::PolyTrait {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::PolyTrait {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.lifetimes.len() > 0 {
try!(f.write_str("for&lt;"));
@@ -174,7 +214,15 @@ impl fmt::Show for clean::PolyTrait {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::TyParamBound {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::TyParamBound {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
clean::RegionBound(ref lt) => {
@@ -191,7 +239,15 @@ impl fmt::Show for clean::TyParamBound {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::PathParameters {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::PathParameters {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
clean::PathParameters::AngleBracketed { ref lifetimes, ref types } => {
@@ -236,14 +292,30 @@ impl fmt::Show for clean::PathParameters {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::PathSegment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::PathSegment {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
try!(f.write_str(self.name.as_slice()));
write!(f, "{}", self.params)
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::Path {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if self.global {
try!(f.write_str("::"))
@@ -429,7 +501,15 @@ fn tybounds(w: &mut fmt::Formatter,
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::Type {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::Type {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
clean::TyParamBinder(id) => {
@@ -570,7 +650,16 @@ impl fmt::Show for clean::Type {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::Arguments {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String 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, ", ")); }
@@ -583,7 +672,15 @@ impl fmt::Show for clean::Arguments {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::FunctionRetTy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String 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(()),
@@ -593,13 +690,29 @@ impl fmt::Show for clean::FunctionRetTy {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::FnDecl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::FnDecl {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl<'a> fmt::Show for Method<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl<'a> fmt::String for Method<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Method(selfty, d) = *self;
let mut args = String::new();
@@ -629,7 +742,15 @@ impl<'a> fmt::Show for Method<'a> {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for VisSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for VisSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.get() {
Some(ast::Public) => write!(f, "pub "),
@@ -638,7 +759,15 @@ impl fmt::Show for VisSpace {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for UnsafetySpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for UnsafetySpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.get() {
ast::Unsafety::Unsafe => write!(f, "unsafe "),
@@ -647,7 +776,15 @@ impl fmt::Show for UnsafetySpace {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::ViewPath {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::ViewPath {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
clean::SimpleImport(ref name, ref src) => {
@@ -674,7 +811,15 @@ impl fmt::Show for clean::ViewPath {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::ImportSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::ImportSource {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.did {
Some(did) => resolved_path(f, did, &self.path, true),
@@ -691,7 +836,15 @@ impl fmt::Show for clean::ImportSource {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for clean::ViewListIdent {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for clean::ViewListIdent {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.source {
Some(did) => {
@@ -712,7 +865,15 @@ impl fmt::Show for clean::ViewListIdent {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for MutableSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for MutableSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
MutableSpace(clean::Immutable) => Ok(()),
@@ -721,7 +882,15 @@ impl fmt::Show for MutableSpace {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for RawMutableSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for RawMutableSpace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
RawMutableSpace(clean::Immutable) => write!(f, "const "),
@@ -730,13 +899,21 @@ impl fmt::Show for RawMutableSpace {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl<'a> fmt::Show for Stability<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl<'a> fmt::String for Stability<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let Stability(stab) = *self;
match *stab {
Some(ref stability) => {
write!(f, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
lvl = stability.level.to_string(),
lvl = stability.level,
reason = stability.text)
}
None => Ok(())
@@ -744,13 +921,21 @@ impl<'a> fmt::Show for Stability<'a> {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl<'a> fmt::Show for ConciseStability<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl<'a> fmt::String for ConciseStability<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let ConciseStability(stab) = *self;
match *stab {
Some(ref stability) => {
write!(f, "<a class='stability {lvl}' title='{lvl}{colon}{reason}'></a>",
lvl = stability.level.to_string(),
lvl = stability.level,
colon = if stability.text.len() > 0 { ": " } else { "" },
reason = stability.text)
}
@@ -761,7 +946,15 @@ impl<'a> fmt::Show for ConciseStability<'a> {
}
}
//NOTE(stage0): remove impl after snapshot
#[cfg(stage0)]
impl fmt::Show for ModuleSummary {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fmt::String::fmt(self, f)
}
}
impl fmt::String for ModuleSummary {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt_inner<'a>(f: &mut fmt::Formatter,
context: &mut Vec<&'a str>,