From b53454e2e413ac58da20933968cb4a86a3c7c476 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 22 May 2014 11:28:01 -0700 Subject: [PATCH] Move std::{reflect,repr,Poly} to a libdebug crate 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] --- mk/crates.mk | 11 +- src/doc/guide-container.md | 24 +- src/doc/guide-pointers.md | 20 +- src/doc/guide-tasks.md | 2 +- src/doc/tutorial.md | 30 +- src/liballoc/lib.rs | 2 + src/libcollections/lib.rs | 1 + src/libcore/ops.rs | 5 +- src/libcore/slice.rs | 4 +- src/libdebug/fmt.rs | 53 ++ src/libdebug/lib.rs | 32 + src/libdebug/reflect.rs | 438 ++++++++++++ src/libdebug/repr.rs | 659 ++++++++++++++++++ src/libgetopts/lib.rs | 1 + src/libgreen/stack.rs | 4 +- src/libnative/lib.rs | 1 + src/librand/lib.rs | 10 +- src/librustc/lib.rs | 11 +- src/librustdoc/lib.rs | 13 +- src/librustuv/lib.rs | 1 + src/libserialize/ebml.rs | 13 +- src/libserialize/hex.rs | 2 +- src/libserialize/json.rs | 10 +- src/libstd/fmt.rs | 50 +- src/libstd/lib.rs | 1 + src/libsyntax/ext/format.rs | 36 +- src/libsyntax/lib.rs | 1 + src/libtime/lib.rs | 2 + src/libworkcache/lib.rs | 6 +- .../auxiliary/extern_calling_convention.rs | 2 + src/test/auxiliary/logging_right_crate.rs | 1 + src/test/bench/msgsend-pipes-shared.rs | 1 + src/test/bench/msgsend-pipes.rs | 1 + src/test/bench/std-smallintmap.rs | 1 + src/test/compile-fail/autoderef-full-lval.rs | 2 + src/test/compile-fail/block-coerce-no.rs | 2 + .../borrowck-borrowed-uniq-rvalue-2.rs | 2 + .../compile-fail/borrowck-if-with-else.rs | 2 + .../compile-fail/borrowck-init-in-fn-expr.rs | 2 + .../borrowck-move-out-of-vec-tail.rs | 2 + .../borrowck-mut-addr-of-imm-var.rs | 2 + src/test/compile-fail/copy-a-resource.rs | 2 + .../compile-fail/if-without-else-result.rs | 2 + src/test/compile-fail/issue-1476.rs | 2 + src/test/compile-fail/issue-2823.rs | 2 + src/test/compile-fail/issue-3038.rs | 2 + src/test/compile-fail/issue-3521.rs | 2 + src/test/compile-fail/issue-5062.rs | 2 + src/test/compile-fail/issue-6458-2.rs | 2 + .../liveness-closure-require-ret.rs | 2 + .../compile-fail/liveness-move-in-loop.rs | 1 + .../compile-fail/liveness-move-in-while.rs | 1 + .../compile-fail/liveness-use-after-move.rs | 2 + .../compile-fail/liveness-use-after-send.rs | 1 + src/test/compile-fail/match-join.rs | 2 + .../moves-based-on-type-access-to-field.rs | 2 + ...ased-on-type-no-recursive-stack-closure.rs | 2 + src/test/compile-fail/no-send-res-ports.rs | 2 + src/test/compile-fail/noncopyable-class.rs | 3 + src/test/compile-fail/nonscalar-cast.rs | 2 + .../packed-struct-generic-transmute.rs | 2 + .../compile-fail/packed-struct-transmute.rs | 2 + src/test/compile-fail/pattern-tyvar.rs | 2 + src/test/compile-fail/pinned-deep-copy.rs | 2 + src/test/compile-fail/unique-pinned-nocopy.rs | 2 + src/test/compile-fail/unique-vec-res.rs | 1 + src/test/pretty/block-comment-wchar.pp | 2 +- src/test/pretty/block-comment-wchar.rs | 2 +- src/test/run-fail/result-get-fail.rs | 2 + src/test/run-fail/unwind-box-fn-unique.rs | 2 + src/test/run-fail/unwind-box-res.rs | 2 + src/test/run-fail/unwind-box-str.rs | 2 + src/test/run-fail/unwind-box-unique-unique.rs | 1 + src/test/run-fail/unwind-box-unique.rs | 2 + src/test/run-fail/unwind-box-vec.rs | 2 + src/test/run-pass/alignment-gep-tup-like-1.rs | 1 + src/test/run-pass/auto-instantiate.rs | 4 +- src/test/run-pass/block-arg.rs | 2 + src/test/run-pass/block-iter-1.rs | 2 +- src/test/run-pass/block-iter-2.rs | 2 +- src/test/run-pass/borrowck-mut-uniq.rs | 2 + .../close-over-big-then-small-data.rs | 1 + src/test/run-pass/comm.rs | 2 + .../run-pass/conditional-debug-macro-off.rs | 1 + .../run-pass/conditional-debug-macro-on.rs | 2 + .../run-pass/const-fields-and-indexing.rs | 2 + src/test/run-pass/const-vecs-and-slices.rs | 2 + src/test/run-pass/deref-lval.rs | 2 + src/test/run-pass/enum-discrim-width-stuff.rs | 2 + src/test/run-pass/evec-slice.rs | 2 + src/test/run-pass/float.rs | 2 +- src/test/run-pass/format-ref-cell.rs | 2 + src/test/run-pass/functional-struct-upd.rs | 2 + src/test/run-pass/generic-alias-box.rs | 2 + src/test/run-pass/generic-alias-unique.rs | 1 + src/test/run-pass/generic-derived-type.rs | 2 +- src/test/run-pass/generic-fn-box.rs | 2 + src/test/run-pass/generic-fn-unique.rs | 1 + src/test/run-pass/generic-tag-values.rs | 3 +- src/test/run-pass/generic-tup.rs | 2 + src/test/run-pass/getopts_ref.rs | 2 +- src/test/run-pass/hashmap-memory.rs | 2 +- src/test/run-pass/if-bot.rs | 2 +- src/test/run-pass/ifmt.rs | 2 + src/test/run-pass/import.rs | 3 +- src/test/run-pass/issue-1696.rs | 2 +- src/test/run-pass/issue-2216.rs | 2 + src/test/run-pass/issue-2804-2.rs | 1 + src/test/run-pass/issue-2804.rs | 1 + src/test/run-pass/issue-2904.rs | 2 + src/test/run-pass/issue-3109.rs | 2 + src/test/run-pass/issue-3556.rs | 2 + src/test/run-pass/issue-3794.rs | 1 + src/test/run-pass/issue-4252.rs | 2 + src/test/run-pass/issue-5688.rs | 2 + src/test/run-pass/issue-6344-let.rs | 3 + src/test/run-pass/issue-6344-match.rs | 3 + src/test/run-pass/issue-7563.rs | 2 + src/test/run-pass/issue-8898.rs | 2 + src/test/run-pass/last-use-is-capture.rs | 1 + src/test/run-pass/lazy-and-or.rs | 2 +- src/test/run-pass/linear-for-loop.rs | 2 + .../log-knows-the-names-of-variants-in-std.rs | 3 +- .../log-knows-the-names-of-variants.rs | 2 + src/test/run-pass/log-poly.rs | 2 + src/test/run-pass/match-unique-bind.rs | 2 + src/test/run-pass/nested-matchs.rs | 1 + src/test/run-pass/over-constrained-vregs.rs | 3 +- src/test/run-pass/overload-index-operator.rs | 2 + src/test/run-pass/pass-by-copy.rs | 2 + src/test/run-pass/rec-align-u32.rs | 3 +- src/test/run-pass/rec-align-u64.rs | 3 +- src/test/run-pass/regions-self-impls.rs | 2 + src/test/run-pass/regions-self-in-enums.rs | 2 + src/test/run-pass/regions-simple.rs | 2 + src/test/run-pass/repeated-vector-syntax.rs | 2 + .../run-pass/resource-assign-is-not-copy.rs | 2 + src/test/run-pass/shadow.rs | 1 + .../run-pass/shape_intrinsic_tag_then_rec.rs | 2 + src/test/run-pass/signal-exit-status.rs | 12 +- src/test/run-pass/size-and-align.rs | 1 + src/test/run-pass/small-enums-with-fields.rs | 2 + src/test/run-pass/spawn-fn.rs | 2 + src/test/run-pass/str-idx.rs | 2 +- src/test/run-pass/tag-align-shape.rs | 1 + src/test/run-pass/tag-disr-val-shape.rs | 2 + src/test/run-pass/tail-cps.rs | 3 +- src/test/run-pass/task-comm-3.rs | 1 + src/test/run-pass/task-comm-9.rs | 1 + src/test/run-pass/tcp-stress.rs | 1 + src/test/run-pass/tempfile.rs | 2 + src/test/run-pass/trivial-message.rs | 2 + src/test/run-pass/tuple-struct-construct.rs | 2 + src/test/run-pass/unique-in-tag.rs | 1 + src/test/run-pass/unique-log.rs | 2 + src/test/run-pass/unique-pat-3.rs | 1 + 156 files changed, 1545 insertions(+), 147 deletions(-) create mode 100644 src/libdebug/fmt.rs create mode 100644 src/libdebug/lib.rs create mode 100644 src/libdebug/reflect.rs create mode 100644 src/libdebug/repr.rs diff --git a/mk/crates.mk b/mk/crates.mk index a0a0bc800c4..a4dc0c0465e 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -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 diff --git a/src/doc/guide-container.md b/src/doc/guide-container.md index 1ab92d45378..30bfd28d57e 100644 --- a/src/doc/guide-container.md +++ b/src/doc/guide-container.md @@ -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` ~~~ diff --git a/src/doc/guide-pointers.md b/src/doc/guide-pointers.md index 948d033e06c..1ab98138492 100644 --- a/src/doc/guide-pointers.md +++ b/src/doc/guide-pointers.md @@ -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 { Nil, Cons(T, Box>), @@ -190,7 +192,7 @@ enum List { fn main() { let list: List = 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); } ~~~ diff --git a/src/doc/guide-tasks.md b/src/doc/guide-tasks.md index f6b7946c86c..ad6ec65ef44 100644 --- a/src/doc/guide-tasks.md +++ b/src/doc/guide-tasks.md @@ -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()) # } ~~~ diff --git a/src/doc/tutorial.md b/src/doc/tutorial.md index 2a59e3a756a..011d1b2b5db 100644 --- a/src/doc/tutorial.md +++ b/src/doc/tutorial.md @@ -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 diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index bf870e101eb..7e250e130fa 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -74,8 +74,10 @@ 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; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 4c5f55e5376..cbf4ae03a76 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -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; diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 1eab5c04469..a3cb18a283e 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -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}); * } * ``` * diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 31313050165..795dd389958 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -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 index 00000000000..4087cb95271 --- /dev/null +++ b/src/libdebug/fmt.rs @@ -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 or the MIT license +// , 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(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 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 index 00000000000..452c3d2937c --- /dev/null +++ b/src/libdebug/lib.rs @@ -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 or the MIT license +// , 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 index 00000000000..367994466b2 --- /dev/null +++ b/src/libdebug/reflect.rs @@ -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 or the MIT license +// , 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 { + inner: V +} +pub fn MovePtrAdaptor(v: V) -> MovePtrAdaptor { + MovePtrAdaptor { inner: v } +} + +impl MovePtrAdaptor { + #[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(&mut self) { + self.align(mem::min_align_of::()); + } + + #[inline] + pub fn bump_past(&mut self) { + self.bump(mem::size_of::()); + } + + pub fn unwrap(self) -> V { self.inner } +} + +/// Abstract type-directed pointer-movement using the MovePtr trait +impl TyVisitor for MovePtrAdaptor { + 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::(); + if ! self.inner.visit_bool() { return false; } + self.bump_past::(); + true + } + + fn visit_int(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_int() { return false; } + self.bump_past::(); + true + } + + fn visit_i8(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_i8() { return false; } + self.bump_past::(); + true + } + + fn visit_i16(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_i16() { return false; } + self.bump_past::(); + true + } + + fn visit_i32(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_i32() { return false; } + self.bump_past::(); + true + } + + fn visit_i64(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_i64() { return false; } + self.bump_past::(); + true + } + + fn visit_uint(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_uint() { return false; } + self.bump_past::(); + true + } + + fn visit_u8(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_u8() { return false; } + self.bump_past::(); + true + } + + fn visit_u16(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_u16() { return false; } + self.bump_past::(); + true + } + + fn visit_u32(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_u32() { return false; } + self.bump_past::(); + true + } + + fn visit_u64(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_u64() { return false; } + self.bump_past::(); + true + } + + fn visit_f32(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_f32() { return false; } + self.bump_past::(); + true + } + + fn visit_f64(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_f64() { return false; } + self.bump_past::(); + true + } + + fn visit_f128(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_f128() { return false; } + self.bump_past::(); + true + } + + fn visit_char(&mut self) -> bool { + self.align_to::(); + if ! self.inner.visit_char() { return false; } + self.bump_past::(); + 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::>(); + if ! self.inner.visit_uniq(mtbl, inner) { return false; } + self.bump_past::>(); + 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::>(); + if ! self.inner.visit_trait(name) { return false; } + self.bump_past::>(); + 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 index 00000000000..6807e73982d --- /dev/null +++ b/src/libdebug/repr.rs @@ -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 or the MIT license +// , 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, + writer: &'a mut io::Writer, + last_err: Option, +} + +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(&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(&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::() } + fn visit_int(&mut self) -> bool { self.write::() } + fn visit_i8(&mut self) -> bool { self.write::() } + fn visit_i16(&mut self) -> bool { self.write::() } + fn visit_i32(&mut self) -> bool { self.write::() } + fn visit_i64(&mut self) -> bool { self.write::() } + + fn visit_uint(&mut self) -> bool { self.write::() } + fn visit_u8(&mut self) -> bool { self.write::() } + fn visit_u16(&mut self) -> bool { self.write::() } + fn visit_u32(&mut self) -> bool { self.write::() } + fn visit_u64(&mut self) -> bool { self.write::() } + + fn visit_f32(&mut self) -> bool { self.write::() } + fn visit_f64(&mut self) -> bool { self.write::() } + fn visit_f128(&mut self) -> bool { fail!("not implemented") } + + fn visit_char(&mut self) -> bool { + self.get::(|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>>(|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::>(|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(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { + unsafe { + let ptr = object as *T as *u8; + let tydesc = get_tydesc::(); + 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) -> 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, 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::, "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)"); +} diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 08aead02598..c88b825811f 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -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; diff --git a/src/libgreen/stack.rs b/src/libgreen/stack.rs index 1f06ba379f0..f42d636cafb 100644 --- a/src/libgreen/stack.rs +++ b/src/libgreen/stack.rs @@ -51,8 +51,8 @@ impl 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 { diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index d2d8ad06fdb..f04dfac80cc 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -59,6 +59,7 @@ extern crate alloc; extern crate libc; +#[cfg(test)] extern crate debug; use std::os; use std::rt; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 95c56152df6..4a11b692076 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -65,7 +65,7 @@ if rng.gen() { // bool ```rust let tuple_ptr = rand::random::>(); -println!("{:?}", tuple_ptr) +println!("{}", tuple_ptr) ``` */ @@ -80,8 +80,8 @@ println!("{:?}", tuple_ptr) #![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 @@ pub trait Rng { /// /// 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 @@ pub trait Rng { /// 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(&mut self) -> T { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 2459c1d53c0..6ef33c20786 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -31,16 +31,17 @@ This API is completely unstable and subject to change. #![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; diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 160994f603a..ae708a71987 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -16,17 +16,18 @@ #![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}; diff --git a/src/librustuv/lib.rs b/src/librustuv/lib.rs index 4bae9bb797a..20893b9e84c 100644 --- a/src/librustuv/lib.rs +++ b/src/librustuv/lib.rs @@ -44,6 +44,7 @@ via `close` and `delete` methods. #![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; diff --git a/src/libserialize/ebml.rs b/src/libserialize/ebml.rs index e6fe57006ca..a127c11f509 100644 --- a/src/libserialize/ebml.rs +++ b/src/libserialize/ebml.rs @@ -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 @@ pub mod reader { } fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult> { - 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 @@ pub mod reader { 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 @@ pub mod reader { fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult { 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 @@ mod tests { #[test] fn test_option_int() { fn test_v(v: Option) { - debug!("v == {:?}", v); + debug!("v == {}", v); let mut wr = MemWriter::new(); { let mut ebml_w = writer::Encoder(&mut wr); @@ -1094,7 +1095,7 @@ mod tests { 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); } diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index e72de88a06b..373bff8b0cc 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -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); * } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 4375e65891b..08ac66959bc 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1906,7 +1906,7 @@ impl ::Decoder for Decoder { names: &[&str], f: |&mut Decoder, uint| -> DecodeResult) -> DecodeResult { - 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 @@ impl ::Decoder for Decoder { names: &[&str], f: |&mut Decoder, uint| -> DecodeResult) -> DecodeResult { - debug!("read_enum_struct_variant(names={:?})", names); + debug!("read_enum_struct_variant(names={})", names); self.read_enum_variant(names, f) } @@ -3013,7 +3013,7 @@ mod tests { 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 @@ mod tests { 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 @@ mod tests { 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); diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index ba2bc261bc3..d53a0f93c9b 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -34,12 +34,15 @@ format arguments directly while performing minimal allocations. 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 over the argument. Each time a "next argument" specifier is seen, the 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 @@ -89,9 +92,12 @@ identifier '=' expression 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 @@ -101,18 +107,15 @@ parameters that are unused by the format string. ### 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 @@ -134,7 +137,7 @@ actually requesting that an argument ascribes to a particular trait. This allows 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` @@ -149,7 +152,11 @@ The current mapping of types to traits is: * `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 @@ to reference the string value of the argument which was selected upon. As an 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 @@ will look like `"\\{"`. 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 @@ pub use core::fmt::{secret_float, secret_upper_exp, secret_lower_exp}; pub use core::fmt::{secret_pointer}; #[doc(hidden)] +#[cfg(stage0)] pub fn secret_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(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 Poly for T { fn fmt(&self, f: &mut Formatter) -> Result { match (f.width, f.precision) { diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index bc1e3b82547..c1bc68b3e12 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -117,6 +117,7 @@ #[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 diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 86652cd50b0..f21239af6af 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -773,30 +773,30 @@ impl<'a, 'b> Context<'a, 'b> { 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 @@ impl<'a, 'b> Context<'a, 'b> { }; 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!( diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 52612bb4dec..627b2b71b35 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -36,6 +36,7 @@ extern crate collections; #[phase(syntax, link)] extern crate log; extern crate fmt_macros; +extern crate debug; pub mod util { pub mod interner; diff --git a/src/libtime/lib.rs b/src/libtime/lib.rs index 743ad823eb3..9b5bbbadc9c 100644 --- a/src/libtime/lib.rs +++ b/src/libtime/lib.rs @@ -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")] diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs index 9a82c411437..064979fa277 100644 --- a/src/libworkcache/lib.rs +++ b/src/libworkcache/lib.rs @@ -412,8 +412,7 @@ impl<'a> Prep<'a> { &'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 @@ impl<'a> Prep<'a> { 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())) } diff --git a/src/test/auxiliary/extern_calling_convention.rs b/src/test/auxiliary/extern_calling_convention.rs index 41c57831da6..4dbae50aad4 100644 --- a/src/test/auxiliary/extern_calling_convention.rs +++ b/src/test/auxiliary/extern_calling_convention.rs @@ -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) { diff --git a/src/test/auxiliary/logging_right_crate.rs b/src/test/auxiliary/logging_right_crate.rs index b0a6e0f84fc..3f0da3e344a 100644 --- a/src/test/auxiliary/logging_right_crate.rs +++ b/src/test/auxiliary/logging_right_crate.rs @@ -10,6 +10,7 @@ #![feature(phase)] #[phase(syntax, link)] extern crate log; +extern crate debug; pub fn foo() { fn death() -> int { fail!() } diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 1ec4a236dfd..03d91cf3aaa 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -19,6 +19,7 @@ // version. extern crate time; +extern crate debug; use std::comm; use std::os; diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 5da3e1e9ca6..4de51c3ab4b 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -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; diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index f774be582a1..8841e7f4b4d 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -12,6 +12,7 @@ extern crate collections; extern crate time; +extern crate debug; use collections::SmallIntMap; use std::os; diff --git a/src/test/compile-fail/autoderef-full-lval.rs b/src/test/compile-fail/autoderef-full-lval.rs index ae9fe611221..3bb66e3b099 100644 --- a/src/test/compile-fail/autoderef-full-lval.rs +++ b/src/test/compile-fail/autoderef-full-lval.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + struct clam { x: @int, y: @int, diff --git a/src/test/compile-fail/block-coerce-no.rs b/src/test/compile-fail/block-coerce-no.rs index 98d81db8261..19d3e84520d 100644 --- a/src/test/compile-fail/block-coerce-no.rs +++ b/src/test/compile-fail/block-coerce-no.rs @@ -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); } diff --git a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs index ef9bee80c2b..6f385a8d1eb 100644 --- a/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs +++ b/src/test/compile-fail/borrowck-borrowed-uniq-rvalue-2.rs @@ -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], } diff --git a/src/test/compile-fail/borrowck-if-with-else.rs b/src/test/compile-fail/borrowck-if-with-else.rs index dabe0a59429..6e2dae0af7d 100644 --- a/src/test/compile-fail/borrowck-if-with-else.rs +++ b/src/test/compile-fail/borrowck-if-with-else.rs @@ -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() { diff --git a/src/test/compile-fail/borrowck-init-in-fn-expr.rs b/src/test/compile-fail/borrowck-init-in-fn-expr.rs index c44e2bee052..83bfc754a6b 100644 --- a/src/test/compile-fail/borrowck-init-in-fn-expr.rs +++ b/src/test/compile-fail/borrowck-init-in-fn-expr.rs @@ -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; diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index 4110cfd28ef..d87557a46f7 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -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 diff --git a/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs b/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs index 738652dddb3..84b8b2c59e6 100644 --- a/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs +++ b/src/test/compile-fail/borrowck-mut-addr-of-imm-var.rs @@ -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 diff --git a/src/test/compile-fail/copy-a-resource.rs b/src/test/compile-fail/copy-a-resource.rs index ac893277749..ee2a183cbe1 100644 --- a/src/test/compile-fail/copy-a-resource.rs +++ b/src/test/compile-fail/copy-a-resource.rs @@ -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, } diff --git a/src/test/compile-fail/if-without-else-result.rs b/src/test/compile-fail/if-without-else-result.rs index 38cae632320..c15e28f9517 100644 --- a/src/test/compile-fail/if-without-else-result.rs +++ b/src/test/compile-fail/if-without-else-result.rs @@ -10,6 +10,8 @@ // error-pattern:mismatched types: expected `()` but found `bool` +extern crate debug; + fn main() { let a = if true { true }; println!("{:?}", a); diff --git a/src/test/compile-fail/issue-1476.rs b/src/test/compile-fail/issue-1476.rs index 80e0d037f7c..8526596acaa 100644 --- a/src/test/compile-fail/issue-1476.rs +++ b/src/test/compile-fail/issue-1476.rs @@ -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`. } diff --git a/src/test/compile-fail/issue-2823.rs b/src/test/compile-fail/issue-2823.rs index 4106a775248..3d3a0740e44 100644 --- a/src/test/compile-fail/issue-2823.rs +++ b/src/test/compile-fail/issue-2823.rs @@ -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, } diff --git a/src/test/compile-fail/issue-3038.rs b/src/test/compile-fail/issue-3038.rs index 684318bafc6..b13b037ef1a 100644 --- a/src/test/compile-fail/issue-3038.rs +++ b/src/test/compile-fail/issue-3038.rs @@ -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) } diff --git a/src/test/compile-fail/issue-3521.rs b/src/test/compile-fail/issue-3521.rs index f9fb2daaf58..7b7cdd20851 100644 --- a/src/test/compile-fail/issue-3521.rs +++ b/src/test/compile-fail/issue-3521.rs @@ -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; diff --git a/src/test/compile-fail/issue-5062.rs b/src/test/compile-fail/issue-5062.rs index 8ff81df938d..1cf6dcda04c 100644 --- a/src/test/compile-fail/issue-5062.rs +++ b/src/test/compile-fail/issue-5062.rs @@ -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 diff --git a/src/test/compile-fail/issue-6458-2.rs b/src/test/compile-fail/issue-6458-2.rs index f395b7fdd76..f302472d070 100644 --- a/src/test/compile-fail/issue-6458-2.rs +++ b/src/test/compile-fail/issue-6458-2.rs @@ -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 } diff --git a/src/test/compile-fail/liveness-closure-require-ret.rs b/src/test/compile-fail/liveness-closure-require-ret.rs index 676d5212e99..65856c5250c 100644 --- a/src/test/compile-fail/liveness-closure-require-ret.rs +++ b/src/test/compile-fail/liveness-closure-require-ret.rs @@ -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 diff --git a/src/test/compile-fail/liveness-move-in-loop.rs b/src/test/compile-fail/liveness-move-in-loop.rs index 018b0aaecfd..270142c6378 100644 --- a/src/test/compile-fail/liveness-move-in-loop.rs +++ b/src/test/compile-fail/liveness-move-in-loop.rs @@ -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 = box 42; diff --git a/src/test/compile-fail/liveness-move-in-while.rs b/src/test/compile-fail/liveness-move-in-while.rs index e32d8a78585..f40b866214d 100644 --- a/src/test/compile-fail/liveness-move-in-while.rs +++ b/src/test/compile-fail/liveness-move-in-while.rs @@ -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 = box 42; diff --git a/src/test/compile-fail/liveness-use-after-move.rs b/src/test/compile-fail/liveness-use-after-move.rs index f2b8976c61b..9927e2ea9da 100644 --- a/src/test/compile-fail/liveness-use-after-move.rs +++ b/src/test/compile-fail/liveness-use-after-move.rs @@ -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; diff --git a/src/test/compile-fail/liveness-use-after-send.rs b/src/test/compile-fail/liveness-use-after-send.rs index 2716d476c3a..6a2a1e7dec5 100644 --- a/src/test/compile-fail/liveness-use-after-send.rs +++ b/src/test/compile-fail/liveness-use-after-send.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +extern crate debug; fn send(ch: _chan, data: T) { println!("{:?}", ch); diff --git a/src/test/compile-fail/match-join.rs b/src/test/compile-fail/match-join.rs index 3e1c9e850fa..c16d85cd73e 100644 --- a/src/test/compile-fail/match-join.rs +++ b/src/test/compile-fail/match-join.rs @@ -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() { diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs index fd44b693dde..15cf176a0db 100644 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ b/src/test/compile-fail/moves-based-on-type-access-to-field.rs @@ -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) {} diff --git a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs index 3521347705b..aded89e5820 100644 --- a/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs +++ b/src/test/compile-fail/moves-based-on-type-no-recursive-stack-closure.rs @@ -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 diff --git a/src/test/compile-fail/no-send-res-ports.rs b/src/test/compile-fail/no-send-res-ports.rs index 825a8fc604c..0f7491e231b 100644 --- a/src/test/compile-fail/no-send-res-ports.rs +++ b/src/test/compile-fail/no-send-res-ports.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + use std::task; struct Port(@T); diff --git a/src/test/compile-fail/noncopyable-class.rs b/src/test/compile-fail/noncopyable-class.rs index 778f3a3b997..8594e7ca625 100644 --- a/src/test/compile-fail/noncopyable-class.rs +++ b/src/test/compile-fail/noncopyable-class.rs @@ -10,6 +10,9 @@ // Test that a class with a non-copyable field can't be // copied + +extern crate debug; + struct bar { x: int, } diff --git a/src/test/compile-fail/nonscalar-cast.rs b/src/test/compile-fail/nonscalar-cast.rs index c0749984cc9..97a514e1584 100644 --- a/src/test/compile-fail/nonscalar-cast.rs +++ b/src/test/compile-fail/nonscalar-cast.rs @@ -10,6 +10,8 @@ // error-pattern:non-scalar cast +extern crate debug; + struct foo { x:int } diff --git a/src/test/compile-fail/packed-struct-generic-transmute.rs b/src/test/compile-fail/packed-struct-generic-transmute.rs index 45e6b76e200..b5bb3314dcf 100644 --- a/src/test/compile-fail/packed-struct-generic-transmute.rs +++ b/src/test/compile-fail/packed-struct-generic-transmute.rs @@ -15,6 +15,8 @@ // error-pattern: transmute called on types with different size +extern crate debug; + use std::mem; #[packed] diff --git a/src/test/compile-fail/packed-struct-transmute.rs b/src/test/compile-fail/packed-struct-transmute.rs index 24be7d3a297..0611c470d10 100644 --- a/src/test/compile-fail/packed-struct-transmute.rs +++ b/src/test/compile-fail/packed-struct-transmute.rs @@ -15,6 +15,8 @@ // error-pattern: transmute called on types with different size +extern crate debug; + use std::mem; #[packed] diff --git a/src/test/compile-fail/pattern-tyvar.rs b/src/test/compile-fail/pattern-tyvar.rs index e1566e7c897..83f2ef250dc 100644 --- a/src/test/compile-fail/pattern-tyvar.rs +++ b/src/test/compile-fail/pattern-tyvar.rs @@ -10,6 +10,8 @@ // error-pattern: mismatched types +extern crate debug; + enum bar { t1((), Option >), t2, } fn foo(t: bar) { diff --git a/src/test/compile-fail/pinned-deep-copy.rs b/src/test/compile-fail/pinned-deep-copy.rs index 49f2f35d29d..e118549f2c2 100644 --- a/src/test/compile-fail/pinned-deep-copy.rs +++ b/src/test/compile-fail/pinned-deep-copy.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + use std::cell::Cell; struct r { diff --git a/src/test/compile-fail/unique-pinned-nocopy.rs b/src/test/compile-fail/unique-pinned-nocopy.rs index 04d8bc96a47..1b767e0270b 100644 --- a/src/test/compile-fail/unique-pinned-nocopy.rs +++ b/src/test/compile-fail/unique-pinned-nocopy.rs @@ -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, } diff --git a/src/test/compile-fail/unique-vec-res.rs b/src/test/compile-fail/unique-vec-res.rs index adeecf2babf..91d4c39edcb 100644 --- a/src/test/compile-fail/unique-vec-res.rs +++ b/src/test/compile-fail/unique-vec-res.rs @@ -10,6 +10,7 @@ #![feature(managed_boxes)] +extern crate debug; use std::cell::Cell; struct r { diff --git a/src/test/pretty/block-comment-wchar.pp b/src/test/pretty/block-comment-wchar.pp index 2367645aefa..7def090edbb 100644 --- a/src/test/pretty/block-comment-wchar.pp +++ b/src/test/pretty/block-comment-wchar.pp @@ -110,6 +110,6 @@ fn main() { '\u205F', '\u3000']; for c in chars.iter() { let ws = c.is_whitespace(); - println!("{:?} {:?}" , c , ws); + println!("{} {}" , c , ws); } } diff --git a/src/test/pretty/block-comment-wchar.rs b/src/test/pretty/block-comment-wchar.rs index 95fcda38b9e..777c456335d 100644 --- a/src/test/pretty/block-comment-wchar.rs +++ b/src/test/pretty/block-comment-wchar.rs @@ -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); } } diff --git a/src/test/run-fail/result-get-fail.rs b/src/test/run-fail/result-get-fail.rs index 549a101654b..216cf7211f6 100644 --- a/src/test/run-fail/result-get-fail.rs +++ b/src/test/run-fail/result-get-fail.rs @@ -10,6 +10,8 @@ // error-pattern:called `Result::unwrap()` on an `Err` value +extern crate debug; + use std::result; fn main() { diff --git a/src/test/run-fail/unwind-box-fn-unique.rs b/src/test/run-fail/unwind-box-fn-unique.rs index 50ecedd68fe..e3507ff450b 100644 --- a/src/test/run-fail/unwind-box-fn-unique.rs +++ b/src/test/run-fail/unwind-box-fn-unique.rs @@ -12,6 +12,8 @@ // error-pattern:fail +extern crate debug; + fn failfn() { fail!(); } diff --git a/src/test/run-fail/unwind-box-res.rs b/src/test/run-fail/unwind-box-res.rs index 2044d6f1cc8..0750c1897ee 100644 --- a/src/test/run-fail/unwind-box-res.rs +++ b/src/test/run-fail/unwind-box-res.rs @@ -12,6 +12,8 @@ #![feature(managed_boxes)] +extern crate debug; + use std::mem; fn failfn() { diff --git a/src/test/run-fail/unwind-box-str.rs b/src/test/run-fail/unwind-box-str.rs index 08c8461afe0..dd6303ad183 100644 --- a/src/test/run-fail/unwind-box-str.rs +++ b/src/test/run-fail/unwind-box-str.rs @@ -12,6 +12,8 @@ #![feature(managed_boxes)] +extern crate debug; + fn failfn() { fail!(); } diff --git a/src/test/run-fail/unwind-box-unique-unique.rs b/src/test/run-fail/unwind-box-unique-unique.rs index 82da2bc6ca3..9cb17163d11 100644 --- a/src/test/run-fail/unwind-box-unique-unique.rs +++ b/src/test/run-fail/unwind-box-unique-unique.rs @@ -12,6 +12,7 @@ #![feature(managed_boxes)] +extern crate debug; fn failfn() { fail!(); diff --git a/src/test/run-fail/unwind-box-unique.rs b/src/test/run-fail/unwind-box-unique.rs index 99adaaad314..91681ff3b78 100644 --- a/src/test/run-fail/unwind-box-unique.rs +++ b/src/test/run-fail/unwind-box-unique.rs @@ -12,6 +12,8 @@ #![feature(managed_boxes)] +extern crate debug; + fn failfn() { fail!(); } diff --git a/src/test/run-fail/unwind-box-vec.rs b/src/test/run-fail/unwind-box-vec.rs index 07d978a191d..7946812bae5 100644 --- a/src/test/run-fail/unwind-box-vec.rs +++ b/src/test/run-fail/unwind-box-vec.rs @@ -12,6 +12,8 @@ #![feature(managed_boxes)] +extern crate debug; + fn failfn() { fail!(); } diff --git a/src/test/run-pass/alignment-gep-tup-like-1.rs b/src/test/run-pass/alignment-gep-tup-like-1.rs index 0af2be8ab29..38a3d3c5fff 100644 --- a/src/test/run-pass/alignment-gep-tup-like-1.rs +++ b/src/test/run-pass/alignment-gep-tup-like-1.rs @@ -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: A, b: B diff --git a/src/test/run-pass/auto-instantiate.rs b/src/test/run-pass/auto-instantiate.rs index c2b276aac09..51af6444e9c 100644 --- a/src/test/run-pass/auto-instantiate.rs +++ b/src/test/run-pass/auto-instantiate.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - - +extern crate debug; struct Pair { a: T, b: U } struct Triple { x: int, y: int, z: int } diff --git a/src/test/run-pass/block-arg.rs b/src/test/run-pass/block-arg.rs index 8d0412ba30e..59786e993f2 100644 --- a/src/test/run-pass/block-arg.rs +++ b/src/test/run-pass/block-arg.rs @@ -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) } diff --git a/src/test/run-pass/block-iter-1.rs b/src/test/run-pass/block-iter-1.rs index 6ffb032090c..4f0cf855dd1 100644 --- a/src/test/run-pass/block-iter-1.rs +++ b/src/test/run-pass/block-iter-1.rs @@ -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(v: Vec , f: |&T|) { for x in v.iter() { f(x); } } diff --git a/src/test/run-pass/block-iter-2.rs b/src/test/run-pass/block-iter-2.rs index 5f4154290ac..8d28022bc1d 100644 --- a/src/test/run-pass/block-iter-2.rs +++ b/src/test/run-pass/block-iter-2.rs @@ -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(v: Vec , f: |&T|) { for x in v.iter() { f(x); } } diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index ea849ee9829..1ab573db37b 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -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, values: Vec } diff --git a/src/test/run-pass/close-over-big-then-small-data.rs b/src/test/run-pass/close-over-big-then-small-data.rs index 3e14d5b82c4..acae6135937 100644 --- a/src/test/run-pass/close-over-big-then-small-data.rs +++ b/src/test/run-pass/close-over-big-then-small-data.rs @@ -12,6 +12,7 @@ // storing closure data (as we used to do), the u64 would // overwrite the u16. +extern crate debug; struct Pair { a: A, b: B diff --git a/src/test/run-pass/comm.rs b/src/test/run-pass/comm.rs index 03617537c49..7f5454405df 100644 --- a/src/test/run-pass/comm.rs +++ b/src/test/run-pass/comm.rs @@ -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() { diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass/conditional-debug-macro-off.rs index 944141839cf..56b38033c83 100644 --- a/src/test/run-pass/conditional-debug-macro-off.rs +++ b/src/test/run-pass/conditional-debug-macro-off.rs @@ -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. diff --git a/src/test/run-pass/conditional-debug-macro-on.rs b/src/test/run-pass/conditional-debug-macro-on.rs index 732c50afbf3..399a145468d 100644 --- a/src/test/run-pass/conditional-debug-macro-on.rs +++ b/src/test/run-pass/conditional-debug-macro-on.rs @@ -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. diff --git a/src/test/run-pass/const-fields-and-indexing.rs b/src/test/run-pass/const-fields-and-indexing.rs index e99b0ed185b..ff44c76048f 100644 --- a/src/test/run-pass/const-fields-and-indexing.rs +++ b/src/test/run-pass/const-fields-and-indexing.rs @@ -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]; diff --git a/src/test/run-pass/const-vecs-and-slices.rs b/src/test/run-pass/const-vecs-and-slices.rs index 3935bb241c7..a1cd4fe4253 100644 --- a/src/test/run-pass/const-vecs-and-slices.rs +++ b/src/test/run-pass/const-vecs-and-slices.rs @@ -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]; diff --git a/src/test/run-pass/deref-lval.rs b/src/test/run-pass/deref-lval.rs index 15a8a2e9eac..122c4b47310 100644 --- a/src/test/run-pass/deref-lval.rs +++ b/src/test/run-pass/deref-lval.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + use std::cell::Cell; pub fn main() { diff --git a/src/test/run-pass/enum-discrim-width-stuff.rs b/src/test/run-pass/enum-discrim-width-stuff.rs index 85da586a72c..814e2cca97c 100644 --- a/src/test/run-pass/enum-discrim-width-stuff.rs +++ b/src/test/run-pass/enum-discrim-width-stuff.rs @@ -10,6 +10,8 @@ #![feature(macro_rules)] +extern crate debug; + macro_rules! check { ($m:ident, $t:ty, $v:expr) => {{ mod $m { diff --git a/src/test/run-pass/evec-slice.rs b/src/test/run-pass/evec-slice.rs index f8e1dc27e32..9c5995b7ba0 100644 --- a/src/test/run-pass/evec-slice.rs +++ b/src/test/run-pass/evec-slice.rs @@ -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]; diff --git a/src/test/run-pass/float.rs b/src/test/run-pass/float.rs index 277f0011c1c..4cd7e7112a9 100644 --- a/src/test/run-pass/float.rs +++ b/src/test/run-pass/float.rs @@ -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; diff --git a/src/test/run-pass/format-ref-cell.rs b/src/test/run-pass/format-ref-cell.rs index 520735c05c3..3267ca06171 100644 --- a/src/test/run-pass/format-ref-cell.rs +++ b/src/test/run-pass/format-ref-cell.rs @@ -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() { diff --git a/src/test/run-pass/functional-struct-upd.rs b/src/test/run-pass/functional-struct-upd.rs index 10efc0b53f2..215de30535d 100644 --- a/src/test/run-pass/functional-struct-upd.rs +++ b/src/test/run-pass/functional-struct-upd.rs @@ -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 diff --git a/src/test/run-pass/generic-alias-box.rs b/src/test/run-pass/generic-alias-box.rs index 1de3fcd202b..1d1e4864acb 100644 --- a/src/test/run-pass/generic-alias-box.rs +++ b/src/test/run-pass/generic-alias-box.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + fn id(t: T) -> T { return t; } pub fn main() { diff --git a/src/test/run-pass/generic-alias-unique.rs b/src/test/run-pass/generic-alias-unique.rs index f1338358903..0fd4ba3ec5f 100644 --- a/src/test/run-pass/generic-alias-unique.rs +++ b/src/test/run-pass/generic-alias-unique.rs @@ -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: T) -> T { return t; } diff --git a/src/test/run-pass/generic-derived-type.rs b/src/test/run-pass/generic-derived-type.rs index 80f64d8df3d..09a53f86f2d 100644 --- a/src/test/run-pass/generic-derived-type.rs +++ b/src/test/run-pass/generic-derived-type.rs @@ -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 { return x; } diff --git a/src/test/run-pass/generic-fn-box.rs b/src/test/run-pass/generic-fn-box.rs index 8314208ca24..d162daf7cec 100644 --- a/src/test/run-pass/generic-fn-box.rs +++ b/src/test/run-pass/generic-fn-box.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + fn f(x: @T) -> @T { return x; } pub fn main() { let x = f(@3); println!("{:?}", *x); } diff --git a/src/test/run-pass/generic-fn-unique.rs b/src/test/run-pass/generic-fn-unique.rs index c0b3fd5bc94..d8f782d9773 100644 --- a/src/test/run-pass/generic-fn-unique.rs +++ b/src/test/run-pass/generic-fn-unique.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +extern crate debug; fn f(x: Box) -> Box { return x; } diff --git a/src/test/run-pass/generic-tag-values.rs b/src/test/run-pass/generic-tag-values.rs index e9848960180..e3ed380c37e 100644 --- a/src/test/run-pass/generic-tag-values.rs +++ b/src/test/run-pass/generic-tag-values.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - - +extern crate debug; enum noption { some(T), } diff --git a/src/test/run-pass/generic-tup.rs b/src/test/run-pass/generic-tup.rs index 2e9bd371e29..d0ae17053ae 100644 --- a/src/test/run-pass/generic-tup.rs +++ b/src/test/run-pass/generic-tup.rs @@ -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 { let (_, _, x) = t; return x; } pub fn main() { diff --git a/src/test/run-pass/getopts_ref.rs b/src/test/run-pass/getopts_ref.rs index 6ccd9c33be9..8fc84cece5a 100644 --- a/src/test/run-pass/getopts_ref.rs +++ b/src/test/run-pass/getopts_ref.rs @@ -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}; diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index d7eb2de36b0..e64ef3def2d 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -12,7 +12,7 @@ #![feature(managed_boxes)] extern crate collections; - +extern crate debug; /** A somewhat reduced test case to expose some Valgrind issues. diff --git a/src/test/run-pass/if-bot.rs b/src/test/run-pass/if-bot.rs index 97429131a7c..c5193b2aa6f 100644 --- a/src/test/run-pass/if-bot.rs +++ b/src/test/run-pass/if-bot.rs @@ -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 }; diff --git a/src/test/run-pass/ifmt.rs b/src/test/run-pass/ifmt.rs index 6d875a7ff9b..b69450024f6 100644 --- a/src/test/run-pass/ifmt.rs +++ b/src/test/run-pass/ifmt.rs @@ -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; diff --git a/src/test/run-pass/import.rs b/src/test/run-pass/import.rs index 6b0ad24da1d..5d404909bf2 100644 --- a/src/test/run-pass/import.rs +++ b/src/test/run-pass/import.rs @@ -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); } } diff --git a/src/test/run-pass/issue-1696.rs b/src/test/run-pass/issue-1696.rs index 0113b8e2fd9..29384424cbe 100644 --- a/src/test/run-pass/issue-1696.rs +++ b/src/test/run-pass/issue-1696.rs @@ -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; diff --git a/src/test/run-pass/issue-2216.rs b/src/test/run-pass/issue-2216.rs index 311ce2d64b2..ae5cff0dddf 100644 --- a/src/test/run-pass/issue-2216.rs +++ b/src/test/run-pass/issue-2216.rs @@ -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; diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs index 7ad8ff9bfaa..f8032d99ebe 100644 --- a/src/test/run-pass/issue-2804-2.rs +++ b/src/test/run-pass/issue-2804-2.rs @@ -13,6 +13,7 @@ // clobber the previous node ID in a macro expr extern crate collections; +extern crate debug; use collections::HashMap; diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index fd0cfb5425d..fa5cd972029 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -11,6 +11,7 @@ extern crate collections; extern crate serialize; +extern crate debug; use collections::HashMap; use serialize::json; diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 5542418ebdd..d48a944c2f0 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -11,6 +11,8 @@ #![feature(managed_boxes)] +extern crate debug; + /// Map representation use std::io; diff --git a/src/test/run-pass/issue-3109.rs b/src/test/run-pass/issue-3109.rs index dc22ebce804..cef42966889 100644 --- a/src/test/run-pass/issue-3109.rs +++ b/src/test/run-pass/issue-3109.rs @@ -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")); } diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index b9b3301fc88..9f3cb653eb9 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + enum Token { Text(@String), ETag(@Vec , @String), diff --git a/src/test/run-pass/issue-3794.rs b/src/test/run-pass/issue-3794.rs index b08e6525ba5..00878189627 100644 --- a/src/test/run-pass/issue-3794.rs +++ b/src/test/run-pass/issue-3794.rs @@ -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); diff --git a/src/test/run-pass/issue-4252.rs b/src/test/run-pass/issue-4252.rs index ba080e98183..151d00eb2d0 100644 --- a/src/test/run-pass/issue-4252.rs +++ b/src/test/run-pass/issue-4252.rs @@ -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(&self, x: &T); fn default_method(&self, x: &T) { diff --git a/src/test/run-pass/issue-5688.rs b/src/test/run-pass/issue-5688.rs index 869374d6ad4..281070754c4 100644 --- a/src/test/run-pass/issue-5688.rs +++ b/src/test/run-pass/issue-5688.rs @@ -17,6 +17,8 @@ with the representation of [int, ..n] and [int] somehow, or at least failed to typecheck correctly. */ +extern crate debug; + struct X { vec: &'static [int] } static V: &'static [X] = &[X { vec: &[1, 2, 3] }]; pub fn main() { diff --git a/src/test/run-pass/issue-6344-let.rs b/src/test/run-pass/issue-6344-let.rs index 99d943a2f6b..0b5e92fcf30 100644 --- a/src/test/run-pass/issue-6344-let.rs +++ b/src/test/run-pass/issue-6344-let.rs @@ -7,6 +7,9 @@ // , 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 { diff --git a/src/test/run-pass/issue-6344-match.rs b/src/test/run-pass/issue-6344-match.rs index f51221c419e..67807a82759 100644 --- a/src/test/run-pass/issue-6344-match.rs +++ b/src/test/run-pass/issue-6344-match.rs @@ -7,6 +7,9 @@ // , 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 { diff --git a/src/test/run-pass/issue-7563.rs b/src/test/run-pass/issue-7563.rs index 538699512a3..bf62c2e459a 100644 --- a/src/test/run-pass/issue-7563.rs +++ b/src/test/run-pass/issue-7563.rs @@ -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); } diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index 595ddffd39c..ac0ac95c73b 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + fn assert_repr_eq(obj : T, expected : String) { assert_eq!(expected, format_strbuf!("{:?}", obj)); } diff --git a/src/test/run-pass/last-use-is-capture.rs b/src/test/run-pass/last-use-is-capture.rs index 5e892d5433e..f381bb02e54 100644 --- a/src/test/run-pass/last-use-is-capture.rs +++ b/src/test/run-pass/last-use-is-capture.rs @@ -10,6 +10,7 @@ // Make sure #1399 stays fixed +extern crate debug; struct A { a: Box } diff --git a/src/test/run-pass/lazy-and-or.rs b/src/test/run-pass/lazy-and-or.rs index aa303aa3b81..c4f37ccf88a 100644 --- a/src/test/run-pass/lazy-and-or.rs +++ b/src/test/run-pass/lazy-and-or.rs @@ -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; } diff --git a/src/test/run-pass/linear-for-loop.rs b/src/test/run-pass/linear-for-loop.rs index b260e0af9e3..665456bb457 100644 --- a/src/test/run-pass/linear-for-loop.rs +++ b/src/test/run-pass/linear-for-loop.rs @@ -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; diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index dd0e9dc4295..d26075af3ce 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -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), diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs index 2a8402cc3fc..2956a030faa 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants.rs @@ -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), diff --git a/src/test/run-pass/log-poly.rs b/src/test/run-pass/log-poly.rs index 69685b58ab5..17fa14ec92d 100644 --- a/src/test/run-pass/log-poly.rs +++ b/src/test/run-pass/log-poly.rs @@ -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 } diff --git a/src/test/run-pass/match-unique-bind.rs b/src/test/run-pass/match-unique-bind.rs index 9fae0e30d59..26d5a018a66 100644 --- a/src/test/run-pass/match-unique-bind.rs +++ b/src/test/run-pass/match-unique-bind.rs @@ -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 => { diff --git a/src/test/run-pass/nested-matchs.rs b/src/test/run-pass/nested-matchs.rs index 5f86cde261c..571b3371fe6 100644 --- a/src/test/run-pass/nested-matchs.rs +++ b/src/test/run-pass/nested-matchs.rs @@ -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!(); } diff --git a/src/test/run-pass/over-constrained-vregs.rs b/src/test/run-pass/over-constrained-vregs.rs index 9a2e83ef2d0..3cc485c8f3a 100644 --- a/src/test/run-pass/over-constrained-vregs.rs +++ b/src/test/run-pass/over-constrained-vregs.rs @@ -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() { diff --git a/src/test/run-pass/overload-index-operator.rs b/src/test/run-pass/overload-index-operator.rs index c6f3dae7fc1..1727de79c78 100644 --- a/src/test/run-pass/overload-index-operator.rs +++ b/src/test/run-pass/overload-index-operator.rs @@ -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 { diff --git a/src/test/run-pass/pass-by-copy.rs b/src/test/run-pass/pass-by-copy.rs index 5b274ea079a..1d48cd3226d 100644 --- a/src/test/run-pass/pass-by-copy.rs +++ b/src/test/run-pass/pass-by-copy.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + fn magic(x: A) { println!("{:?}", x); } fn magic2(x: @int) { println!("{:?}", x); } diff --git a/src/test/run-pass/rec-align-u32.rs b/src/test/run-pass/rec-align-u32.rs index 16755190a14..69a4c1cd053 100644 --- a/src/test/run-pass/rec-align-u32.rs +++ b/src/test/run-pass/rec-align-u32.rs @@ -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 { diff --git a/src/test/run-pass/rec-align-u64.rs b/src/test/run-pass/rec-align-u64.rs index f96794b0b88..399f947df06 100644 --- a/src/test/run-pass/rec-align-u64.rs +++ b/src/test/run-pass/rec-align-u64.rs @@ -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 { diff --git a/src/test/run-pass/regions-self-impls.rs b/src/test/run-pass/regions-self-impls.rs index f1e6c6a0e2f..33f080d8db2 100644 --- a/src/test/run-pass/regions-self-impls.rs +++ b/src/test/run-pass/regions-self-impls.rs @@ -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 } diff --git a/src/test/run-pass/regions-self-in-enums.rs b/src/test/run-pass/regions-self-in-enums.rs index c4037a70d96..9b817c5c906 100644 --- a/src/test/run-pass/regions-self-in-enums.rs +++ b/src/test/run-pass/regions-self-in-enums.rs @@ -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) } diff --git a/src/test/run-pass/regions-simple.rs b/src/test/run-pass/regions-simple.rs index 62be5860508..bcd66eef957 100644 --- a/src/test/run-pass/regions-simple.rs +++ b/src/test/run-pass/regions-simple.rs @@ -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; diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index 38f0f12267b..27c5e5397f9 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + pub fn main() { let x = [ [true], ..512 ]; let y = [ 0, ..1 ]; diff --git a/src/test/run-pass/resource-assign-is-not-copy.rs b/src/test/run-pass/resource-assign-is-not-copy.rs index 837ae68c85e..9b0837594cf 100644 --- a/src/test/run-pass/resource-assign-is-not-copy.rs +++ b/src/test/run-pass/resource-assign-is-not-copy.rs @@ -10,6 +10,8 @@ #![feature(managed_boxes)] +extern crate debug; + use std::cell::Cell; struct r { diff --git a/src/test/run-pass/shadow.rs b/src/test/run-pass/shadow.rs index a6ae21c81f1..a65e44166e9 100644 --- a/src/test/run-pass/shadow.rs +++ b/src/test/run-pass/shadow.rs @@ -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 ) { let a: int = 5; diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index 96fd75c5156..0f188216745 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -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 diff --git a/src/test/run-pass/signal-exit-status.rs b/src/test/run-pass/signal-exit-status.rs index 1989b638680..c28e128dd05 100644 --- a/src/test/run-pass/signal-exit-status.rs +++ b/src/test/run-pass/signal-exit-status.rs @@ -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 or the mit license -// , 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}; diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index c91b16c9ca0..5d07ca56041 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +extern crate debug; enum clam { a(T, int), b, } diff --git a/src/test/run-pass/small-enums-with-fields.rs b/src/test/run-pass/small-enums-with-fields.rs index 060274f1bc7..e7d4e25c2bb 100644 --- a/src/test/run-pass/small-enums-with-fields.rs +++ b/src/test/run-pass/small-enums-with-fields.rs @@ -10,6 +10,8 @@ #![feature(macro_rules)] +extern crate debug; + use std::mem::size_of; #[deriving(Eq, Show)] diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index 34ae825c0d2..15301e96e69 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -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) { diff --git a/src/test/run-pass/str-idx.rs b/src/test/run-pass/str-idx.rs index 75d7b3ed2cd..8ac13e81463 100644 --- a/src/test/run-pass/str-idx.rs +++ b/src/test/run-pass/str-idx.rs @@ -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(); diff --git a/src/test/run-pass/tag-align-shape.rs b/src/test/run-pass/tag-align-shape.rs index c07ca9cae76..e161f6887e1 100644 --- a/src/test/run-pass/tag-align-shape.rs +++ b/src/test/run-pass/tag-align-shape.rs @@ -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) diff --git a/src/test/run-pass/tag-disr-val-shape.rs b/src/test/run-pass/tag-disr-val-shape.rs index beb0c5dbe81..57f0f862fbf 100644 --- a/src/test/run-pass/tag-disr-val-shape.rs +++ b/src/test/run-pass/tag-disr-val-shape.rs @@ -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, diff --git a/src/test/run-pass/tail-cps.rs b/src/test/run-pass/tail-cps.rs index 5cf6c2af12b..13a2ab47bf3 100644 --- a/src/test/run-pass/tail-cps.rs +++ b/src/test/run-pass/tail-cps.rs @@ -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; } diff --git a/src/test/run-pass/task-comm-3.rs b/src/test/run-pass/task-comm-3.rs index 3fb91b67c9d..217bab5c1de 100644 --- a/src/test/run-pass/task-comm-3.rs +++ b/src/test/run-pass/task-comm-3.rs @@ -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; diff --git a/src/test/run-pass/task-comm-9.rs b/src/test/run-pass/task-comm-9.rs index 188d8288b09..ab6498c0027 100644 --- a/src/test/run-pass/task-comm-9.rs +++ b/src/test/run-pass/task-comm-9.rs @@ -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; diff --git a/src/test/run-pass/tcp-stress.rs b/src/test/run-pass/tcp-stress.rs index 799d07891db..4034c2571cd 100644 --- a/src/test/run-pass/tcp-stress.rs +++ b/src/test/run-pass/tcp-stress.rs @@ -18,6 +18,7 @@ extern crate log; extern crate libc; extern crate green; extern crate rustuv; +extern crate debug; use std::io::net::tcp::{TcpListener, TcpStream}; use std::io::{Acceptor, Listener}; diff --git a/src/test/run-pass/tempfile.rs b/src/test/run-pass/tempfile.rs index 387a454542a..316d1facb18 100644 --- a/src/test/run-pass/tempfile.rs +++ b/src/test/run-pass/tempfile.rs @@ -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; diff --git a/src/test/run-pass/trivial-message.rs b/src/test/run-pass/trivial-message.rs index 840ab18dafa..2b60cf12cc5 100644 --- a/src/test/run-pass/trivial-message.rs +++ b/src/test/run-pass/trivial-message.rs @@ -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. diff --git a/src/test/run-pass/tuple-struct-construct.rs b/src/test/run-pass/tuple-struct-construct.rs index 3c15bc0bd6b..0c2dc121828 100644 --- a/src/test/run-pass/tuple-struct-construct.rs +++ b/src/test/run-pass/tuple-struct-construct.rs @@ -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() { diff --git a/src/test/run-pass/unique-in-tag.rs b/src/test/run-pass/unique-in-tag.rs index 2045beb7f32..42ed47ebbb7 100644 --- a/src/test/run-pass/unique-in-tag.rs +++ b/src/test/run-pass/unique-in-tag.rs @@ -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), w(int), } diff --git a/src/test/run-pass/unique-log.rs b/src/test/run-pass/unique-log.rs index e2de566090d..994e8df417d 100644 --- a/src/test/run-pass/unique-log.rs +++ b/src/test/run-pass/unique-log.rs @@ -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); diff --git a/src/test/run-pass/unique-pat-3.rs b/src/test/run-pass/unique-pat-3.rs index 55fda4c1106..13416c5acbb 100644 --- a/src/test/run-pass/unique-pat-3.rs +++ b/src/test/run-pass/unique-pat-3.rs @@ -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), w(int), }