]> git.lizzy.rs Git - rust.git/commitdiff
Move std::{reflect,repr,Poly} to a libdebug crate
authorAlex Crichton <alex@alexcrichton.com>
Thu, 22 May 2014 18:28:01 +0000 (11:28 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 28 May 2014 04:44:51 +0000 (21:44 -0700)
This commit moves reflection (as well as the {:?} format modifier) to a new
libdebug crate, all of which is marked experimental.

This is a breaking change because it now requires the debug crate to be
explicitly linked if the :? format qualifier is used. This means that any code
using this feature will have to add `extern crate debug;` to the top of the
crate. Any code relying on reflection will also need to do this.

Closes #12019

[breaking-change]

156 files changed:
mk/crates.mk
src/doc/guide-container.md
src/doc/guide-pointers.md
src/doc/guide-tasks.md
src/doc/tutorial.md
src/liballoc/lib.rs
src/libcollections/lib.rs
src/libcore/ops.rs
src/libcore/slice.rs
src/libdebug/fmt.rs [new file with mode: 0644]
src/libdebug/lib.rs [new file with mode: 0644]
src/libdebug/reflect.rs [new file with mode: 0644]
src/libdebug/repr.rs [new file with mode: 0644]
src/libgetopts/lib.rs
src/libgreen/stack.rs
src/libnative/lib.rs
src/librand/lib.rs
src/librustc/lib.rs
src/librustdoc/lib.rs
src/librustuv/lib.rs
src/libserialize/ebml.rs
src/libserialize/hex.rs
src/libserialize/json.rs
src/libstd/fmt.rs
src/libstd/lib.rs
src/libsyntax/ext/format.rs
src/libsyntax/lib.rs
src/libtime/lib.rs
src/libworkcache/lib.rs
src/test/auxiliary/extern_calling_convention.rs
src/test/auxiliary/logging_right_crate.rs
src/test/bench/msgsend-pipes-shared.rs
src/test/bench/msgsend-pipes.rs
src/test/bench/std-smallintmap.rs
src/test/compile-fail/autoderef-full-lval.rs
src/test/compile-fail/block-coerce-no.rs
src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs
src/test/compile-fail/borrowck-if-with-else.rs
src/test/compile-fail/borrowck-init-in-fn-expr.rs
src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs
src/test/compile-fail/copy-a-resource.rs
src/test/compile-fail/if-without-else-result.rs
src/test/compile-fail/issue-1476.rs
src/test/compile-fail/issue-2823.rs
src/test/compile-fail/issue-3038.rs
src/test/compile-fail/issue-3521.rs
src/test/compile-fail/issue-5062.rs
src/test/compile-fail/issue-6458-2.rs
src/test/compile-fail/liveness-closure-require-ret.rs
src/test/compile-fail/liveness-move-in-loop.rs
src/test/compile-fail/liveness-move-in-while.rs
src/test/compile-fail/liveness-use-after-move.rs
src/test/compile-fail/liveness-use-after-send.rs
src/test/compile-fail/match-join.rs
src/test/compile-fail/moves-based-on-type-access-to-field.rs
src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs
src/test/compile-fail/no-send-res-ports.rs
src/test/compile-fail/noncopyable-class.rs
src/test/compile-fail/nonscalar-cast.rs
src/test/compile-fail/packed-struct-generic-transmute.rs
src/test/compile-fail/packed-struct-transmute.rs
src/test/compile-fail/pattern-tyvar.rs
src/test/compile-fail/pinned-deep-copy.rs
src/test/compile-fail/unique-pinned-nocopy.rs
src/test/compile-fail/unique-vec-res.rs
src/test/pretty/block-comment-wchar.pp
src/test/pretty/block-comment-wchar.rs
src/test/run-fail/result-get-fail.rs
src/test/run-fail/unwind-box-fn-unique.rs
src/test/run-fail/unwind-box-res.rs
src/test/run-fail/unwind-box-str.rs
src/test/run-fail/unwind-box-unique-unique.rs
src/test/run-fail/unwind-box-unique.rs
src/test/run-fail/unwind-box-vec.rs
src/test/run-pass/alignment-gep-tup-like-1.rs
src/test/run-pass/auto-instantiate.rs
src/test/run-pass/block-arg.rs
src/test/run-pass/block-iter-1.rs
src/test/run-pass/block-iter-2.rs
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/close-over-big-then-small-data.rs
src/test/run-pass/comm.rs
src/test/run-pass/conditional-debug-macro-off.rs
src/test/run-pass/conditional-debug-macro-on.rs
src/test/run-pass/const-fields-and-indexing.rs
src/test/run-pass/const-vecs-and-slices.rs
src/test/run-pass/deref-lval.rs
src/test/run-pass/enum-discrim-width-stuff.rs
src/test/run-pass/evec-slice.rs
src/test/run-pass/float.rs
src/test/run-pass/format-ref-cell.rs
src/test/run-pass/functional-struct-upd.rs
src/test/run-pass/generic-alias-box.rs
src/test/run-pass/generic-alias-unique.rs
src/test/run-pass/generic-derived-type.rs
src/test/run-pass/generic-fn-box.rs
src/test/run-pass/generic-fn-unique.rs
src/test/run-pass/generic-tag-values.rs
src/test/run-pass/generic-tup.rs
src/test/run-pass/getopts_ref.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/if-bot.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/import.rs
src/test/run-pass/issue-1696.rs
src/test/run-pass/issue-2216.rs
src/test/run-pass/issue-2804-2.rs
src/test/run-pass/issue-2804.rs
src/test/run-pass/issue-2904.rs
src/test/run-pass/issue-3109.rs
src/test/run-pass/issue-3556.rs
src/test/run-pass/issue-3794.rs
src/test/run-pass/issue-4252.rs
src/test/run-pass/issue-5688.rs
src/test/run-pass/issue-6344-let.rs
src/test/run-pass/issue-6344-match.rs
src/test/run-pass/issue-7563.rs
src/test/run-pass/issue-8898.rs
src/test/run-pass/last-use-is-capture.rs
src/test/run-pass/lazy-and-or.rs
src/test/run-pass/linear-for-loop.rs
src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
src/test/run-pass/log-knows-the-names-of-variants.rs
src/test/run-pass/log-poly.rs
src/test/run-pass/match-unique-bind.rs
src/test/run-pass/nested-matchs.rs
src/test/run-pass/over-constrained-vregs.rs
src/test/run-pass/overload-index-operator.rs
src/test/run-pass/pass-by-copy.rs
src/test/run-pass/rec-align-u32.rs
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/regions-self-impls.rs
src/test/run-pass/regions-self-in-enums.rs
src/test/run-pass/regions-simple.rs
src/test/run-pass/repeated-vector-syntax.rs
src/test/run-pass/resource-assign-is-not-copy.rs
src/test/run-pass/shadow.rs
src/test/run-pass/shape_intrinsic_tag_then_rec.rs
src/test/run-pass/signal-exit-status.rs
src/test/run-pass/size-and-align.rs
src/test/run-pass/small-enums-with-fields.rs
src/test/run-pass/spawn-fn.rs
src/test/run-pass/str-idx.rs
src/test/run-pass/tag-align-shape.rs
src/test/run-pass/tag-disr-val-shape.rs
src/test/run-pass/tail-cps.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/trivial-message.rs
src/test/run-pass/tuple-struct-construct.rs
src/test/run-pass/unique-in-tag.rs
src/test/run-pass/unique-log.rs
src/test/run-pass/unique-pat-3.rs

index a0a0bc800c45acff070fbd53616944306d641605..a4dc0c0465e77cdf7f4385773709583b317a7c43 100644 (file)
@@ -51,7 +51,7 @@
 
 TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
                  uuid serialize sync getopts collections num test time rand \
-                workcache url log regex graphviz core rlibc alloc
+                workcache url log regex graphviz core rlibc alloc debug
 HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros
 CRATES := $(TARGET_CRATES) $(HOST_CRATES)
 TOOLS := compiletest rustdoc rustc
@@ -59,16 +59,17 @@ TOOLS := compiletest rustdoc rustc
 DEPS_core :=
 DEPS_rlibc :=
 DEPS_alloc := core libc native:jemalloc
+DEPS_debug := std
 DEPS_std := core libc alloc native:rustrt native:backtrace
 DEPS_graphviz := std
 DEPS_green := std rand native:context_switch
 DEPS_rustuv := std native:uv native:uv_support
 DEPS_native := std
-DEPS_syntax := std term serialize collections log fmt_macros
+DEPS_syntax := std term serialize collections log fmt_macros debug
 DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
-              collections time log graphviz
+              collections time log graphviz debug
 DEPS_rustdoc := rustc native:hoedown serialize sync getopts collections \
-                test time
+                test time debug
 DEPS_flate := std native:miniz
 DEPS_arena := std collections
 DEPS_graphviz := std
@@ -79,7 +80,7 @@ DEPS_semver := std
 DEPS_uuid := std serialize rand
 DEPS_sync := std alloc
 DEPS_getopts := std
-DEPS_collections := std rand
+DEPS_collections := std rand debug
 DEPS_fourcc := syntax std
 DEPS_hexfloat := syntax std
 DEPS_num := std rand
index 1ab92d453785e41f1fe4f2b80ea3edf801e22408..30bfd28d57ee06d05e679c1bd65589aadc9804af 100644 (file)
@@ -254,7 +254,7 @@ for (x, y) in it {
 }
 
 // yield and print the last pair from the iterator
-println!("last: {:?}", it.next());
+println!("last: {}", it.next());
 
 // the iterator is now fully consumed
 assert!(it.next().is_none());
@@ -349,9 +349,9 @@ returning another `DoubleEndedIterator` with `next` and `next_back` exchanged.
 ~~~
 let xs = [1, 2, 3, 4, 5, 6];
 let mut it = xs.iter();
-println!("{:?}", it.next()); // prints `Some(&1)`
-println!("{:?}", it.next()); // prints `Some(&2)`
-println!("{:?}", it.next_back()); // prints `Some(&6)`
+println!("{}", it.next()); // prints `Some(1)`
+println!("{}", it.next()); // prints `Some(2)`
+println!("{}", it.next_back()); // prints `Some(6)`
 
 // prints `5`, `4` and `3`
 for &x in it.rev() {
@@ -367,7 +367,7 @@ let xs = [1, 2, 3, 4];
 let ys = [5, 6, 7, 8];
 let mut it = xs.iter().chain(ys.iter()).map(|&x| x * 2);
 
-println!("{:?}", it.next()); // prints `Some(2)`
+println!("{}", it.next()); // prints `Some(2)`
 
 // prints `16`, `14`, `12`, `10`, `8`, `6`, `4`
 for x in it.rev() {
@@ -398,17 +398,17 @@ underlying iterators are.
 let xs = [1, 2, 3, 4, 5];
 let ys = ~[7, 9, 11];
 let mut it = xs.iter().chain(ys.iter());
-println!("{:?}", it.idx(0)); // prints `Some(&1)`
-println!("{:?}", it.idx(5)); // prints `Some(&7)`
-println!("{:?}", it.idx(7)); // prints `Some(&11)`
-println!("{:?}", it.idx(8)); // prints `None`
+println!("{}", it.idx(0)); // prints `Some(1)`
+println!("{}", it.idx(5)); // prints `Some(7)`
+println!("{}", it.idx(7)); // prints `Some(11)`
+println!("{}", it.idx(8)); // prints `None`
 
 // yield two elements from the beginning, and one from the end
 it.next();
 it.next();
 it.next_back();
 
-println!("{:?}", it.idx(0)); // prints `Some(&3)`
-println!("{:?}", it.idx(4)); // prints `Some(&9)`
-println!("{:?}", it.idx(6)); // prints `None`
+println!("{}", it.idx(0)); // prints `Some(3)`
+println!("{}", it.idx(4)); // prints `Some(9)`
+println!("{}", it.idx(6)); // prints `None`
 ~~~
index 948d033e06c03a704f92c5021db75ab46800dbcc..1ab981384920dc25218c6f1937ebc1011a8ebb47 100644 (file)
@@ -102,6 +102,7 @@ you were writing this Rust code:
 
 ~~~rust
 # fn transform(p: Point) -> Point { p }
+#[deriving(Show)]
 struct Point {
     x: int,
     y: int,
@@ -110,7 +111,7 @@ struct Point {
 fn main() {
     let p0 = Point { x: 5, y: 10};
     let p1 = transform(p0);
-    println!("{:?}", p1);
+    println!("{}", p1);
 }
 
 ~~~
@@ -134,6 +135,7 @@ let p1 = transform(&p0);
 This does work, but you don't need to create those references! The better way to write this is simply:
 
 ~~~rust
+#[deriving(Show)]
 struct Point {
     x: int,
     y: int,
@@ -146,7 +148,7 @@ fn transform(p: Point) -> Point {
 fn main() {
     let p0 = Point { x: 5, y: 10};
     let p1 = transform(p0);
-    println!("{:?}", p1);
+    println!("{}", p1);
 }
 ~~~
 
@@ -182,7 +184,7 @@ trait. Therefore, unboxed traits don't make any sense, and aren't allowed.
 Sometimes, you need a recursive data structure. The simplest is known as a 'cons list':
 
 ~~~rust
-
+#[deriving(Show)]
 enum List<T> {
     Nil,
     Cons(T, Box<List<T>>),
@@ -190,7 +192,7 @@ enum List<T> {
 
 fn main() {
     let list: List<int> = Cons(1, box Cons(2, box Cons(3, box Nil)));
-    println!("{:?}", list);
+    println!("{}", list);
 }
 ~~~
 
@@ -349,7 +351,7 @@ fn main() {
     let origin =    @Point { x: 0.0, y: 0.0 };
     let p1     = box Point { x: 5.0, y: 3.0 };
 
-    println!("{:?}", compute_distance(origin, p1));
+    println!("{}", compute_distance(origin, p1));
 }
 ~~~
 
@@ -385,11 +387,11 @@ fn main() {
     let mut x = box 5;
     if *x < 10 {
         let y = &x;
-        println!("Oh no: {:?}", y);
+        println!("Oh no: {}", y);
         return;
     }
     *x -= 1;
-    println!("Oh no: {:?}", x);
+    println!("Oh no: {}", x);
 }
 ~~~
 
@@ -404,11 +406,11 @@ fn main() {
         let y = &x;
         *x -= 1;
 
-        println!("Oh no: {:?}", y);
+        println!("Oh no: {}", y);
         return;
     }
     *x -= 1;
-    println!("Oh no: {:?}", x);
+    println!("Oh no: {}", x);
 }
 ~~~
 
index f6b7946c86c68089a06e2c7b003c09924d43ee1a..ad6ec65ef44baae93570575db8fe0e50aad1e311 100644 (file)
@@ -280,7 +280,7 @@ fn fib(n: u64) -> u64 {
 
 let mut delayed_fib = sync::Future::spawn(proc() fib(50));
 make_a_sandwich();
-println!("fib(50) = {:?}", delayed_fib.get())
+println!("fib(50) = {}", delayed_fib.get())
 # }
 ~~~
 
index 2a59e3a756acc2b205423758c36c84082aa16c73..011d1b2b5db8f1fabc9a976843b2ac40ae5e2ffd 100644 (file)
@@ -405,14 +405,20 @@ will often see in examples, and its related family of macros: `print!`,
 that [printf][pf] has. Unlike printf, `format!` will give you a compile-time
 error when the types of the directives don't match the types of the arguments.
 
-~~~~
-# let mystery_object = ();
-
+~~~
 // `{}` will print the "default format" of a type
 println!("{} is {}", "the answer", 43);
+~~~
 
-// `{:?}` will conveniently print any type
+~~~~
+extern crate debug;
+
+# fn main() {
+# let mystery_object = ();
+// `{:?}` will conveniently print any type,
+// but requires the `debug` crate to be linked in
 println!("what is this thing: {:?}", mystery_object);
+# }
 ~~~~
 
 [pf]: http://en.cppreference.com/w/cpp/io/c/fprintf
@@ -698,8 +704,8 @@ When an enum has simple integer discriminators, you can apply the `as` cast
 operator to convert a variant to its discriminator value as an `int`:
 
 ~~~~
-# enum Direction { North }
-println!( "{:?} => {}", North, North as int );
+# #[deriving(Show)] enum Direction { North }
+println!( "{} => {}", North, North as int );
 ~~~~
 
 It is possible to set the discriminator values to chosen constant values:
@@ -2228,7 +2234,7 @@ method.
 ~~~~
 # trait Printable { fn print(&self); }
 impl Printable for int {
-    fn print(&self) { println!("{:?}", *self) }
+    fn print(&self) { println!("{}", *self) }
 }
 
 impl Printable for String {
@@ -2253,11 +2259,11 @@ types to be exactly as it is for `int`, above:
 ~~~~
 # trait Printable { fn print(&self); }
 impl Printable for f32 {
-    fn print(&self) { println!("{:?}", *self) }
+    fn print(&self) { println!("{}", *self) }
 }
 
 impl Printable for bool {
-    fn print(&self) { println!("{:?}", *self) }
+    fn print(&self) { println!("{}", *self) }
 }
 
 # true.print();
@@ -2270,8 +2276,11 @@ definition of `print` right in the trait definition, instead of just
 giving its signature.  That is, we can write the following:
 
 ~~~~
+extern crate debug;
+
+# fn main() {
 trait Printable {
-       // Default method implementation
+    // Default method implementation
     fn print(&self) { println!("{:?}", *self) }
 }
 
@@ -2289,6 +2298,7 @@ impl Printable for f32 {}
 # ("foo".to_string()).print();
 # true.print();
 # 3.14159.print();
+# }
 ~~~~
 
 Here, the impls of `Printable` for `int`, `bool`, and `f32` don't
index bf870e101eb86cc293416334f50c59b125cbf458..7e250e130fac8199cfc13ee33a11719aadd17ca4 100644 (file)
 extern crate core;
 extern crate libc;
 
+
 // Allow testing this library
 
+#[cfg(test)] extern crate debug;
 #[cfg(test)] extern crate sync;
 #[cfg(test)] extern crate native;
 #[cfg(test)] #[phase(syntax, link)] extern crate std;
index 4c5f55e53763c5480202e709df5eed07d4492ff4..cbf4ae03a767086dbd2f9088df62df240bbde4c8 100644 (file)
@@ -25,6 +25,7 @@
 #![deny(deprecated_owned_vector)]
 
 extern crate rand;
+extern crate debug;
 
 #[cfg(test)] extern crate test;
 #[cfg(test)] #[phase(syntax, link)] extern crate log;
index 1eab5c04469fc62c920471356017f40e38189e9b..a3cb18a283ed42e03103b63a7bf9d9a3e536bd1f 100644 (file)
@@ -27,6 +27,7 @@
  * demonstrates adding and subtracting two `Point`s.
  *
  * ```rust
+ * #[deriving(Show)]
  * struct Point {
  *     x: int,
  *     y: int
@@ -44,8 +45,8 @@
  *     }
  * }
  * fn main() {
- *     println!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
- *     println!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
+ *     println!("{}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
+ *     println!("{}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
  * }
  * ```
  *
index 31313050165a6d022f7a5af436a35293274dde0a..795dd389958eec2bac3cd00f3312222bbdd49daf 100644 (file)
@@ -419,7 +419,7 @@ pub trait ImmutableVector<'a, T> {
      * ```rust
      * let v = &[1,2,3,4];
      * for win in v.windows(2) {
-     *     println!("{:?}", win);
+     *     println!("{}", win);
      * }
      * ```
      *
@@ -444,7 +444,7 @@ pub trait ImmutableVector<'a, T> {
      * ```rust
      * let v = &[1,2,3,4,5];
      * for win in v.chunks(2) {
-     *     println!("{:?}", win);
+     *     println!("{}", win);
      * }
      * ```
      *
diff --git a/src/libdebug/fmt.rs b/src/libdebug/fmt.rs
new file mode 100644 (file)
index 0000000..4087cb9
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Implementation of the `{:?}` format qualifier
+//!
+//! This module contains the `Poly` trait which is used to implement the `{:?}`
+//! format expression in formatting macros. This trait is defined for all types
+//! automatically, so it is likely not necessary to use this module manually
+
+use std::fmt;
+
+use repr;
+
+/// Format trait for the `?` character
+pub trait Poly {
+    /// Formats the value using the given formatter.
+    #[experimental]
+    fn fmt(&self, &mut fmt::Formatter) -> fmt::Result;
+}
+
+#[doc(hidden)]
+pub fn secret_poly<T: Poly>(x: &T, fmt: &mut fmt::Formatter) -> fmt::Result {
+    // FIXME #11938 - UFCS would make us able call the this method
+    //                directly Poly::fmt(x, fmt).
+    x.fmt(fmt)
+}
+
+impl<T> Poly for T {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        match (f.width, f.precision) {
+            (None, None) => {
+                match repr::write_repr(f, self) {
+                    Ok(()) => Ok(()),
+                    Err(..) => Err(fmt::WriteError),
+                }
+            }
+
+            // If we have a specified width for formatting, then we have to make
+            // this allocation of a new string
+            _ => {
+                let s = repr::repr_to_str(self);
+                f.pad(s.as_slice())
+            }
+        }
+    }
+}
diff --git a/src/libdebug/lib.rs b/src/libdebug/lib.rs
new file mode 100644 (file)
index 0000000..452c3d2
--- /dev/null
@@ -0,0 +1,32 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Debugging utilities for Rust programs
+//!
+//! This crate is intended to provide useful functionality when debugging
+//! programs, such as reflection for printing values. This crate is currently
+//! entirely experimental as its makeup will likely change over time.
+//! Additionally, it is not guaranteed that functionality such as reflection
+//! will persist into the future.
+
+#![crate_id = "debug#0.11.0-pre"]
+#![license = "MIT/ASL2"]
+#![crate_type = "rlib"]
+#![crate_type = "dylib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+       html_root_url = "http://doc.rust-lang.org/")]
+#![experimental]
+#![feature(managed_boxes, macro_rules, quad_precision_float)]
+#![allow(experimental)]
+
+pub mod fmt;
+pub mod reflect;
+pub mod repr;
diff --git a/src/libdebug/reflect.rs b/src/libdebug/reflect.rs
new file mode 100644 (file)
index 0000000..3679944
--- /dev/null
@@ -0,0 +1,438 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/*!
+
+Runtime type reflection
+
+*/
+
+#![allow(missing_doc)]
+
+use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor};
+use std::mem;
+
+/**
+ * Trait for visitor that wishes to reflect on data.
+ *
+ * To use this, create a struct that encapsulates the set of pointers you wish
+ * to walk through a data structure, and implement both `MovePtr` for it as well
+ * as `TyVisitor`; then build a MovePtrAdaptor wrapped around your struct.
+ */
+pub trait MovePtr {
+    fn move_ptr(&mut self, adjustment: |*u8| -> *u8);
+    fn push_ptr(&mut self);
+    fn pop_ptr(&mut self);
+}
+
+/// Helper function for alignment calculation.
+#[inline]
+pub fn align(size: uint, align: uint) -> uint {
+    ((size + align) - 1u) & !(align - 1u)
+}
+
+/// Adaptor to wrap around visitors implementing MovePtr.
+pub struct MovePtrAdaptor<V> {
+    inner: V
+}
+pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> {
+    MovePtrAdaptor { inner: v }
+}
+
+impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
+    #[inline]
+    pub fn bump(&mut self, sz: uint) {
+        self.inner.move_ptr(|p| ((p as uint) + sz) as *u8)
+    }
+
+    #[inline]
+    pub fn align(&mut self, a: uint) {
+        self.inner.move_ptr(|p| align(p as uint, a) as *u8)
+    }
+
+    #[inline]
+    pub fn align_to<T>(&mut self) {
+        self.align(mem::min_align_of::<T>());
+    }
+
+    #[inline]
+    pub fn bump_past<T>(&mut self) {
+        self.bump(mem::size_of::<T>());
+    }
+
+    pub fn unwrap(self) -> V { self.inner }
+}
+
+/// Abstract type-directed pointer-movement using the MovePtr trait
+impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
+    fn visit_bot(&mut self) -> bool {
+        self.align_to::<()>();
+        if ! self.inner.visit_bot() { return false; }
+        self.bump_past::<()>();
+        true
+    }
+
+    fn visit_nil(&mut self) -> bool {
+        self.align_to::<()>();
+        if ! self.inner.visit_nil() { return false; }
+        self.bump_past::<()>();
+        true
+    }
+
+    fn visit_bool(&mut self) -> bool {
+        self.align_to::<bool>();
+        if ! self.inner.visit_bool() { return false; }
+        self.bump_past::<bool>();
+        true
+    }
+
+    fn visit_int(&mut self) -> bool {
+        self.align_to::<int>();
+        if ! self.inner.visit_int() { return false; }
+        self.bump_past::<int>();
+        true
+    }
+
+    fn visit_i8(&mut self) -> bool {
+        self.align_to::<i8>();
+        if ! self.inner.visit_i8() { return false; }
+        self.bump_past::<i8>();
+        true
+    }
+
+    fn visit_i16(&mut self) -> bool {
+        self.align_to::<i16>();
+        if ! self.inner.visit_i16() { return false; }
+        self.bump_past::<i16>();
+        true
+    }
+
+    fn visit_i32(&mut self) -> bool {
+        self.align_to::<i32>();
+        if ! self.inner.visit_i32() { return false; }
+        self.bump_past::<i32>();
+        true
+    }
+
+    fn visit_i64(&mut self) -> bool {
+        self.align_to::<i64>();
+        if ! self.inner.visit_i64() { return false; }
+        self.bump_past::<i64>();
+        true
+    }
+
+    fn visit_uint(&mut self) -> bool {
+        self.align_to::<uint>();
+        if ! self.inner.visit_uint() { return false; }
+        self.bump_past::<uint>();
+        true
+    }
+
+    fn visit_u8(&mut self) -> bool {
+        self.align_to::<u8>();
+        if ! self.inner.visit_u8() { return false; }
+        self.bump_past::<u8>();
+        true
+    }
+
+    fn visit_u16(&mut self) -> bool {
+        self.align_to::<u16>();
+        if ! self.inner.visit_u16() { return false; }
+        self.bump_past::<u16>();
+        true
+    }
+
+    fn visit_u32(&mut self) -> bool {
+        self.align_to::<u32>();
+        if ! self.inner.visit_u32() { return false; }
+        self.bump_past::<u32>();
+        true
+    }
+
+    fn visit_u64(&mut self) -> bool {
+        self.align_to::<u64>();
+        if ! self.inner.visit_u64() { return false; }
+        self.bump_past::<u64>();
+        true
+    }
+
+    fn visit_f32(&mut self) -> bool {
+        self.align_to::<f32>();
+        if ! self.inner.visit_f32() { return false; }
+        self.bump_past::<f32>();
+        true
+    }
+
+    fn visit_f64(&mut self) -> bool {
+        self.align_to::<f64>();
+        if ! self.inner.visit_f64() { return false; }
+        self.bump_past::<f64>();
+        true
+    }
+
+    fn visit_f128(&mut self) -> bool {
+        self.align_to::<f128>();
+        if ! self.inner.visit_f128() { return false; }
+        self.bump_past::<f128>();
+        true
+    }
+
+    fn visit_char(&mut self) -> bool {
+        self.align_to::<char>();
+        if ! self.inner.visit_char() { return false; }
+        self.bump_past::<char>();
+        true
+    }
+
+    fn visit_estr_box(&mut self) -> bool {
+        true
+    }
+
+    fn visit_estr_uniq(&mut self) -> bool {
+        self.align_to::<~str>();
+        if ! self.inner.visit_estr_uniq() { return false; }
+        self.bump_past::<~str>();
+        true
+    }
+
+    fn visit_estr_slice(&mut self) -> bool {
+        self.align_to::<&'static str>();
+        if ! self.inner.visit_estr_slice() { return false; }
+        self.bump_past::<&'static str>();
+        true
+    }
+
+    fn visit_estr_fixed(&mut self, n: uint,
+                        sz: uint,
+                        align: uint) -> bool {
+        self.align(align);
+        if ! self.inner.visit_estr_fixed(n, sz, align) { return false; }
+        self.bump(sz);
+        true
+    }
+
+    fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.align_to::<@u8>();
+        if ! self.inner.visit_box(mtbl, inner) { return false; }
+        self.bump_past::<@u8>();
+        true
+    }
+
+    fn visit_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.align_to::<Box<u8>>();
+        if ! self.inner.visit_uniq(mtbl, inner) { return false; }
+        self.bump_past::<Box<u8>>();
+        true
+    }
+
+    fn visit_ptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.align_to::<*u8>();
+        if ! self.inner.visit_ptr(mtbl, inner) { return false; }
+        self.bump_past::<*u8>();
+        true
+    }
+
+    fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.align_to::<&'static u8>();
+        if ! self.inner.visit_rptr(mtbl, inner) { return false; }
+        self.bump_past::<&'static u8>();
+        true
+    }
+
+    fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool {
+        true
+    }
+
+    fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.align_to::<~[u8]>();
+        if ! self.inner.visit_evec_uniq(mtbl, inner) { return false; }
+        self.bump_past::<~[u8]>();
+        true
+    }
+
+    fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.align_to::<&'static [u8]>();
+        if ! self.inner.visit_evec_slice(mtbl, inner) { return false; }
+        self.bump_past::<&'static [u8]>();
+        true
+    }
+
+    fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
+                        mtbl: uint, inner: *TyDesc) -> bool {
+        self.align(align);
+        if ! self.inner.visit_evec_fixed(n, sz, align, mtbl, inner) {
+            return false;
+        }
+        self.bump(sz);
+        true
+    }
+
+    fn visit_enter_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
+        self.align(align);
+        if ! self.inner.visit_enter_rec(n_fields, sz, align) { return false; }
+        true
+    }
+
+    fn visit_rec_field(&mut self, i: uint, name: &str,
+                       mtbl: uint, inner: *TyDesc) -> bool {
+        unsafe { self.align((*inner).align); }
+        if ! self.inner.visit_rec_field(i, name, mtbl, inner) {
+            return false;
+        }
+        unsafe { self.bump((*inner).size); }
+        true
+    }
+
+    fn visit_leave_rec(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
+        if ! self.inner.visit_leave_rec(n_fields, sz, align) { return false; }
+        true
+    }
+
+    fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint,
+                         align: uint) -> bool {
+        self.align(align);
+        if ! self.inner.visit_enter_class(name, named_fields, n_fields, sz, align) {
+            return false;
+        }
+        true
+    }
+
+    fn visit_class_field(&mut self, i: uint, name: &str, named: bool, mtbl: uint,
+                         inner: *TyDesc) -> bool {
+        unsafe { self.align((*inner).align); }
+        if ! self.inner.visit_class_field(i, name, named, mtbl, inner) {
+            return false;
+        }
+        unsafe { self.bump((*inner).size); }
+        true
+    }
+
+    fn visit_leave_class(&mut self, name: &str, named_fields: bool, n_fields: uint, sz: uint,
+                         align: uint) -> bool {
+        if ! self.inner.visit_leave_class(name, named_fields, n_fields, sz, align) {
+            return false;
+        }
+        true
+    }
+
+    fn visit_enter_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
+        self.align(align);
+        if ! self.inner.visit_enter_tup(n_fields, sz, align) { return false; }
+        true
+    }
+
+    fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool {
+        unsafe { self.align((*inner).align); }
+        if ! self.inner.visit_tup_field(i, inner) { return false; }
+        unsafe { self.bump((*inner).size); }
+        true
+    }
+
+    fn visit_leave_tup(&mut self, n_fields: uint, sz: uint, align: uint) -> bool {
+        if ! self.inner.visit_leave_tup(n_fields, sz, align) { return false; }
+        true
+    }
+
+    fn visit_enter_fn(&mut self, purity: uint, proto: uint,
+                      n_inputs: uint, retstyle: uint) -> bool {
+        if ! self.inner.visit_enter_fn(purity, proto, n_inputs, retstyle) {
+            return false
+        }
+        true
+    }
+
+    fn visit_fn_input(&mut self, i: uint, mode: uint, inner: *TyDesc) -> bool {
+        if ! self.inner.visit_fn_input(i, mode, inner) { return false; }
+        true
+    }
+
+    fn visit_fn_output(&mut self, retstyle: uint, variadic: bool, inner: *TyDesc) -> bool {
+        if ! self.inner.visit_fn_output(retstyle, variadic, inner) { return false; }
+        true
+    }
+
+    fn visit_leave_fn(&mut self, purity: uint, proto: uint,
+                      n_inputs: uint, retstyle: uint) -> bool {
+        if ! self.inner.visit_leave_fn(purity, proto, n_inputs, retstyle) {
+            return false;
+        }
+        true
+    }
+
+    fn visit_enter_enum(&mut self, n_variants: uint,
+                        get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
+                        sz: uint, align: uint)
+                     -> bool {
+        self.align(align);
+        if ! self.inner.visit_enter_enum(n_variants, get_disr, sz, align) {
+            return false;
+        }
+        true
+    }
+
+    fn visit_enter_enum_variant(&mut self, variant: uint,
+                                disr_val: Disr,
+                                n_fields: uint,
+                                name: &str) -> bool {
+        if ! self.inner.visit_enter_enum_variant(variant, disr_val,
+                                                 n_fields, name) {
+            return false;
+        }
+        true
+    }
+
+    fn visit_enum_variant_field(&mut self, i: uint, offset: uint, inner: *TyDesc) -> bool {
+        self.inner.push_ptr();
+        self.bump(offset);
+        if ! self.inner.visit_enum_variant_field(i, offset, inner) { return false; }
+        self.inner.pop_ptr();
+        true
+    }
+
+    fn visit_leave_enum_variant(&mut self, variant: uint,
+                                disr_val: Disr,
+                                n_fields: uint,
+                                name: &str) -> bool {
+        if ! self.inner.visit_leave_enum_variant(variant, disr_val,
+                                                 n_fields, name) {
+            return false;
+        }
+        true
+    }
+
+    fn visit_leave_enum(&mut self, n_variants: uint,
+                        get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
+                        sz: uint, align: uint) -> bool {
+        if ! self.inner.visit_leave_enum(n_variants, get_disr, sz, align) {
+            return false;
+        }
+        self.bump(sz);
+        true
+    }
+
+    fn visit_trait(&mut self, name: &str) -> bool {
+        self.align_to::<Box<TyVisitor>>();
+        if ! self.inner.visit_trait(name) { return false; }
+        self.bump_past::<Box<TyVisitor>>();
+        true
+    }
+
+    fn visit_param(&mut self, i: uint) -> bool {
+        if ! self.inner.visit_param(i) { return false; }
+        true
+    }
+
+    fn visit_self(&mut self) -> bool {
+        self.align_to::<&'static u8>();
+        if ! self.inner.visit_self() { return false; }
+        self.align_to::<&'static u8>();
+        true
+    }
+}
diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs
new file mode 100644 (file)
index 0000000..6807e73
--- /dev/null
@@ -0,0 +1,659 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/*!
+
+More runtime type reflection
+
+*/
+
+use std::char;
+use std::intrinsics::{Disr, Opaque, TyDesc, TyVisitor, get_tydesc, visit_tydesc};
+use std::io;
+use std::mem;
+use std::raw;
+
+use reflect;
+use reflect::{MovePtr, align};
+
+macro_rules! try( ($me:expr, $e:expr) => (
+    match $e {
+        Ok(()) => {},
+        Err(e) => { $me.last_err = Some(e); return false; }
+    }
+) )
+
+/// Representations
+
+trait Repr {
+    fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()>;
+}
+
+impl Repr for () {
+    fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> {
+        writer.write("()".as_bytes())
+    }
+}
+
+impl Repr for bool {
+    fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> {
+        let s = if *self { "true" } else { "false" };
+        writer.write(s.as_bytes())
+    }
+}
+
+impl Repr for int {
+    fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> {
+        write!(writer, "{}", *self)
+    }
+}
+
+macro_rules! int_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty {
+    fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> {
+        write!(writer, "{}{}", *self, $suffix)
+    }
+}))
+
+int_repr!(i8, "i8")
+int_repr!(i16, "i16")
+int_repr!(i32, "i32")
+int_repr!(i64, "i64")
+int_repr!(uint, "u")
+int_repr!(u8, "u8")
+int_repr!(u16, "u16")
+int_repr!(u32, "u32")
+int_repr!(u64, "u64")
+
+macro_rules! num_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty {
+    fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> {
+        let s = self.to_str();
+        writer.write(s.as_bytes()).and_then(|()| {
+            writer.write(bytes!($suffix))
+        })
+    }
+}))
+
+num_repr!(f32, "f32")
+num_repr!(f64, "f64")
+
+// New implementation using reflect::MovePtr
+
+enum VariantState {
+    SearchingFor(Disr),
+    Matched,
+    AlreadyFound
+}
+
+pub struct ReprVisitor<'a> {
+    ptr: *u8,
+    ptr_stk: Vec<*u8>,
+    var_stk: Vec<VariantState>,
+    writer: &'a mut io::Writer,
+    last_err: Option<io::IoError>,
+}
+
+pub fn ReprVisitor<'a>(ptr: *u8,
+                       writer: &'a mut io::Writer) -> ReprVisitor<'a> {
+    ReprVisitor {
+        ptr: ptr,
+        ptr_stk: vec!(),
+        var_stk: vec!(),
+        writer: writer,
+        last_err: None,
+    }
+}
+
+impl<'a> MovePtr for ReprVisitor<'a> {
+    #[inline]
+    fn move_ptr(&mut self, adjustment: |*u8| -> *u8) {
+        self.ptr = adjustment(self.ptr);
+    }
+    fn push_ptr(&mut self) {
+        self.ptr_stk.push(self.ptr);
+    }
+    fn pop_ptr(&mut self) {
+        self.ptr = self.ptr_stk.pop().unwrap();
+    }
+}
+
+impl<'a> ReprVisitor<'a> {
+    // Various helpers for the TyVisitor impl
+
+    #[inline]
+    pub fn get<T>(&mut self, f: |&mut ReprVisitor, &T| -> bool) -> bool {
+        unsafe {
+            f(self, mem::transmute::<*u8,&T>(self.ptr))
+        }
+    }
+
+    #[inline]
+    pub fn visit_inner(&mut self, inner: *TyDesc) -> bool {
+        self.visit_ptr_inner(self.ptr, inner)
+    }
+
+    #[inline]
+    pub fn visit_ptr_inner(&mut self, ptr: *u8, inner: *TyDesc) -> bool {
+        unsafe {
+            // This should call the constructor up above, but due to limiting
+            // issues we have to recreate it here.
+            let u = ReprVisitor {
+                ptr: ptr,
+                ptr_stk: vec!(),
+                var_stk: vec!(),
+                writer: mem::transmute_copy(&self.writer),
+                last_err: None,
+            };
+            let mut v = reflect::MovePtrAdaptor(u);
+            // Obviously this should not be a thing, but blame #8401 for now
+            visit_tydesc(inner, &mut v as &mut TyVisitor);
+            match v.unwrap().last_err {
+                Some(e) => {
+                    self.last_err = Some(e);
+                    false
+                }
+                None => true,
+            }
+        }
+    }
+
+    #[inline]
+    pub fn write<T:Repr>(&mut self) -> bool {
+        self.get(|this, v:&T| {
+            try!(this, v.write_repr(this.writer));
+            true
+        })
+    }
+
+    pub fn write_escaped_slice(&mut self, slice: &str) -> bool {
+        try!(self, self.writer.write(['"' as u8]));
+        for ch in slice.chars() {
+            if !self.write_escaped_char(ch, true) { return false }
+        }
+        try!(self, self.writer.write(['"' as u8]));
+        true
+    }
+
+    pub fn write_mut_qualifier(&mut self, mtbl: uint) -> bool {
+        if mtbl == 0 {
+            try!(self, self.writer.write("mut ".as_bytes()));
+        } else if mtbl == 1 {
+            // skip, this is ast::m_imm
+        } else {
+            fail!("invalid mutability value");
+        }
+        true
+    }
+
+    pub fn write_vec_range(&mut self, ptr: *(), len: uint, inner: *TyDesc) -> bool {
+        let mut p = ptr as *u8;
+        let (sz, al) = unsafe { ((*inner).size, (*inner).align) };
+        try!(self, self.writer.write(['[' as u8]));
+        let mut first = true;
+        let mut left = len;
+        // unit structs have 0 size, and don't loop forever.
+        let dec = if sz == 0 {1} else {sz};
+        while left > 0 {
+            if first {
+                first = false;
+            } else {
+                try!(self, self.writer.write(", ".as_bytes()));
+            }
+            self.visit_ptr_inner(p as *u8, inner);
+            p = align(unsafe { p.offset(sz as int) as uint }, al) as *u8;
+            left -= dec;
+        }
+        try!(self, self.writer.write([']' as u8]));
+        true
+    }
+
+    pub fn write_unboxed_vec_repr(&mut self, _: uint, v: &raw::Vec<()>, inner: *TyDesc) -> bool {
+        self.write_vec_range(&v.data, v.fill, inner)
+    }
+
+    fn write_escaped_char(&mut self, ch: char, is_str: bool) -> bool {
+        try!(self, match ch {
+            '\t' => self.writer.write("\\t".as_bytes()),
+            '\r' => self.writer.write("\\r".as_bytes()),
+            '\n' => self.writer.write("\\n".as_bytes()),
+            '\\' => self.writer.write("\\\\".as_bytes()),
+            '\'' => {
+                if is_str {
+                    self.writer.write("'".as_bytes())
+                } else {
+                    self.writer.write("\\'".as_bytes())
+                }
+            }
+            '"' => {
+                if is_str {
+                    self.writer.write("\\\"".as_bytes())
+                } else {
+                    self.writer.write("\"".as_bytes())
+                }
+            }
+            '\x20'..'\x7e' => self.writer.write([ch as u8]),
+            _ => {
+                char::escape_unicode(ch, |c| {
+                    let _ = self.writer.write([c as u8]);
+                });
+                Ok(())
+            }
+        });
+        return true;
+    }
+}
+
+impl<'a> TyVisitor for ReprVisitor<'a> {
+    fn visit_bot(&mut self) -> bool {
+        try!(self, self.writer.write("!".as_bytes()));
+        true
+    }
+    fn visit_nil(&mut self) -> bool { self.write::<()>() }
+    fn visit_bool(&mut self) -> bool { self.write::<bool>() }
+    fn visit_int(&mut self) -> bool { self.write::<int>() }
+    fn visit_i8(&mut self) -> bool { self.write::<i8>() }
+    fn visit_i16(&mut self) -> bool { self.write::<i16>() }
+    fn visit_i32(&mut self) -> bool { self.write::<i32>()  }
+    fn visit_i64(&mut self) -> bool { self.write::<i64>() }
+
+    fn visit_uint(&mut self) -> bool { self.write::<uint>() }
+    fn visit_u8(&mut self) -> bool { self.write::<u8>() }
+    fn visit_u16(&mut self) -> bool { self.write::<u16>() }
+    fn visit_u32(&mut self) -> bool { self.write::<u32>() }
+    fn visit_u64(&mut self) -> bool { self.write::<u64>() }
+
+    fn visit_f32(&mut self) -> bool { self.write::<f32>() }
+    fn visit_f64(&mut self) -> bool { self.write::<f64>() }
+    fn visit_f128(&mut self) -> bool { fail!("not implemented") }
+
+    fn visit_char(&mut self) -> bool {
+        self.get::<char>(|this, &ch| {
+            try!(this, this.writer.write(['\'' as u8]));
+            if !this.write_escaped_char(ch, false) { return false }
+            try!(this, this.writer.write(['\'' as u8]));
+            true
+        })
+    }
+
+    fn visit_estr_box(&mut self) -> bool {
+        true
+    }
+
+    fn visit_estr_uniq(&mut self) -> bool {
+        self.get::<~str>(|this, s| {
+            try!(this, this.writer.write(['~' as u8]));
+            this.write_escaped_slice(*s)
+        })
+    }
+
+    fn visit_estr_slice(&mut self) -> bool {
+        self.get::<&str>(|this, s| this.write_escaped_slice(*s))
+    }
+
+    // Type no longer exists, vestigial function.
+    fn visit_estr_fixed(&mut self, _n: uint, _sz: uint,
+                        _align: uint) -> bool { fail!(); }
+
+    fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        try!(self, self.writer.write(['@' as u8]));
+        self.write_mut_qualifier(mtbl);
+        self.get::<&raw::Box<()>>(|this, b| {
+            let p = &b.data as *() as *u8;
+            this.visit_ptr_inner(p, inner)
+        })
+    }
+
+    fn visit_uniq(&mut self, _mtbl: uint, inner: *TyDesc) -> bool {
+        try!(self, self.writer.write("box ".as_bytes()));
+        self.get::<*u8>(|this, b| {
+            this.visit_ptr_inner(*b, inner)
+        })
+    }
+
+    fn visit_ptr(&mut self, mtbl: uint, _inner: *TyDesc) -> bool {
+        self.get::<*u8>(|this, p| {
+            try!(this, write!(this.writer, "({} as *", *p));
+            this.write_mut_qualifier(mtbl);
+            try!(this, this.writer.write("())".as_bytes()));
+            true
+        })
+    }
+
+    fn visit_rptr(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        try!(self, self.writer.write(['&' as u8]));
+        self.write_mut_qualifier(mtbl);
+        self.get::<*u8>(|this, p| {
+            this.visit_ptr_inner(*p, inner)
+        })
+    }
+
+    fn visit_evec_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.get::<&raw::Box<raw::Vec<()>>>(|this, b| {
+            try!(this, this.writer.write(['@' as u8]));
+            this.write_mut_qualifier(mtbl);
+            this.write_unboxed_vec_repr(mtbl, &b.data, inner)
+        })
+    }
+
+    fn visit_evec_uniq(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.get::<&raw::Vec<()>>(|this, b| {
+            try!(this, this.writer.write("box ".as_bytes()));
+            this.write_unboxed_vec_repr(mtbl, *b, inner)
+        })
+    }
+
+    fn visit_evec_slice(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
+        self.get::<raw::Slice<()>>(|this, s| {
+            try!(this, this.writer.write(['&' as u8]));
+            this.write_mut_qualifier(mtbl);
+            let size = unsafe {
+                if (*inner).size == 0 { 1 } else { (*inner).size }
+            };
+            this.write_vec_range(s.data, s.len * size, inner)
+        })
+    }
+
+    fn visit_evec_fixed(&mut self, n: uint, sz: uint, _align: uint,
+                        _: uint, inner: *TyDesc) -> bool {
+        let assumed_size = if sz == 0 { n } else { sz };
+        self.get::<()>(|this, b| {
+            this.write_vec_range(b, assumed_size, inner)
+        })
+    }
+
+    fn visit_enter_rec(&mut self, _n_fields: uint,
+                       _sz: uint, _align: uint) -> bool {
+        try!(self, self.writer.write(['{' as u8]));
+        true
+    }
+
+    fn visit_rec_field(&mut self, i: uint, name: &str,
+                       mtbl: uint, inner: *TyDesc) -> bool {
+        if i != 0 {
+            try!(self, self.writer.write(", ".as_bytes()));
+        }
+        self.write_mut_qualifier(mtbl);
+        try!(self, self.writer.write(name.as_bytes()));
+        try!(self, self.writer.write(": ".as_bytes()));
+        self.visit_inner(inner);
+        true
+    }
+
+    fn visit_leave_rec(&mut self, _n_fields: uint,
+                       _sz: uint, _align: uint) -> bool {
+        try!(self, self.writer.write(['}' as u8]));
+        true
+    }
+
+    fn visit_enter_class(&mut self, name: &str, named_fields: bool, n_fields: uint,
+                         _sz: uint, _align: uint) -> bool {
+        try!(self, self.writer.write(name.as_bytes()));
+        if n_fields != 0 {
+            if named_fields {
+                try!(self, self.writer.write(['{' as u8]));
+            } else {
+                try!(self, self.writer.write(['(' as u8]));
+            }
+        }
+        true
+    }
+
+    fn visit_class_field(&mut self, i: uint, name: &str, named: bool,
+                         _mtbl: uint, inner: *TyDesc) -> bool {
+        if i != 0 {
+            try!(self, self.writer.write(", ".as_bytes()));
+        }
+        if named {
+            try!(self, self.writer.write(name.as_bytes()));
+            try!(self, self.writer.write(": ".as_bytes()));
+        }
+        self.visit_inner(inner);
+        true
+    }
+
+    fn visit_leave_class(&mut self, _name: &str, named_fields: bool, n_fields: uint,
+                         _sz: uint, _align: uint) -> bool {
+        if n_fields != 0 {
+            if named_fields {
+                try!(self, self.writer.write(['}' as u8]));
+            } else {
+                try!(self, self.writer.write([')' as u8]));
+            }
+        }
+        true
+    }
+
+    fn visit_enter_tup(&mut self, _n_fields: uint,
+                       _sz: uint, _align: uint) -> bool {
+        try!(self, self.writer.write(['(' as u8]));
+        true
+    }
+
+    fn visit_tup_field(&mut self, i: uint, inner: *TyDesc) -> bool {
+        if i != 0 {
+            try!(self, self.writer.write(", ".as_bytes()));
+        }
+        self.visit_inner(inner);
+        true
+    }
+
+    fn visit_leave_tup(&mut self, _n_fields: uint,
+                       _sz: uint, _align: uint) -> bool {
+        if _n_fields == 1 {
+            try!(self, self.writer.write([',' as u8]));
+        }
+        try!(self, self.writer.write([')' as u8]));
+        true
+    }
+
+    fn visit_enter_enum(&mut self,
+                        _n_variants: uint,
+                        get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
+                        _sz: uint,
+                        _align: uint) -> bool {
+        let disr = unsafe {
+            get_disr(mem::transmute(self.ptr))
+        };
+        self.var_stk.push(SearchingFor(disr));
+        true
+    }
+
+    fn visit_enter_enum_variant(&mut self, _variant: uint,
+                                disr_val: Disr,
+                                n_fields: uint,
+                                name: &str) -> bool {
+        let mut write = false;
+        match self.var_stk.pop().unwrap() {
+            SearchingFor(sought) => {
+                if disr_val == sought {
+                    self.var_stk.push(Matched);
+                    write = true;
+                } else {
+                    self.var_stk.push(SearchingFor(sought));
+                }
+            }
+            Matched | AlreadyFound => {
+                self.var_stk.push(AlreadyFound);
+            }
+        }
+
+        if write {
+            try!(self, self.writer.write(name.as_bytes()));
+            if n_fields > 0 {
+                try!(self, self.writer.write(['(' as u8]));
+            }
+        }
+        true
+    }
+
+    fn visit_enum_variant_field(&mut self,
+                                i: uint,
+                                _offset: uint,
+                                inner: *TyDesc)
+                                -> bool {
+        match *self.var_stk.get(self.var_stk.len() - 1) {
+            Matched => {
+                if i != 0 {
+                    try!(self, self.writer.write(", ".as_bytes()));
+                }
+                if ! self.visit_inner(inner) {
+                    return false;
+                }
+            }
+            _ => ()
+        }
+        true
+    }
+
+    fn visit_leave_enum_variant(&mut self, _variant: uint,
+                                _disr_val: Disr,
+                                n_fields: uint,
+                                _name: &str) -> bool {
+        match *self.var_stk.get(self.var_stk.len() - 1) {
+            Matched => {
+                if n_fields > 0 {
+                    try!(self, self.writer.write([')' as u8]));
+                }
+            }
+            _ => ()
+        }
+        true
+    }
+
+    fn visit_leave_enum(&mut self,
+                        _n_variants: uint,
+                        _get_disr: unsafe extern fn(ptr: *Opaque) -> Disr,
+                        _sz: uint,
+                        _align: uint)
+                        -> bool {
+        match self.var_stk.pop().unwrap() {
+            SearchingFor(..) => fail!("enum value matched no variant"),
+            _ => true
+        }
+    }
+
+    fn visit_enter_fn(&mut self, _purity: uint, _proto: uint,
+                      _n_inputs: uint, _retstyle: uint) -> bool {
+        try!(self, self.writer.write("fn(".as_bytes()));
+        true
+    }
+
+    fn visit_fn_input(&mut self, i: uint, _mode: uint, inner: *TyDesc) -> bool {
+        if i != 0 {
+            try!(self, self.writer.write(", ".as_bytes()));
+        }
+        let name = unsafe { (*inner).name };
+        try!(self, self.writer.write(name.as_bytes()));
+        true
+    }
+
+    fn visit_fn_output(&mut self, _retstyle: uint, variadic: bool,
+                       inner: *TyDesc) -> bool {
+        if variadic {
+            try!(self, self.writer.write(", ...".as_bytes()));
+        }
+        try!(self, self.writer.write(")".as_bytes()));
+        let name = unsafe { (*inner).name };
+        if name != "()" {
+            try!(self, self.writer.write(" -> ".as_bytes()));
+            try!(self, self.writer.write(name.as_bytes()));
+        }
+        true
+    }
+
+    fn visit_leave_fn(&mut self, _purity: uint, _proto: uint,
+                      _n_inputs: uint, _retstyle: uint) -> bool { true }
+
+
+    fn visit_trait(&mut self, name: &str) -> bool {
+        try!(self, self.writer.write(name.as_bytes()));
+        true
+    }
+
+    fn visit_param(&mut self, _i: uint) -> bool { true }
+    fn visit_self(&mut self) -> bool { true }
+}
+
+pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> {
+    unsafe {
+        let ptr = object as *T as *u8;
+        let tydesc = get_tydesc::<T>();
+        let u = ReprVisitor(ptr, writer);
+        let mut v = reflect::MovePtrAdaptor(u);
+        visit_tydesc(tydesc, &mut v as &mut TyVisitor);
+        match v.unwrap().last_err {
+            Some(e) => Err(e),
+            None => Ok(()),
+        }
+    }
+}
+
+pub fn repr_to_str<T>(t: &T) -> String {
+    let mut result = io::MemWriter::new();
+    write_repr(&mut result as &mut io::Writer, t).unwrap();
+    String::from_utf8(result.unwrap()).unwrap()
+}
+
+#[cfg(test)]
+struct P {a: int, b: f64}
+
+#[test]
+fn test_repr() {
+    use std::str;
+    use std::io::stdio::println;
+    use std::char::is_alphabetic;
+    use std::mem::swap;
+
+    fn exact_test<T>(t: &T, e:&str) {
+        let mut m = io::MemWriter::new();
+        write_repr(&mut m as &mut io::Writer, t).unwrap();
+        let s = str::from_utf8(m.unwrap().as_slice()).unwrap().to_owned();
+        assert_eq!(s.as_slice(), e);
+    }
+
+    exact_test(&10, "10");
+    exact_test(&true, "true");
+    exact_test(&false, "false");
+    exact_test(&1.234, "1.234f64");
+    exact_test(&("hello"), "\"hello\"");
+
+    exact_test(&(@10), "@10");
+    exact_test(&(box 10), "box 10");
+    exact_test(&(&10), "&10");
+    let mut x = 10;
+    exact_test(&(&mut x), "&mut 10");
+
+    exact_test(&(0 as *()), "(0x0 as *())");
+    exact_test(&(0 as *mut ()), "(0x0 as *mut ())");
+
+    exact_test(&(1,), "(1,)");
+    exact_test(&(&["hi", "there"]),
+               "&[\"hi\", \"there\"]");
+    exact_test(&(P{a:10, b:1.234}),
+               "repr::P{a: 10, b: 1.234f64}");
+    exact_test(&(@P{a:10, b:1.234}),
+               "@repr::P{a: 10, b: 1.234f64}");
+    exact_test(&(box P{a:10, b:1.234}),
+               "box repr::P{a: 10, b: 1.234f64}");
+
+    exact_test(&(&[1, 2]), "&[1, 2]");
+    exact_test(&(&mut [1, 2]), "&mut [1, 2]");
+
+    exact_test(&'\'', "'\\''");
+    exact_test(&'"', "'\"'");
+    exact_test(&("'"), "\"'\"");
+    exact_test(&("\""), "\"\\\"\"");
+
+    exact_test(&println, "fn(&str)");
+    exact_test(&swap::<int>, "fn(&mut int, &mut int)");
+    exact_test(&is_alphabetic, "fn(char) -> bool");
+
+    struct Bar(int, int);
+    exact_test(&(Bar(2, 2)), "repr::test_repr::Bar(2, 2)");
+}
index 08aead025985a8f78828a39eac32e6b7fe54b859..c88b825811f51b112f448e00fd11d86f8bedd0b2 100644 (file)
@@ -89,6 +89,7 @@
 #![deny(missing_doc)]
 #![deny(deprecated_owned_vector)]
 
