Skip to content

Commit 1a375ea

Browse files
committed
---
yaml --- r: 148827 b: refs/heads/try2 c: 8665a51 h: refs/heads/master i: 148825: 1290db8 148823: ebc9cb6 v: v3
1 parent 72a40d3 commit 1a375ea

File tree

16 files changed

+118
-74
lines changed

16 files changed

+118
-74
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 25fe2cadb10db1a54cefbd1520708d4397874bc3
8+
refs/heads/try2: 8665a51201f8610bcb35a6f52676fe3906250479
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustdoc/html/escape.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::fmt;
1919
/// string when passed to a format string.
2020
pub struct Escape<'a>(&'a str);
2121

22-
impl<'a> fmt::Default for Escape<'a> {
22+
impl<'a> fmt::Show for Escape<'a> {
2323
fn fmt(s: &Escape<'a>, fmt: &mut fmt::Formatter) {
2424
// Because the internet is always right, turns out there's not that many
2525
// characters to escape: http://stackoverflow.com/questions/7381974

branches/try2/src/librustdoc/html/format.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! HTML formatting module
1212
//!
13-
//! This module contains a large number of `fmt::Default` implementations for
13+
//! This module contains a large number of `fmt::Show` implementations for
1414
//! various types in `rustdoc::clean`. These implementations all currently
1515
//! assume that HTML output is desired, although it may be possible to redesign
1616
//! them in the future to instead emit any format desired.
@@ -47,7 +47,7 @@ impl PuritySpace {
4747
}
4848
}
4949

50-
impl fmt::Default for clean::Generics {
50+
impl fmt::Show for clean::Generics {
5151
fn fmt(g: &clean::Generics, f: &mut fmt::Formatter) {
5252
if g.lifetimes.len() == 0 && g.type_params.len() == 0 { return }
5353
f.buf.write("&lt;".as_bytes());
@@ -77,14 +77,14 @@ impl fmt::Default for clean::Generics {
7777
}
7878
}
7979

80-
impl fmt::Default for clean::Lifetime {
80+
impl fmt::Show for clean::Lifetime {
8181
fn fmt(l: &clean::Lifetime, f: &mut fmt::Formatter) {
8282
f.buf.write("'".as_bytes());
8383
f.buf.write(l.get_ref().as_bytes());
8484
}
8585
}
8686

87-
impl fmt::Default for clean::TyParamBound {
87+
impl fmt::Show for clean::TyParamBound {
8888
fn fmt(bound: &clean::TyParamBound, f: &mut fmt::Formatter) {
8989
match *bound {
9090
clean::RegionBound => {
@@ -97,7 +97,7 @@ impl fmt::Default for clean::TyParamBound {
9797
}
9898
}
9999

100-
impl fmt::Default for clean::Path {
100+
impl fmt::Show for clean::Path {
101101
fn fmt(path: &clean::Path, f: &mut fmt::Formatter) {
102102
if path.global { f.buf.write("::".as_bytes()) }
103103
for (i, seg) in path.segments.iter().enumerate() {
@@ -269,7 +269,7 @@ fn typarams(w: &mut io::Writer, typarams: &Option<~[clean::TyParamBound]>) {
269269
}
270270
}
271271

272-
impl fmt::Default for clean::Type {
272+
impl fmt::Show for clean::Type {
273273
fn fmt(g: &clean::Type, f: &mut fmt::Formatter) {
274274
match *g {
275275
clean::TyParamBinder(id) | clean::Generic(id) => {
@@ -374,7 +374,7 @@ impl fmt::Default for clean::Type {
374374
}
375375
}
376376

377-
impl fmt::Default for clean::FnDecl {
377+
impl fmt::Show for clean::FnDecl {
378378
fn fmt(d: &clean::FnDecl, f: &mut fmt::Formatter) {
379379
write!(f.buf, "({args}){arrow, select, yes{ -&gt; {ret}} other{}}",
380380
args = d.inputs,
@@ -383,7 +383,7 @@ impl fmt::Default for clean::FnDecl {
383383
}
384384
}
385385

386-
impl fmt::Default for ~[clean::Argument] {
386+
impl fmt::Show for ~[clean::Argument] {
387387
fn fmt(inputs: &~[clean::Argument], f: &mut fmt::Formatter) {
388388
let mut args = ~"";
389389
for (i, input) in inputs.iter().enumerate() {
@@ -397,7 +397,7 @@ impl fmt::Default for ~[clean::Argument] {
397397
}
398398
}
399399

400-
impl<'a> fmt::Default for Method<'a> {
400+
impl<'a> fmt::Show for Method<'a> {
401401
fn fmt(m: &Method<'a>, f: &mut fmt::Formatter) {
402402
let Method(selfty, d) = *m;
403403
let mut args = ~"";
@@ -433,7 +433,7 @@ impl<'a> fmt::Default for Method<'a> {
433433
}
434434
}
435435

436-
impl fmt::Default for VisSpace {
436+
impl fmt::Show for VisSpace {
437437
fn fmt(v: &VisSpace, f: &mut fmt::Formatter) {
438438
match v.get() {
439439
Some(ast::Public) => { write!(f.buf, "pub "); }
@@ -443,7 +443,7 @@ impl fmt::Default for VisSpace {
443443
}
444444
}
445445

446-
impl fmt::Default for PuritySpace {
446+
impl fmt::Show for PuritySpace {
447447
fn fmt(p: &PuritySpace, f: &mut fmt::Formatter) {
448448
match p.get() {
449449
ast::UnsafeFn => write!(f.buf, "unsafe "),
@@ -453,7 +453,7 @@ impl fmt::Default for PuritySpace {
453453
}
454454
}
455455

456-
impl fmt::Default for clean::ViewPath {
456+
impl fmt::Show for clean::ViewPath {
457457
fn fmt(v: &clean::ViewPath, f: &mut fmt::Formatter) {
458458
match *v {
459459
clean::SimpleImport(ref name, ref src) => {
@@ -478,7 +478,7 @@ impl fmt::Default for clean::ViewPath {
478478
}
479479
}
480480

481-
impl fmt::Default for clean::ImportSource {
481+
impl fmt::Show for clean::ImportSource {
482482
fn fmt(v: &clean::ImportSource, f: &mut fmt::Formatter) {
483483
match v.did {
484484
// FIXME: shouldn't be restricted to just local imports
@@ -495,7 +495,7 @@ impl fmt::Default for clean::ImportSource {
495495
}
496496
}
497497

498-
impl fmt::Default for clean::ViewListIdent {
498+
impl fmt::Show for clean::ViewListIdent {
499499
fn fmt(v: &clean::ViewListIdent, f: &mut fmt::Formatter) {
500500
match v.source {
501501
// FIXME: shouldn't be limited to just local imports

branches/try2/src/librustdoc/html/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Page<'a> {
2424
root_path: &'a str,
2525
}
2626

27-
pub fn render<T: fmt::Default, S: fmt::Default>(
27+
pub fn render<T: fmt::Show, S: fmt::Show>(
2828
dst: &mut io::Writer, layout: &Layout, page: &Page, sidebar: &S, t: &T)
2929
{
3030
write!(dst,

branches/try2/src/librustdoc/html/markdown.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! (bundled into the rust runtime). This module self-contains the C bindings
1515
//! and necessary legwork to render markdown, and exposes all of the
1616
//! functionality through a unit-struct, `Markdown`, which has an implementation
17-
//! of `fmt::Default`. Example usage:
17+
//! of `fmt::Show`. Example usage:
1818
//!
1919
//! ```rust,ignore
2020
//! use rustdoc::html::markdown::Markdown;
@@ -32,7 +32,7 @@ use std::str;
3232
use std::unstable::intrinsics;
3333
use std::vec;
3434

35-
/// A unit struct which has the `fmt::Default` trait implemented. When
35+
/// A unit struct which has the `fmt::Show` trait implemented. When
3636
/// formatted, this struct will emit the HTML corresponding to the rendered
3737
/// version of the contained markdown string.
3838
pub struct Markdown<'a>(&'a str);
@@ -209,7 +209,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
209209
}
210210
}
211211

212-
impl<'a> fmt::Default for Markdown<'a> {
212+
impl<'a> fmt::Show for Markdown<'a> {
213213
fn fmt(md: &Markdown<'a>, fmt: &mut fmt::Formatter) {
214214
let Markdown(md) = *md;
215215
// This is actually common enough to special-case

branches/try2/src/librustdoc/html/render.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ impl<'a> Item<'a> {
801801
}
802802
}
803803

804-
impl<'a> fmt::Default for Item<'a> {
804+
impl<'a> fmt::Show for Item<'a> {
805805
fn fmt(it: &Item<'a>, fmt: &mut fmt::Formatter) {
806806
match attr::find_stability(it.item.attrs.iter()) {
807807
Some(ref stability) => {
@@ -990,7 +990,7 @@ fn item_module(w: &mut Writer, cx: &Context,
990990
match myitem.inner {
991991
clean::StaticItem(ref s) | clean::ForeignStaticItem(ref s) => {
992992
struct Initializer<'a>(&'a str);
993-
impl<'a> fmt::Default for Initializer<'a> {
993+
impl<'a> fmt::Show for Initializer<'a> {
994994
fn fmt(s: &Initializer<'a>, f: &mut fmt::Formatter) {
995995
let Initializer(s) = *s;
996996
if s.len() == 0 { return; }
@@ -1491,7 +1491,7 @@ fn item_typedef(w: &mut Writer, it: &clean::Item, t: &clean::Typedef) {
14911491
document(w, it);
14921492
}
14931493

1494-
impl<'a> fmt::Default for Sidebar<'a> {
1494+
impl<'a> fmt::Show for Sidebar<'a> {
14951495
fn fmt(s: &Sidebar<'a>, fmt: &mut fmt::Formatter) {
14961496
let cx = s.cx;
14971497
let it = s.item;
@@ -1556,7 +1556,7 @@ fn build_sidebar(m: &clean::Module) -> HashMap<~str, ~[~str]> {
15561556
return map;
15571557
}
15581558

1559-
impl<'a> fmt::Default for Source<'a> {
1559+
impl<'a> fmt::Show for Source<'a> {
15601560
fn fmt(s: &Source<'a>, fmt: &mut fmt::Formatter) {
15611561
let Source(s) = *s;
15621562
let lines = s.lines().len();

branches/try2/src/libstd/fmt/mod.rs

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ The current mapping of types to traits is:
149149
* `f` ⇒ `Float`
150150
* `e` ⇒ `LowerExp`
151151
* `E` ⇒ `UpperExp`
152-
* *nothing* ⇒ `Default`
152+
* *nothing* ⇒ `Show`
153153
154154
What this means is that any type of argument which implements the
155155
`std::fmt::Binary` trait can then be formatted with `{:t}`. Implementations are
156156
provided for these traits for a number of primitive types by the standard
157157
library as well. If no format is specified (as in `{}` or `{:6}`), then the
158-
format trait used is the `Default` trait. This is one of the more commonly
158+
format trait used is the `Show` trait. This is one of the more commonly
159159
implemented traits when formatting a custom type.
160160
161161
When implementing a format trait for your own time, you will have to implement a
@@ -186,7 +186,7 @@ struct Vector2D {
186186
y: int,
187187
}
188188
189-
impl fmt::Default for Vector2D {
189+
impl fmt::Show for Vector2D {
190190
fn fmt(obj: &Vector2D, f: &mut fmt::Formatter) {
191191
// The `f.buf` value is of the type `&mut io::Writer`, which is what th
192192
// write! macro is expecting. Note that this formatting ignores the
@@ -468,6 +468,7 @@ will look like `"\\{"`.
468468
469469
*/
470470

471+
#[cfg(not(stage0))]
471472
use prelude::*;
472473

473474
use cast;
@@ -479,6 +480,24 @@ use repr;
479480
use util;
480481
use vec;
481482

483+
// NOTE this is just because the `prelude::*` import above includes
484+
// default::Default, so the reexport doesn't work.
485+
#[cfg(stage0)]
486+
pub use Default = fmt::Show; // export required for `format!()` etc.
487+
488+
#[cfg(stage0)]
489+
use container::Container;
490+
#[cfg(stage0)]
491+
use iter::{Iterator, range};
492+
#[cfg(stage0)]
493+
use option::{Option,Some,None};
494+
#[cfg(stage0)]
495+
use vec::ImmutableVector;
496+
#[cfg(stage0)]
497+
use str::StrSlice;
498+
#[cfg(stage0)]
499+
use num::Signed;
500+
482501
pub mod parse;
483502
pub mod rt;
484503

@@ -542,7 +561,7 @@ pub struct Arguments<'a> {
542561
/// to this trait. There is not an explicit way of selecting this trait to be
543562
/// used for formatting, it is only if no other format is specified.
544563
#[allow(missing_doc)]
545-
pub trait Default { fn fmt(&Self, &mut Formatter); }
564+
pub trait Show { fn fmt(&Self, &mut Formatter); }
546565

547566
/// Format trait for the `b` character
548567
#[allow(missing_doc)]
@@ -587,6 +606,41 @@ pub trait LowerExp { fn fmt(&Self, &mut Formatter); }
587606
#[allow(missing_doc)]
588607
pub trait UpperExp { fn fmt(&Self, &mut Formatter); }
589608

609+
// FIXME #11938 - UFCS would make us able call the above methods
610+
// directly Show::show(x, fmt).
611+
612+
// FIXME(huonw's WIP): this is a intermediate state waiting for a
613+
// snapshot (at the time of writing we're at 2014-01-20 b6400f9), to
614+
// be able to make the `fmt` functions into normal methods and have
615+
// `format!()` still work.
616+
macro_rules! uniform_fn_call_workaround {
617+
($( $name: ident, $trait_: ident; )*) => {
618+
$(
619+
#[doc(hidden)]
620+
pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) {
621+
$trait_::fmt(x, fmt)
622+
}
623+
)*
624+
}
625+
}
626+
uniform_fn_call_workaround! {
627+
secret_show, Show;
628+
secret_bool, Bool;
629+
secret_char, Char;
630+
secret_signed, Signed;
631+
secret_unsigned, Unsigned;
632+
secret_octal, Octal;
633+
secret_binary, Binary;
634+
secret_lower_hex, LowerHex;
635+
secret_upper_hex, UpperHex;
636+
secret_string, String;
637+
secret_poly, Poly;
638+
secret_pointer, Pointer;
639+
secret_float, Float;
640+
secret_lower_exp, LowerExp;
641+
secret_upper_exp, UpperExp;
642+
}
643+
590644
/// The `write` function takes an output stream, a precompiled format string,
591645
/// and a list of arguments. The arguments will be formatted according to the
592646
/// specified format string into the output stream provided.
@@ -1148,10 +1202,10 @@ impl<T> Pointer for *mut T {
11481202
fn fmt(t: &*mut T, f: &mut Formatter) { Pointer::fmt(&(*t as *T), f) }
11491203
}
11501204

1151-
// Implementation of Default for various core types
1205+
// Implementation of Show for various core types
11521206

11531207
macro_rules! delegate(($ty:ty to $other:ident) => {
1154-
impl<'a> Default for $ty {
1208+
impl<'a> Show for $ty {
11551209
fn fmt(me: &$ty, f: &mut Formatter) {
11561210
$other::fmt(me, f)
11571211
}
@@ -1174,10 +1228,10 @@ delegate!(char to Char)
11741228
delegate!(f32 to Float)
11751229
delegate!(f64 to Float)
11761230

1177-
impl<T> Default for *T {
1231+
impl<T> Show for *T {
11781232
fn fmt(me: &*T, f: &mut Formatter) { Pointer::fmt(me, f) }
11791233
}
1180-
impl<T> Default for *mut T {
1234+
impl<T> Show for *mut T {
11811235
fn fmt(me: &*mut T, f: &mut Formatter) { Pointer::fmt(me, f) }
11821236
}
11831237

branches/try2/src/libstd/io/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub enum ProcessExit {
9191
ExitSignal(int),
9292
}
9393

94-
impl fmt::Default for ProcessExit {
94+
impl fmt::Show for ProcessExit {
9595
/// Format a ProcessExit enum, to nicely present the information.
9696
fn fmt(obj: &ProcessExit, f: &mut fmt::Formatter) {
9797
match *obj {

branches/try2/src/libstd/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ impl<T: Default> Option<T> {
380380
// Trait implementations
381381
/////////////////////////////////////////////////////////////////////////////
382382

383-
impl<T: fmt::Default> fmt::Default for Option<T> {
383+
impl<T: fmt::Show> fmt::Show for Option<T> {
384384
#[inline]
385385
fn fmt(s: &Option<T>, f: &mut fmt::Formatter) {
386386
match *s {

branches/try2/src/libstd/os.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ pub enum MapError {
928928
ErrMapViewOfFile(uint)
929929
}
930930

931-
impl fmt::Default for MapError {
931+
impl fmt::Show for MapError {
932932
fn fmt(val: &MapError, out: &mut fmt::Formatter) {
933933
let str = match *val {
934934
ErrFdNotAvail => "fd not available for reading or writing",

0 commit comments

Comments
 (0)