+#[cfg(test)] extern crate debug;
 #[cfg(test)] #[phase(syntax, link)] extern crate log;
 
 use std::cmp::Eq;
index 1f06ba379f0fa00c9c8a27a341a1430c5f9aaac4..f42d636cafbddc5caefb63591df6de026feee826 100644 (file)
@@ -51,8 +51,8 @@ pub fn new(size: uint) -> Stack {
         // page. It isn't guaranteed, but that's why FFI is unsafe. buf.data is
         // guaranteed to be aligned properly.
         if !protect_last_page(&stack) {
-            fail!("Could not memory-protect guard page. stack={:?}, errno={}",
-                  stack, errno());
+            fail!("Could not memory-protect guard page. stack={}, errno={}",
+                  stack.data, errno());
         }
 
         let mut stk = Stack {
index d2d8ad06fdb469edb7319afaa8804d992dd9c686..f04dfac80ccfe54c252d7c2b08fe4da6c9dcd9b6 100644 (file)
@@ -59,6 +59,7 @@
 
 extern crate alloc;
 extern crate libc;
+#[cfg(test)] extern crate debug;
 
 use std::os;
 use std::rt;
index 95c56152df66da230a8ffeb5347210cac37bc676..4a11b692076008c70c2e204fad02ba9cb1b270da 100644 (file)
@@ -65,7 +65,7 @@
 
 ```rust
 let tuple_ptr = rand::random::<Box<(f64, char)>>();
-println!("{:?}", tuple_ptr)
+println!("{}", tuple_ptr)
 ```
 */
 
@@ -80,8 +80,8 @@
 #![feature(macro_rules, managed_boxes, phase)]
 #![deny(deprecated_owned_vector)]
 
-#[cfg(test)]
-#[phase(syntax, link)] extern crate log;
+#[cfg(test)] extern crate debug;
+#[cfg(test)] #[phase(syntax, link)] extern crate log;
 
 use std::io::IoResult;
 use std::kinds::marker;
@@ -152,7 +152,7 @@ fn next_u64(&mut self) -> u64 {
     ///
     /// let mut v = [0u8, .. 13579];
     /// task_rng().fill_bytes(v);
-    /// println!("{:?}", v);
+    /// println!("{}", v.as_slice());
     /// ```
     fn fill_bytes(&mut self, dest: &mut [u8]) {
         // this could, in theory, be done by transmuting dest to a
@@ -188,7 +188,7 @@ fn fill_bytes(&mut self, dest: &mut [u8]) {
     /// let mut rng = task_rng();
     /// let x: uint = rng.gen();
     /// println!("{}", x);
-    /// println!("{:?}", rng.gen::<(f64, bool)>());
+    /// println!("{}", rng.gen::<(f64, bool)>());
     /// ```
     #[inline(always)]
     fn gen<T: Rand>(&mut self) -> T {
index 2459c1d53c0c46bca502e6c59aff7121774b9b7f..6ef33c20786fdffdbf77ecf6c13bc036acc4ff97 100644 (file)
 #![feature(macro_rules, globs, struct_variant, managed_boxes, quote,
            default_type_params, phase)]
 
-extern crate flate;
 extern crate arena;
+extern crate collections;
+extern crate debug;
+extern crate flate;
+extern crate getopts;
 extern crate graphviz;
-extern crate syntax;
+extern crate libc;
 extern crate serialize;
 extern crate sync;
-extern crate getopts;
-extern crate collections;
+extern crate syntax;
 extern crate time;
-extern crate libc;
 
 #[phase(syntax, link)]
 extern crate log;
index 160994f603aa3e15764dd7ac4646df64fbe3b3ef..ae708a7198716eb64151d675e1bcaa6c840c60a4 100644 (file)
 
 #![feature(globs, struct_variant, managed_boxes, macro_rules, phase)]
 
-extern crate syntax;
+extern crate collections;
+extern crate debug;
+extern crate getopts;
+extern crate libc;
+#[phase(syntax, link)]
+extern crate log;
 extern crate rustc;
 extern crate serialize;
 extern crate sync;
-extern crate getopts;
-extern crate collections;
+extern crate syntax;
 extern crate testing = "test";
 extern crate time;
-#[phase(syntax, link)]
-extern crate log;
-extern crate libc;
 
 use std::io;
 use std::io::{File, MemWriter};
index 4bae9bb797a72d00c6249b73561442d4fc0466e0..20893b9e84c881195d5eb22faed59362d685f645 100644 (file)
@@ -44,6 +44,7 @@
 #![allow(visible_private_types)]
 
 #[cfg(test)] extern crate green;
+#[cfg(test)] extern crate debug;
 #[cfg(test)] extern crate realrustuv = "rustuv";
 extern crate libc;
 extern crate alloc;
index e6fe57006cae6ba341eb524674e8acd04fa58ba3..a127c11f50932e22475d7b5e79cb7ee857007637 100644 (file)
@@ -44,6 +44,7 @@ pub struct TaggedDoc<'a> {
     pub doc: Doc<'a>,
 }
 
+#[deriving(Show)]
 pub enum EbmlEncoderTag {
     EsUint,     // 0
     EsU64,      // 1
@@ -323,7 +324,7 @@ fn _check_label(&mut self, lbl: &str) -> DecodeResult<()> {
         }
 
         fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<Doc<'doc>> {
-            debug!(". next_doc(exp_tag={:?})", exp_tag);
+            debug!(". next_doc(exp_tag={})", exp_tag);
             if self.pos >= self.parent.end {
                 return Err(Expected(format_strbuf!("no more documents in \
                                                     current node!")));
@@ -339,8 +340,8 @@ fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<Doc<'doc>> {
                    r_doc.end);
             if r_tag != (exp_tag as uint) {
                 return Err(Expected(format_strbuf!("expected EBML doc with \
-                                                    tag {:?} but found tag \
-                                                    {:?}",
+                                                    tag {} but found tag \
+                                                    {}",
                                                    exp_tag,
                                                    r_tag)));
             }
@@ -370,7 +371,7 @@ fn push_doc<T>(&mut self, exp_tag: EbmlEncoderTag,
 
         fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<uint> {
             let r = doc_as_u32(try!(self.next_doc(exp_tag)));
-            debug!("_next_uint exp_tag={:?} result={}", exp_tag, r);
+            debug!("_next_uint exp_tag={} result={}", exp_tag, r);
             Ok(r as uint)
         }
 
@@ -1085,7 +1086,7 @@ fn test_vuint_at() {
     #[test]
     fn test_option_int() {
         fn test_v(v: Option<int>) {
-            debug!("v == {:?}", v);
+            debug!("v == {}", v);
             let mut wr = MemWriter::new();
             {
                 let mut ebml_w = writer::Encoder(&mut wr);
@@ -1094,7 +1095,7 @@ fn test_v(v: Option<int>) {
             let ebml_doc = reader::Doc(wr.get_ref());
             let mut deser = reader::Decoder(ebml_doc);
             let v1 = Decodable::decode(&mut deser).unwrap();
-            debug!("v1 == {:?}", v1);
+            debug!("v1 == {}", v1);
             assert_eq!(v, v1);
         }
 
index e72de88a06b47526ffb4db8bba92bb618d90660f..373bff8b0cc6136a960c5a86b659f43081c0bdd2 100644 (file)
@@ -95,7 +95,7 @@ impl<'a> FromHex for &'a str {
      *     let hello_str = "Hello, World".as_bytes().to_hex();
      *     println!("{}", hello_str);
      *     let bytes = hello_str.as_slice().from_hex().unwrap();
-     *     println!("{:?}", bytes);
+     *     println!("{}", bytes);
      *     let result_str = String::from_utf8(bytes).unwrap();
      *     println!("{}", result_str);
      * }
index 4375e65891bc9b18a64daac97b38c8a872ab7071..08ac66959bc3c06e8c7785ff4526debe6344d3cf 100644 (file)
@@ -1906,7 +1906,7 @@ fn read_enum_variant<T>(&mut self,
                             names: &[&str],
                             f: |&mut Decoder, uint| -> DecodeResult<T>)
                             -> DecodeResult<T> {
-        debug!("read_enum_variant(names={:?})", names);
+        debug!("read_enum_variant(names={})", names);
         let name = match self.pop() {
             String(s) => s,
             Object(mut o) => {
@@ -1961,7 +1961,7 @@ fn read_enum_struct_variant<T>(&mut self,
                                    names: &[&str],
                                    f: |&mut Decoder, uint| -> DecodeResult<T>)
                                    -> DecodeResult<T> {
-        debug!("read_enum_struct_variant(names={:?})", names);
+        debug!("read_enum_struct_variant(names={})", names);
         self.read_enum_variant(names, f)
     }
 
@@ -3013,7 +3013,7 @@ fn test_encode_hashmap_with_numeric_key() {
         let bytes = mem_buf.unwrap();
         let json_str = from_utf8(bytes.as_slice()).unwrap();
         match from_str(json_str) {
-            Err(_) => fail!("Unable to parse json_str: {:?}", json_str),
+            Err(_) => fail!("Unable to parse json_str: {}", json_str),
             _ => {} // it parsed and we are good to go
         }
     }
@@ -3033,7 +3033,7 @@ fn test_prettyencode_hashmap_with_numeric_key() {
         let bytes = mem_buf.unwrap();
         let json_str = from_utf8(bytes.as_slice()).unwrap();
         match from_str(json_str) {
-            Err(_) => fail!("Unable to parse json_str: {:?}", json_str),
+            Err(_) => fail!("Unable to parse json_str: {}", json_str),
             _ => {} // it parsed and we are good to go
         }
     }
@@ -3043,7 +3043,7 @@ fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() {
         use Decodable;
         let json_str = "{\"1\":true}";
         let json_obj = match from_str(json_str) {
-            Err(_) => fail!("Unable to parse json_str: {:?}", json_str),
+            Err(_) => fail!("Unable to parse json_str: {}", json_str),
             Ok(o) => o
         };
         let mut decoder = Decoder::new(json_obj);
index ba2bc261bc3018735d280e1f0b32cae1348ad183..d53a0f93c9b7cdfacf8f795df251b6ca285feb58 100644 (file)
 Some examples of the `format!` extension are:
 
 ```rust
-format!("Hello");                 // => "Hello".to_string()
-format!("Hello, {:s}!", "world"); // => "Hello, world!".to_string()
-format!("The number is {:d}", 1); // => "The number is 1".to_string()
-format!("{:?}", ~[3, 4]);         // => "~[3, 4]".to_string()
-format!("{value}", value=4);      // => "4".to_string()
-format!("{} {}", 1, 2);           // => "1 2".to_string()
+# extern crate debug;
+# fn main() {
+format!("Hello");                 // => "Hello"
+format!("Hello, {:s}!", "world"); // => "Hello, world!"
+format!("The number is {:d}", 1); // => "The number is 1"
+format!("{:?}", (3, 4));          // => "(3, 4)"
+format!("{value}", value=4);      // => "4"
+format!("{} {}", 1, 2);           // => "1 2"
+# }
 ```
 
 From these, you can see that the first argument is a format string. It is
@@ -62,7 +65,7 @@
 iterator advances. This leads to behavior like this:
 
 ```rust
-format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2".to_string()
+format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2"
 ```
 
 The internal iterator over the argument has not been advanced by the time the
 For example, the following `format!` expressions all use named argument:
 
 ```rust
-format!("{argument}", argument = "test");       // => "test".to_string()
-format!("{name} {}", 1, name = 2);              // => "2 1".to_string()
-format!("{a:s} {c:d} {b:?}", a="a", b=(), c=3); // => "a 3 ()".to_string()
+# extern crate debug;
+# fn main() {
+format!("{argument}", argument = "test");       // => "test"
+format!("{name} {}", 1, name = 2);              // => "2 1"
+format!("{a:s} {c:d} {b:?}", a="a", b=(), c=3); // => "a 3 ()"
+# }
 ```
 
 It is illegal to put positional parameters (those without names) after arguments
 ### Argument types
 
 Each argument's type is dictated by the format string. It is a requirement that
-every argument is only ever referred to by one type. When specifying the format
-of an argument, however, a string like `{}` indicates no type. This is allowed,
-and if all references to one argument do not provide a type, then the format `?`
-is used (the type's rust-representation is printed). For example, this is an
+every argument is only ever referred to by one type. For example, this is an
 invalid format string:
 
 ```notrust
 {0:d} {0:s}
 ```
 
-Because the first argument is both referred to as an integer as well as a
-string.
+This is invalid because the first argument is both referred to as an integer as
+well as a string.
 
 Because formatting is done via traits, there is no requirement that the
 `d` format actually takes an `int`, but rather it simply requires a type which
 multiple actual types to be formatted via `{:d}` (like `i8` as well as `int`).
 The current mapping of types to traits is:
 
-* `?` â‡’ `Poly`
+* *nothing* â‡’ `Show`
 * `d` â‡’ `Signed`
 * `i` â‡’ `Signed`
 * `u` â‡’ `Unsigned`
 * `f` â‡’ `Float`
 * `e` â‡’ `LowerExp`
 * `E` â‡’ `UpperExp`
-* *nothing* â‡’ `Show`
+* `?` â‡’ `Poly`
+
+> **Note**: The `Poly` formatting trait is provided by [libdebug](../../debug/)
+> and is an experimental implementation that should not be relied upon. In order
+> to use the `?` modifier, the libdebug crate must be linked against.
 
 What this means is that any type of argument which implements the
 `std::fmt::Binary` trait can then be formatted with `{:t}`. Implementations are
@@ -330,7 +337,7 @@ fn my_fmt_fn(args: &fmt::Arguments) {
 example:
 
 ```rust
-format!("{0, select, other{#}}", "hello"); // => "hello".to_string()
+format!("{0, select, other{#}}", "hello"); // => "hello"
 ```
 
 This example is the equivalent of `{0:s}` essentially.
@@ -485,7 +492,9 @@ fn my_fmt_fn(args: &fmt::Arguments) {
 
 use io::Writer;
 use io;
+#[cfg(stage0)]
 use option::None;
+#[cfg(stage0)]
 use repr;
 use result::{Ok, Err};
 use str::{Str, StrAllocating};
@@ -516,6 +525,7 @@ fn my_fmt_fn(args: &fmt::Arguments) {
 pub use core::fmt::{secret_pointer};
 
 #[doc(hidden)]
+#[cfg(stage0)]
 pub fn secret_poly<T: Poly>(x: &T, fmt: &mut Formatter) -> Result {
     // FIXME #11938 - UFCS would make us able call the this method
     //                directly Poly::fmt(x, fmt).
@@ -523,6 +533,7 @@ pub fn secret_poly<T: Poly>(x: &T, fmt: &mut Formatter) -> Result {
 }
 
 /// Format trait for the `?` character
+#[cfg(stage0)]
 pub trait Poly {
     /// Formats the value using the given formatter.
     fn fmt(&self, &mut Formatter) -> Result;
@@ -558,6 +569,7 @@ pub fn format_strbuf(args: &Arguments) -> string::String {
     str::from_utf8(output.unwrap().as_slice()).unwrap().into_string()
 }
 
+#[cfg(stage0)]
 impl<T> Poly for T {
     fn fmt(&self, f: &mut Formatter) -> Result {
         match (f.width, f.precision) {
index bc1e3b82547fe4aa86090b915ceed8fa337e64f1..c1bc68b3e1293cbd3776c2692cd042c93fa7225b 100644 (file)
 #[cfg(test)] extern crate rustuv;
 #[cfg(test)] extern crate native;
 #[cfg(test)] extern crate green;
+#[cfg(test)] extern crate debug;
 #[cfg(test)] #[phase(syntax, link)] extern crate log;
 
 // Make and rand accessible for benchmarking/testcases
index 86652cd50b0dc6f8343660287a99d040e609d313..f21239af6afc84a4b2f26e44c70645ad36d59ae7 100644 (file)
@@ -773,30 +773,30 @@ fn format_arg(&self, sp: Span, argno: Position, arg: @ast::Expr)
             Named(ref s) => self.name_types.get(s)
         };
 
-        let fmt_fn = match *ty {
+        let (krate, fmt_fn) = match *ty {
             Known(ref tyname) => {
                 match tyname.as_slice() {
-                    ""  => "secret_show",
-                    "?" => "secret_poly",
-                    "b" => "secret_bool",
-                    "c" => "secret_char",
-                    "d" | "i" => "secret_signed",
-                    "e" => "secret_lower_exp",
-                    "E" => "secret_upper_exp",
-                    "f" => "secret_float",
-                    "o" => "secret_octal",
-                    "p" => "secret_pointer",
-                    "s" => "secret_string",
-                    "t" => "secret_binary",
-                    "u" => "secret_unsigned",
-                    "x" => "secret_lower_hex",
-                    "X" => "secret_upper_hex",
+                    ""  => ("std", "secret_show"),
+                    "?" => ("debug", "secret_poly"),
+                    "b" => ("std", "secret_bool"),
+                    "c" => ("std", "secret_char"),
+                    "d" | "i" => ("std", "secret_signed"),
+                    "e" => ("std", "secret_lower_exp"),
+                    "E" => ("std", "secret_upper_exp"),
+                    "f" => ("std", "secret_float"),
+                    "o" => ("std", "secret_octal"),
+                    "p" => ("std", "secret_pointer"),
+                    "s" => ("std", "secret_string"),
+                    "t" => ("std", "secret_binary"),
+                    "u" => ("std", "secret_unsigned"),
+                    "x" => ("std", "secret_lower_hex"),
+                    "X" => ("std", "secret_upper_hex"),
                     _ => {
                         self.ecx
                             .span_err(sp,
                                       format!("unknown format trait `{}`",
                                               *tyname).as_slice());
-                        "dummy"
+                        ("std", "dummy")
                     }
                 }
             }
@@ -815,7 +815,7 @@ fn format_arg(&self, sp: Span, argno: Position, arg: @ast::Expr)
         };
 
         let format_fn = self.ecx.path_global(sp, vec!(
-                self.ecx.ident_of("std"),
+                self.ecx.ident_of(krate),
                 self.ecx.ident_of("fmt"),
                 self.ecx.ident_of(fmt_fn)));
         self.ecx.expr_call_global(sp, vec!(
index 52612bb4decd38a88e50dfb229bcd11134bab1d4..627b2b71b3552b02493ceadd30a29bb725758b6e 100644 (file)
@@ -36,6 +36,7 @@
 #[phase(syntax, link)]
 extern crate log;
 extern crate fmt_macros;
+extern crate debug;
 
 pub mod util {
     pub mod interner;
index 743ad823eb367de4948b3b96c6bfc98235bfaf6d..9b5bbbadc9c5eb0b3e0ef6157552179a38bee3f8 100644 (file)
@@ -21,7 +21,9 @@
 #![feature(phase)]
 #![deny(deprecated_owned_vector)]
 
+#[cfg(test)] extern crate debug;
 #[cfg(test)] #[phase(syntax, link)] extern crate log;
+
 extern crate serialize;
 extern crate libc;
 #[cfg(target_os = "macos")]
index 9a82c411437e3ebcee60bc0fb9f38d611b83ab17..064979fa2771c42aaff77a86ab15bc193500d1f9 100644 (file)
@@ -412,8 +412,7 @@ fn exec_work<'a, T:Send +
             &'a self, blk: proc(&mut Exec):Send -> T) -> Work<'a, T> {
         let mut bo = Some(blk);
 
-        debug!("exec_work: looking up {} and {:?}", self.fn_name,
-               self.declared_inputs);
+        debug!("exec_work: looking up {}", self.fn_name);
         let cached = {
             let db = self.ctxt.db.deref().read();
             db.deref().prepare(self.fn_name, &self.declared_inputs)
@@ -425,8 +424,7 @@ fn exec_work<'a, T:Send +
                self.all_fresh("discovered input", disc_in) &&
                self.all_fresh("discovered output", disc_out) => {
                 debug!("Cache hit!");
-                debug!("Trying to decode: {:?} / {:?} / {}",
-                       disc_in, disc_out, *res);
+                debug!("Trying to decode: {}", *res);
                 Work::from_value(json_decode(res.as_slice()))
             }
 
index 41c57831da64fe4443d04a37c02d291fb4ac06af..4dbae50aad42bcd07d7da8d5c0fc078833efbf2c 100644 (file)
@@ -11,6 +11,8 @@
 // Make sure Rust generates the correct calling convention for extern
 // functions.
 
+extern crate debug;
+
 #[inline(never)]
 #[cfg(target_arch = "x86_64")]
 pub extern "win64" fn foo(a: int, b: int, c: int, d: int) {
index b0a6e0f84fcd59c18365037ee4f6d563176b2d7b..3f0da3e344af2c5def69faf28e16309022414743 100644 (file)
@@ -10,6 +10,7 @@
 
 #![feature(phase)]
 #[phase(syntax, link)] extern crate log;
+extern crate debug;
 
 pub fn foo<T>() {
     fn death() -> int { fail!() }
index 1ec4a236dfd135904fed154ee7bace4b097035cb..03d91cf3aaa7a4e35af92bb9c0a52ba6b888e280 100644 (file)
@@ -19,6 +19,7 @@
 // version.
 
 extern crate time;
+extern crate debug;
 
 use std::comm;
 use std::os;
index 5da3e1e9ca6c5d01c8775d253cd287d594147da3..4de51c3ab4b8e97093310845de7213c4fa2bf502 100644 (file)
@@ -15,6 +15,7 @@
 // I *think* it's the same, more or less.
 
 extern crate time;
+extern crate debug;
 
 use std::os;
 use std::task;
index f774be582a158fa259ec7d506348aa813c6f1f97..8841e7f4b4df0f62e2425c106c3c66e69b7584f8 100644 (file)
@@ -12,6 +12,7 @@
 
 extern crate collections;
 extern crate time;
+extern crate debug;
 
 use collections::SmallIntMap;
 use std::os;
index ae9fe6112210b5c78311d438b0dcee8e85bd187f..3bb66e3b099f7bf167a3483c7b2377e0f039e17f 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 struct clam {
     x: @int,
     y: @int,
index 98d81db8261141e5825a7f017b0b2ef4015f77cb..19d3e84520d89b310ae4fdb9b6ee9aa6403876b7 100644 (file)
@@ -11,6 +11,8 @@
 // Make sure that fn-to-block coercion isn't incorrectly lifted over
 // other tycons.
 
+extern crate debug;
+
 fn coerce(b: ||) -> extern fn() {
     fn lol(f: extern fn(v: ||) -> extern fn(),
            g: ||) -> extern fn() { return f(g); }
index ef9bee80c2b2db02ddc5caf309dad4ef42e9f818..6f385a8d1eb5e71282cc66f7492cd46cc5c5f1ed 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 struct defer<'a> {
     x: &'a [&'a str],
 }
index dabe0a594299795a99304b883e155ac99cb22897..6e2dae0af7db06852639cd730bc5357128a3b9c6 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn foo(x: int) { println!("{:?}", x); }
 
 fn main() {
index c44e2bee0520c0eb39589e4968f60687bd564567..83bfc754a6bd3ef9d19b0ac87a6c8bb40ba923d1 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn main() {
     let f: || -> int = || {
         let i: int;
index 4110cfd28efceef44950b2eeba865b9e5b0399dc..d87557a46f753d2aa5231836a9fd53a982512bb4 100644 (file)
@@ -10,6 +10,8 @@
 
 // Test that we do not permit moves from &[] matched by a vec pattern.
 
+extern crate debug;
+
 #[deriving(Clone)]
 struct Foo {
     string: String
index 738652dddb32aa928215ce8a9d4ee85bc7fdb03b..84b8b2c59e65f30f9edabb8ed55dd618089af32d 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn main() {
     let x: int = 3;
     let y: &mut int = &mut x; //~ ERROR cannot borrow
index ac893277749e1dc0e09b3d19d7ea8d13768169eb..ee2a183cbe1d70c78934ecd1537af9239d81b770 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 struct foo {
   i: int,
 }
index 38cae6323203481078d8198957c52ae4b8e69f5d..c15e28f95173999d4698b54186fe1e271b665777 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:mismatched types: expected `()` but found `bool`
 
+extern crate debug;
+
 fn main() {
     let a = if true { true };
     println!("{:?}", a);
index 80e0d037f7c5130e0efcba9319ed6b6ea278c5a0..8526596acaaeb701bcad1f6e198a793fa4eaa7a2 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn main() {
     println!("{:?}", x); //~ ERROR unresolved name `x`.
 }
index 4106a77524845f85b68a150af39fee75ea8221ae..3d3a0740e44379525f87314c7b6f153472c57c98 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 struct C {
     x: int,
 }
index 684318bafc685097de76cef984253e59950d58e3..b13b037ef1ab0b25a1db89e4ff2ae832553c8b0d 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 enum f { g(int, int) }
 
 enum h { i(j, k) }
index f9fb2daaf58a2ddbf5d3b0447ae05062cabd9692..7b7cdd2085105b4fbabdab8f0c90e45d348f942e 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn main() {
     let foo = 100;
 
index 8ff81df938d4e01d6d58fb153d95fe29f7893b7e..1cf6dcda04cf8a05d2d577d2ba4571ed49280623 100644 (file)
@@ -8,4 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn main() { format!("{:?}", None); } //~ ERROR unconstrained type
index f395b7fdd76af9960c78bcd777a7642352f124a8..f302472d070bd6312c552b629d393f7338024526 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn main() {
     format!("{:?}", None); //~ ERROR: cannot determine a type for this bounded
 }
index 676d5212e998090617e721ff7f137f7705786e89..65856c5250c62e7b22a8255f6116b7635f2e2dba 100644 (file)
@@ -8,5 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn force(f: || -> int) -> int { f() }
 fn main() { println!("{:?}", force(|| {})); } //~ ERROR mismatched types
index 018b0aaecfda4f271cb6ced39add1a7164654813..270142c637807c4cdc72fc3eab0afffff2ea433c 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn main() {
     let y: Box<int> = box 42;
index e32d8a78585de2a6fa1e40a7892cbf76d0e69a77..f40b866214d71e16354174a894bf087f9dcd6f03 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn main() {
     let y: Box<int> = box 42;
index f2b8976c61b930f52ef0c997e45dc687d47828f8..9927e2ea9da3124c161fcbee65849d434391feaa 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn main() {
     let x = box 5;
     let y = x;
index 2716d476c3a174ed4481661047b953692db94454..6a2a1e7dec55653f2f2000d07c19758991300ca8 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn send<T:Send>(ch: _chan<T>, data: T) {
     println!("{:?}", ch);
index 3e1c9e850fa9e4b6926fefb45d06e0fb2fa33b5f..c16d85cd73eed80fd76c7c50c54029f3928e3165 100644 (file)
@@ -11,6 +11,8 @@
 // a good test that we merge paths correctly in the presence of a
 // variable that's used before it's declared
 
+extern crate debug;
+
 fn my_fail() -> ! { fail!(); }
 
 fn main() {
index fd44b693dde6a2b1d8bc0ae2433efb29d8128d15..15cf176a0dbcbfa2983b079dbed90e7fab9b6f9a 100644 (file)
@@ -11,6 +11,8 @@
 // Tests that if you move from `x.f` or `x[0]`, `x` is inaccessible.
 // Also tests that we give a more specific error message.
 
+extern crate debug;
+
 struct Foo { f: String, y: int }
 fn consume(_s: String) {}
 fn touch<A>(_a: &A) {}
index 3521347705b95b668d5441bee750ced19a8acaa9..aded89e5820ae10aee5953f786132f00c1ea7158 100644 (file)
@@ -12,6 +12,8 @@
 // bound must be noncopyable. For details see
 // http://smallcultfollowing.com/babysteps/blog/2013/04/30/the-case-of-the-recurring-closure/
 
+extern crate debug;
+
 struct R<'a> {
     // This struct is needed to create the
     // otherwise infinite type of a fn that
index 825a8fc604c6ffff8e95cb37188ccad88fb83143..0f7491e231bc05ba1676f8bda6f7e5802aeab9c8 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 use std::task;
 
 struct Port<T>(@T);
index 778f3a3b997845b84f4fa487d425b4e080307699..8594e7ca625e74533e6bd9b4b306d968522a9ecb 100644 (file)
@@ -10,6 +10,9 @@
 
 // Test that a class with a non-copyable field can't be
 // copied
+
+extern crate debug;
+
 struct bar {
   x: int,
 }
index c0749984cc9e38a064409884e9eea4ea9e8e6a68..97a514e158416f2692f0eafbd38cb3dd63f9de2c 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:non-scalar cast
 
+extern crate debug;
+
 struct foo {
     x:int
 }
index 45e6b76e200386aa2f9ad3df2f044e101e6d77c7..b5bb3314dcf1bcc411e66652aaa73bb2a4644b30 100644 (file)
@@ -15,6 +15,8 @@
 
 // error-pattern: transmute called on types with different size
 
+extern crate debug;
+
 use std::mem;
 
 #[packed]
index 24be7d3a2972f8d9113a4adb4a01616c570fd6ae..0611c470d10185185e48432d23146b635a42ad21 100644 (file)
@@ -15,6 +15,8 @@
 
 // error-pattern: transmute called on types with different size
 
+extern crate debug;
+
 use std::mem;
 
 #[packed]
index e1566e7c897244e9256bced3070f99b8d2023a3d..83f2ef250dc5027bbdcd71075cbf80cea773153d 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern: mismatched types
 
+extern crate debug;
+
 enum bar { t1((), Option<Vec<int> >), t2, }
 
 fn foo(t: bar) {
index 49f2f35d29dcdc7029e30f453f2bdf1fec309d53..e118549f2c2e7fa54ec56c0f7671ce8678037b32 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 use std::cell::Cell;
 
 struct r {
index 04d8bc96a4717af69da4f9635b2a0ef9f242c569..1b767e0270bffbb65f1ac87c368172b270c4dd50 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 struct r {
   b: bool,
 }
index adeecf2babf32c1041907cc4abe648b6adeb818e..91d4c39edcb62aea23b27904a5b1032a8716bd40 100644 (file)
@@ -10,6 +10,7 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
 use std::cell::Cell;
 
 struct r {
index 2367645aefa578146e918fb5891641a2c310d581..7def090edbb1173ba99e87954d69476e40d99962 100644 (file)
@@ -110,6 +110,6 @@ fn main() {
          '\u205F', '\u3000'];
     for c in chars.iter() {
         let ws = c.is_whitespace();
-        println!("{:?} {:?}" , c , ws);
+        println!("{} {}" , c , ws);
     }
 }
index 95fcda38b9e9304699b1f6e07633e23a08ac7413..777c456335dc4237b351393cc69d432e459cb07c 100644 (file)
@@ -104,6 +104,6 @@ fn main() {
          '\u2028', '\u2029', '\u202F', '\u205F', '\u3000'];
     for c in chars.iter() {
         let ws = c.is_whitespace();
-        println!("{:?} {:?}", c , ws);
+        println!("{} {}", c , ws);
     }
 }
index 549a101654ba2fbcb048722508968852f0bcf7d6..216cf7211f674e613735eeabbf25b4e7fcdae441 100644 (file)
@@ -10,6 +10,8 @@
 
 // error-pattern:called `Result::unwrap()` on an `Err` value
 
+extern crate debug;
+
 use std::result;
 
 fn main() {
index 50ecedd68fe2d866acb3578478b36932c1d9d0cb..e3507ff450bb61c997d92db688118353b4b87bcd 100644 (file)
@@ -12,6 +12,8 @@
 
 // error-pattern:fail
 
+extern crate debug;
+
 fn failfn() {
     fail!();
 }
index 2044d6f1cc815c5083034c06eba31bf33ce3a041..0750c1897ee8b8fe3819d1b0525d1aa9331b78d3 100644 (file)
@@ -12,6 +12,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 use std::mem;
 
 fn failfn() {
index 08c8461afe02929d79a55131485fce9ed5ffd054..dd6303ad18348a1c38c472b13ef13cc3b4b0452e 100644 (file)
@@ -12,6 +12,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 fn failfn() {
     fail!();
 }
index 82da2bc6ca3d18212f62a2a206bc8826846e2d4c..9cb17163d11ccf1223a2082a1350dbdefcfd35ca 100644 (file)
@@ -12,6 +12,7 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
 
 fn failfn() {
     fail!();
index 99adaaad314d5a5396803d8f3aba38c85f95fbe5..91681ff3b780f84b06816fd3192a7cd884191606 100644 (file)
@@ -12,6 +12,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 fn failfn() {
     fail!();
 }
index 07d978a191d409bc496be140b60c258cdf0ecd6f..7946812bae58e0e7de0daf9a7172737a4069b478 100644 (file)
@@ -12,6 +12,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 fn failfn() {
     fail!();
 }
index 0af2be8ab2940ff41fbee8da4ee44ccab77e659b..38a3d3c5fffdc475bb19189098e3e6d33647e9af 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 struct pair<A,B> {
     a: A, b: B
index c2b276aac095b9e14b51ffb4979cfac895a439da..51af6444e9c71cd3848ed67028d875d8475476af 100644 (file)
@@ -8,9 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
-
+extern crate debug;
 
 struct Pair<T, U> { a: T, b: U }
 struct Triple { x: int, y: int, z: int }
index 8d0412ba30ef6baf5ac763c0b0d135e338c5370e..59786e993f2630f1171920114c54292124568be2 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn inty(fun: proc(int) -> int) -> int {
     fun(100)
 }
index 6ffb032090c9a8264438039d7301a15508a046ca..4f0cf855dd11f95f8dfdb094a62e90066ecbeaa0 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+extern crate debug;
 
 fn iter_vec<T>(v: Vec<T> , f: |&T|) { for x in v.iter() { f(x); } }
 
index 5f4154290ac70d5eb00cf940675eb1a89d2520cd..8d28022bc1df65046111e6ddc907de50769d9354 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+extern crate debug;
 
 fn iter_vec<T>(v: Vec<T> , f: |&T|) { for x in v.iter() { f(x); } }
 
index ea849ee9829e9853a7b863f45a1f8c3a6e0ce07f..1ab573db37b87a0d9326789dddc64e9c6e0c9c03 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 use std::mem::swap;
 
 struct Ints {sum: Box<int>, values: Vec<int> }
index 3e14d5b82c47d87d93381fa43dee62f50df3430c..acae61359370bb1d44f2c78904d786a900ea74a8 100644 (file)
@@ -12,6 +12,7 @@
 // storing closure data (as we used to do), the u64 would
 // overwrite the u16.
 
+extern crate debug;
 
 struct Pair<A,B> {
     a: A, b: B
index 03617537c49bba0ae704029ad17fbb409649240d..7f5454405df7a6e0961f06605a320912f24e1cad 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 use std::task;
 
 pub fn main() {
index 944141839cf54090f895672ccf4e3e2ad08c7399..56b38033c8327813204848e710cf2bf8556e2d9c 100644 (file)
@@ -14,6 +14,7 @@
 #![feature(phase)]
 #[phase(syntax, link)]
 extern crate log;
+extern crate debug;
 
 pub fn main() {
     // only fails if println! evaluates its argument.
index 732c50afbf3b2dd5563980613aed5e5592243084..399a145468d133e43977a6ef1f92e702be92d982 100644 (file)
@@ -10,6 +10,8 @@
 
 // exec-env:RUST_LOG=conditional-debug-macro-on=4
 
+extern crate debug;
+
 pub fn main() {
     // exits early if println! evaluates its arguments, otherwise it
     // will hit the fail.
index e99b0ed185b398b49f15d7fc55f5db8d61723d28..ff44c76048fab4028e22a75c9b7b816fc9e09bcb 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 static x : [int, ..4] = [1,2,3,4];
 static p : int = x[2];
 static y : &'static [int] = &[1,2,3,4];
index 3935bb241c75134760d1c77d0010b6691985c2ad..a1cd4fe425336db0984b8988acaf04e8b3e17e9c 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 static x : [int, ..4] = [1,2,3,4];
 static y : &'static [int] = &[1,2,3,4];
 
index 15a8a2e9eac2d6334bb003e5ae6f564a6ba5f037..122c4b47310c740b0ab1ccc00d67e444a2838ed0 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 use std::cell::Cell;
 
 pub fn main() {
index 85da586a72c0185a1a3c3bbbb8c43cc51e5ead69..814e2cca97cc7c1bb3244b4640be418c6d58aa58 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(macro_rules)]
 
+extern crate debug;
+
 macro_rules! check {
     ($m:ident, $t:ty, $v:expr) => {{
         mod $m {
index f8e1dc27e32f81fa38c9e5938a17bae7bb41b859..9c5995b7ba010af9823e838f35ced7f5293b8d90 100644 (file)
@@ -10,6 +10,8 @@
 
 #![allow(dead_assignment)]
 
+extern crate debug;
+
 pub fn main() {
     let x : &[int] = &[1,2,3,4,5];
     let mut z = &[1,2,3,4,5];
index 277f0011c1cfb7a719b3d22059f794b4173799dd..4cd7e7112a9e53394ef97fae15b2a7a7291cfa71 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+extern crate debug;
 
 pub fn main() {
     let pi = 3.1415927;
index 520735c05c33b978eae0fe3088ad51e6f14b7bc9..3267ca061717809e71a26a041aad83836be2b431 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 use std::cell::RefCell;
 
 pub fn main() {
index 10efc0b53f228b2f3f219e3e32bf99354dd314ec..215de30535d9ed146b58f55281d6fd910d478b53 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 struct Foo {
     x: int,
     y: int
index 1de3fcd202ba2c6e6aad98c1ee4c3aa04cc968de..1d1e4864acb1e0048d2bf8495083ba0ce72688a4 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 fn id<T>(t: T) -> T { return t; }
 
 pub fn main() {
index f13383589035c402fe0c44430c2c78ed9f8f4285..0fd4ba3ec5ff323b6f990288dcf05397a0b01424 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn id<T:Send>(t: T) -> T { return t; }
 
index 80f64d8df3d8fabb382006e987aa9711d7dc86b7..09a53f86f2db8a6ff50a12a45745ec413eba24fa 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+extern crate debug;
 
 fn g<X>(x: X) -> X { return x; }
 
index 8314208ca24b619ec52cad8398206bbf492f3402..d162daf7cecfd94ba2b8022c21bd1f4d4f60091a 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 fn f<T>(x: @T) -> @T { return x; }
 
 pub fn main() { let x = f(@3); println!("{:?}", *x); }
index c0b3fd5bc94b0fd611fc7ade619497f9e51611e6..d8f782d9773779c18016e4720c7051b09c87a588 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn f<T>(x: Box<T>) -> Box<T> { return x; }
 
index e9848960180961df381341cfd2f92bd971fac9b4..e3ed380c37eabf6738d949ad4cdc7162fe2cf144 100644 (file)
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+extern crate debug;
 
 enum noption<T> { some(T), }
 
index 2e9bd371e29ccbfaae98f4286cc94a3f6f28ec31..d0ae17053ae5733aca6b5040428a166473ac81cb 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 fn get_third<T>(t: (T, T, T)) -> T { let (_, _, x) = t; return x; }
 
 pub fn main() {
index 6ccd9c33be91cd44127f22c35cb6dec029f76c14..8fc84cece5a7ff46e29cbd298eaa6460eacc7511 100644 (file)
@@ -1,4 +1,3 @@
-
 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
@@ -10,6 +9,7 @@
 // except according to those terms.
 
 extern crate getopts;
+extern crate debug;
 
 use getopts::{optopt, getopts};
 
index d7eb2de36b03457256445de12a405087f6164b6e..e64ef3def2db7fb9b0ab5cb140d689c230594051 100644 (file)
@@ -12,7 +12,7 @@
 #![feature(managed_boxes)]
 
 extern crate collections;
-
+extern crate debug;
 
 /**
    A somewhat reduced test case to expose some Valgrind issues.
index 97429131a7c3261b26aac2b96991153ded3f81aa..c5193b2aa6f4d155e98b7f0cf2cf38c11a6730c7 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+extern crate debug;
 
 pub fn main() {
     let i: int = if false { fail!() } else { 5 };
index 6d875a7ff9b558469737c3161439a0179bf74911..b69450024f656685757be2fd16efa750e47f6388 100644 (file)
@@ -15,6 +15,8 @@
 #![allow(unused_must_use)]
 #![allow(deprecated_owned_vector)]
 
+extern crate debug;
+
 use std::fmt;
 use std::io::MemWriter;
 use std::io;
index 6b0ad24da1d20059e07ecb13324f7a06181c94f1..5d404909bf229b54655a97cbb95ffa2e978c353d 100644 (file)
@@ -1,4 +1,3 @@
-
 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
@@ -9,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 mod foo {
     pub fn x(y: int) { println!("{:?}", y); }
 }
index 0113b8e2fd99fabc1c6aa1028533da136ecc5eca..29384424cbed2b9cc63e571975ab3baae5092c83 100644 (file)
@@ -1,4 +1,3 @@
-
 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
@@ -10,6 +9,7 @@
 // except according to those terms.
 
 extern crate collections;
+extern crate debug;
 
 use collections::HashMap;
 
index 311ce2d64b20dc9feeef6cde53395ceb22e6175b..ae5cff0dddf4cb704a3356d61fe8e9bcff5c856b 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 pub fn main() {
     let mut x = 0;
 
index 7ad8ff9bfaa0b35be72d9bce9d9a9824fe251237..f8032d99ebec083e37deb64049af8023eadef8de 100644 (file)
@@ -13,6 +13,7 @@
 // clobber the previous node ID in a macro expr
 
 extern crate collections;
+extern crate debug;
 
 use collections::HashMap;
 
index fd0cfb5425defcb5ca0cbfa271502432759635fa..fa5cd97202928ab382bc764dcc7bc56823b87c76 100644 (file)
@@ -11,6 +11,7 @@
 
 extern crate collections;
 extern crate serialize;
+extern crate debug;
 
 use collections::HashMap;
 use serialize::json;
index 5542418ebddb2621fe961ebf6d628f657a4be591..d48a944c2f0d8aa060d9d2a4b371fd56cde7923d 100644 (file)
@@ -11,6 +11,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 /// Map representation
 
 use std::io;
index dc22ebce804e643d6fea7c1482c61dadb5acb820..cef4296688952ba96b8e91dcaf06b93f0edfd75c 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 pub fn main() {
     println!("{:?}", ("hi there!", "you"));
 }
index b9b3301fc883dfa2aeeb3e3a922b72400358c5df..9f3cb653eb947f168f700177b9ed68dca10a6741 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 enum Token {
     Text(@String),
     ETag(@Vec<String> , @String),
index b08e6525ba5133bd73c022950c84abc37a845ae5..00878189627aebf0a64f4b5404d33ca0d4280fac 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 trait T {
     fn print(&self);
index ba080e9818302f7d9c8af3249de5a87ce82d7492..151d00eb2d02b0619e5ff24f87bf608ecc5785d5 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 trait X {
     fn call<T>(&self, x: &T);
     fn default_method<T>(&self, x: &T) {
index 869374d6ad4fb64fbd917d674b6ce679bae1359e..281070754c4c798533c23992a79440a67fbbbcf5 100644 (file)
@@ -17,6 +17,8 @@
 failed to typecheck correctly.
 */
 
+extern crate debug;
+
 struct X { vec: &'static [int] }
 static V: &'static [X] = &[X { vec: &[1, 2, 3] }];
 pub fn main() {
index 99d943a2f6bdcfc693813101babded1631902b64..0b5e92fcf3075d2b7df840b4429de481f154fd86 100644 (file)
@@ -7,6 +7,9 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+
+extern crate debug;
+
 struct A { x: uint }
 
 impl Drop for A {
index f51221c419ef070a86e6049adf13323afd1ea8f2..67807a8275927e4dbb60f26e8b3c20f8e18ab2cd 100644 (file)
@@ -7,6 +7,9 @@
 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
+
+extern crate debug;
+
 struct A { x: uint }
 
 impl Drop for A {
index 538699512a3afe01fd0c3d4750e14bffe8d168c7..bf62c2e459a814a1830a301259c333a950403ba9 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 trait IDummy {
     fn do_nothing(&self);
 }
index 595ddffd39cff9875c31bea381e802d49db8cba2..ac0ac95c73bbe0a682b654a88168d85402b0d45c 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 fn assert_repr_eq<T>(obj : T, expected : String) {
     assert_eq!(expected, format_strbuf!("{:?}", obj));
 }
index 5e892d5433e7a9ec598b8b6fe76a103608232080..f381bb02e540dffc479cadf0b82f6eabb4fcb7d6 100644 (file)
@@ -10,6 +10,7 @@
 
 // Make sure #1399 stays fixed
 
+extern crate debug;
 
 struct A { a: Box<int> }
 
index aa303aa3b817058014720d9f8e090fb588eaf32b..c4f37ccf88ad389fdea6660de57f90d95808f474 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+extern crate debug;
 
 fn incr(x: &mut int) -> bool { *x += 1; assert!((false)); return false; }
 
index b260e0af9e3ad728d46f22c35be9a8217ae67749..665456bb457042cbacb6f0baef2f889f7289c76a 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 pub fn main() {
     let x = vec!(1, 2, 3);
     let mut y = 0;
index dd0e9dc4295f7882f021f4039066f21873886122..d26075af3cedee665795c723d5bfd3ef6fa22f63 100644 (file)
@@ -1,4 +1,3 @@
-
 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
@@ -9,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 #[deriving(Clone)]
 enum foo {
   a(uint),
index 2a8402cc3fc335d3b0bca4849155879899eba568..2956a030faa55458f49827ee2d3c4337a461206f 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 enum foo {
   a(uint),
   b(String),
index 69685b58ab5046820e1d8a068d5362b7816cdf17..17fa14ec92daf7f8a15b7487ac1a70dacf581964 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 enum Numbers {
     Three
 }
index 9fae0e30d5935347e1aeab3c6d858e444d2a3087..26d5a018a667806ea888c41dfcfd0a7a6b5eb5fc 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 pub fn main() {
     match box 100 {
       box x => {
index 5f86cde261c5ce484a5f9527d56fcf66883049ab..571b3371fe6b0a3ea3e75aadba50586817d7836f 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn baz() -> ! { fail!(); }
 
index 9a2e83ef2d07c129d8883123ccd5f31da8743a60..3cc485c8f3ab2612d9279349538bfa1318b0f525 100644 (file)
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+extern crate debug;
 
 // Regression test for issue #152.
 pub fn main() {
index c6f3dae7fc177c18cf117d5b4284d257f0befdc3..1727de79c7862ba6f3fe14f6158158e0d4ff29c0 100644 (file)
@@ -11,6 +11,8 @@
 // Test overloading of the `[]` operator.  In particular test that it
 // takes its argument *by reference*.
 
+extern crate debug;
+
 use std::ops::Index;
 
 struct AssociationList<K,V> {
index 5b274ea079acf80422d95dabd10e350c4835c820..1d48cd3226d00124a6a6e94a88f81b82da39e2d5 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 fn magic(x: A) { println!("{:?}", x); }
 fn magic2(x: @int) { println!("{:?}", x); }
 
index 16755190a140541cf7f7b6ed44d0ca3fcbee4ea0..69a4c1cd05374a522056d106af309f0521d28852 100644 (file)
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
 // Issue #2303
 
+extern crate debug;
+
 use std::mem;
 
 mod rusti {
index f96794b0b886765a8951a442dd4ae915d50a153e..399f947df06cf862e89379695cd9968647709623 100644 (file)
@@ -8,9 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
 // Issue #2303
 
+extern crate debug;
+
 use std::mem;
 
 mod rusti {
index f1e6c6a0e2fe57e1d3dc0c32a261d35780185065..33f080d8db257911ca1cfc2e4baf7f20dd6187ca 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 struct Clam<'a> {
     chowder: &'a int
 }
index c4037a70d96963cc81f6fbb8466d1ffbd681d32d..9b817c5c90644b3e448c2ad6405050d951146358 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 enum int_wrapper<'a> {
     int_wrapper_ctor(&'a int)
 }
index 62be58605084bb2979c916f7f40860cfefb3f1f8..bcd66eef957dbc8b6ba9e90641fc6dab0c476b90 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 pub fn main() {
     let mut x: int = 3;
     let y: &mut int = &mut x;
index 38f0f12267ba5a403b7d7294f1f50df07b7a5232..27c5e5397f954dbb74d103d9f6163aa57b7c0720 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 pub fn main() {
     let x = [ [true], ..512 ];
     let y = [ 0, ..1 ];
index 837ae68c85e650a643c18fd7b71476735bfaebf5..9b0837594cfde8761e6c9b78c4f064827e8ec29c 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 use std::cell::Cell;
 
 struct r {
index a6ae21c81f1948b7043962a6b44815dff2286199..a65e44166e9eded28c384d9b3293d4b1555d1a6d 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn foo(c: Vec<int> ) {
     let a: int = 5;
index 96fd75c5156f05ba769a139732403c9518cc5028..0f1882167451e99650ea0fd1c6f8995b0806650f 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(managed_boxes)]
 
+extern crate debug;
+
 // Exercises a bug in the shape code that was exposed
 // on x86_64: when there is an enum embedded in an
 // interior record which is then itself interior to
index 1989b638680c6e6f255c68221cbb96f4c29c569d..c28e128dd05274eb5b1642e5185279ba4cfd1fe8 100644 (file)
@@ -8,18 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// copyright 2013-2014 the rust project developers. see the copyright
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/copyright.
-//
-// licensed under the apache license, version 2.0 <license-apache or
-// http://www.apache.org/licenses/license-2.0> or the mit license
-// <license-mit or http://opensource.org/licenses/mit>, at your
-// option. this file may not be copied, modified, or distributed
-// except according to those terms.
-
 // ignore-win32
 
+extern crate debug;
+
 use std::os;
 use std::io::process::{Command, ExitSignal, ExitStatus};
 
index c91b16c9ca02a3de64ba87ff7c7fe8c22587c10b..5d07ca56041c423d687d4f3a9f603e2967600ed3 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 enum clam<T> { a(T, int), b, }
 
index 060274f1bc7895c8fa7ee9b3e1252fe180d34fb8..e7d4e25c2bb998f7450db6aa92cffd1df90e39af 100644 (file)
@@ -10,6 +10,8 @@
 
 #![feature(macro_rules)]
 
+extern crate debug;
+
 use std::mem::size_of;
 
 #[deriving(Eq, Show)]
index 34ae825c0d2c90e154ef8b7ba6d404825f6861e5..15301e96e69dcbe2ac2b83740e9dc4088393d6d0 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 use std::task;
 
 fn x(s: String, n: int) {
index 75d7b3ed2cde5b944110c222d747f64839b65394..8ac13e81463acaeb3aa441a8f93e8093ed241a84 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
+extern crate debug;
 
 pub fn main() {
     let s = "hello".to_string();
index c07ca9cae76b674759d2eca42d3b13e2dfcf6742..e161f6887e116e3d67b0d07fc30e3c3465c9d57c 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 enum a_tag {
     a_tag(u64)
index beb0c5dbe815ada004dadc20c52d1e356c2a08e2..57f0f862fbf9189db1aeb6616bfb0502a113de9a 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 enum color {
     red = 0xff0000,
     green = 0x00ff00,
index 5cf6c2af12b85322f81a81bc7291c76a7389ad4e..13a2ab47bf3a3491b3449ef6e82b2d85bdde7d63 100644 (file)
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
+extern crate debug;
 
 fn checktrue(rs: bool) -> bool { assert!((rs)); return true; }
 
index 3fb91b67c9d27cf698adfa78ffb6e1ba426978ce..217bab5c1dea6fdd6b032cef2aa71d33e8f1eb22 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 use std::task::TaskBuilder;
 
index 188d8288b095ea2aeb98dc4ea4554378642038bf..ab6498c00279b07be5aaf854539010a0ccce9e1f 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 use std::task::TaskBuilder;
 
index 799d07891db0cfff2e367fd4258e74fc870bb7a8..4034c2571cd078094dd910adf4a283f25b382a99 100644 (file)
@@ -18,6 +18,7 @@
 extern crate libc;
 extern crate green;
 extern crate rustuv;
+extern crate debug;
 
 use std::io::net::tcp::{TcpListener, TcpStream};
 use std::io::{Acceptor, Listener};
index 387a454542adf3cb694dbcd6333b8dbf35f1184f..316d1facb18ff54bf8901c867461979578fd3c17 100644 (file)
@@ -18,6 +18,8 @@
 // they're in a different location than before. Hence, these tests are all run
 // serially here.
 
+extern crate debug;
+
 use std::io::{fs, TempDir};
 use std::io;
 use std::os;
index 840ab18dafa3d9a690a72cc80534041c5e282547..2b60cf12cc5b523ac784a398c44ad7fed8471136 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 /*
   This is about the simplest program that can successfully send a
   message.
index 3c15bc0bd6bf404ffcaa43eee6c8fdeb635b2853..0c2dc121828c103ba7aca2e9d44fe757cb08ca4a 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 struct Foo(int, int);
 
 pub fn main() {
index 2045beb7f32dc11ca55cb9a212d1fc3611731922..42ed47ebbb77fe81a73b828c449cd0c1a5b4cf42 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 fn test1() {
     enum bar { u(Box<int>), w(int), }
index e2de566090dc0334257b0fcbece389f0d1e4f8a6..994e8df417db0ef0c8dfd3593dc6ed05d98e0bbd 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
+
 pub fn main() {
     let i = box 100;
     println!("{:?}", i);
index 55fda4c11069e04e79222ab6557055e73003febf..13416c5acbbbd81df9e39b447f423408a33d350b 100644 (file)
@@ -8,6 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+extern crate debug;
 
 enum bar { u(Box<int>), w(int), }