From c14d86fd3ff3ba2d01a6e859290b30e74081313b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 9 Jun 2015 11:18:03 -0700 Subject: [PATCH 01/48] core: Split apart the global `core` feature This commit shards the broad `core` feature of the libcore library into finer grained features. This split groups together similar APIs and enables tracking each API separately, giving a better sense of where each feature is within the stabilization process. A few minor APIs were deprecated along the way: * Iterator::reverse_in_place * marker::NoCopy --- src/liballoc/boxed.rs | 18 +++++---- src/liballoc/lib.rs | 22 ++++++---- src/libarena/lib.rs | 4 +- src/libcollections/lib.rs | 30 ++++++++++---- src/libcore/any.rs | 2 +- src/libcore/array.rs | 11 ++--- src/libcore/cell.rs | 50 +++++++++++++---------- src/libcore/char.rs | 7 ++++ src/libcore/clone.rs | 9 ++--- src/libcore/cmp.rs | 38 +++++++++--------- src/libcore/convert.rs | 9 +++-- src/libcore/fmt/mod.rs | 20 +++++----- src/libcore/fmt/num.rs | 6 +-- src/libcore/fmt/rt/v1.rs | 2 - src/libcore/hash/mod.rs | 27 +++++++------ src/libcore/intrinsics.rs | 13 +++--- src/libcore/iter.rs | 73 ++++++++++++++++++---------------- src/libcore/lib.rs | 8 +++- src/libcore/macros.rs | 1 + src/libcore/marker.rs | 8 +++- src/libcore/mem.rs | 4 +- src/libcore/nonzero.rs | 3 +- src/libcore/num/f32.rs | 4 +- src/libcore/num/f64.rs | 4 +- src/libcore/num/flt2dec/mod.rs | 2 + src/libcore/num/int_macros.rs | 6 ++- src/libcore/num/mod.rs | 33 ++++++++------- src/libcore/num/uint_macros.rs | 6 ++- src/libcore/num/wrapping.rs | 2 +- src/libcore/ops.rs | 30 ++++++-------- src/libcore/option.rs | 2 +- src/libcore/panicking.rs | 3 ++ src/libcore/prelude.rs | 5 ++- src/libcore/ptr.rs | 26 ++++++------ src/libcore/raw.rs | 2 +- src/libcore/result.rs | 5 ++- src/libcore/simd.rs | 13 ++---- src/libcore/slice.rs | 27 ++++++------- src/libcore/str/mod.rs | 13 +++--- src/libcore/str/pattern.rs | 3 ++ src/libcore/ty.rs | 13 ------ src/liblog/lib.rs | 3 +- src/librand/lib.rs | 4 ++ src/librbml/lib.rs | 2 +- src/librustc/lib.rs | 9 ++++- src/librustc_back/lib.rs | 10 ++--- src/librustc_lint/lib.rs | 5 ++- src/librustc_trans/lib.rs | 14 +++++-- src/librustc_typeck/lib.rs | 4 +- src/librustc_unicode/lib.rs | 16 +++++--- src/libserialize/lib.rs | 5 ++- src/libstd/error.rs | 2 +- src/libstd/lib.rs | 26 +++++++++--- src/libsyntax/lib.rs | 3 +- 54 files changed, 379 insertions(+), 288 deletions(-) delete mode 100644 src/libcore/ty.rs diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 4ee500faa22c4..91cbd3915d006 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -10,9 +10,9 @@ //! A pointer type for heap allocation. //! -//! `Box`, casually referred to as a 'box', provides the simplest form of heap allocation in -//! Rust. Boxes provide ownership for this allocation, and drop their contents when they go out of -//! scope. +//! `Box`, casually referred to as a 'box', provides the simplest form of +//! heap allocation in Rust. Boxes provide ownership for this allocation, and +//! drop their contents when they go out of scope. //! //! # Examples //! @@ -39,15 +39,17 @@ //! //! This will print `Cons(1, Cons(2, Nil))`. //! -//! Recursive structures must be boxed, because if the definition of `Cons` looked like this: +//! Recursive structures must be boxed, because if the definition of `Cons` +//! looked like this: //! //! ```rust,ignore //! Cons(T, List), //! ``` //! -//! It wouldn't work. This is because the size of a `List` depends on how many elements are in the -//! list, and so we don't know how much memory to allocate for a `Cons`. By introducing a `Box`, -//! which has a defined size, we know how big `Cons` needs to be. +//! It wouldn't work. This is because the size of a `List` depends on how many +//! elements are in the list, and so we don't know how much memory to allocate +//! for a `Cons`. By introducing a `Box`, which has a defined size, we know how +//! big `Cons` needs to be. #![stable(feature = "rust1", since = "1.0.0")] @@ -355,7 +357,7 @@ impl ExactSizeIterator for Box {} /// } /// ``` #[rustc_paren_sugar] -#[unstable(feature = "core", reason = "Newly introduced")] +#[unstable(feature = "fnbox", reason = "Newly introduced")] pub trait FnBox { type Output; diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 5541a5f34c41c..91585c3cb6cf7 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -60,26 +60,32 @@ #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "alloc"] #![unstable(feature = "alloc")] -#![feature(staged_api)] #![staged_api] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "http://doc.rust-lang.org/nightly/")] -#![doc(test(no_crate_inject))] - -#![feature(no_std)] + html_root_url = "http://doc.rust-lang.org/nightly/", + test(no_crate_inject))] #![no_std] + #![feature(allocator)] +#![feature(box_syntax)] +#![feature(coerce_unsized)] +#![feature(core)] +#![feature(core_intrinsics)] +#![feature(core_prelude)] #![feature(custom_attribute)] #![feature(fundamental)] #![feature(lang_items)] -#![feature(box_syntax)] +#![feature(no_std)] +#![feature(nonzero)] #![feature(optin_builtin_traits)] +#![feature(raw)] +#![feature(staged_api)] #![feature(unboxed_closures)] -#![feature(unsafe_no_drop_flag, filling_drop)] -#![feature(core)] #![feature(unique)] +#![feature(unsafe_no_drop_flag, filling_drop)] +#![feature(unsize)] #![cfg_attr(test, feature(test, alloc, rustc_private))] #![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")), feature(libc))] diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 9bd23494da3d9..73641647bf426 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -32,7 +32,9 @@ #![feature(alloc)] #![feature(box_syntax)] -#![feature(core)] +#![feature(core_intrinsics)] +#![feature(ptr_as_ref)] +#![feature(raw)] #![feature(staged_api)] #![feature(unboxed_closures)] #![cfg_attr(test, feature(test))] diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 6c233a31149e7..0c1349bc2e6c8 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -21,26 +21,42 @@ #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/", - html_playground_url = "http://play.rust-lang.org/")] -#![doc(test(no_crate_inject))] + html_playground_url = "http://play.rust-lang.org/", + test(no_crate_inject))] #![allow(trivial_casts)] +#![cfg_attr(test, allow(deprecated))] // rand + #![feature(alloc)] -#![feature(box_syntax)] #![feature(box_patterns)] +#![feature(box_syntax)] +#![feature(copy_lifetime)] #![feature(core)] +#![feature(core_intrinsics)] +#![feature(core_prelude)] +#![feature(core_slice_ext)] +#![feature(core_str_ext)] +#![feature(iter_cmp)] +#![feature(iter_idx)] +#![feature(iter_order)] +#![feature(iter_product)] +#![feature(iter_sum)] #![feature(lang_items)] +#![feature(num_bits_bytes)] +#![feature(pattern)] +#![feature(ptr_as_ref)] +#![feature(raw)] +#![feature(slice_patterns)] #![feature(staged_api)] +#![feature(step_by)] +#![feature(str_char)] +#![feature(str_internals)] #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] -#![feature(step_by)] -#![feature(str_char)] -#![feature(slice_patterns)] #![feature(utf8_error)] #![cfg_attr(test, feature(rand, test))] -#![cfg_attr(test, allow(deprecated))] // rand #![cfg_attr(not(test), feature(str_words))] #![feature(no_std)] diff --git a/src/libcore/any.rs b/src/libcore/any.rs index a65394f52682c..f0c77ae866d59 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -92,7 +92,7 @@ use marker::{Reflect, Sized}; #[stable(feature = "rust1", since = "1.0.0")] pub trait Any: Reflect + 'static { /// Gets the `TypeId` of `self`. - #[unstable(feature = "core", + #[unstable(feature = "get_type_id", reason = "this method will likely be replaced by an associated static")] fn get_type_id(&self) -> TypeId; } diff --git a/src/libcore/array.rs b/src/libcore/array.rs index 91301ee558ca5..a9b240de30bef 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -12,9 +12,10 @@ //! up to a certain length. Eventually we should able to generalize //! to all lengths. -#![unstable(feature = "core")] // not yet reviewed - #![doc(primitive = "array")] +#![unstable(feature = "fixed_size_array", + reason = "traits and impls are better expressed through generic \ + integer constants")] use clone::Clone; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; @@ -30,7 +31,6 @@ use slice::{Iter, IterMut, SliceExt}; /// /// This trait can be used to implement other traits on fixed-size arrays /// without causing much metadata bloat. -#[unstable(feature = "core")] pub trait FixedSizeArray { /// Converts the array to immutable slice fn as_slice(&self) -> &[T]; @@ -42,7 +42,6 @@ pub trait FixedSizeArray { macro_rules! array_impls { ($($N:expr)+) => { $( - #[unstable(feature = "core")] impl FixedSizeArray for [T; $N] { #[inline] fn as_slice(&self) -> &[T] { @@ -54,8 +53,6 @@ macro_rules! array_impls { } } - #[unstable(feature = "array_as_ref", - reason = "should ideally be implemented for all fixed-sized arrays")] impl AsRef<[T]> for [T; $N] { #[inline] fn as_ref(&self) -> &[T] { @@ -63,8 +60,6 @@ macro_rules! array_impls { } } - #[unstable(feature = "array_as_ref", - reason = "should ideally be implemented for all fixed-sized arrays")] impl AsMut<[T]> for [T; $N] { #[inline] fn as_mut(&mut self) -> &mut [T] { diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 175dabaf1d2cb..56dfd922dc188 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -229,7 +229,7 @@ impl Cell { /// let uc = unsafe { c.as_unsafe_cell() }; /// ``` #[inline] - #[unstable(feature = "core")] + #[unstable(feature = "as_unsafe_cell")] pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell { &self.value } @@ -277,7 +277,7 @@ pub struct RefCell { /// An enumeration of values returned from the `state` method on a `RefCell`. #[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[unstable(feature = "std_misc")] +#[unstable(feature = "borrow_state")] pub enum BorrowState { /// The cell is currently being read, there is at least one active `borrow`. Reading, @@ -339,7 +339,7 @@ impl RefCell { /// /// The returned value can be dispatched on to determine if a call to /// `borrow` or `borrow_mut` would succeed. - #[unstable(feature = "std_misc")] + #[unstable(feature = "borrow_state")] #[inline] pub fn borrow_state(&self) -> BorrowState { match self.borrow.get() { @@ -448,7 +448,7 @@ impl RefCell { /// /// This function is `unsafe` because `UnsafeCell`'s field is public. #[inline] - #[unstable(feature = "core")] + #[unstable(feature = "as_unsafe_cell")] pub unsafe fn as_unsafe_cell<'a>(&'a self) -> &'a UnsafeCell { &self.value } @@ -564,9 +564,10 @@ impl<'b, T: ?Sized> Ref<'b, T> { /// /// The `RefCell` is already immutably borrowed, so this cannot fail. /// - /// This is an associated function that needs to be used as `Ref::clone(...)`. - /// A `Clone` implementation or a method would interfere with the widespread - /// use of `r.borrow().clone()` to clone the contents of a `RefCell`. + /// This is an associated function that needs to be used as + /// `Ref::clone(...)`. A `Clone` implementation or a method would interfere + /// with the widespread use of `r.borrow().clone()` to clone the contents of + /// a `RefCell`. #[unstable(feature = "cell_extras", reason = "likely to be moved to a method, pending language changes")] #[inline] @@ -582,8 +583,8 @@ impl<'b, T: ?Sized> Ref<'b, T> { /// The `RefCell` is already immutably borrowed, so this cannot fail. /// /// This is an associated function that needs to be used as `Ref::map(...)`. - /// A method would interfere with methods of the same name on the contents of a `RefCell` - /// used through `Deref`. + /// A method would interfere with methods of the same name on the contents + /// of a `RefCell` used through `Deref`. /// /// # Example /// @@ -607,13 +608,14 @@ impl<'b, T: ?Sized> Ref<'b, T> { } } - /// Make a new `Ref` for a optional component of the borrowed data, e.g. an enum variant. + /// Make a new `Ref` for a optional component of the borrowed data, e.g. an + /// enum variant. /// /// The `RefCell` is already immutably borrowed, so this cannot fail. /// - /// This is an associated function that needs to be used as `Ref::filter_map(...)`. - /// A method would interfere with methods of the same name on the contents of a `RefCell` - /// used through `Deref`. + /// This is an associated function that needs to be used as + /// `Ref::filter_map(...)`. A method would interfere with methods of the + /// same name on the contents of a `RefCell` used through `Deref`. /// /// # Example /// @@ -639,13 +641,14 @@ impl<'b, T: ?Sized> Ref<'b, T> { } impl<'b, T: ?Sized> RefMut<'b, T> { - /// Make a new `RefMut` for a component of the borrowed data, e.g. an enum variant. + /// Make a new `RefMut` for a component of the borrowed data, e.g. an enum + /// variant. /// /// The `RefCell` is already mutably borrowed, so this cannot fail. /// - /// This is an associated function that needs to be used as `RefMut::map(...)`. - /// A method would interfere with methods of the same name on the contents of a `RefCell` - /// used through `Deref`. + /// This is an associated function that needs to be used as + /// `RefMut::map(...)`. A method would interfere with methods of the same + /// name on the contents of a `RefCell` used through `Deref`. /// /// # Example /// @@ -673,13 +676,14 @@ impl<'b, T: ?Sized> RefMut<'b, T> { } } - /// Make a new `RefMut` for a optional component of the borrowed data, e.g. an enum variant. + /// Make a new `RefMut` for a optional component of the borrowed data, e.g. + /// an enum variant. /// /// The `RefCell` is already mutably borrowed, so this cannot fail. /// - /// This is an associated function that needs to be used as `RefMut::filter_map(...)`. - /// A method would interfere with methods of the same name on the contents of a `RefCell` - /// used through `Deref`. + /// This is an associated function that needs to be used as + /// `RefMut::filter_map(...)`. A method would interfere with methods of the + /// same name on the contents of a `RefCell` used through `Deref`. /// /// # Example /// @@ -690,7 +694,9 @@ impl<'b, T: ?Sized> RefMut<'b, T> { /// let c = RefCell::new(Ok(5)); /// { /// let b1: RefMut> = c.borrow_mut(); - /// let mut b2: RefMut = RefMut::filter_map(b1, |o| o.as_mut().ok()).unwrap(); + /// let mut b2: RefMut = RefMut::filter_map(b1, |o| { + /// o.as_mut().ok() + /// }).unwrap(); /// assert_eq!(*b2, 5); /// *b2 = 42; /// } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index df371752b8651..9f5944d3c9c71 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -14,6 +14,7 @@ #![allow(non_snake_case)] #![doc(primitive = "char")] +#![stable(feature = "rust1", since = "1.0.0")] use iter::Iterator; use mem::transmute; @@ -131,6 +132,8 @@ pub fn from_digit(num: u32, radix: u32) -> Option { // unicode/char.rs, not here #[allow(missing_docs)] // docs in libunicode/u_char.rs #[doc(hidden)] +#[unstable(feature = "core_char_ext", + reason = "the stable interface is `impl char` in later crate")] pub trait CharExt { fn is_digit(self, radix: u32) -> bool; fn to_digit(self, radix: u32) -> Option; @@ -220,6 +223,8 @@ impl CharExt for char { /// If the buffer is not large enough, nothing will be written into it /// and a `None` will be returned. #[inline] +#[unstable(feature = "char_internals", + reason = "this function should not be exposed publicly")] pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option { // Marked #[inline] to allow llvm optimizing it away if code < MAX_ONE_B && !dst.is_empty() { @@ -251,6 +256,8 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option { /// If the buffer is not large enough, nothing will be written into it /// and a `None` will be returned. #[inline] +#[unstable(feature = "char_internals", + reason = "this function should not be exposed publicly")] pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option { // Marked #[inline] to allow llvm optimizing it away if (ch & 0xFFFF) == ch && !dst.is_empty() { diff --git a/src/libcore/clone.rs b/src/libcore/clone.rs index f11c01507dcd8..a13160b3a19ee 100644 --- a/src/libcore/clone.rs +++ b/src/libcore/clone.rs @@ -89,29 +89,28 @@ clone_impl! { char } macro_rules! extern_fn_clone { ($($A:ident),*) => ( - #[unstable(feature = "core", - reason = "this may not be sufficient for fns with region parameters")] + #[stable(feature = "rust1", since = "1.0.0")] impl<$($A,)* ReturnType> Clone for extern "Rust" fn($($A),*) -> ReturnType { /// Returns a copy of a function pointer. #[inline] fn clone(&self) -> extern "Rust" fn($($A),*) -> ReturnType { *self } } - #[unstable(feature = "core", reason = "brand new")] + #[stable(feature = "rust1", since = "1.0.0")] impl<$($A,)* ReturnType> Clone for extern "C" fn($($A),*) -> ReturnType { /// Returns a copy of a function pointer. #[inline] fn clone(&self) -> extern "C" fn($($A),*) -> ReturnType { *self } } - #[unstable(feature = "core", reason = "brand new")] + #[stable(feature = "rust1", since = "1.0.0")] impl<$($A,)* ReturnType> Clone for unsafe extern "Rust" fn($($A),*) -> ReturnType { /// Returns a copy of a function pointer. #[inline] fn clone(&self) -> unsafe extern "Rust" fn($($A),*) -> ReturnType { *self } } - #[unstable(feature = "core", reason = "brand new")] + #[stable(feature = "rust1", since = "1.0.0")] impl<$($A,)* ReturnType> Clone for unsafe extern "C" fn($($A),*) -> ReturnType { /// Returns a copy of a function pointer. #[inline] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index dab549f784cf8..b12b59760106a 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -10,10 +10,10 @@ //! Functionality for ordering and comparison. //! -//! This module defines both `PartialOrd` and `PartialEq` traits which are used by the compiler to -//! implement comparison operators. Rust programs may implement `PartialOrd` to overload the `<`, -//! `<=`, `>`, and `>=` operators, and may implement `PartialEq` to overload the `==` and `!=` -//! operators. +//! This module defines both `PartialOrd` and `PartialEq` traits which are used +//! by the compiler to implement comparison operators. Rust programs may +//! implement `PartialOrd` to overload the `<`, `<=`, `>`, and `>=` operators, +//! and may implement `PartialEq` to overload the `==` and `!=` operators. #![stable(feature = "rust1", since = "1.0.0")] @@ -22,29 +22,31 @@ use self::Ordering::*; use marker::Sized; use option::Option::{self, Some, None}; -/// Trait for equality comparisons which are [partial equivalence relations]( -/// http://en.wikipedia.org/wiki/Partial_equivalence_relation). +/// Trait for equality comparisons which are [partial equivalence +/// relations](http://en.wikipedia.org/wiki/Partial_equivalence_relation). /// -/// This trait allows for partial equality, for types that do not have a full equivalence relation. -/// For example, in floating point numbers `NaN != NaN`, so floating point types implement -/// `PartialEq` but not `Eq`. +/// This trait allows for partial equality, for types that do not have a full +/// equivalence relation. For example, in floating point numbers `NaN != NaN`, +/// so floating point types implement `PartialEq` but not `Eq`. /// /// Formally, the equality must be (for all `a`, `b` and `c`): /// /// - symmetric: `a == b` implies `b == a`; and /// - transitive: `a == b` and `b == c` implies `a == c`. /// -/// Note that these requirements mean that the trait itself must be implemented symmetrically and -/// transitively: if `T: PartialEq` and `U: PartialEq` then `U: PartialEq` and `T: -/// PartialEq`. +/// Note that these requirements mean that the trait itself must be implemented +/// symmetrically and transitively: if `T: PartialEq` and `U: PartialEq` +/// then `U: PartialEq` and `T: PartialEq`. /// -/// PartialEq only requires the `eq` method to be implemented; `ne` is defined in terms of it by -/// default. Any manual implementation of `ne` *must* respect the rule that `eq` is a strict -/// inverse of `ne`; that is, `!(a == b)` if and only if `a != b`. +/// PartialEq only requires the `eq` method to be implemented; `ne` is defined +/// in terms of it by default. Any manual implementation of `ne` *must* respect +/// the rule that `eq` is a strict inverse of `ne`; that is, `!(a == b)` if and +/// only if `a != b`. #[lang = "eq"] #[stable(feature = "rust1", since = "1.0.0")] pub trait PartialEq { - /// This method tests for `self` and `other` values to be equal, and is used by `==`. + /// This method tests for `self` and `other` values to be equal, and is used + /// by `==`. #[stable(feature = "rust1", since = "1.0.0")] fn eq(&self, other: &Rhs) -> bool; @@ -396,7 +398,7 @@ pub fn max(v1: T, v2: T) -> T { /// assert_eq!(result, None); /// ``` #[inline] -#[unstable(feature = "core")] +#[unstable(feature = "cmp_partial")] pub fn partial_min(v1: T, v2: T) -> Option { match v1.partial_cmp(&v2) { Some(Less) | Some(Equal) => Some(v1), @@ -429,7 +431,7 @@ pub fn partial_min(v1: T, v2: T) -> Option { /// assert_eq!(result, None); /// ``` #[inline] -#[unstable(feature = "core")] +#[unstable(feature = "cmp_partial")] pub fn partial_max(v1: T, v2: T) -> Option { match v1.partial_cmp(&v2) { Some(Equal) | Some(Less) => Some(v2), diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index f6987c1966493..70868805299f3 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -10,11 +10,12 @@ //! Traits for conversions between types. //! -//! The traits in this module provide a general way to talk about conversions from one type to -//! another. They follow the standard Rust conventions of `as`/`into`/`from`. +//! The traits in this module provide a general way to talk about conversions +//! from one type to another. They follow the standard Rust conventions of +//! `as`/`into`/`from`. //! -//! Like many traits, these are often used as bounds for generic functions, to support arguments of -//! multiple types. +//! Like many traits, these are often used as bounds for generic functions, to +//! support arguments of multiple types. //! //! See each trait for usage examples. diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 76a40dc8a528a..cbbb186af7609 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -33,7 +33,7 @@ pub use self::builders::{DebugStruct, DebugTuple, DebugSet, DebugList, DebugMap} mod num; mod builders; -#[unstable(feature = "core", reason = "internal to format_args!")] +#[unstable(feature = "fmt_internals", reason = "internal to format_args!")] #[doc(hidden)] pub mod rt { pub mod v1; @@ -146,7 +146,7 @@ enum Void {} /// compile time it is ensured that the function and the value have the correct /// types, and then this struct is used to canonicalize arguments to one type. #[derive(Copy)] -#[unstable(feature = "core", reason = "internal to format_args!")] +#[unstable(feature = "fmt_internals", reason = "internal to format_args!")] #[doc(hidden)] pub struct ArgumentV1<'a> { value: &'a Void, @@ -166,7 +166,7 @@ impl<'a> ArgumentV1<'a> { } #[doc(hidden)] - #[unstable(feature = "core", reason = "internal to format_args!")] + #[unstable(feature = "fmt_internals", reason = "internal to format_args!")] pub fn new<'b, T>(x: &'b T, f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> { unsafe { @@ -178,7 +178,7 @@ impl<'a> ArgumentV1<'a> { } #[doc(hidden)] - #[unstable(feature = "core", reason = "internal to format_args!")] + #[unstable(feature = "fmt_internals", reason = "internal to format_args!")] pub fn from_usize(x: &usize) -> ArgumentV1 { ArgumentV1::new(x, ArgumentV1::show_usize) } @@ -201,7 +201,7 @@ impl<'a> Arguments<'a> { /// When using the format_args!() macro, this function is used to generate the /// Arguments structure. #[doc(hidden)] #[inline] - #[unstable(feature = "core", reason = "internal to format_args!")] + #[unstable(feature = "fmt_internals", reason = "internal to format_args!")] pub fn new_v1(pieces: &'a [&'a str], args: &'a [ArgumentV1<'a>]) -> Arguments<'a> { Arguments { @@ -218,7 +218,7 @@ impl<'a> Arguments<'a> { /// created with `argumentusize`. However, failing to do so doesn't cause /// unsafety, but will ignore invalid . #[doc(hidden)] #[inline] - #[unstable(feature = "core", reason = "internal to format_args!")] + #[unstable(feature = "fmt_internals", reason = "internal to format_args!")] pub fn new_v1_formatted(pieces: &'a [&'a str], args: &'a [ArgumentV1<'a>], fmt: &'a [rt::v1::Argument]) -> Arguments<'a> { @@ -742,19 +742,19 @@ impl<'a> Formatter<'a> { pub fn flags(&self) -> u32 { self.flags } /// Character used as 'fill' whenever there is alignment - #[unstable(feature = "core", reason = "method was just created")] + #[unstable(feature = "fmt_flags", reason = "method was just created")] pub fn fill(&self) -> char { self.fill } /// Flag indicating what form of alignment was requested - #[unstable(feature = "core", reason = "method was just created")] + #[unstable(feature = "fmt_flags", reason = "method was just created")] pub fn align(&self) -> Alignment { self.align } /// Optionally specified integer width that the output should be - #[unstable(feature = "core", reason = "method was just created")] + #[unstable(feature = "fmt_flags", reason = "method was just created")] pub fn width(&self) -> Option { self.width } /// Optionally specified precision for numeric types - #[unstable(feature = "core", reason = "method was just created")] + #[unstable(feature = "fmt_flags", reason = "method was just created")] pub fn precision(&self) -> Option { self.precision } /// Creates a `DebugStruct` builder designed to assist with creation of diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 122fffc595905..6aaec20382ecf 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -127,7 +127,7 @@ radix! { UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x, /// A radix with in the range of `2..36`. #[derive(Clone, Copy, PartialEq)] -#[unstable(feature = "core", +#[unstable(feature = "fmt_radix", reason = "may be renamed or move to a different module")] pub struct Radix { base: u8, @@ -152,7 +152,7 @@ impl GenericRadix for Radix { } /// A helper type for formatting radixes. -#[unstable(feature = "core", +#[unstable(feature = "fmt_radix", reason = "may be renamed or move to a different module")] #[derive(Copy, Clone)] pub struct RadixFmt(T, R); @@ -166,7 +166,7 @@ pub struct RadixFmt(T, R); /// use std::fmt::radix; /// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string()); /// ``` -#[unstable(feature = "core", +#[unstable(feature = "fmt_radix", reason = "may be renamed or move to a different module")] pub fn radix(x: T, base: u8) -> RadixFmt { RadixFmt(x, Radix::new(base)) diff --git a/src/libcore/fmt/rt/v1.rs b/src/libcore/fmt/rt/v1.rs index 2afd8abeb31aa..033834dd5aaaa 100644 --- a/src/libcore/fmt/rt/v1.rs +++ b/src/libcore/fmt/rt/v1.rs @@ -14,8 +14,6 @@ //! These definitions are similar to their `ct` equivalents, but differ in that //! these can be statically allocated and are slightly optimized for the runtime -#![unstable(feature = "core", reason = "internal to format_args!")] - #[derive(Copy, Clone)] pub struct Argument { pub position: Position, diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index e848a44e01ce0..cbf2828a7dc18 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -89,7 +89,8 @@ pub trait Hash { fn hash(&self, state: &mut H); /// Feeds a slice of this type into the state provided. - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hash_slice", + reason = "module was recently redesigned")] fn hash_slice(data: &[Self], state: &mut H) where Self: Sized { for piece in data { piece.hash(state); @@ -110,29 +111,29 @@ pub trait Hasher { /// Write a single `u8` into this hasher #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_u8(&mut self, i: u8) { self.write(&[i]) } /// Write a single `u16` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_u16(&mut self, i: u16) { self.write(&unsafe { mem::transmute::<_, [u8; 2]>(i) }) } /// Write a single `u32` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_u32(&mut self, i: u32) { self.write(&unsafe { mem::transmute::<_, [u8; 4]>(i) }) } /// Write a single `u64` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_u64(&mut self, i: u64) { self.write(&unsafe { mem::transmute::<_, [u8; 8]>(i) }) } /// Write a single `usize` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_usize(&mut self, i: usize) { if cfg!(target_pointer_width = "32") { self.write_u32(i as u32) @@ -143,23 +144,23 @@ pub trait Hasher { /// Write a single `i8` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_i8(&mut self, i: i8) { self.write_u8(i as u8) } /// Write a single `i16` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_i16(&mut self, i: i16) { self.write_u16(i as u16) } /// Write a single `i32` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_i32(&mut self, i: i32) { self.write_u32(i as u32) } /// Write a single `i64` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_i64(&mut self, i: i64) { self.write_u64(i as u64) } /// Write a single `isize` into this hasher. #[inline] - #[unstable(feature = "hash", reason = "module was recently redesigned")] + #[unstable(feature = "hasher_write", reason = "module was recently redesigned")] fn write_isize(&mut self, i: isize) { self.write_usize(i as usize) } } @@ -167,7 +168,9 @@ pub trait Hasher { /// /// The specified value will be hashed with this hasher and then the resulting /// hash will be returned. -#[unstable(feature = "hash", reason = "module was recently redesigned")] +#[unstable(feature = "hash_default", + reason = "not the most ergonomic interface unless `H` is defaulted \ + to SipHasher, but perhaps not ready to commit to that")] pub fn hash(value: &T) -> u64 { let mut h: H = Default::default(); value.hash(&mut h); diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 774f86563d79c..455928077da46 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -39,7 +39,10 @@ //! guaranteed to happen in order. This is the standard mode for working //! with atomic types and is equivalent to Java's `volatile`. -#![unstable(feature = "core")] +#![unstable(feature = "core_intrinsics", + reason = "intrinsics are unlikely to ever be stabilized, instead \ + they should be used through stabilized interfaces \ + in the rest of the standard library")] #![allow(missing_docs)] use marker::Sized; @@ -141,10 +144,10 @@ extern "rust-intrinsic" { /// A compiler-only memory barrier. /// - /// Memory accesses will never be reordered across this barrier by the compiler, - /// but no instructions will be emitted for it. This is appropriate for operations - /// on the same thread that may be preempted, such as when interacting with signal - /// handlers. + /// Memory accesses will never be reordered across this barrier by the + /// compiler, but no instructions will be emitted for it. This is + /// appropriate for operations on the same thread that may be preempted, + /// such as when interacting with signal handlers. pub fn atomic_singlethreadfence(); pub fn atomic_singlethreadfence_acq(); pub fn atomic_singlethreadfence_rel(); diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index ae2248206c40d..da714671c5723 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -51,8 +51,8 @@ //! } //! ``` //! -//! Because `Iterator`s implement `IntoIterator`, this `for` loop syntax can be applied to any -//! iterator over any type. +//! Because `Iterator`s implement `IntoIterator`, this `for` loop syntax can be +//! applied to any iterator over any type. #![stable(feature = "rust1", since = "1.0.0")] @@ -837,7 +837,9 @@ pub trait Iterator { /// let a = [1, 1, 1, 1]; /// assert_eq!(a.iter().min_max(), MinMax(&1, &1)); /// ``` - #[unstable(feature = "core", reason = "return type may change")] + #[unstable(feature = "iter_min_max", + reason = "return type may change or may wish to have a closure \ + based version as well")] fn min_max(mut self) -> MinMaxResult where Self: Sized, Self::Item: Ord { let (mut min, mut max) = match self.next() { @@ -897,7 +899,7 @@ pub trait Iterator { /// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10); /// ``` #[inline] - #[unstable(feature = "core", + #[unstable(feature = "iter_cmp", reason = "may want to produce an Ordering directly; see #15311")] fn max_by(self, f: F) -> Option where Self: Sized, @@ -925,7 +927,7 @@ pub trait Iterator { /// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0); /// ``` #[inline] - #[unstable(feature = "core", + #[unstable(feature = "iter_cmp", reason = "may want to produce an Ordering directly; see #15311")] fn min_by(self, f: F) -> Option where Self: Sized, @@ -1041,6 +1043,8 @@ pub trait Iterator { /// Use an iterator to reverse a container in place. #[unstable(feature = "core", reason = "uncertain about placement or widespread use")] + #[deprecated(since = "1.2.0", + reason = "not performant enough to justify inclusion")] fn reverse_in_place<'a, T: 'a>(&mut self) where Self: Sized + Iterator + DoubleEndedIterator { @@ -1062,7 +1066,7 @@ pub trait Iterator { /// let it = a.iter(); /// assert_eq!(it.sum::(), 15); /// ``` - #[unstable(feature="core")] + #[unstable(feature="iter_sum", reason = "bounds recently changed")] fn sum::Item>(self) -> S where S: Add + Zero, Self: Sized, @@ -1083,7 +1087,7 @@ pub trait Iterator { /// assert_eq!(factorial(1), 1); /// assert_eq!(factorial(5), 120); /// ``` - #[unstable(feature="core")] + #[unstable(feature="iter_product", reason = "bounds recently changed")] fn product::Item>(self) -> P where P: Mul + One, Self: Sized, @@ -1223,7 +1227,7 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I { /// `DoubleEndedIterator`. Calling `next()` or `next_back()` on a /// `RandomAccessIterator` reduces the indexable range accordingly. That is, /// `it.idx(1)` will become `it.idx(0)` after `it.next()` is called. -#[unstable(feature = "core", +#[unstable(feature = "iter_idx", reason = "not widely used, may be better decomposed into Index \ and ExactSizeIterator")] pub trait RandomAccessIterator: Iterator { @@ -1304,7 +1308,7 @@ impl DoubleEndedIterator for Rev where I: DoubleEndedIterator { fn next_back(&mut self) -> Option<::Item> { self.iter.next() } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Rev where I: DoubleEndedIterator + RandomAccessIterator { @@ -1324,7 +1328,7 @@ impl RandomAccessIterator for Rev /// `MinMaxResult` is an enum returned by `min_max`. See `Iterator::min_max` for /// more detail. #[derive(Clone, PartialEq, Debug)] -#[unstable(feature = "core", +#[unstable(feature = "iter_min_max", reason = "unclear whether such a fine-grained result is widely useful")] pub enum MinMaxResult { /// Empty iterator @@ -1338,6 +1342,7 @@ pub enum MinMaxResult { MinMax(T, T) } +#[unstable(feature = "iter_min_max", reason = "type is unstable")] impl MinMaxResult { /// `into_option` creates an `Option` of type `(T,T)`. The returned `Option` /// has variant `None` if and only if the `MinMaxResult` has variant @@ -1360,7 +1365,6 @@ impl MinMaxResult { /// let r = MinMax(1, 2); /// assert_eq!(r.into_option(), Some((1, 2))); /// ``` - #[unstable(feature = "core", reason = "type is unstable")] pub fn into_option(self) -> Option<(T,T)> { match self { NoElements => None, @@ -1407,7 +1411,7 @@ impl<'a, I, T: 'a> ExactSizeIterator for Cloned where I: ExactSizeIterator, T: Clone {} -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl<'a, I, T: 'a> RandomAccessIterator for Cloned where I: RandomAccessIterator, T: Clone { @@ -1454,7 +1458,7 @@ impl Iterator for Cycle where I: Clone + Iterator { } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Cycle where I: Clone + RandomAccessIterator, { @@ -1568,7 +1572,7 @@ impl DoubleEndedIterator for Chain where } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Chain where A: RandomAccessIterator, B: RandomAccessIterator, @@ -1656,7 +1660,7 @@ impl DoubleEndedIterator for Zip where } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Zip where A: RandomAccessIterator, B: RandomAccessIterator @@ -1710,7 +1714,7 @@ impl DoubleEndedIterator for Map where } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Map where F: FnMut(I::Item) -> B, { @@ -1884,7 +1888,7 @@ impl DoubleEndedIterator for Enumerate where } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Enumerate where I: RandomAccessIterator { #[inline] fn indexable(&self) -> usize { @@ -2134,7 +2138,7 @@ impl Iterator for Skip where I: Iterator { } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Skip where I: RandomAccessIterator{ #[inline] fn indexable(&self) -> usize { @@ -2206,7 +2210,7 @@ impl Iterator for Take where I: Iterator{ } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Take where I: RandomAccessIterator{ #[inline] fn indexable(&self) -> usize { @@ -2236,7 +2240,8 @@ pub struct Scan { f: F, /// The current internal state to be passed to the closure next. - #[unstable(feature = "core")] + #[unstable(feature = "scan_state", + reason = "public fields are otherwise rare in the stdlib")] pub state: St, } @@ -2406,7 +2411,7 @@ impl DoubleEndedIterator for Fuse where I: DoubleEndedIterator { } // Allow RandomAccessIterators to be fused without affecting random-access behavior -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Fuse where I: RandomAccessIterator { #[inline] fn indexable(&self) -> usize { @@ -2427,7 +2432,7 @@ impl Fuse { /// `.next_back()` will call the underlying iterator again even if it /// previously returned `None`. #[inline] - #[unstable(feature = "core", reason = "seems marginal")] + #[unstable(feature = "iter_reset_fuse", reason = "seems marginal")] pub fn reset_fuse(&mut self) { self.done = false } @@ -2481,7 +2486,7 @@ impl DoubleEndedIterator for Inspect } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Inspect where F: FnMut(&I::Item), { @@ -2531,16 +2536,16 @@ impl RandomAccessIterator for Inspect /// println!("{}", i); /// } /// ``` -#[unstable(feature = "core")] +#[unstable(feature = "iter_unfold")] #[derive(Clone)] pub struct Unfold { f: F, /// Internal state that will be passed to the closure on the next iteration - #[unstable(feature = "core")] + #[unstable(feature = "iter_unfold")] pub state: St, } -#[unstable(feature = "core")] +#[unstable(feature = "iter_unfold")] impl Unfold where F: FnMut(&mut St) -> Option { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the closure @@ -2767,7 +2772,7 @@ impl Iterator for StepBy> where /// An iterator over the range [start, stop] #[derive(Clone)] -#[unstable(feature = "core", +#[unstable(feature = "range_inclusive", reason = "likely to be replaced by range notation and adapters")] pub struct RangeInclusive { range: ops::Range, @@ -2776,7 +2781,7 @@ pub struct RangeInclusive { /// Returns an iterator over the range [start, stop]. #[inline] -#[unstable(feature = "core", +#[unstable(feature = "range_inclusive", reason = "likely to be replaced by range notation and adapters")] pub fn range_inclusive(start: A, stop: A) -> RangeInclusive where A: Step + One + Clone @@ -2787,7 +2792,7 @@ pub fn range_inclusive(start: A, stop: A) -> RangeInclusive } } -#[unstable(feature = "core", +#[unstable(feature = "range_inclusive", reason = "likely to be replaced by range notation and adapters")] impl Iterator for RangeInclusive where A: PartialEq + Step + One + Clone, @@ -2820,7 +2825,7 @@ impl Iterator for RangeInclusive where } } -#[unstable(feature = "core", +#[unstable(feature = "range_inclusive", reason = "likely to be replaced by range notation and adapters")] impl DoubleEndedIterator for RangeInclusive where A: PartialEq + Step + One + Clone, @@ -2973,7 +2978,7 @@ impl DoubleEndedIterator for Repeat { fn next_back(&mut self) -> Option { self.idx(0) } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl RandomAccessIterator for Repeat { #[inline] fn indexable(&self) -> usize { usize::MAX } @@ -2985,12 +2990,12 @@ type IterateState = (F, Option, bool); /// An iterator that repeatedly applies a given function, starting /// from a given seed value. -#[unstable(feature = "core")] +#[unstable(feature = "iter_iterate")] pub type Iterate = Unfold, fn(&mut IterateState) -> Option>; /// Creates a new iterator that produces an infinite sequence of /// repeated applications of the given function `f`. -#[unstable(feature = "core")] +#[unstable(feature = "iter_iterate")] pub fn iterate(seed: T, f: F) -> Iterate where T: Clone, F: FnMut(T) -> T, @@ -3123,7 +3128,7 @@ pub fn once(value: T) -> Once { /// /// If two sequences are equal up until the point where one ends, /// the shorter sequence compares less. -#[unstable(feature = "core", reason = "needs review and revision")] +#[unstable(feature = "iter_order", reason = "needs review and revision")] pub mod order { use cmp; use cmp::{Eq, Ord, PartialOrd, PartialEq}; diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 9dfaec0095a5a..030d2a33f8f65 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -49,7 +49,9 @@ // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "core"] -#![unstable(feature = "core")] +#![unstable(feature = "core", + reason = "the libcore library has not yet been scrutinized for \ + stabilization in terms of structure and naming")] #![staged_api] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", @@ -63,7 +65,8 @@ #![allow(raw_pointer_derive)] #![deny(missing_docs)] -#![feature(intrinsics, lang_items)] +#![feature(intrinsics)] +#![feature(lang_items)] #![feature(on_unimplemented)] #![feature(simd)] #![feature(staged_api)] @@ -75,6 +78,7 @@ #![feature(reflect)] #![feature(custom_attribute)] #![feature(const_fn)] +#![feature(allow_internal_unstable)] #[macro_use] mod macros; diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index b5555fa51197c..14bb82dff7d6e 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -10,6 +10,7 @@ /// Entry point of thread panic, for details, see std::macros #[macro_export] +#[allow_internal_unstable] macro_rules! panic { () => ( panic!("explicit panic") diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 7c20722b26d47..dc3b06977d6c6 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -54,7 +54,7 @@ pub trait Sized { } /// Types that can be "unsized" to a dynamically sized type. -#[unstable(feature = "core")] +#[unstable(feature = "unsize")] #[lang="unsize"] pub trait Unsize { // Empty. @@ -223,7 +223,10 @@ impl !Sync for *mut T { } /// ensure that they are never copied, even if they lack a destructor. #[unstable(feature = "core", reason = "likely to change with new variance strategy")] +#[deprecated(since = "1.2.0", + reason = "structs are by default not copyable")] #[lang = "no_copy_bound"] +#[allow(deprecated)] #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct NoCopy; @@ -410,7 +413,8 @@ mod impls { /// /// [1]: http://en.wikipedia.org/wiki/Parametricity #[rustc_reflect_like] -#[unstable(feature = "core", reason = "requires RFC and more experience")] +#[unstable(feature = "reflect_marker", + reason = "requires RFC and more experience")] #[allow(deprecated)] #[rustc_on_unimplemented = "`{Self}` does not implement `Any`; \ ensure all type parameters are bounded by `Any`"] diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 26c6e899df1ce..4e9613454ab97 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -459,7 +459,7 @@ pub unsafe fn transmute_copy(src: &T) -> U { /// Transforms lifetime of the second pointer to match the first. #[inline] -#[unstable(feature = "core", +#[unstable(feature = "copy_lifetime", reason = "this function may be removed in the future due to its \ questionable utility")] pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, @@ -469,7 +469,7 @@ pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, /// Transforms lifetime of the second mutable pointer to match the first. #[inline] -#[unstable(feature = "core", +#[unstable(feature = "copy_lifetime", reason = "this function may be removed in the future due to its \ questionable utility")] pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, diff --git a/src/libcore/nonzero.rs b/src/libcore/nonzero.rs index 32522794254f6..1b5fa4e0e950b 100644 --- a/src/libcore/nonzero.rs +++ b/src/libcore/nonzero.rs @@ -9,6 +9,8 @@ // except according to those terms. //! Exposes the NonZero lang item which provides optimization hints. +#![unstable(feature = "nonzero", + reason = "needs an RFC to flesh out the design")] use marker::Sized; use ops::{CoerceUnsized, Deref}; @@ -33,7 +35,6 @@ unsafe impl Zeroable for u64 {} /// NULL or 0 that might allow certain optimizations. #[lang = "non_zero"] #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash)] -#[unstable(feature = "core")] pub struct NonZero(T); impl NonZero { diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 50dd3f1661adf..229414fe76664 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -71,7 +71,8 @@ pub mod consts { pub const PI: f32 = 3.14159265358979323846264338327950288_f32; /// pi * 2.0 - #[unstable(feature = "core", reason = "unclear naming convention/usefulness")] + #[unstable(feature = "float_consts", + reason = "unclear naming convention/usefulness")] pub const PI_2: f32 = 6.28318530717958647692528676655900576_f32; /// pi/2.0 @@ -135,7 +136,6 @@ pub mod consts { pub const LN_10: f32 = 2.30258509299404568401799145468436421_f32; } -#[unstable(feature = "core", reason = "trait is unstable")] impl Float for f32 { #[inline] fn nan() -> f32 { NAN } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 62b566e7eb40c..bbc1bdacde713 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -71,7 +71,8 @@ pub mod consts { pub const PI: f64 = 3.14159265358979323846264338327950288_f64; /// pi * 2.0 - #[unstable(feature = "core", reason = "unclear naming convention/usefulness")] + #[unstable(feature = "float_consts", + reason = "unclear naming convention/usefulness")] pub const PI_2: f64 = 6.28318530717958647692528676655900576_f64; /// pi/2.0 @@ -135,7 +136,6 @@ pub mod consts { pub const LN_10: f64 = 2.30258509299404568401799145468436421_f64; } -#[unstable(feature = "core", reason = "trait is unstable")] impl Float for f64 { #[inline] fn nan() -> f64 { NAN } diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs index f51dcf54a1959..f3a7e8f09a9eb 100644 --- a/src/libcore/num/flt2dec/mod.rs +++ b/src/libcore/num/flt2dec/mod.rs @@ -126,6 +126,8 @@ functions. // while this is extensively documented, this is in principle private which is // only made public for testing. do not expose us. #![doc(hidden)] +#![unstable(feature = "flt2dec", + reason = "internal routines only exposed for testing")] use prelude::*; use i16; diff --git a/src/libcore/num/int_macros.rs b/src/libcore/num/int_macros.rs index 3113521e0afff..efc9123880978 100644 --- a/src/libcore/num/int_macros.rs +++ b/src/libcore/num/int_macros.rs @@ -14,11 +14,13 @@ macro_rules! int_module { ($T:ty, $bits:expr) => ( // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of // calling the `mem::size_of` function. -#[unstable(feature = "core")] +#[unstable(feature = "num_bits_bytes", + reason = "may want to be an associated function")] pub const BITS : usize = $bits; // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of // calling the `mem::size_of` function. -#[unstable(feature = "core")] +#[unstable(feature = "num_bits_bytes", + reason = "may want to be an associated function")] pub const BYTES : usize = ($bits / 8); // FIXME(#11621): Should be deprecated once CTFE is implemented in favour of diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index bf26022692d09..c8a0ae47637d2 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -41,10 +41,7 @@ use str::{FromStr, StrExt}; #[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug)] pub struct Wrapping(#[stable(feature = "rust1", since = "1.0.0")] pub T); -#[unstable(feature = "core", reason = "may be removed or relocated")] pub mod wrapping; - -#[unstable(feature = "core", reason = "internal routines only exposed for testing")] pub mod flt2dec; /// Types that have a "zero" value. @@ -471,7 +468,7 @@ macro_rules! int_impl { /// to `-MIN`, a positive value that is too large to represent /// in the type. In such a case, this function returns `MIN` /// itself.. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_div(self, rhs: Self) -> Self { self.overflowing_div(rhs).0 @@ -484,7 +481,7 @@ macro_rules! int_impl { /// implementation artifacts make `x % y` illegal for `MIN / /// -1` on a signed type illegal (where `MIN` is the negative /// minimal value). In such a case, this function returns `0`. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_rem(self, rhs: Self) -> Self { self.overflowing_rem(rhs).0 @@ -498,7 +495,7 @@ macro_rules! int_impl { /// negative minimal value for the type); this is a positive /// value that is too large to represent in the type. In such /// a case, this function returns `MIN` itself. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_neg(self) -> Self { self.overflowing_neg().0 @@ -507,7 +504,7 @@ macro_rules! int_impl { /// Panic-free bitwise shift-left; yields `self << mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_shl(self, rhs: u32) -> Self { self.overflowing_shl(rhs).0 @@ -516,7 +513,7 @@ macro_rules! int_impl { /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_shr(self, rhs: u32) -> Self { self.overflowing_shr(rhs).0 @@ -1041,7 +1038,7 @@ macro_rules! uint_impl { /// to `-MIN`, a positive value that is too large to represent /// in the type. In such a case, this function returns `MIN` /// itself.. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_div(self, rhs: Self) -> Self { self.overflowing_div(rhs).0 @@ -1054,7 +1051,7 @@ macro_rules! uint_impl { /// implementation artifacts make `x % y` illegal for `MIN / /// -1` on a signed type illegal (where `MIN` is the negative /// minimal value). In such a case, this function returns `0`. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_rem(self, rhs: Self) -> Self { self.overflowing_rem(rhs).0 @@ -1068,7 +1065,7 @@ macro_rules! uint_impl { /// negative minimal value for the type); this is a positive /// value that is too large to represent in the type. In such /// a case, this function returns `MIN` itself. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_neg(self) -> Self { self.overflowing_neg().0 @@ -1077,7 +1074,7 @@ macro_rules! uint_impl { /// Panic-free bitwise shift-left; yields `self << mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_shl(self, rhs: u32) -> Self { self.overflowing_shl(rhs).0 @@ -1086,7 +1083,7 @@ macro_rules! uint_impl { /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "core", since = "1.0.0")] + #[unstable(feature = "num_wrapping")] #[inline(always)] pub fn wrapping_shr(self, rhs: u32) -> Self { self.overflowing_shr(rhs).0 @@ -1262,6 +1259,8 @@ pub enum FpCategory { /// A built-in floating point number. #[doc(hidden)] +#[unstable(feature = "core_float", + reason = "stable interface is via `impl f{32,64}` in later crates")] pub trait Float { /// Returns the NaN value. fn nan() -> Self; @@ -1512,7 +1511,9 @@ enum IntErrorKind { } impl ParseIntError { - #[unstable(feature = "core", reason = "available through Error trait")] + #[unstable(feature = "int_error_internals", + reason = "available through Error trait and this method should \ + not be exposed publicly")] pub fn description(&self) -> &str { match self.kind { IntErrorKind::Empty => "cannot parse integer from empty string", @@ -1535,10 +1536,14 @@ impl fmt::Display for ParseIntError { #[stable(feature = "rust1", since = "1.0.0")] pub struct ParseFloatError { #[doc(hidden)] + #[unstable(feature = "float_error_internals", + reason = "should not be exposed publicly")] pub __kind: FloatErrorKind } #[derive(Debug, Clone, PartialEq)] +#[unstable(feature = "float_error_internals", + reason = "should not be exposed publicly")] pub enum FloatErrorKind { Empty, Invalid, diff --git a/src/libcore/num/uint_macros.rs b/src/libcore/num/uint_macros.rs index 8678295074550..0719d7c17cc4e 100644 --- a/src/libcore/num/uint_macros.rs +++ b/src/libcore/num/uint_macros.rs @@ -12,9 +12,11 @@ macro_rules! uint_module { ($T:ty, $T_SIGNED:ty, $bits:expr) => ( -#[unstable(feature = "core")] +#[unstable(feature = "num_bits_bytes", + reason = "may want to be an associated function")] pub const BITS : usize = $bits; -#[unstable(feature = "core")] +#[unstable(feature = "num_bits_bytes", + reason = "may want to be an associated function")] pub const BYTES : usize = ($bits / 8); #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcore/num/wrapping.rs b/src/libcore/num/wrapping.rs index 69c2222949032..748ed29e3a306 100644 --- a/src/libcore/num/wrapping.rs +++ b/src/libcore/num/wrapping.rs @@ -10,6 +10,7 @@ #![allow(missing_docs)] #![allow(deprecated)] +#![unstable(feature = "wrapping", reason = "may be removed or relocated")] use super::Wrapping; @@ -30,7 +31,6 @@ use intrinsics::{i64_mul_with_overflow, u64_mul_with_overflow}; use ::{i8,i16,i32,i64}; -#[unstable(feature = "core", reason = "may be removed, renamed, or relocated")] pub trait OverflowingOps { fn overflowing_add(self, rhs: Self) -> (Self, bool); fn overflowing_sub(self, rhs: Self) -> (Self, bool); diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index c52f4de732ff9..48b1cbeef4fdd 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -29,8 +29,8 @@ //! //! # Examples //! -//! This example creates a `Point` struct that implements `Add` and `Sub`, and then -//! demonstrates adding and subtracting two `Point`s. +//! This example creates a `Point` struct that implements `Add` and `Sub`, and +//! then demonstrates adding and subtracting two `Point`s. //! //! ```rust //! use std::ops::{Add, Sub}; @@ -62,21 +62,21 @@ //! } //! ``` //! -//! See the documentation for each trait for a minimum implementation that prints -//! something to the screen. +//! See the documentation for each trait for a minimum implementation that +//! prints something to the screen. #![stable(feature = "rust1", since = "1.0.0")] use marker::{Sized, Unsize}; use fmt; -/// The `Drop` trait is used to run some code when a value goes out of scope. This -/// is sometimes called a 'destructor'. +/// The `Drop` trait is used to run some code when a value goes out of scope. +/// This is sometimes called a 'destructor'. /// /// # Examples /// -/// A trivial implementation of `Drop`. The `drop` method is called when `_x` goes -/// out of scope, and therefore `main` prints `Dropping!`. +/// A trivial implementation of `Drop`. The `drop` method is called when `_x` +/// goes out of scope, and therefore `main` prints `Dropping!`. /// /// ``` /// struct HasDrop; @@ -103,8 +103,7 @@ pub trait Drop { // based on "op T" where T is expected to be `Copy`able macro_rules! forward_ref_unop { (impl $imp:ident, $method:ident for $t:ty) => { - #[unstable(feature = "core", - reason = "recently added, waiting for dust to settle")] + #[stable(feature = "rust1", since = "1.0.0")] impl<'a> $imp for &'a $t { type Output = <$t as $imp>::Output; @@ -120,8 +119,7 @@ macro_rules! forward_ref_unop { // based on "T op U" where T and U are expected to be `Copy`able macro_rules! forward_ref_binop { (impl $imp:ident, $method:ident for $t:ty, $u:ty) => { - #[unstable(feature = "core", - reason = "recently added, waiting for dust to settle")] + #[stable(feature = "rust1", since = "1.0.0")] impl<'a> $imp<$u> for &'a $t { type Output = <$t as $imp<$u>>::Output; @@ -131,8 +129,7 @@ macro_rules! forward_ref_binop { } } - #[unstable(feature = "core", - reason = "recently added, waiting for dust to settle")] + #[stable(feature = "rust1", since = "1.0.0")] impl<'a> $imp<&'a $u> for $t { type Output = <$t as $imp<$u>>::Output; @@ -142,8 +139,7 @@ macro_rules! forward_ref_binop { } } - #[unstable(feature = "core", - reason = "recently added, waiting for dust to settle")] + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, 'b> $imp<&'a $u> for &'b $t { type Output = <$t as $imp<$u>>::Output; @@ -1210,7 +1206,7 @@ mod impls { /// Trait that indicates that this is a pointer or a wrapper for one, /// where unsizing can be performed on the pointee. -#[unstable(feature = "core")] +#[unstable(feature = "coerce_unsized")] #[lang="coerce_unsized"] pub trait CoerceUnsized { // Empty. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 593c5e79d3425..9a00d1071473f 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -285,7 +285,7 @@ impl Option { /// assert_eq!(x, Some("Dirt")); /// ``` #[inline] - #[unstable(feature = "core", + #[unstable(feature = "as_slice", reason = "waiting for mut conventions")] pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] { match *self { diff --git a/src/libcore/panicking.rs b/src/libcore/panicking.rs index 635150c088688..8133db097dfcf 100644 --- a/src/libcore/panicking.rs +++ b/src/libcore/panicking.rs @@ -29,6 +29,9 @@ //! library, but the location of this may change over time. #![allow(dead_code, missing_docs)] +#![unstable(feature = "core_panic", + reason = "internal details of the implementation of the `panic!` \ + and related macros")] use fmt; diff --git a/src/libcore/prelude.rs b/src/libcore/prelude.rs index a4d529ad47d09..ac153d64ab28f 100644 --- a/src/libcore/prelude.rs +++ b/src/libcore/prelude.rs @@ -24,6 +24,10 @@ //! use core::prelude::*; //! ``` +#![unstable(feature = "core_prelude", + reason = "the libcore prelude has not been scrutinized and \ + stabilized yet")] + // Reexported core operators pub use marker::{Copy, Send, Sized, Sync}; pub use ops::{Drop, Fn, FnMut, FnOnce}; @@ -32,7 +36,6 @@ pub use ops::{Drop, Fn, FnMut, FnOnce}; pub use mem::drop; // Reexported types and traits - pub use char::CharExt; pub use clone::Clone; pub use cmp::{PartialEq, PartialOrd, Eq, Ord}; diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 9ca9b4fc46c99..0f1831e8314d3 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -204,7 +204,7 @@ pub unsafe fn read(src: *const T) -> T { /// /// This is unsafe for the same reasons that `read` is unsafe. #[inline(always)] -#[unstable(feature = "core", +#[unstable(feature = "read_and_zero", reason = "may play a larger role in std::ptr future extensions")] pub unsafe fn read_and_zero(dest: *mut T) -> T { // Copy the data out from `dest`: @@ -219,7 +219,7 @@ pub unsafe fn read_and_zero(dest: *mut T) -> T { /// Variant of read_and_zero that writes the specific drop-flag byte /// (which may be more appropriate than zero). #[inline(always)] -#[unstable(feature = "core", +#[unstable(feature = "filling_drop", reason = "may play a larger role in std::ptr future extensions")] pub unsafe fn read_and_drop(dest: *mut T) -> T { // Copy the data out from `dest`: @@ -267,9 +267,10 @@ impl *const T { /// null-safety, it is important to note that this is still an unsafe /// operation because the returned value could be pointing to invalid /// memory. - #[unstable(feature = "core", - reason = "Option is not clearly the right return type, and we may want \ - to tie the return lifetime to a borrow of the raw pointer")] + #[unstable(feature = "ptr_as_ref", + reason = "Option is not clearly the right return type, and we \ + may want to tie the return lifetime to a borrow of \ + the raw pointer")] #[inline] pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> where T: Sized { if self.is_null() { @@ -314,9 +315,10 @@ impl *mut T { /// null-safety, it is important to note that this is still an unsafe /// operation because the returned value could be pointing to invalid /// memory. - #[unstable(feature = "core", - reason = "Option is not clearly the right return type, and we may want \ - to tie the return lifetime to a borrow of the raw pointer")] + #[unstable(feature = "ptr_as_ref", + reason = "Option is not clearly the right return type, and we \ + may want to tie the return lifetime to a borrow of \ + the raw pointer")] #[inline] pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> where T: Sized { if self.is_null() { @@ -347,7 +349,7 @@ impl *mut T { /// /// As with `as_ref`, this is unsafe because it cannot verify the validity /// of the returned pointer. - #[unstable(feature = "core", + #[unstable(feature = "ptr_as_ref", reason = "return value does not necessarily convey all possible \ information")] #[inline] @@ -507,7 +509,7 @@ impl PartialOrd for *mut T { /// modified without a unique path to the `Unique` reference. Useful /// for building abstractions like `Vec` or `Box`, which /// internally use raw pointers to manage the memory that they own. -#[unstable(feature = "unique")] +#[unstable(feature = "unique", reason = "needs an RFC to flesh out design")] pub struct Unique { pointer: NonZero<*const T>, _marker: PhantomData, @@ -527,21 +529,19 @@ unsafe impl Send for Unique { } #[unstable(feature = "unique")] unsafe impl Sync for Unique { } +#[unstable(feature = "unique")] impl Unique { /// Creates a new `Unique`. - #[unstable(feature = "unique")] pub unsafe fn new(ptr: *mut T) -> Unique { Unique { pointer: NonZero::new(ptr), _marker: PhantomData } } /// Dereferences the content. - #[unstable(feature = "unique")] pub unsafe fn get(&self) -> &T { &**self.pointer } /// Mutably dereferences the content. - #[unstable(feature = "unique")] pub unsafe fn get_mut(&mut self) -> &mut T { &mut ***self } diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index ec84ef7986a43..85e1318d7a115 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -9,7 +9,7 @@ // except according to those terms. #![allow(missing_docs)] -#![unstable(feature = "core")] +#![unstable(feature = "raw")] //! Contains struct definitions for the layout of compiler built-in types. //! diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 772831b1a5862..998657a236dec 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -434,7 +434,7 @@ impl Result { /// assert!(x.as_mut_slice().is_empty()); /// ``` #[inline] - #[unstable(feature = "core", + #[unstable(feature = "as_slice", reason = "waiting for mut conventions")] pub fn as_mut_slice(&mut self) -> &mut [T] { match *self { @@ -966,7 +966,8 @@ impl> FromIterator> for Result { /// If an `Err` is encountered, it is immediately returned. /// Otherwise, the folded value is returned. #[inline] -#[unstable(feature = "core")] +#[unstable(feature = "result_fold", + reason = "unclear if this function should exist")] pub fn fold SliceExt for [T] { type Item = T; @@ -256,7 +257,6 @@ impl SliceExt for [T] { self.repr().data } - #[unstable(feature = "core")] fn binary_search_by(&self, mut f: F) -> Result where F: FnMut(&T) -> Ordering { @@ -437,12 +437,10 @@ impl SliceExt for [T] { m >= n && needle == &self[m-n..] } - #[unstable(feature = "core")] fn binary_search(&self, x: &T) -> Result where T: Ord { self.binary_search_by(|p| p.cmp(x)) } - #[unstable(feature = "core")] fn next_permutation(&mut self) -> bool where T: Ord { // These cases only have 1 permutation each, so we can't do anything. if self.len() < 2 { return false; } @@ -473,7 +471,6 @@ impl SliceExt for [T] { true } - #[unstable(feature = "core")] fn prev_permutation(&mut self) -> bool where T: Ord { // These cases only have 1 permutation each, so we can't do anything. if self.len() < 2 { return false; } @@ -774,7 +771,7 @@ impl<'a, T> Iter<'a, T> { /// /// This has the same lifetime as the original slice, and so the /// iterator can continue to be used while this exists. - #[unstable(feature = "core")] + #[unstable(feature = "iter_to_slice")] pub fn as_slice(&self) -> &'a [T] { make_slice!(self.ptr, self.end) } @@ -804,7 +801,7 @@ impl<'a, T> Clone for Iter<'a, T> { fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } } } -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl<'a, T> RandomAccessIterator for Iter<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -842,7 +839,7 @@ impl<'a, T> IterMut<'a, T> { /// to consume the iterator. Consider using the `Slice` and /// `SliceMut` implementations for obtaining slices with more /// restricted lifetimes that do not consume the iterator. - #[unstable(feature = "core")] + #[unstable(feature = "iter_to_slice")] pub fn into_slice(self) -> &'a mut [T] { make_mut_slice!(self.ptr, self.end) } @@ -1176,7 +1173,7 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> ExactSizeIterator for Windows<'a, T> {} -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl<'a, T> RandomAccessIterator for Windows<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1263,7 +1260,7 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> ExactSizeIterator for Chunks<'a, T> {} -#[unstable(feature = "core", reason = "trait is experimental")] +#[unstable(feature = "iter_idx", reason = "trait is experimental")] impl<'a, T> RandomAccessIterator for Chunks<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1349,7 +1346,7 @@ impl<'a, T> ExactSizeIterator for ChunksMut<'a, T> {} // /// Converts a pointer to A into a slice of length 1 (without copying). -#[unstable(feature = "core")] +#[unstable(feature = "ref_slice")] pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] { unsafe { from_raw_parts(s, 1) @@ -1357,7 +1354,7 @@ pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] { } /// Converts a pointer to A into a slice of length 1 (without copying). -#[unstable(feature = "core")] +#[unstable(feature = "ref_slice")] pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] { unsafe { from_raw_parts_mut(s, 1) @@ -1415,7 +1412,7 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] { // /// Operations on `[u8]`. -#[unstable(feature = "core", reason = "needs review")] +#[unstable(feature = "slice_bytes", reason = "needs review")] pub mod bytes { use ptr; use slice::SliceExt; @@ -1503,7 +1500,7 @@ impl PartialOrd for [T] { } /// Extension methods for slices containing integers. -#[unstable(feature = "core")] +#[unstable(feature = "int_slice")] pub trait IntSliceExt { /// Converts the slice to an immutable slice of unsigned integers with the same width. fn as_unsigned<'a>(&'a self) -> &'a [U]; @@ -1518,7 +1515,7 @@ pub trait IntSliceExt { macro_rules! impl_int_slice { ($u:ty, $s:ty, $t:ty) => { - #[unstable(feature = "core")] + #[unstable(feature = "int_slice")] impl IntSliceExt<$u, $s> for [$t] { #[inline] fn as_unsigned(&self) -> &[$u] { unsafe { transmute(self) } } diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index ef8b371f06179..13c6ad367257d 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -13,6 +13,7 @@ //! For more details, see std::str #![doc(primitive = "str")] +#![stable(feature = "rust1", since = "1.0.0")] use self::OldSearcher::{TwoWay, TwoWayLong}; use self::pattern::Pattern; @@ -191,7 +192,7 @@ fn unwrap_or_0(opt: Option<&u8>) -> u8 { /// Reads the next code point out of a byte iterator (assuming a /// UTF-8-like encoding). -#[unstable(feature = "core")] +#[unstable(feature = "str_internals")] #[inline] pub fn next_code_point(bytes: &mut slice::Iter) -> Option { // Decode UTF-8 @@ -226,7 +227,7 @@ pub fn next_code_point(bytes: &mut slice::Iter) -> Option { /// Reads the last code point out of a byte iterator (assuming a /// UTF-8-like encoding). -#[unstable(feature = "core")] +#[unstable(feature = "str_internals")] #[inline] pub fn next_code_point_reverse(bytes: &mut slice::Iter) -> Option { // Decode UTF-8 @@ -738,7 +739,7 @@ generate_pattern_iterators! { #[doc="Created with the method `.rmatch_indices()`."] struct RMatchIndices; stability: - #[unstable(feature = "core", + #[unstable(feature = "str_internals", reason = "type may be removed or have its iterator impl changed")] internal: MatchIndicesInternal yielding ((usize, usize)); @@ -779,7 +780,7 @@ generate_pattern_iterators! { #[doc="Created with the method `.rmatches()`."] struct RMatches; stability: - #[unstable(feature = "core", reason = "type got recently added")] + #[unstable(feature = "str_internals", reason = "type got recently added")] internal: MatchesInternal yielding (&'a str); delegate double ended; @@ -1470,6 +1471,8 @@ mod traits { /// Methods for string slices #[allow(missing_docs)] #[doc(hidden)] +#[unstable(feature = "core_str_ext", + reason = "stable interface provided by `impl str` in later crates")] pub trait StrExt { // NB there are no docs here are they're all located on the StrExt trait in // libcollections, not here. @@ -1870,7 +1873,7 @@ impl AsRef<[u8]> for str { /// Pluck a code point out of a UTF-8-like byte slice and return the /// index of the next code point. #[inline] -#[unstable(feature = "core")] +#[unstable(feature = "str_internals")] pub fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) { if bytes[i] < 128 { return (bytes[i] as u32, i + 1); diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 9a96612195cf8..8bdbab55211d8 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -13,6 +13,9 @@ //! For more details, see the traits `Pattern`, `Searcher`, //! `ReverseSearcher` and `DoubleEndedSearcher`. +#![unstable(feature = "pattern", + reason = "API not fully fleshed out and ready to be stabilized")] + use prelude::*; // Pattern diff --git a/src/libcore/ty.rs b/src/libcore/ty.rs deleted file mode 100644 index 35c1cb09281f4..0000000000000 --- a/src/libcore/ty.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2012-2013 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. - -//! Types dealing with unsafe actions. - -use marker; diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 15767024ba80f..0760ccb723b19 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -172,8 +172,7 @@ #![feature(alloc)] #![feature(staged_api)] #![feature(box_syntax)] -#![feature(core)] -#![feature(const_fn)] +#![feature(iter_cmp)] #![feature(std_misc)] use std::boxed; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 7ade4ef1c4628..6a6adb0db6b45 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -29,7 +29,11 @@ #![unstable(feature = "rand", reason = "use `rand` from crates.io")] #![feature(core)] +#![feature(core_float)] +#![feature(core_prelude)] +#![feature(core_slice_ext)] #![feature(no_std)] +#![feature(num_bits_bytes)] #![feature(staged_api)] #![feature(step_by)] diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 41ae0f2d5e203..18b1d39ea82d8 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -123,9 +123,9 @@ html_root_url = "http://doc.rust-lang.org/nightly/", html_playground_url = "http://play.rust-lang.org/")] -#![feature(core)] #![feature(rustc_private)] #![feature(staged_api)] +#![feature(slice_bytes)] #![cfg_attr(test, feature(test))] diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 8b46e2fe2e9c1..944af19a44313 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -30,21 +30,26 @@ #![feature(box_syntax)] #![feature(collections)] #![feature(const_fn)] -#![feature(core)] #![feature(duration)] #![feature(duration_span)] #![feature(fs_canonicalize)] -#![feature(hash)] +#![feature(hash_default)] #![feature(into_cow)] +#![feature(iter_sum)] #![feature(libc)] +#![feature(num_bits_bytes)] #![feature(path_ext)] #![feature(quote)] +#![feature(range_inclusive)] +#![feature(ref_slice)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] +#![feature(slice_bytes)] #![feature(slice_patterns)] #![feature(staged_api)] #![feature(std_misc)] #![feature(str_char)] +#![feature(wrapping)] #![cfg_attr(test, feature(test))] #![allow(trivial_casts)] diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index 7d46cc84fd685..e4d0c9aa15f7a 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -34,14 +34,14 @@ #![feature(box_syntax)] #![feature(collections)] -#![feature(core)] +#![feature(fs_canonicalize)] +#![feature(libc)] +#![feature(path_ext)] +#![feature(rand)] #![feature(rustc_private)] +#![feature(slice_bytes)] #![feature(staged_api)] -#![feature(rand)] -#![feature(path_ext)] #![feature(step_by)] -#![feature(libc)] -#![feature(fs_canonicalize)] #![cfg_attr(test, feature(test, rand))] extern crate syntax; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 1737de827e3ce..88d307610208f 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -32,9 +32,10 @@ #![feature(box_patterns)] #![feature(box_syntax)] -#![cfg_attr(stage0, feature(collections))] -#![feature(core)] +#![feature(collections)] +#![feature(num_bits_bytes)] #![feature(quote)] +#![feature(ref_slice)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 9f25c8d5fee14..6173e3c8205c1 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -29,17 +29,23 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(collections)] -#![feature(core)] #![feature(const_fn)] +#![feature(fs)] +#![feature(iter_cmp)] +#![feature(iter_sum)] +#![feature(iter_unfold)] #![feature(libc)] +#![feature(path_ext)] +#![feature(path_ext)] +#![feature(path_relative_from)] +#![feature(path_relative_from)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] -#![feature(unicode)] -#![feature(path_ext)] -#![feature(path_relative_from)] #![feature(std_misc)] +#![feature(unicode)] +#![feature(unicode)] #![allow(trivial_casts)] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 67101a69b5709..f5a7ec4dbd246 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -78,8 +78,10 @@ This API is completely unstable and subject to change. #![feature(box_patterns)] #![feature(box_syntax)] #![feature(collections, collections_drain)] -#![feature(core)] +#![feature(iter_cmp)] +#![feature(iter_sum)] #![feature(quote)] +#![feature(ref_slice)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/librustc_unicode/lib.rs b/src/librustc_unicode/lib.rs index a9456cb487c6a..750df19047d73 100644 --- a/src/librustc_unicode/lib.rs +++ b/src/librustc_unicode/lib.rs @@ -24,18 +24,24 @@ #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_unicode"] #![unstable(feature = "unicode")] -#![feature(lang_items)] -#![feature(staged_api)] #![staged_api] #![crate_type = "rlib"] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/", - html_playground_url = "http://play.rust-lang.org/")] -#![feature(no_std)] + html_playground_url = "http://play.rust-lang.org/", + test(no_crate_inject))] #![no_std] + #![feature(core)] -#![doc(test(no_crate_inject))] +#![feature(core_char_ext)] +#![feature(core_prelude)] +#![feature(core_slice_ext)] +#![feature(core_str_ext)] +#![feature(iter_sum)] +#![feature(lang_items)] +#![feature(no_std)] +#![feature(staged_api)] extern crate core; diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 31790ce6290fe..8170dd957307b 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -29,12 +29,13 @@ Core encoding and decoding interfaces. #![feature(box_syntax)] #![feature(collections)] -#![feature(core)] +#![feature(num_bits_bytes)] +#![feature(num_wrapping)] #![feature(rustc_private)] #![feature(staged_api)] #![feature(std_misc)] -#![feature(unicode)] #![feature(str_char)] +#![feature(unicode)] #![cfg_attr(test, feature(test))] // test harness access diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 328c75b6d9e20..1677f95ca9039 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -77,7 +77,7 @@ pub trait Error: Debug + Display + Reflect { /// Get the `TypeId` of `self` #[doc(hidden)] - #[unstable(feature = "core", + #[unstable(feature = "error_type_id", reason = "unclear whether to commit to this public implementation detail")] fn type_id(&self) -> TypeId where Self: 'static { TypeId::of::() diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8305088057c41..8f7ed6388f575 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -99,38 +99,52 @@ #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/", - html_playground_url = "http://play.rust-lang.org/")] -#![doc(test(no_crate_inject, attr(deny(warnings))))] -#![doc(test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] + html_playground_url = "http://play.rust-lang.org/", + test(no_crate_inject, attr(deny(warnings))), + test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] #![feature(alloc)] #![feature(allow_internal_unstable)] #![feature(associated_consts)] +#![feature(borrow_state)] #![feature(box_syntax)] +#![feature(char_internals)] #![feature(collections)] -#![feature(core)] #![feature(const_fn)] +#![feature(core)] +#![feature(core_float)] +#![feature(core_intrinsics)] +#![feature(core_prelude)] +#![feature(core_simd)] +#![feature(fnbox)] +#![feature(int_error_internals)] #![feature(into_cow)] +#![feature(iter_order)] #![feature(lang_items)] #![feature(libc)] #![feature(linkage, thread_local, asm)] #![feature(macro_reexport)] +#![feature(no_std)] +#![feature(num_bits_bytes)] #![feature(optin_builtin_traits)] #![feature(rand)] +#![feature(raw)] +#![feature(reflect_marker)] +#![feature(slice_bytes)] #![feature(slice_patterns)] #![feature(staged_api)] -#![feature(std_misc)] #![feature(str_char)] +#![feature(str_internals)] #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] +#![feature(wrapping)] #![feature(zero_one)] #![cfg_attr(test, feature(float_from_str_radix))] #![cfg_attr(test, feature(test, rustc_private, std_misc))] // Don't link to std. We are std. -#![feature(no_std)] #![no_std] #![allow(trivial_casts)] diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 11c4b0f12610a..432cdbdfef05e 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -28,8 +28,9 @@ #![feature(associated_consts)] #![feature(collections)] #![feature(collections_drain)] -#![feature(core)] +#![feature(filling_drop)] #![feature(libc)] +#![feature(ref_slice)] #![feature(rustc_private)] #![feature(staged_api)] #![feature(str_char)] From c44f5399e4dd2f9d55e107d365d6fe98f6491dc9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 9 Jun 2015 11:52:41 -0700 Subject: [PATCH 02/48] alloc: Split apart the global `alloc` feature --- src/liballoc/arc.rs | 16 ++++++++-------- src/liballoc/boxed.rs | 6 +++--- src/liballoc/heap.rs | 7 ++++++- src/liballoc/lib.rs | 10 +++++++--- src/liballoc/rc.rs | 20 ++++++++++---------- src/libarena/lib.rs | 3 ++- src/libcollections/lib.rs | 3 +++ src/liblog/lib.rs | 5 +++-- src/librustc_resolve/lib.rs | 2 +- src/librustc_trans/lib.rs | 2 +- src/libstd/lib.rs | 3 +++ src/libtest/lib.rs | 11 ++++++----- 12 files changed, 53 insertions(+), 35 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 616071f0df709..e0d459d877fd2 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -134,7 +134,7 @@ impl, U: ?Sized> CoerceUnsized> for Arc {} /// Weak pointers will not keep the data inside of the `Arc` alive, and can be /// used to break cycles between `Arc` pointers. #[unsafe_no_drop_flag] -#[unstable(feature = "alloc", +#[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] pub struct Weak { // FIXME #12808: strange name to try to avoid interfering with @@ -198,7 +198,7 @@ impl Arc { /// /// let weak_five = five.downgrade(); /// ``` - #[unstable(feature = "alloc", + #[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] pub fn downgrade(&self) -> Weak { // See the clone() impl for why this is relaxed @@ -236,12 +236,12 @@ impl Arc { /// Get the number of weak references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "arc_extras")] pub fn weak_count(this: &Arc) -> usize { this.inner().weak.load(SeqCst) - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "arc_extras")] pub fn strong_count(this: &Arc) -> usize { this.inner().strong.load(SeqCst) } @@ -271,7 +271,7 @@ pub fn strong_count(this: &Arc) -> usize { this.inner().strong.loa /// # } /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "arc_extras")] pub unsafe fn get_mut(this: &mut Arc) -> Option<&mut T> { // FIXME(#24880) potential race with upgraded weak pointers here if strong_count(this) == 1 && weak_count(this) == 0 { @@ -352,7 +352,7 @@ impl Arc { /// # } /// ``` #[inline] - #[unstable(feature = "alloc")] + #[unstable(feature = "arc_extras")] pub unsafe fn make_unique(&mut self) -> &mut T { // FIXME(#24880) potential race with upgraded weak pointers here // @@ -438,7 +438,7 @@ impl Drop for Arc { } } -#[unstable(feature = "alloc", +#[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] impl Weak { /// Upgrades a weak reference to a strong reference. @@ -479,7 +479,7 @@ impl Weak { } } -#[unstable(feature = "alloc", +#[unstable(feature = "arc_weak", reason = "Weak pointers may not belong in this module.")] impl Clone for Weak { /// Makes a clone of the `Weak`. diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 91cbd3915d006..ffc4186dee8d9 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -81,7 +81,7 @@ use core::raw::{TraitObject}; /// } /// ``` #[lang = "exchange_heap"] -#[unstable(feature = "alloc", +#[unstable(feature = "box_heap", reason = "may be renamed; uncertain about custom allocator design")] pub const HEAP: () = (); @@ -121,7 +121,7 @@ impl Box { /// Function is unsafe, because improper use of this function may /// lead to memory problems like double-free, for example if the /// function is called twice on the same raw pointer. - #[unstable(feature = "alloc", + #[unstable(feature = "box_raw", reason = "may be renamed or moved out of Box scope")] #[inline] pub unsafe fn from_raw(raw: *mut T) -> Self { @@ -146,7 +146,7 @@ impl Box { /// let raw = boxed::into_raw(seventeen); /// let boxed_again = unsafe { Box::from_raw(raw) }; /// ``` -#[unstable(feature = "alloc", +#[unstable(feature = "box_raw", reason = "may be renamed")] #[inline] pub fn into_raw(b: Box) -> *mut T { diff --git a/src/liballoc/heap.rs b/src/liballoc/heap.rs index 1cc63588fddff..14797d7f4b54d 100644 --- a/src/liballoc/heap.rs +++ b/src/liballoc/heap.rs @@ -8,6 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![unstable(feature = "heap_api", + reason = "the precise API and guarantees it provides may be tweaked \ + slightly, especially to possibly take into account the \ + types being stored to make room for a future \ + tracing garbage collector")] + use core::{isize, usize}; #[inline(always)] @@ -94,7 +100,6 @@ pub fn usable_size(size: usize, align: usize) -> usize { /// /// These statistics may be inconsistent if other threads use the allocator /// during the call. -#[unstable(feature = "alloc")] pub fn stats_print() { imp::stats_print(); } diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 91585c3cb6cf7..e297d4cbf7762 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -59,9 +59,11 @@ // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "alloc"] -#![unstable(feature = "alloc")] -#![staged_api] #![crate_type = "rlib"] +#![staged_api] +#![unstable(feature = "alloc", + reason = "this library is unlikely to be stabilized in its current \ + form or name")] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/", @@ -86,11 +88,11 @@ #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] #![feature(unsize)] + #![cfg_attr(test, feature(test, alloc, rustc_private))] #![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")), feature(libc))] - #[macro_use] extern crate core; @@ -124,6 +126,7 @@ pub mod rc; /// Common out-of-memory routine #[cold] #[inline(never)] +#[unstable(feature = "oom", reason = "not a scrutinized interface")] pub fn oom() -> ! { // FIXME(#14674): This really needs to do something other than just abort // here, but any printing done must be *guaranteed* to not @@ -144,4 +147,5 @@ pub fn oom() -> ! { // to get linked in to libstd successfully (the linker won't // optimize it out). #[doc(hidden)] +#[unstable(feature = "issue_14344_fixme")] pub fn fixme_14344_be_sure_to_link_to_collections() {} diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 44f4a6a6290c8..04dde7a07f920 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -236,7 +236,7 @@ impl Rc { /// /// let weak_five = five.downgrade(); /// ``` - #[unstable(feature = "alloc", + #[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module")] pub fn downgrade(&self) -> Weak { self.inc_weak(); @@ -246,12 +246,12 @@ impl Rc { /// Get the number of weak references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn weak_count(this: &Rc) -> usize { this.weak() - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn strong_count(this: &Rc) -> usize { this.strong() } /// Returns true if there are no other `Rc` or `Weak` values that share the @@ -269,7 +269,7 @@ pub fn strong_count(this: &Rc) -> usize { this.strong() } /// rc::is_unique(&five); /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn is_unique(rc: &Rc) -> bool { weak_count(rc) == 0 && strong_count(rc) == 1 } @@ -292,7 +292,7 @@ pub fn is_unique(rc: &Rc) -> bool { /// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn try_unwrap(rc: Rc) -> Result> { if is_unique(&rc) { unsafe { @@ -327,7 +327,7 @@ pub fn try_unwrap(rc: Rc) -> Result> { /// assert!(rc::get_mut(&mut x).is_none()); /// ``` #[inline] -#[unstable(feature = "alloc")] +#[unstable(feature = "rc_extras")] pub fn get_mut(rc: &mut Rc) -> Option<&mut T> { if is_unique(rc) { let inner = unsafe { &mut **rc._ptr }; @@ -354,7 +354,7 @@ impl Rc { /// let mut_five = five.make_unique(); /// ``` #[inline] - #[unstable(feature = "alloc")] + #[unstable(feature = "rc_extras")] pub fn make_unique(&mut self) -> &mut T { if !is_unique(self) { *self = Rc::new((**self).clone()) @@ -652,7 +652,7 @@ impl fmt::Pointer for Rc { /// /// See the [module level documentation](./index.html) for more. #[unsafe_no_drop_flag] -#[unstable(feature = "alloc", +#[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module.")] pub struct Weak { // FIXME #12808: strange names to try to avoid interfering with @@ -663,7 +663,7 @@ pub struct Weak { impl !marker::Send for Weak {} impl !marker::Sync for Weak {} -#[unstable(feature = "alloc", +#[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module.")] impl Weak { @@ -741,7 +741,7 @@ impl Drop for Weak { } } -#[unstable(feature = "alloc", +#[unstable(feature = "rc_weak", reason = "Weak pointers may not belong in this module.")] impl Clone for Weak { diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 73641647bf426..109ad8a942c84 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -33,10 +33,11 @@ #![feature(alloc)] #![feature(box_syntax)] #![feature(core_intrinsics)] +#![feature(heap_api)] +#![feature(oom)] #![feature(ptr_as_ref)] #![feature(raw)] #![feature(staged_api)] -#![feature(unboxed_closures)] #![cfg_attr(test, feature(test))] extern crate alloc; diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 0c1349bc2e6c8..ecf5bace3825a 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -29,6 +29,7 @@ #![feature(alloc)] #![feature(box_patterns)] +#![feature(box_raw)] #![feature(box_syntax)] #![feature(copy_lifetime)] #![feature(core)] @@ -36,6 +37,7 @@ #![feature(core_prelude)] #![feature(core_slice_ext)] #![feature(core_str_ext)] +#![feature(heap_api)] #![feature(iter_cmp)] #![feature(iter_idx)] #![feature(iter_order)] @@ -43,6 +45,7 @@ #![feature(iter_sum)] #![feature(lang_items)] #![feature(num_bits_bytes)] +#![feature(oom)] #![feature(pattern)] #![feature(ptr_as_ref)] #![feature(raw)] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 0760ccb723b19..0238bf1f4be18 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -169,10 +169,11 @@ html_playground_url = "http://play.rust-lang.org/")] #![deny(missing_docs)] -#![feature(alloc)] -#![feature(staged_api)] +#![feature(box_raw)] #![feature(box_syntax)] +#![feature(const_fn)] #![feature(iter_cmp)] +#![feature(staged_api)] #![feature(std_misc)] use std::boxed; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index c47922dd95471..0c0fd3f93dcdd 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -19,9 +19,9 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(alloc)] #![feature(associated_consts)] #![feature(collections)] +#![feature(rc_weak)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 6173e3c8205c1..d0fadd6565c3b 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -25,7 +25,6 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(alloc)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(collections)] @@ -40,6 +39,7 @@ #![feature(path_relative_from)] #![feature(path_relative_from)] #![feature(quote)] +#![feature(rc_weak)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8f7ed6388f575..7504488122396 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -107,6 +107,7 @@ #![feature(allow_internal_unstable)] #![feature(associated_consts)] #![feature(borrow_state)] +#![feature(box_raw)] #![feature(box_syntax)] #![feature(char_internals)] #![feature(collections)] @@ -117,6 +118,7 @@ #![feature(core_prelude)] #![feature(core_simd)] #![feature(fnbox)] +#![feature(heap_api)] #![feature(int_error_internals)] #![feature(into_cow)] #![feature(iter_order)] @@ -126,6 +128,7 @@ #![feature(macro_reexport)] #![feature(no_std)] #![feature(num_bits_bytes)] +#![feature(oom)] #![feature(optin_builtin_traits)] #![feature(rand)] #![feature(raw)] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 9850e0a6c2fc9..6ee6f8c2e24bd 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -37,14 +37,15 @@ #![feature(asm)] #![feature(box_syntax)] #![feature(collections)] -#![feature(core)] +#![feature(duration)] +#![feature(duration_span)] +#![feature(fnbox)] +#![feature(iter_cmp)] +#![feature(libc)] #![feature(rustc_private)] +#![feature(set_stdio)] #![feature(staged_api)] #![feature(std_misc)] -#![feature(libc)] -#![feature(set_stdio)] -#![feature(duration)] -#![feature(duration_span)] extern crate getopts; extern crate serialize; From d444d0c357e85c90e73585520e2da74304c7265a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 9 Jun 2015 14:39:23 -0700 Subject: [PATCH 03/48] collections: Split the `collections` feature This commit also deprecates the `as_string` and `as_slice` free functions in the `string` and `vec` modules. --- src/libcollections/binary_heap.rs | 16 ++++++----- src/libcollections/bit.rs | 40 +++++++++++++------------- src/libcollections/btree/map.rs | 4 +-- src/libcollections/btree/set.rs | 4 +-- src/libcollections/enum_set.rs | 37 +++++++----------------- src/libcollections/lib.rs | 15 ++++++---- src/libcollections/linked_list.rs | 4 +-- src/libcollections/range.rs | 1 + src/libcollections/slice.rs | 48 +++++++++++++++++-------------- src/libcollections/str.rs | 20 ++++++------- src/libcollections/string.rs | 19 ++++++++---- src/libcollections/vec.rs | 33 ++++++++++++++------- src/libcollections/vec_deque.rs | 20 ++++++------- src/libcollections/vec_map.rs | 20 +++++++------ src/libgraphviz/lib.rs | 3 +- src/librustc/lib.rs | 8 ++++++ src/librustc_back/lib.rs | 2 +- src/librustc_driver/lib.rs | 7 +++-- src/librustc_lint/lib.rs | 4 +-- src/librustc_llvm/lib.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_trans/lib.rs | 2 +- src/librustc_typeck/lib.rs | 4 ++- src/librustc_unicode/char.rs | 12 ++++++-- src/libserialize/lib.rs | 2 ++ src/libstd/lib.rs | 5 ++++ src/libsyntax/lib.rs | 6 ++-- src/libterm/lib.rs | 4 +-- src/libtest/lib.rs | 2 +- src/rustbook/main.rs | 6 ++-- 30 files changed, 197 insertions(+), 155 deletions(-) diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index 451b1fd61cbdf..f6204173ed7a5 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -10,10 +10,11 @@ //! A priority queue implemented with a binary heap. //! -//! Insertion and popping the largest element have `O(log n)` time complexity. Checking the largest -//! element is `O(1)`. Converting a vector to a binary heap can be done in-place, and has `O(n)` -//! complexity. A binary heap can also be converted to a sorted vector in-place, allowing it to -//! be used for an `O(n log n)` in-place heapsort. +//! Insertion and popping the largest element have `O(log n)` time complexity. +//! Checking the largest element is `O(1)`. Converting a vector to a binary heap +//! can be done in-place, and has `O(n)` complexity. A binary heap can also be +//! converted to a sorted vector in-place, allowing it to be used for an `O(n +//! log n)` in-place heapsort. //! //! # Examples //! @@ -539,8 +540,9 @@ impl BinaryHeap { /// /// The elements are removed in arbitrary order. #[inline] - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] + #[unstable(feature = "drain", + reason = "matches collection reform specification, \ + waiting for dust to settle")] pub fn drain(&mut self) -> Drain { Drain { iter: self.data.drain(..) } } @@ -678,7 +680,7 @@ impl DoubleEndedIterator for IntoIter { impl ExactSizeIterator for IntoIter {} /// An iterator that drains a `BinaryHeap`. -#[unstable(feature = "collections", reason = "recent addition")] +#[unstable(feature = "drain", reason = "recent addition")] pub struct Drain<'a, T: 'a> { iter: vec::Drain<'a, T>, } diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 562bbe262068f..5709ed7a29499 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -156,8 +156,7 @@ const FALSE: &'static bool = &false; /// println!("{:?}", bv); /// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count()); /// ``` -#[unstable(feature = "collections", - reason = "RFC 509")] +#[unstable(feature = "bitvec", reason = "RFC 509")] pub struct BitVec { /// Internal representation of the bit vector storage: Vec, @@ -181,14 +180,16 @@ impl Index for BitVec { /// Computes how many blocks are needed to store that many bits fn blocks_for_bits(bits: usize) -> usize { - // If we want 17 bits, dividing by 32 will produce 0. So we add 1 to make sure we - // reserve enough. But if we want exactly a multiple of 32, this will actually allocate - // one too many. So we need to check if that's the case. We can do that by computing if - // bitwise AND by `32 - 1` is 0. But LLVM should be able to optimize the semantically - // superior modulo operator on a power of two to this. + // If we want 17 bits, dividing by 32 will produce 0. So we add 1 to make + // sure we reserve enough. But if we want exactly a multiple of 32, this + // will actually allocate one too many. So we need to check if that's the + // case. We can do that by computing if bitwise AND by `32 - 1` is 0. But + // LLVM should be able to optimize the semantically superior modulo operator + // on a power of two to this. // // Note that we can technically avoid this branch with the expression - // `(nbits + u32::BITS - 1) / 32::BITS`, but if nbits is almost usize::MAX this will overflow. + // `(nbits + u32::BITS - 1) / 32::BITS`, but if nbits is almost usize::MAX + // this will overflow. if bits % u32::BITS == 0 { bits / u32::BITS } else { @@ -202,6 +203,7 @@ fn mask_for_bits(bits: usize) -> u32 { !0 >> (u32::BITS - bits % u32::BITS) % u32::BITS } +#[unstable(feature = "bitvec", reason = "RFC 509")] impl BitVec { /// Applies the given operation to the blocks of self and other, and sets /// self to be the result. This relies on the caller not to corrupt the @@ -407,8 +409,6 @@ impl BitVec { /// assert_eq!(bv[3], true); /// ``` #[inline] - #[unstable(feature = "collections", - reason = "panic semantics are likely to change in the future")] pub fn set(&mut self, i: usize, x: bool) { assert!(i < self.nbits); let w = i / u32::BITS; @@ -608,7 +608,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections, bit_vec_append_split_off)] + /// # #![feature(bitvec, append)] /// use std::collections::BitVec; /// /// let mut a = BitVec::from_bytes(&[0b10000000]); @@ -621,7 +621,7 @@ impl BitVec { /// assert!(a.eq_vec(&[true, false, false, false, false, false, false, false, /// false, true, true, false, false, false, false, true])); /// ``` - #[unstable(feature = "bit_vec_append_split_off", + #[unstable(feature = "append", reason = "recently added as part of collections reform 2")] pub fn append(&mut self, other: &mut Self) { let b = self.len() % u32::BITS; @@ -651,7 +651,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections, bit_vec_append_split_off)] + /// # #![feature(bitvec, split_off)] /// use std::collections::BitVec; /// let mut a = BitVec::new(); /// a.push(true); @@ -666,7 +666,7 @@ impl BitVec { /// assert!(a.eq_vec(&[true, false])); /// assert!(b.eq_vec(&[false, true])); /// ``` - #[unstable(feature = "bit_vec_append_split_off", + #[unstable(feature = "split_off", reason = "recently added as part of collections reform 2")] pub fn split_off(&mut self, at: usize) -> Self { assert!(at <= self.len(), "`at` out of bounds"); @@ -1254,8 +1254,7 @@ impl<'a> IntoIterator for &'a BitVec { /// assert!(bv[3]); /// ``` #[derive(Clone)] -#[unstable(feature = "collections", - reason = "RFC 509")] +#[unstable(feature = "bitset", reason = "RFC 509")] pub struct BitSet { bit_vec: BitVec, } @@ -1322,6 +1321,7 @@ impl cmp::PartialEq for BitSet { #[stable(feature = "rust1", since = "1.0.0")] impl cmp::Eq for BitSet {} +#[unstable(feature = "bitset", reason = "RFC 509")] impl BitSet { /// Creates a new empty `BitSet`. /// @@ -1808,7 +1808,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections, bit_set_append_split_off)] + /// # #![feature(collections, append)] /// use std::collections::{BitVec, BitSet}; /// /// let mut a = BitSet::new(); @@ -1826,7 +1826,7 @@ impl BitSet { /// assert_eq!(b.len(), 0); /// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01110010]))); /// ``` - #[unstable(feature = "bit_set_append_split_off", + #[unstable(feature = "append", reason = "recently added as part of collections reform 2")] pub fn append(&mut self, other: &mut Self) { self.union_with(other); @@ -1839,7 +1839,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections, bit_set_append_split_off)] + /// # #![feature(bitset, split_off)] /// use std::collections::{BitSet, BitVec}; /// let mut a = BitSet::new(); /// a.insert(2); @@ -1854,7 +1854,7 @@ impl BitSet { /// assert_eq!(a, BitSet::from_bit_vec(BitVec::from_bytes(&[0b01100000]))); /// assert_eq!(b, BitSet::from_bit_vec(BitVec::from_bytes(&[0b00010010]))); /// ``` - #[unstable(feature = "bit_set_append_split_off", + #[unstable(feature = "split_off", reason = "recently added as part of collections reform 2")] pub fn split_off(&mut self, at: usize) -> Self { let mut other = BitSet::new(); diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 314036ef59d80..127f470c9aaae 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -1520,7 +1520,7 @@ impl BTreeMap { /// } /// assert_eq!(Some((&5, &"b")), map.range(Included(&4), Unbounded).next()); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "btree_range", reason = "matches collection reform specification, waiting for dust to settle")] pub fn range<'a>(&'a self, min: Bound<&K>, max: Bound<&K>) -> Range<'a, K, V> { range_impl!(&self.root, min, max, as_slices_internal, iter, Range, edges, []) @@ -1548,7 +1548,7 @@ impl BTreeMap { /// println!("{} => {}", name, balance); /// } /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "btree_range", reason = "matches collection reform specification, waiting for dust to settle")] pub fn range_mut<'a>(&'a mut self, min: Bound<&K>, max: Bound<&K>) -> RangeMut<'a, K, V> { range_impl!(&mut self.root, min, max, as_slices_internal_mut, iter_mut, RangeMut, diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index ec6c5e63e2daf..5914e2f296a33 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -102,7 +102,7 @@ impl BTreeSet { /// Makes a new BTreeSet with the given B. /// /// B cannot be less than 2. - #[unstable(feature = "collections", + #[unstable(feature = "btree_b", reason = "probably want this to be on the type, eventually")] pub fn with_b(b: usize) -> BTreeSet { BTreeSet { map: BTreeMap::with_b(b) } @@ -154,7 +154,7 @@ impl BTreeSet { /// } /// assert_eq!(Some(&5), set.range(Included(&4), Unbounded).next()); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "btree_range", reason = "matches collection reform specification, waiting for dust to settle")] pub fn range<'a>(&'a self, min: Bound<&T>, max: Bound<&T>) -> Range<'a, T> { fn first((a, _): (A, B)) -> A { a } diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs index ad90f9f1caa9c..e90e6c065a2c2 100644 --- a/src/libcollections/enum_set.rs +++ b/src/libcollections/enum_set.rs @@ -13,21 +13,26 @@ //! This module defines a container which uses an efficient bit mask //! representation to hold C-like enum variants. +#![unstable(feature = "enumset", + reason = "matches collection reform specification, \ + waiting for dust to settle")] + use core::prelude::*; use core::marker; use core::fmt; use core::iter::{FromIterator}; use core::ops::{Sub, BitOr, BitAnd, BitXor}; -// FIXME(contentions): implement union family of methods? (general design may be wrong here) +// FIXME(contentions): implement union family of methods? (general design may be +// wrong here) -#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] /// A specialized set implementation to use enum types. /// -/// It is a logic error for an item to be modified in such a way that the transformation of the -/// item to or from a `usize`, as determined by the `CLike` trait, changes while the item is in the -/// set. This is normally only possible through `Cell`, `RefCell`, global state, I/O, or unsafe -/// code. +/// It is a logic error for an item to be modified in such a way that the +/// transformation of the item to or from a `usize`, as determined by the +/// `CLike` trait, changes while the item is in the set. This is normally only +/// possible through `Cell`, `RefCell`, global state, I/O, or unsafe code. +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct EnumSet { // We must maintain the invariant that no bits are set // for which no variant exists @@ -93,22 +98,16 @@ fn bit(e: &E) -> usize { impl EnumSet { /// Returns an empty `EnumSet`. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn new() -> EnumSet { EnumSet {bits: 0, marker: marker::PhantomData} } /// Returns the number of elements in the given `EnumSet`. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn len(&self) -> usize { self.bits.count_ones() as usize } /// Returns true if the `EnumSet` is empty. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn is_empty(&self) -> bool { self.bits == 0 } @@ -118,22 +117,16 @@ impl EnumSet { } /// Returns `false` if the `EnumSet` contains any enum of the given `EnumSet`. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn is_disjoint(&self, other: &EnumSet) -> bool { (self.bits & other.bits) == 0 } /// Returns `true` if a given `EnumSet` is included in this `EnumSet`. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn is_superset(&self, other: &EnumSet) -> bool { (self.bits & other.bits) == other.bits } /// Returns `true` if this `EnumSet` is included in the given `EnumSet`. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn is_subset(&self, other: &EnumSet) -> bool { other.is_superset(self) } @@ -151,8 +144,6 @@ impl EnumSet { } /// Adds an enum to the `EnumSet`, and returns `true` if it wasn't there before - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn insert(&mut self, e: E) -> bool { let result = !self.contains(&e); self.bits |= bit(&e); @@ -160,8 +151,6 @@ impl EnumSet { } /// Removes an enum from the EnumSet - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn remove(&mut self, e: &E) -> bool { let result = self.contains(e); self.bits &= !bit(e); @@ -169,15 +158,11 @@ impl EnumSet { } /// Returns `true` if an `EnumSet` contains a given enum. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn contains(&self, e: &E) -> bool { (self.bits & bit(e)) != 0 } /// Returns an iterator over an `EnumSet`. - #[unstable(feature = "collections", - reason = "matches collection reform specification, waiting for dust to settle")] pub fn iter(&self) -> Iter { Iter::new(self.bits) } diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index ecf5bace3825a..9762381381c60 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -10,14 +10,17 @@ //! Collection types. //! -//! See [std::collections](../std/collections) for a detailed discussion of collections in Rust. +//! See [std::collections](../std/collections) for a detailed discussion of +//! collections in Rust. // Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "collections"] -#![unstable(feature = "collections")] #![staged_api] #![crate_type = "rlib"] +#![unstable(feature = "collections", + reason = "library is unlikely to be stabilized with the current \ + layout and name, use std::collections instead")] #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/", @@ -107,14 +110,12 @@ pub mod vec; pub mod vec_deque; pub mod vec_map; -#[unstable(feature = "collections", - reason = "RFC 509")] +#[unstable(feature = "bitvec", reason = "RFC 509")] pub mod bit_vec { pub use bit::{BitVec, Iter}; } -#[unstable(feature = "collections", - reason = "RFC 509")] +#[unstable(feature = "bitset", reason = "RFC 509")] pub mod bit_set { pub use bit::{BitSet, Union, Intersection, Difference, SymmetricDifference}; pub use bit::SetIter as Iter; @@ -133,6 +134,7 @@ pub mod btree_set { // FIXME(#14344) this shouldn't be necessary #[doc(hidden)] +#[unstable(feature = "issue_14344_fixme")] pub fn fixme_14344_be_sure_to_link_to_collections() {} #[cfg(not(test))] @@ -141,6 +143,7 @@ mod std { } /// An endpoint of a range of keys. +#[unstable(feature = "collections_bound")] #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] pub enum Bound { /// An inclusive bound. diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index 8ff49efe9d7d2..a732ce9e81df7 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -801,7 +801,7 @@ impl<'a, A> IterMut<'a, A> { /// } /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "linked_list_extras", reason = "this is probably better handled by a cursor type -- we'll see")] pub fn insert_next(&mut self, elt: A) { self.insert_next_node(box Node::new(elt)) @@ -824,7 +824,7 @@ impl<'a, A> IterMut<'a, A> { /// assert_eq!(it.next().unwrap(), &2); /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "linked_list_extras", reason = "this is probably better handled by a cursor type -- we'll see")] pub fn peek_next(&mut self) -> Option<&mut A> { if self.nelem == 0 { diff --git a/src/libcollections/range.rs b/src/libcollections/range.rs index 6ab143998d299..f37c4aede6a1a 100644 --- a/src/libcollections/range.rs +++ b/src/libcollections/range.rs @@ -7,6 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. + #![unstable(feature = "collections_range", reason = "was just added")] //! Range syntax. diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 310652727b77e..c5418c9a0db8e 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -11,7 +11,8 @@ //! Utilities for slice manipulation //! //! The `slice` module contains useful code to help work with slice values. -//! Slices are a view into a block of memory represented as a pointer and a length. +//! Slices are a view into a block of memory represented as a pointer and a +//! length. //! //! ``` //! // slicing a Vec @@ -69,8 +70,9 @@ //! } //! ``` //! -//! This iterator yields mutable references to the slice's elements, so while the element -//! type of the slice is `i32`, the element type of the iterator is `&mut i32`. +//! This iterator yields mutable references to the slice's elements, so while +//! the element type of the slice is `i32`, the element type of the iterator is +//! `&mut i32`. //! //! * `.iter()` and `.iter_mut()` are the explicit methods to return the default //! iterators. @@ -278,14 +280,14 @@ impl [T] { } /// Returns all but the first element of a slice. - #[unstable(feature = "collections", reason = "likely to be renamed")] + #[unstable(feature = "slice_extras", reason = "likely to be renamed")] #[inline] pub fn tail(&self) -> &[T] { core_slice::SliceExt::tail(self) } /// Returns all but the first element of a mutable slice - #[unstable(feature = "collections", + #[unstable(feature = "slice_extras", reason = "likely to be renamed or removed")] #[inline] pub fn tail_mut(&mut self) -> &mut [T] { @@ -293,14 +295,14 @@ impl [T] { } /// Returns all but the last element of a slice. - #[unstable(feature = "collections", reason = "likely to be renamed")] + #[unstable(feature = "slice_extras", reason = "likely to be renamed")] #[inline] pub fn init(&self) -> &[T] { core_slice::SliceExt::init(self) } /// Returns all but the last element of a mutable slice - #[unstable(feature = "collections", + #[unstable(feature = "slice_extras", reason = "likely to be renamed or removed")] #[inline] pub fn init_mut(&mut self) -> &mut [T] { @@ -727,13 +729,13 @@ impl [T] { } /// Find the first index containing a matching value. - #[unstable(feature = "collections")] + #[unstable(feature = "slice_position_elem")] pub fn position_elem(&self, t: &T) -> Option where T: PartialEq { core_slice::SliceExt::position_elem(self, t) } /// Find the last index containing a matching value. - #[unstable(feature = "collections")] + #[unstable(feature = "slice_position_elem")] pub fn rposition_elem(&self, t: &T) -> Option where T: PartialEq { core_slice::SliceExt::rposition_elem(self, t) } @@ -869,7 +871,7 @@ impl [T] { /// assert_eq!(Some(vec![1, 3, 2]), perms.next()); /// assert_eq!(Some(vec![3, 1, 2]), perms.next()); /// ``` - #[unstable(feature = "collections")] + #[unstable(feature = "permutations")] #[inline] pub fn permutations(&self) -> Permutations where T: Clone { // NB see hack module in this file @@ -893,7 +895,7 @@ impl [T] { /// let b: &mut [_] = &mut [1, 0, 2]; /// assert!(v == b); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] pub fn next_permutation(&mut self) -> bool where T: Ord { core_slice::SliceExt::next_permutation(self) @@ -916,7 +918,7 @@ impl [T] { /// let b: &mut [_] = &mut [0, 1, 2]; /// assert!(v == b); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] pub fn prev_permutation(&mut self) -> bool where T: Ord { core_slice::SliceExt::prev_permutation(self) @@ -940,7 +942,7 @@ impl [T] { /// assert!(dst.clone_from_slice(&src2) == 3); /// assert!(dst == [3, 4, 5]); /// ``` - #[unstable(feature = "collections")] + #[unstable(feature = "clone_from_slice")] pub fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone { core_slice::SliceExt::clone_from_slice(self, src) } @@ -967,7 +969,7 @@ impl [T] { /// assert_eq!(num_moved, 3); /// assert!(a == [6, 7, 8, 4, 5]); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "move_from", reason = "uncertain about this API approach")] #[inline] pub fn move_from(&mut self, mut src: Vec, start: usize, end: usize) -> usize { @@ -997,10 +999,12 @@ impl [T] { //////////////////////////////////////////////////////////////////////////////// // Extension traits for slices over specific kinds of data //////////////////////////////////////////////////////////////////////////////// -#[unstable(feature = "collections", reason = "recently changed")] +#[unstable(feature = "slice_concat_ext", + reason = "trait should not have to exist")] /// An extension trait for concatenating slices pub trait SliceConcatExt { - #[unstable(feature = "collections", reason = "recently changed")] + #[unstable(feature = "slice_concat_ext", + reason = "trait should not have to exist")] /// The resulting type after concatenation type Output; @@ -1014,8 +1018,8 @@ pub trait SliceConcatExt { #[stable(feature = "rust1", since = "1.0.0")] fn concat(&self) -> Self::Output; - /// Flattens a slice of `T` into a single value `Self::Output`, placing a given separator - /// between each. + /// Flattens a slice of `T` into a single value `Self::Output`, placing a + /// given separator between each. /// /// # Examples /// @@ -1060,7 +1064,7 @@ impl> SliceConcatExt for [V] { /// /// The last generated swap is always (0, 1), and it returns the /// sequence to its initial order. -#[unstable(feature = "collections")] +#[unstable(feature = "permutations")] #[derive(Clone)] pub struct ElementSwaps { sdir: Vec, @@ -1072,7 +1076,7 @@ pub struct ElementSwaps { impl ElementSwaps { /// Creates an `ElementSwaps` iterator for a sequence of `length` elements. - #[unstable(feature = "collections")] + #[unstable(feature = "permutations")] pub fn new(length: usize) -> ElementSwaps { // Initialize `sdir` with a direction that position should move in // (all negative at the beginning) and the `size` of the @@ -1194,13 +1198,13 @@ impl Iterator for ElementSwaps { /// swap applied. /// /// Generates even and odd permutations alternately. -#[unstable(feature = "collections")] +#[unstable(feature = "permutations")] pub struct Permutations { swaps: ElementSwaps, v: Vec, } -#[unstable(feature = "collections", reason = "trait is unstable")] +#[unstable(feature = "permutations", reason = "trait is unstable")] impl Iterator for Permutations { type Item = Vec; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 39e1812512f44..61e09a2670ab3 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -366,7 +366,7 @@ impl<'a> Iterator for Recompositions<'a> { /// /// For use with the `std::iter` module. #[derive(Clone)] -#[unstable(feature = "collections")] +#[unstable(feature = "str_utf16")] pub struct Utf16Units<'a> { encoder: Utf16Encoder> } @@ -591,7 +591,7 @@ impl str { /// assert_eq!(s.slice_chars(0, 4), "Löwe"); /// assert_eq!(s.slice_chars(5, 7), "老虎"); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "slice_chars", reason = "may have yet to prove its worth")] pub fn slice_chars(&self, begin: usize, end: usize) -> &str { core_str::StrExt::slice_chars(self, begin, end) @@ -1068,7 +1068,7 @@ impl str { } /// Returns an iterator of `u16` over the string encoded as UTF-16. - #[unstable(feature = "collections", + #[unstable(feature = "str_utf16", reason = "this functionality may only be provided by libunicode")] pub fn utf16_units(&self) -> Utf16Units { Utf16Units { encoder: Utf16Encoder::new(self[..].chars()) } @@ -1527,7 +1527,7 @@ impl str { /// let v: Vec<&str> = "1abc2abc3".matches(char::is_numeric).collect(); /// assert_eq!(v, ["1", "2", "3"]); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "str_matches", reason = "method got recently added")] pub fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P> { core_str::StrExt::matches(self, pat) @@ -1560,7 +1560,7 @@ impl str { /// let v: Vec<&str> = "1abc2abc3".rmatches(char::is_numeric).collect(); /// assert_eq!(v, ["3", "2", "1"]); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "str_matches", reason = "method got recently added")] pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P> where P::Searcher: ReverseSearcher<'a> @@ -1605,7 +1605,7 @@ impl str { /// let v: Vec<(usize, usize)> = "ababa".match_indices("aba").collect(); /// assert_eq!(v, [(0, 3)]); // only the first `aba` /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "str_matches", reason = "might have its iterator type changed")] // NB: Right now MatchIndices yields `(usize, usize)`, but it would // be more consistent with `matches` and `char_indices` to return `(usize, &str)` @@ -1649,7 +1649,7 @@ impl str { /// let v: Vec<(usize, usize)> = "ababa".rmatch_indices("aba").collect(); /// assert_eq!(v, [(2, 5)]); // only the last `aba` /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "str_matches", reason = "might have its iterator type changed")] // NB: Right now RMatchIndices yields `(usize, usize)`, but it would // be more consistent with `rmatches` and `char_indices` to return `(usize, &str)` @@ -1677,7 +1677,7 @@ impl str { /// assert!(string.subslice_offset(lines[1]) == 2); // &"b" /// assert!(string.subslice_offset(lines[2]) == 4); // &"c" /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "subslice_offset", reason = "awaiting convention about comparability of arbitrary slices")] pub fn subslice_offset(&self, inner: &str) -> usize { core_str::StrExt::subslice_offset(self, inner) @@ -1922,14 +1922,14 @@ impl str { } /// Escapes each char in `s` with `char::escape_default`. - #[unstable(feature = "collections", + #[unstable(feature = "str_escape", reason = "return type may change to be an iterator")] pub fn escape_default(&self) -> String { self.chars().flat_map(|c| c.escape_default()).collect() } /// Escapes each char in `s` with `char::escape_unicode`. - #[unstable(feature = "collections", + #[unstable(feature = "str_escape", reason = "return type may change to be an iterator")] pub fn escape_unicode(&self) -> String { self.chars().flat_map(|c| c.escape_unicode()).collect() diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 6717f2f45fab5..6e37a5731b384 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -696,7 +696,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections_drain)] + /// # #![feature(drain)] /// /// let mut s = String::from("α is alpha, β is beta"); /// let beta_offset = s.find('β').unwrap_or(s.len()); @@ -710,7 +710,7 @@ impl String { /// s.drain(..); /// assert_eq!(s, ""); /// ``` - #[unstable(feature = "collections_drain", + #[unstable(feature = "drain", reason = "recently added, matches RFC")] pub fn drain(&mut self, range: R) -> Drain where R: RangeArgument { // Memory safety @@ -975,10 +975,14 @@ impl ops::Deref for String { /// Wrapper type providing a `&String` reference via `Deref`. #[unstable(feature = "collections")] +#[deprecated(since = "1.2.0", + reason = "replaced with deref coercions or Borrow")] +#[allow(deprecated)] pub struct DerefString<'a> { x: DerefVec<'a, u8> } +#[allow(deprecated)] impl<'a> Deref for DerefString<'a> { type Target = String; @@ -1005,6 +1009,9 @@ impl<'a> Deref for DerefString<'a> { /// string_consumer(&as_string("foo")); /// ``` #[unstable(feature = "collections")] +#[deprecated(since = "1.2.0", + reason = "replaced with deref coercions or Borrow")] +#[allow(deprecated)] pub fn as_string<'a>(x: &'a str) -> DerefString<'a> { DerefString { x: as_vec(x.as_bytes()) } } @@ -1134,7 +1141,7 @@ impl fmt::Write for String { } /// A draining iterator for `String`. -#[unstable(feature = "collections_drain", reason = "recently added")] +#[unstable(feature = "drain", reason = "recently added")] pub struct Drain<'a> { /// Will be used as &'a mut String in the destructor string: *mut String, @@ -1149,7 +1156,7 @@ pub struct Drain<'a> { unsafe impl<'a> Sync for Drain<'a> {} unsafe impl<'a> Send for Drain<'a> {} -#[unstable(feature = "collections_drain", reason = "recently added")] +#[unstable(feature = "drain", reason = "recently added")] impl<'a> Drop for Drain<'a> { fn drop(&mut self) { unsafe { @@ -1163,7 +1170,7 @@ impl<'a> Drop for Drain<'a> { } } -#[unstable(feature = "collections_drain", reason = "recently added")] +#[unstable(feature = "drain", reason = "recently added")] impl<'a> Iterator for Drain<'a> { type Item = char; @@ -1177,7 +1184,7 @@ impl<'a> Iterator for Drain<'a> { } } -#[unstable(feature = "collections_drain", reason = "recently added")] +#[unstable(feature = "drain", reason = "recently added")] impl<'a> DoubleEndedIterator for Drain<'a> { #[inline] fn next_back(&mut self) -> Option { diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index ba41f438b37fb..1409ececfc7a5 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -276,7 +276,7 @@ impl Vec { /// the buffer are copied into the vector without cloning, as if /// `ptr::read()` were called on them. #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "vec_from_raw_buf", reason = "may be better expressed via composition")] pub unsafe fn from_raw_buf(ptr: *const T, elts: usize) -> Vec { let mut dst = Vec::with_capacity(elts); @@ -704,7 +704,7 @@ impl Vec { /// assert_eq!(vec2, []); /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "append", reason = "new API, waiting for dust to settle")] pub fn append(&mut self, other: &mut Self) { if mem::size_of::() == 0 { @@ -742,7 +742,7 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(collections_drain)] + /// # #![feature(drain)] /// /// // Draining using `..` clears the whole vector. /// let mut v = vec![1, 2, 3]; @@ -750,7 +750,7 @@ impl Vec { /// assert_eq!(v, &[]); /// assert_eq!(u, &[1, 2, 3]); /// ``` - #[unstable(feature = "collections_drain", + #[unstable(feature = "drain", reason = "recently added, matches RFC")] pub fn drain(&mut self, range: R) -> Drain where R: RangeArgument { // Memory safety @@ -851,7 +851,7 @@ impl Vec { /// let newtyped_bytes = bytes.map_in_place(|x| Newtype(x)); /// assert_eq!(&newtyped_bytes[..], &[Newtype(0x11), Newtype(0x22)]); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "map_in_place", reason = "API may change to provide stronger guarantees")] pub fn map_in_place(self, mut f: F) -> Vec where F: FnMut(T) -> U { // FIXME: Assert statically that the types `T` and `U` have the same @@ -1043,14 +1043,14 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(split_off)] /// let mut vec = vec![1,2,3]; /// let vec2 = vec.split_off(1); /// assert_eq!(vec, [1]); /// assert_eq!(vec2, [2, 3]); /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "split_off", reason = "new API, waiting for dust to settle")] pub fn split_off(&mut self, at: usize) -> Self { assert!(at <= self.len(), "`at` out of bounds"); @@ -1091,7 +1091,7 @@ impl Vec { /// vec.resize(2, 0); /// assert_eq!(vec, [1, 2]); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "vec_resize", reason = "matches collection reform specification; waiting for dust to settle")] pub fn resize(&mut self, new_len: usize, value: T) { let len = self.len(); @@ -1117,7 +1117,7 @@ impl Vec { /// assert_eq!(vec, [1, 2, 3, 4]); /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "vec_push_all", reason = "likely to be replaced by a more optimized extend")] pub fn push_all(&mut self, other: &[T]) { self.reserve(other.len()); @@ -1738,7 +1738,7 @@ unsafe impl Sync for IntoIter { } impl IntoIter { #[inline] /// Drops all items that have not yet been moved and returns the empty vector. - #[unstable(feature = "collections")] + #[unstable(feature = "iter_to_vec")] pub fn into_inner(mut self) -> Vec { unsafe { for _x in self.by_ref() { } @@ -1832,7 +1832,7 @@ impl Drop for IntoIter { } /// A draining iterator for `Vec`. -#[unstable(feature = "collections_drain", reason = "recently added")] +#[unstable(feature = "drain", reason = "recently added")] pub struct Drain<'a, T: 'a> { /// Index of tail to preserve tail_start: usize, @@ -1907,12 +1907,17 @@ impl<'a, T> ExactSizeIterator for Drain<'a, T> {} /// Wrapper type providing a `&Vec` reference via `Deref`. #[unstable(feature = "collections")] +#[deprecated(since = "1.2.0", + reason = "replaced with deref coercions or Borrow")] pub struct DerefVec<'a, T:'a> { x: Vec, l: PhantomData<&'a T>, } #[unstable(feature = "collections")] +#[deprecated(since = "1.2.0", + reason = "replaced with deref coercions or Borrow")] +#[allow(deprecated)] impl<'a, T> Deref for DerefVec<'a, T> { type Target = Vec; @@ -1923,6 +1928,9 @@ impl<'a, T> Deref for DerefVec<'a, T> { // Prevent the inner `Vec` from attempting to deallocate memory. #[stable(feature = "rust1", since = "1.0.0")] +#[deprecated(since = "1.2.0", + reason = "replaced with deref coercions or Borrow")] +#[allow(deprecated)] impl<'a, T> Drop for DerefVec<'a, T> { fn drop(&mut self) { self.x.len = 0; @@ -1948,6 +1956,9 @@ impl<'a, T> Drop for DerefVec<'a, T> { /// vec_consumer(&as_vec(&values)); /// ``` #[unstable(feature = "collections")] +#[deprecated(since = "1.2.0", + reason = "replaced with deref coercions or Borrow")] +#[allow(deprecated)] pub fn as_vec<'a, T>(x: &'a [T]) -> DerefVec<'a, T> { unsafe { DerefVec { diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index da13684b4f302..54127ea8a9ef2 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -491,7 +491,7 @@ impl VecDeque { /// assert_eq!(buf.len(), 1); /// assert_eq!(Some(&5), buf.get(0)); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "deque_extras", reason = "matches collection reform specification; waiting on panic semantics")] pub fn truncate(&mut self, len: usize) { for _ in len..self.len() { @@ -552,7 +552,7 @@ impl VecDeque { /// Returns a pair of slices which contain, in order, the contents of the /// `VecDeque`. #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "deque_extras", reason = "matches collection reform specification, waiting for dust to settle")] pub fn as_slices(&self) -> (&[T], &[T]) { unsafe { @@ -572,7 +572,7 @@ impl VecDeque { /// Returns a pair of slices which contain, in order, the contents of the /// `VecDeque`. #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "deque_extras", reason = "matches collection reform specification, waiting for dust to settle")] pub fn as_mut_slices(&mut self) -> (&mut [T], &mut [T]) { unsafe { @@ -638,7 +638,7 @@ impl VecDeque { /// assert!(v.is_empty()); /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "drain", reason = "matches collection reform specification, waiting for dust to settle")] pub fn drain(&mut self) -> Drain { Drain { @@ -880,7 +880,7 @@ impl VecDeque { /// buf.push_back(10); /// assert_eq!(buf.swap_back_remove(1), Some(99)); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "deque_extras", reason = "the naming of this function may be altered")] pub fn swap_back_remove(&mut self, index: usize) -> Option { let length = self.len(); @@ -914,7 +914,7 @@ impl VecDeque { /// buf.push_back(20); /// assert_eq!(buf.swap_front_remove(3), Some(99)); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "deque_extras", reason = "the naming of this function may be altered")] pub fn swap_front_remove(&mut self, index: usize) -> Option { let length = self.len(); @@ -1320,7 +1320,7 @@ impl VecDeque { /// assert_eq!(buf2.len(), 2); /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "split_off", reason = "new API, waiting for dust to settle")] pub fn split_off(&mut self, at: usize) -> Self { let len = self.len(); @@ -1383,7 +1383,7 @@ impl VecDeque { /// assert_eq!(buf2.len(), 0); /// ``` #[inline] - #[unstable(feature = "collections", + #[unstable(feature = "append", reason = "new API, waiting for dust to settle")] pub fn append(&mut self, other: &mut Self) { // naive impl @@ -1447,7 +1447,7 @@ impl VecDeque { /// assert_eq!(a, b); /// } /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "deque_extras", reason = "matches collection reform specification; waiting on panic semantics")] pub fn resize(&mut self, new_len: usize, value: T) { let len = self.len(); @@ -1635,7 +1635,7 @@ impl DoubleEndedIterator for IntoIter { impl ExactSizeIterator for IntoIter {} /// A draining VecDeque iterator -#[unstable(feature = "collections", +#[unstable(feature = "drain", reason = "matches collection reform specification, waiting for dust to settle")] pub struct Drain<'a, T: 'a> { inner: &'a mut VecDeque, diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 5c2f5759604b7..3fd2455a00443 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -12,6 +12,8 @@ //! are O(highest integer key). #![allow(missing_docs)] +#![unstable(feature = "vecmap", + reason = "may not be stabilized in the standard library")] use self::Entry::*; @@ -325,7 +327,7 @@ impl VecMap { /// assert_eq!(a[3], "c"); /// assert_eq!(a[4], "d"); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "append", reason = "recently added as part of collections reform 2")] pub fn append(&mut self, other: &mut Self) { self.extend(other.drain()); @@ -358,7 +360,7 @@ impl VecMap { /// assert_eq!(b[3], "c"); /// assert_eq!(b[4], "d"); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "split_off", reason = "recently added as part of collections reform 2")] pub fn split_off(&mut self, at: usize) -> Self { let mut other = VecMap::new(); @@ -410,7 +412,7 @@ impl VecMap { /// /// assert_eq!(vec, [(1, "a"), (2, "b"), (3, "c")]); /// ``` - #[unstable(feature = "collections", + #[unstable(feature = "drain", reason = "matches collection reform specification, waiting for dust to settle")] pub fn drain<'a>(&'a mut self) -> Drain<'a, V> { fn filter((i, v): (usize, Option)) -> Option<(usize, A)> { @@ -632,7 +634,7 @@ impl VecMap { impl<'a, V> Entry<'a, V> { - #[unstable(feature = "collections", + #[unstable(feature = "entry", reason = "will soon be replaced by or_insert")] #[deprecated(since = "1.0", reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")] @@ -644,7 +646,7 @@ impl<'a, V> Entry<'a, V> { } } - #[unstable(feature = "collections", + #[unstable(feature = "entry", reason = "matches entry v3 specification, waiting for dust to settle")] /// Ensures a value is in the entry by inserting the default if empty, and returns /// a mutable reference to the value in the entry. @@ -655,7 +657,7 @@ impl<'a, V> Entry<'a, V> { } } - #[unstable(feature = "collections", + #[unstable(feature = "entry", reason = "matches entry v3 specification, waiting for dust to settle")] /// Ensures a value is in the entry by inserting the result of the default function if empty, /// and returns a mutable reference to the value in the entry. @@ -1003,14 +1005,14 @@ pub struct IntoIter { fn((usize, Option)) -> Option<(usize, V)>> } -#[unstable(feature = "collections")] +#[unstable(feature = "drain")] pub struct Drain<'a, V:'a> { iter: FilterMap< Enumerate>>, fn((usize, Option)) -> Option<(usize, V)>> } -#[unstable(feature = "collections")] +#[unstable(feature = "drain")] impl<'a, V> Iterator for Drain<'a, V> { type Item = (usize, V); @@ -1018,7 +1020,7 @@ impl<'a, V> Iterator for Drain<'a, V> { fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } -#[unstable(feature = "collections")] +#[unstable(feature = "drain")] impl<'a, V> DoubleEndedIterator for Drain<'a, V> { fn next_back(&mut self) -> Option<(usize, V)> { self.iter.next_back() } } diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index f6c5d66f55cff..f8d80035d97fb 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -281,8 +281,9 @@ #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![feature(collections)] + #![feature(into_cow)] +#![feature(str_escape)] use self::LabelText::*; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 944af19a44313..49667bf74cf2c 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -25,18 +25,22 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] +#![feature(append)] #![feature(associated_consts)] #![feature(box_patterns)] #![feature(box_syntax)] +#![feature(clone_from_slice)] #![feature(collections)] #![feature(const_fn)] #![feature(duration)] #![feature(duration_span)] +#![feature(enumset)] #![feature(fs_canonicalize)] #![feature(hash_default)] #![feature(into_cow)] #![feature(iter_sum)] #![feature(libc)] +#![feature(map_in_place)] #![feature(num_bits_bytes)] #![feature(path_ext)] #![feature(quote)] @@ -45,10 +49,14 @@ #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(slice_bytes)] +#![feature(slice_extras)] #![feature(slice_patterns)] +#![feature(slice_position_elem)] #![feature(staged_api)] #![feature(std_misc)] #![feature(str_char)] +#![feature(str_matches)] +#![feature(vec_push_all)] #![feature(wrapping)] #![cfg_attr(test, feature(test))] diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs index e4d0c9aa15f7a..297041a990790 100644 --- a/src/librustc_back/lib.rs +++ b/src/librustc_back/lib.rs @@ -33,7 +33,6 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![feature(box_syntax)] -#![feature(collections)] #![feature(fs_canonicalize)] #![feature(libc)] #![feature(path_ext)] @@ -42,6 +41,7 @@ #![feature(slice_bytes)] #![feature(staged_api)] #![feature(step_by)] +#![feature(vec_push_all)] #![cfg_attr(test, feature(test, rand))] extern crate syntax; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 6ae0ea81c3dda..e369ca46b2c02 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -26,14 +26,15 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![feature(box_syntax)] -#![feature(collections)] +#![feature(exit_status)] #![feature(libc)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] -#![feature(staged_api)] -#![feature(exit_status)] #![feature(set_stdio)] +#![feature(staged_api)] +#![feature(str_casing)] +#![feature(vec_push_all)] extern crate arena; extern crate flate; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 88d307610208f..d53689bb1d164 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -30,17 +30,17 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] +#![cfg_attr(test, feature(test))] #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(collections)] #![feature(num_bits_bytes)] #![feature(quote)] #![feature(ref_slice)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] +#![feature(str_casing)] #![feature(str_char)] -#![cfg_attr(test, feature(test))] extern crate syntax; #[macro_use] diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index bf331705b32c9..bea934c6aa0dc 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -27,10 +27,10 @@ #![feature(associated_consts)] #![feature(box_syntax)] -#![feature(collections)] #![feature(libc)] #![feature(link_args)] #![feature(staged_api)] +#![feature(vec_push_all)] extern crate libc; #[macro_use] #[no_link] extern crate rustc_bitflags; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 0c0fd3f93dcdd..787f914718d4b 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -20,10 +20,10 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![feature(associated_consts)] -#![feature(collections)] #![feature(rc_weak)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] +#![feature(slice_extras)] #![feature(staged_api)] #[macro_use] extern crate log; diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index d0fadd6565c3b..5ace77284953a 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -27,7 +27,6 @@ #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(collections)] #![feature(const_fn)] #![feature(fs)] #![feature(iter_cmp)] @@ -46,6 +45,7 @@ #![feature(std_misc)] #![feature(unicode)] #![feature(unicode)] +#![feature(vec_push_all)] #![allow(trivial_casts)] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index f5a7ec4dbd246..f204fa2b1fd01 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -77,14 +77,16 @@ This API is completely unstable and subject to change. #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(collections, collections_drain)] +#![feature(drain)] #![feature(iter_cmp)] #![feature(iter_sum)] #![feature(quote)] #![feature(ref_slice)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] +#![feature(slice_extras)] #![feature(staged_api)] +#![feature(vec_push_all)] #[macro_use] extern crate log; #[macro_use] extern crate syntax; diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index a7ced76e10c18..0ad5141c5bee6 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -310,7 +310,9 @@ impl char { #[unstable(feature = "unicode", reason = "pending decision about Iterator/Writer/Reader")] #[inline] - pub fn encode_utf8(self, dst: &mut [u8]) -> Option { C::encode_utf8(self, dst) } + pub fn encode_utf8(self, dst: &mut [u8]) -> Option { + C::encode_utf8(self, dst) + } /// Encodes this character as UTF-16 into the provided `u16` buffer, and /// then returns the number of `u16`s written. @@ -345,7 +347,9 @@ impl char { #[unstable(feature = "unicode", reason = "pending decision about Iterator/Writer/Reader")] #[inline] - pub fn encode_utf16(self, dst: &mut [u16]) -> Option { C::encode_utf16(self, dst) } + pub fn encode_utf16(self, dst: &mut [u16]) -> Option { + C::encode_utf16(self, dst) + } /// Returns whether the specified character is considered a Unicode /// alphabetic code point. @@ -541,5 +545,7 @@ impl char { #[unstable(feature = "unicode", reason = "needs expert opinion. is_cjk flag stands out as ugly")] #[inline] - pub fn width(self, is_cjk: bool) -> Option { charwidth::width(self, is_cjk) } + pub fn width(self, is_cjk: bool) -> Option { + charwidth::width(self, is_cjk) + } } diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 8170dd957307b..7fdab8789158e 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -36,6 +36,8 @@ Core encoding and decoding interfaces. #![feature(std_misc)] #![feature(str_char)] #![feature(unicode)] +#![feature(vecmap)] +#![feature(enumset)] #![cfg_attr(test, feature(test))] // test harness access diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 7504488122396..20211f87689b6 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -110,7 +110,9 @@ #![feature(box_raw)] #![feature(box_syntax)] #![feature(char_internals)] +#![feature(clone_from_slice)] #![feature(collections)] +#![feature(collections_bound)] #![feature(const_fn)] #![feature(core)] #![feature(core_float)] @@ -126,6 +128,8 @@ #![feature(libc)] #![feature(linkage, thread_local, asm)] #![feature(macro_reexport)] +#![feature(slice_concat_ext)] +#![feature(slice_position_elem)] #![feature(no_std)] #![feature(num_bits_bytes)] #![feature(oom)] @@ -142,6 +146,7 @@ #![feature(unicode)] #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] +#![feature(vec_push_all)] #![feature(wrapping)] #![feature(zero_one)] #![cfg_attr(test, feature(float_from_str_radix))] diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 432cdbdfef05e..7333265bdd412 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -26,15 +26,17 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![feature(associated_consts)] -#![feature(collections)] -#![feature(collections_drain)] +#![feature(bitset)] +#![feature(drain)] #![feature(filling_drop)] #![feature(libc)] #![feature(ref_slice)] #![feature(rustc_private)] #![feature(staged_api)] #![feature(str_char)] +#![feature(str_escape)] #![feature(unicode)] +#![feature(vec_push_all)] extern crate fmt_macros; extern crate serialize; diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index ec1426e6e48ce..3affb37ba5b9f 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -56,12 +56,12 @@ #![deny(missing_docs)] #![feature(box_syntax)] -#![feature(collections)] +#![feature(path_ext)] #![feature(rustc_private)] #![feature(staged_api)] #![feature(std_misc)] #![feature(str_char)] -#![feature(path_ext)] +#![feature(vec_push_all)] #![cfg_attr(windows, feature(libc))] #[macro_use] extern crate log; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 6ee6f8c2e24bd..4664968913466 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -36,7 +36,6 @@ #![feature(asm)] #![feature(box_syntax)] -#![feature(collections)] #![feature(duration)] #![feature(duration_span)] #![feature(fnbox)] @@ -44,6 +43,7 @@ #![feature(libc)] #![feature(rustc_private)] #![feature(set_stdio)] +#![feature(slice_extras)] #![feature(staged_api)] #![feature(std_misc)] diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs index 09fcd518c1e7e..e79462a4aafe2 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -10,11 +10,11 @@ #![deny(warnings)] -#![feature(core)] #![feature(exit_status)] -#![feature(rustdoc)] -#![feature(rustc_private)] +#![feature(iter_sum)] #![feature(path_relative_from)] +#![feature(rustc_private)] +#![feature(rustdoc)] extern crate rustdoc; extern crate rustc_back; From 6895311e859e1859f9b3f0adc9f1fbb4d2891534 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 9 Jun 2015 18:15:22 -0700 Subject: [PATCH 04/48] std: Split the `std_misc` feature --- src/libcollections/btree/map.rs | 2 +- src/liblog/lib.rs | 4 +++- src/librustc/lib.rs | 3 ++- src/librustc_trans/lib.rs | 2 +- src/libserialize/lib.rs | 4 ++-- src/libstd/ascii.rs | 6 +----- src/libstd/collections/hash/map.rs | 25 ++++++++++++------------- src/libstd/collections/hash/set.rs | 14 ++++++++------ src/libstd/collections/hash/state.rs | 4 ++-- src/libstd/collections/mod.rs | 2 +- src/libstd/dynamic_lib.rs | 4 +++- src/libstd/ffi/c_str.rs | 1 - src/libstd/io/error.rs | 2 +- src/libstd/lib.rs | 2 +- src/libstd/macros.rs | 6 ++---- src/libstd/num/f32.rs | 28 +++++++++++++++------------- src/libstd/num/f64.rs | 16 ++++++++-------- src/libstd/num/float_macros.rs | 1 - src/libstd/num/int_macros.rs | 1 - src/libstd/num/uint_macros.rs | 1 - src/libstd/panicking.rs | 2 -- src/libstd/rt/mod.rs | 4 +++- src/libstd/rtdeps.rs | 2 -- src/libstd/sync/future.rs | 2 +- src/libstd/sync/mpsc/mpsc_queue.rs | 2 -- src/libstd/sync/mpsc/select.rs | 6 +++--- src/libstd/sync/mpsc/spsc_queue.rs | 2 -- src/libstd/sync/mutex.rs | 19 ++++++------------- src/libstd/sync/once.rs | 2 +- src/libstd/sync/rwlock.rs | 22 ++++++---------------- src/libstd/sync/semaphore.rs | 2 +- src/libstd/sys/common/poison.rs | 8 ++++---- src/libstd/thread/local.rs | 4 ++-- src/libstd/thunk.rs | 2 +- src/libterm/lib.rs | 2 +- 35 files changed, 92 insertions(+), 117 deletions(-) diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 127f470c9aaae..95a6fe14ef60c 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -1151,7 +1151,7 @@ impl<'a, K, V> DoubleEndedIterator for RangeMut<'a, K, V> { } impl<'a, K: Ord, V> Entry<'a, K, V> { - #[unstable(feature = "std_misc", + #[unstable(feature = "entry", reason = "will soon be replaced by or_insert")] #[deprecated(since = "1.0", reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 0238bf1f4be18..246b59098658a 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -173,8 +173,10 @@ #![feature(box_syntax)] #![feature(const_fn)] #![feature(iter_cmp)] +#![feature(once_new)] +#![feature(rt)] #![feature(staged_api)] -#![feature(std_misc)] +#![feature(static_mutex)] use std::boxed; use std::cell::RefCell; diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 49667bf74cf2c..b557b0f564941 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -34,9 +34,11 @@ #![feature(const_fn)] #![feature(duration)] #![feature(duration_span)] +#![feature(dynamic_lib)] #![feature(enumset)] #![feature(fs_canonicalize)] #![feature(hash_default)] +#![feature(hashmap_hasher)] #![feature(into_cow)] #![feature(iter_sum)] #![feature(libc)] @@ -53,7 +55,6 @@ #![feature(slice_patterns)] #![feature(slice_position_elem)] #![feature(staged_api)] -#![feature(std_misc)] #![feature(str_char)] #![feature(str_matches)] #![feature(vec_push_all)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 5ace77284953a..978fa4e745b99 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -33,6 +33,7 @@ #![feature(iter_sum)] #![feature(iter_unfold)] #![feature(libc)] +#![feature(once_new)] #![feature(path_ext)] #![feature(path_ext)] #![feature(path_relative_from)] @@ -42,7 +43,6 @@ #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] -#![feature(std_misc)] #![feature(unicode)] #![feature(unicode)] #![feature(vec_push_all)] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 7fdab8789158e..5951e4f823e7c 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -29,15 +29,15 @@ Core encoding and decoding interfaces. #![feature(box_syntax)] #![feature(collections)] +#![feature(enumset)] +#![feature(hashmap_hasher)] #![feature(num_bits_bytes)] #![feature(num_wrapping)] #![feature(rustc_private)] #![feature(staged_api)] -#![feature(std_misc)] #![feature(str_char)] #![feature(unicode)] #![feature(vecmap)] -#![feature(enumset)] #![cfg_attr(test, feature(test))] // test harness access diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index b808acb73a12a..9b94b7f7003ed 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -18,7 +18,7 @@ use ops::Range; use mem; /// Extension methods for ASCII-subset only operations on owned strings -#[unstable(feature = "std_misc", +#[unstable(feature = "owned_ascii_ext", reason = "would prefer to do this in a more general way")] pub trait OwnedAsciiExt { /// Converts the string to ASCII upper case: @@ -189,8 +189,6 @@ impl AsciiExt for str { } } -#[unstable(feature = "std_misc", - reason = "would prefer to do this in a more general way")] impl OwnedAsciiExt for String { #[inline] fn into_ascii_uppercase(self) -> String { @@ -244,8 +242,6 @@ impl AsciiExt for [u8] { } } -#[unstable(feature = "std_misc", - reason = "would prefer to do this in a more general way")] impl OwnedAsciiExt for Vec { #[inline] fn into_ascii_uppercase(mut self) -> Vec { diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index e12814bf77c7c..1dca3b77f3880 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -43,8 +43,7 @@ use super::table::BucketState::{ use super::state::HashState; const INITIAL_LOG2_CAP: usize = 5; -#[unstable(feature = "std_misc")] -pub const INITIAL_CAPACITY: usize = 1 << INITIAL_LOG2_CAP; // 2^5 +const INITIAL_CAPACITY: usize = 1 << INITIAL_LOG2_CAP; // 2^5 /// The default behavior of HashMap implements a load factor of 90.9%. /// This behavior is characterized by the following condition: @@ -544,7 +543,7 @@ impl HashMap /// # Examples /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(hashmap_hasher)] /// use std::collections::HashMap; /// use std::collections::hash_map::RandomState; /// @@ -553,7 +552,7 @@ impl HashMap /// map.insert(1, 2); /// ``` #[inline] - #[unstable(feature = "std_misc", reason = "hasher stuff is unclear")] + #[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")] pub fn with_hash_state(hash_state: S) -> HashMap { HashMap { hash_state: hash_state, @@ -573,7 +572,7 @@ impl HashMap /// # Examples /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(hashmap_hasher)] /// use std::collections::HashMap; /// use std::collections::hash_map::RandomState; /// @@ -582,7 +581,7 @@ impl HashMap /// map.insert(1, 2); /// ``` #[inline] - #[unstable(feature = "std_misc", reason = "hasher stuff is unclear")] + #[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")] pub fn with_capacity_and_hash_state(capacity: usize, hash_state: S) -> HashMap { let resize_policy = DefaultResizePolicy::new(); @@ -980,7 +979,7 @@ impl HashMap /// # Examples /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(drain)] /// use std::collections::HashMap; /// /// let mut a = HashMap::new(); @@ -995,7 +994,7 @@ impl HashMap /// assert!(a.is_empty()); /// ``` #[inline] - #[unstable(feature = "std_misc", + #[unstable(feature = "drain", reason = "matches collection reform specification, waiting for dust to settle")] pub fn drain(&mut self) -> Drain { fn last_two((_, b, c): (A, B, C)) -> (B, C) { (b, c) } @@ -1308,7 +1307,7 @@ impl<'a, K, V> Clone for Values<'a, K, V> { } /// HashMap drain iterator. -#[unstable(feature = "std_misc", +#[unstable(feature = "drain", reason = "matches collection reform specification, waiting for dust to settle")] pub struct Drain<'a, K: 'a, V: 'a> { inner: iter::Map, fn((SafeHash, K, V)) -> (K, V)> @@ -1480,7 +1479,7 @@ impl<'a, K, V> ExactSizeIterator for Drain<'a, K, V> { } impl<'a, K, V> Entry<'a, K, V> { - #[unstable(feature = "std_misc", + #[unstable(feature = "entry", reason = "will soon be replaced by or_insert")] #[deprecated(since = "1.0", reason = "replaced with more ergonomic `or_insert` and `or_insert_with`")] @@ -1596,14 +1595,14 @@ impl Extend<(K, V)> for HashMap /// `Hasher`, but the hashers created by two different `RandomState` /// instances are unlikely to produce the same result for the same values. #[derive(Clone)] -#[unstable(feature = "std_misc", +#[unstable(feature = "hashmap_hasher", reason = "hashing an hash maps may be altered")] pub struct RandomState { k0: u64, k1: u64, } -#[unstable(feature = "std_misc", +#[unstable(feature = "hashmap_hasher", reason = "hashing an hash maps may be altered")] impl RandomState { /// Constructs a new `RandomState` that is initialized with random keys. @@ -1615,7 +1614,7 @@ impl RandomState { } } -#[unstable(feature = "std_misc", +#[unstable(feature = "hashmap_hasher", reason = "hashing an hash maps may be altered")] impl HashState for RandomState { type Hasher = SipHasher; diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index c31a46ada3287..ba50b156ab230 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -20,9 +20,11 @@ use iter::{Iterator, IntoIterator, ExactSizeIterator, FromIterator, Map, Chain, use ops::{BitOr, BitAnd, BitXor, Sub}; use option::Option::{Some, None, self}; -use super::map::{self, HashMap, Keys, INITIAL_CAPACITY, RandomState}; +use super::map::{self, HashMap, Keys, RandomState}; use super::state::HashState; +const INITIAL_CAPACITY: usize = 32; + // Future Optimization (FIXME!) // ============================= // @@ -152,7 +154,7 @@ impl HashSet /// # Examples /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(hashmap_hasher)] /// use std::collections::HashSet; /// use std::collections::hash_map::RandomState; /// @@ -161,7 +163,7 @@ impl HashSet /// set.insert(2); /// ``` #[inline] - #[unstable(feature = "std_misc", reason = "hasher stuff is unclear")] + #[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")] pub fn with_hash_state(hash_state: S) -> HashSet { HashSet::with_capacity_and_hash_state(INITIAL_CAPACITY, hash_state) } @@ -177,7 +179,7 @@ impl HashSet /// # Examples /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(hashmap_hasher)] /// use std::collections::HashSet; /// use std::collections::hash_map::RandomState; /// @@ -186,7 +188,7 @@ impl HashSet /// set.insert(1); /// ``` #[inline] - #[unstable(feature = "std_misc", reason = "hasher stuff is unclear")] + #[unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")] pub fn with_capacity_and_hash_state(capacity: usize, hash_state: S) -> HashSet { HashSet { @@ -406,7 +408,7 @@ impl HashSet /// Clears the set, returning all elements in an iterator. #[inline] - #[unstable(feature = "std_misc", + #[unstable(feature = "drain", reason = "matches collection reform specification, waiting for dust to settle")] pub fn drain(&mut self) -> Drain { fn first((a, _): (A, B)) -> A { a } diff --git a/src/libstd/collections/hash/state.rs b/src/libstd/collections/hash/state.rs index 3a06d2d03bf3f..365e6268b3b0d 100644 --- a/src/libstd/collections/hash/state.rs +++ b/src/libstd/collections/hash/state.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![unstable(feature = "hashmap_hasher", reason = "hasher stuff is unclear")] + use clone::Clone; use default::Default; use hash; @@ -25,7 +27,6 @@ use marker; /// algorithm can implement the `Default` trait and create hash maps with the /// `DefaultState` structure. This state is 0-sized and will simply delegate /// to `Default` when asked to create a hasher. -#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")] pub trait HashState { /// Type of the hasher that will be created. type Hasher: hash::Hasher; @@ -38,7 +39,6 @@ pub trait HashState { /// default trait. /// /// This struct has is 0-sized and does not need construction. -#[unstable(feature = "std_misc", reason = "hasher stuff is unclear")] pub struct DefaultState(marker::PhantomData); impl HashState for DefaultState { diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index 4781f2b47548f..3f0b223b9977a 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -410,7 +410,7 @@ pub mod hash_set { /// Experimental support for providing custom hash algorithms to a HashMap and /// HashSet. -#[unstable(feature = "std_misc", reason = "module was recently added")] +#[unstable(feature = "hashmap_hasher", reason = "module was recently added")] pub mod hash_state { pub use super::hash::state::*; } diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index 1c8e52f1b5361..ddafe416305e1 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -12,7 +12,9 @@ //! //! A simple wrapper over the platform's dynamic library facilities -#![unstable(feature = "std_misc")] +#![unstable(feature = "dynamic_lib", + reason = "API has not been scrutinized and is highly likely to \ + either disappear or change")] #![allow(missing_docs)] use prelude::v1::*; diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 433bb335a805b..d5df9b3aa72b2 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![unstable(feature = "std_misc")] use borrow::{Cow, ToOwned}; use boxed::{self, Box}; diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index c4e472f158edf..b43ac0daf5127 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -123,7 +123,7 @@ pub enum ErrorKind { Other, /// Any I/O error not part of this list. - #[unstable(feature = "std_misc", + #[unstable(feature = "io_error_internals", reason = "better expressed through extensible enums that this \ enum cannot be exhaustively matched against")] #[doc(hidden)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 20211f87689b6..fb510ed678271 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -150,7 +150,7 @@ #![feature(wrapping)] #![feature(zero_one)] #![cfg_attr(test, feature(float_from_str_radix))] -#![cfg_attr(test, feature(test, rustc_private, std_misc))] +#![cfg_attr(test, feature(test, rustc_private))] // Don't link to std. We are std. #![no_std] diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 706571b67c9ac..749974c7afab0 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -14,8 +14,6 @@ //! library. Each macro is available for use when linking against the standard //! library. -#![unstable(feature = "std_misc")] - /// The entry point for panic of Rust threads. /// /// This macro is used to inject panic into a Rust thread, causing the thread to @@ -165,7 +163,7 @@ macro_rules! try { /// # Examples /// /// ``` -/// # #![feature(std_misc)] +/// # #![feature(mpsc_select)] /// use std::thread; /// use std::sync::mpsc; /// @@ -191,7 +189,7 @@ macro_rules! try { /// /// For more information about select, see the `std::sync::mpsc::Select` structure. #[macro_export] -#[unstable(feature = "std_misc")] +#[unstable(feature = "mpsc_select")] macro_rules! select { ( $($name:pat = $rx:ident.$meth:ident() => $code:expr),+ diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index c22f5d073de89..0c40f6c1fc8a8 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -194,7 +194,7 @@ impl f32 { /// The floating point encoding is documented in the [Reference][floating-point]. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// use std::f32; /// /// let num = 2.0f32; @@ -211,9 +211,11 @@ impl f32 { /// assert!(abs_difference <= f32::EPSILON); /// ``` /// [floating-point]: ../../../../../reference.html#machine-types - #[unstable(feature = "std_misc", reason = "signature is undecided")] + #[unstable(feature = "float_extras", reason = "signature is undecided")] #[inline] - pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) } + pub fn integer_decode(self) -> (u64, i16, i8) { + num::Float::integer_decode(self) + } /// Returns the largest integer less than or equal to a number. /// @@ -555,7 +557,7 @@ impl f32 { /// Converts radians to degrees. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// use std::f32::{self, consts}; /// /// let angle = consts::PI; @@ -564,14 +566,14 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[unstable(feature = "std_misc", reason = "desirability is unclear")] + #[unstable(feature = "float_extras", reason = "desirability is unclear")] #[inline] pub fn to_degrees(self) -> f32 { num::Float::to_degrees(self) } /// Converts degrees to radians. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// use std::f32::{self, consts}; /// /// let angle = 180.0f32; @@ -580,21 +582,21 @@ impl f32 { /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[unstable(feature = "std_misc", reason = "desirability is unclear")] + #[unstable(feature = "float_extras", reason = "desirability is unclear")] #[inline] pub fn to_radians(self) -> f32 { num::Float::to_radians(self) } /// Constructs a floating point number of `x*2^exp`. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// use std::f32; /// // 3*2^2 - 12 == 0 /// let abs_difference = (f32::ldexp(3.0, 2) - 12.0).abs(); /// /// assert!(abs_difference <= f32::EPSILON); /// ``` - #[unstable(feature = "std_misc", + #[unstable(feature = "float_extras", reason = "pending integer conventions")] #[inline] pub fn ldexp(x: f32, exp: isize) -> f32 { @@ -608,7 +610,7 @@ impl f32 { /// * `0.5 <= abs(x) < 1.0` /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// use std::f32; /// /// let x = 4.0f32; @@ -621,7 +623,7 @@ impl f32 { /// assert!(abs_difference_0 <= f32::EPSILON); /// assert!(abs_difference_1 <= f32::EPSILON); /// ``` - #[unstable(feature = "std_misc", + #[unstable(feature = "float_extras", reason = "pending integer conventions")] #[inline] pub fn frexp(self) -> (f32, isize) { @@ -636,7 +638,7 @@ impl f32 { /// `other`. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// use std::f32; /// /// let x = 1.0f32; @@ -645,7 +647,7 @@ impl f32 { /// /// assert!(abs_diff <= f32::EPSILON); /// ``` - #[unstable(feature = "std_misc", + #[unstable(feature = "float_extras", reason = "unsure about its place in the world")] #[inline] pub fn next_after(self, other: f32) -> f32 { diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index cde0b567ade0f..41c0fcb9797a6 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -190,7 +190,7 @@ impl f64 { /// The floating point encoding is documented in the [Reference][floating-point]. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// let num = 2.0f64; /// /// // (8388608, -22, 1) @@ -205,7 +205,7 @@ impl f64 { /// assert!(abs_difference < 1e-10); /// ``` /// [floating-point]: ../../../../../reference.html#machine-types - #[unstable(feature = "std_misc", reason = "signature is undecided")] + #[unstable(feature = "float_extras", reason = "signature is undecided")] #[inline] pub fn integer_decode(self) -> (u64, i16, i8) { num::Float::integer_decode(self) } @@ -567,13 +567,13 @@ impl f64 { /// Constructs a floating point number of `x*2^exp`. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// // 3*2^2 - 12 == 0 /// let abs_difference = (f64::ldexp(3.0, 2) - 12.0).abs(); /// /// assert!(abs_difference < 1e-10); /// ``` - #[unstable(feature = "std_misc", + #[unstable(feature = "float_extras", reason = "pending integer conventions")] #[inline] pub fn ldexp(x: f64, exp: isize) -> f64 { @@ -587,7 +587,7 @@ impl f64 { /// * `0.5 <= abs(x) < 1.0` /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// let x = 4.0_f64; /// /// // (1/2)*2^3 -> 1 * 8/2 -> 4.0 @@ -598,7 +598,7 @@ impl f64 { /// assert!(abs_difference_0 < 1e-10); /// assert!(abs_difference_1 < 1e-10); /// ``` - #[unstable(feature = "std_misc", + #[unstable(feature = "float_extras", reason = "pending integer conventions")] #[inline] pub fn frexp(self) -> (f64, isize) { @@ -613,7 +613,7 @@ impl f64 { /// `other`. /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(float_extras)] /// /// let x = 1.0f32; /// @@ -621,7 +621,7 @@ impl f64 { /// /// assert!(abs_diff < 1e-10); /// ``` - #[unstable(feature = "std_misc", + #[unstable(feature = "float_extras", reason = "unsure about its place in the world")] #[inline] pub fn next_after(self, other: f64) -> f64 { diff --git a/src/libstd/num/float_macros.rs b/src/libstd/num/float_macros.rs index 60a548b596b1c..16ad21a07d700 100644 --- a/src/libstd/num/float_macros.rs +++ b/src/libstd/num/float_macros.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![unstable(feature = "std_misc")] #![doc(hidden)] macro_rules! assert_approx_eq { diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index af1976d575093..178fad09f9881 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![unstable(feature = "std_misc")] #![doc(hidden)] macro_rules! int_module { ($T:ty) => ( diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 96b0ba1c77f8d..555a5cc3e20e9 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![unstable(feature = "std_misc")] #![doc(hidden)] #![allow(unsigned_negation)] diff --git a/src/libstd/panicking.rs b/src/libstd/panicking.rs index 01588843591f3..b584658fb07e7 100644 --- a/src/libstd/panicking.rs +++ b/src/libstd/panicking.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![unstable(feature = "std_misc")] - use prelude::v1::*; use io::prelude::*; diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 0d26206f26bcf..1b8e81e2b7913 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -16,7 +16,9 @@ //! and should be considered as private implementation details for the //! time being. -#![unstable(feature = "std_misc")] +#![unstable(feature = "rt", + reason = "this public module should not exist and is highly likely \ + to disappear")] #![allow(missing_docs)] use prelude::v1::*; diff --git a/src/libstd/rtdeps.rs b/src/libstd/rtdeps.rs index a7f3bc2bdc82c..be674c83e2213 100644 --- a/src/libstd/rtdeps.rs +++ b/src/libstd/rtdeps.rs @@ -12,8 +12,6 @@ //! the standard library This varies per-platform, but these libraries are //! necessary for running libstd. -#![unstable(feature = "std_misc")] - // All platforms need to link to rustrt #[cfg(not(test))] #[link(name = "rust_builtin", kind = "static")] diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 2d281eb4e249c..76b07999280d0 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -28,7 +28,7 @@ //! ``` #![allow(missing_docs)] -#![unstable(feature = "std_misc", +#![unstable(feature = "future", reason = "futures as-is have yet to be deeply reevaluated with recent \ core changes to Rust's synchronization story, and will likely \ become stable in the future but are unstable until that time")] diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index 2c0da938cbf8b..f3edf0d68c759 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -35,8 +35,6 @@ //! method, and see the method for more information about it. Due to this //! caveat, this queue may not be appropriate for all use-cases. -#![unstable(feature = "std_misc")] - // http://www.1024cores.net/home/lock-free-algorithms // /queues/non-intrusive-mpsc-node-based-queue diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index 679cc550454fa..a67138742aeeb 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -27,7 +27,7 @@ //! # Examples //! //! ```rust -//! # #![feature(std_misc)] +//! # #![feature(mpsc_select)] //! use std::sync::mpsc::channel; //! //! let (tx1, rx1) = channel(); @@ -47,7 +47,7 @@ //! ``` #![allow(dead_code)] -#![unstable(feature = "std_misc", +#![unstable(feature = "mpsc_select", reason = "This implementation, while likely sufficient, is unsafe and \ likely to be error prone. At some point in the future this \ module will likely be replaced, and it is currently \ @@ -124,7 +124,7 @@ impl Select { /// # Examples /// /// ``` - /// # #![feature(std_misc)] + /// # #![feature(mpsc_select)] /// use std::sync::mpsc::Select; /// /// let select = Select::new(); diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index a0ed52d4d3c87..770068a66bec6 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -33,8 +33,6 @@ //! concurrently between two threads. This data structure is safe to use and //! enforces the semantics that there is one pusher and one popper. -#![unstable(feature = "std_misc")] - use core::prelude::*; use alloc::boxed; diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index fd22d723ebdb1..5f77ee2054591 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -85,7 +85,6 @@ use sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; /// To recover from a poisoned mutex: /// /// ``` -/// # #![feature(std_misc)] /// use std::sync::{Arc, Mutex}; /// use std::thread; /// @@ -139,7 +138,7 @@ unsafe impl Sync for Mutex { } /// # Examples /// /// ``` -/// # #![feature(std_misc)] +/// # #![feature(static_mutex)] /// use std::sync::{StaticMutex, MUTEX_INIT}; /// /// static LOCK: StaticMutex = MUTEX_INIT; @@ -150,7 +149,7 @@ unsafe impl Sync for Mutex { } /// } /// // lock is unlocked here. /// ``` -#[unstable(feature = "std_misc", +#[unstable(feature = "static_mutex", reason = "may be merged with Mutex in the future")] pub struct StaticMutex { lock: sys::Mutex, @@ -176,7 +175,7 @@ impl<'a, T: ?Sized> !marker::Send for MutexGuard<'a, T> {} /// Static initialization of a mutex. This constant can be used to initialize /// other mutex constants. -#[unstable(feature = "std_misc", +#[unstable(feature = "static_mutex", reason = "may be merged with Mutex in the future")] pub const MUTEX_INIT: StaticMutex = StaticMutex::new(); @@ -237,7 +236,7 @@ impl Mutex { /// time. You should not trust a `false` value for program correctness /// without additional synchronization. #[inline] - #[unstable(feature = "std_misc")] + #[unstable(feature = "sync_poison")] pub fn is_poisoned(&self) -> bool { self.inner.poison.get() } @@ -270,10 +269,10 @@ struct Dummy(UnsafeCell<()>); unsafe impl Sync for Dummy {} static DUMMY: Dummy = Dummy(UnsafeCell::new(())); +#[unstable(feature = "static_mutex", + reason = "may be merged with Mutex in the future")] impl StaticMutex { /// Creates a new mutex in an unlocked state ready for use. - #[unstable(feature = "std_misc", - reason = "may be merged with Mutex in the future")] pub const fn new() -> StaticMutex { StaticMutex { lock: sys::Mutex::new(), @@ -283,8 +282,6 @@ impl StaticMutex { /// Acquires this lock, see `Mutex::lock` #[inline] - #[unstable(feature = "std_misc", - reason = "may be merged with Mutex in the future")] pub fn lock(&'static self) -> LockResult> { unsafe { self.lock.lock() } MutexGuard::new(self, &DUMMY.0) @@ -292,8 +289,6 @@ impl StaticMutex { /// Attempts to grab this lock, see `Mutex::try_lock` #[inline] - #[unstable(feature = "std_misc", - reason = "may be merged with Mutex in the future")] pub fn try_lock(&'static self) -> TryLockResult> { if unsafe { self.lock.try_lock() } { Ok(try!(MutexGuard::new(self, &DUMMY.0))) @@ -312,8 +307,6 @@ impl StaticMutex { /// *all* platforms. It may be the case that some platforms do not leak /// memory if this method is not called, but this is not guaranteed to be /// true on all platforms. - #[unstable(feature = "std_misc", - reason = "may be merged with Mutex in the future")] pub unsafe fn destroy(&'static self) { self.lock.destroy() } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 269affff20855..1e0aa271b4dcd 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -48,7 +48,7 @@ pub const ONCE_INIT: Once = Once::new(); impl Once { /// Creates a new `Once` value. - #[unstable(feature = "std_misc")] + #[unstable(feature = "once_new")] pub const fn new() -> Once { Once { mutex: StaticMutex::new(), diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 857d8889b7c25..5a6bf987fd717 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -81,7 +81,7 @@ unsafe impl Sync for RwLock {} /// # Examples /// /// ``` -/// # #![feature(std_misc)] +/// # #![feature(static_rwlock)] /// use std::sync::{StaticRwLock, RW_LOCK_INIT}; /// /// static LOCK: StaticRwLock = RW_LOCK_INIT; @@ -96,7 +96,7 @@ unsafe impl Sync for RwLock {} /// } /// unsafe { LOCK.destroy() } // free all resources /// ``` -#[unstable(feature = "std_misc", +#[unstable(feature = "static_rwlock", reason = "may be merged with RwLock in the future")] pub struct StaticRwLock { lock: sys::RWLock, @@ -104,7 +104,7 @@ pub struct StaticRwLock { } /// Constant initialization for a statically-initialized rwlock. -#[unstable(feature = "std_misc", +#[unstable(feature = "static_rwlock", reason = "may be merged with RwLock in the future")] pub const RW_LOCK_INIT: StaticRwLock = StaticRwLock::new(); @@ -253,7 +253,7 @@ impl RwLock { /// time. You should not trust a `false` value for program correctness /// without additional synchronization. #[inline] - #[unstable(feature = "std_misc")] + #[unstable(feature = "sync_poison")] pub fn is_poisoned(&self) -> bool { self.inner.poison.get() } @@ -283,10 +283,10 @@ struct Dummy(UnsafeCell<()>); unsafe impl Sync for Dummy {} static DUMMY: Dummy = Dummy(UnsafeCell::new(())); +#[unstable(feature = "static_rwlock", + reason = "may be merged with RwLock in the future")] impl StaticRwLock { /// Creates a new rwlock. - #[unstable(feature = "std_misc", - reason = "may be merged with RwLock in the future")] pub const fn new() -> StaticRwLock { StaticRwLock { lock: sys::RWLock::new(), @@ -299,8 +299,6 @@ impl StaticRwLock { /// /// See `RwLock::read`. #[inline] - #[unstable(feature = "std_misc", - reason = "may be merged with RwLock in the future")] pub fn read(&'static self) -> LockResult> { unsafe { self.lock.read() } RwLockReadGuard::new(self, &DUMMY.0) @@ -310,8 +308,6 @@ impl StaticRwLock { /// /// See `RwLock::try_read`. #[inline] - #[unstable(feature = "std_misc", - reason = "may be merged with RwLock in the future")] pub fn try_read(&'static self) -> TryLockResult> { if unsafe { self.lock.try_read() } { @@ -326,8 +322,6 @@ impl StaticRwLock { /// /// See `RwLock::write`. #[inline] - #[unstable(feature = "std_misc", - reason = "may be merged with RwLock in the future")] pub fn write(&'static self) -> LockResult> { unsafe { self.lock.write() } RwLockWriteGuard::new(self, &DUMMY.0) @@ -337,8 +331,6 @@ impl StaticRwLock { /// /// See `RwLock::try_write`. #[inline] - #[unstable(feature = "std_misc", - reason = "may be merged with RwLock in the future")] pub fn try_write(&'static self) -> TryLockResult> { if unsafe { self.lock.try_write() } { @@ -354,8 +346,6 @@ impl StaticRwLock { /// active users of the lock, and this also doesn't prevent any future users /// of this lock. This method is required to be called to not leak memory on /// all platforms. - #[unstable(feature = "std_misc", - reason = "may be merged with RwLock in the future")] pub unsafe fn destroy(&'static self) { self.lock.destroy() } diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index 776b3c5064ced..0278a6c95b982 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![unstable(feature = "std_misc", +#![unstable(feature = "semaphore", reason = "the interaction between semaphores and the acquisition/release \ of resources is currently unclear")] diff --git a/src/libstd/sys/common/poison.rs b/src/libstd/sys/common/poison.rs index 48c8198272588..75f85879fd1f4 100644 --- a/src/libstd/sys/common/poison.rs +++ b/src/libstd/sys/common/poison.rs @@ -120,24 +120,24 @@ impl Error for PoisonError { impl PoisonError { /// Creates a `PoisonError`. - #[unstable(feature = "std_misc")] + #[unstable(feature = "sync_poison")] pub fn new(guard: T) -> PoisonError { PoisonError { guard: guard } } /// Consumes this error indicating that a lock is poisoned, returning the /// underlying guard to allow access regardless. - #[unstable(feature = "std_misc")] + #[unstable(feature = "sync_poison")] pub fn into_inner(self) -> T { self.guard } /// Reaches into this error indicating that a lock is poisoned, returning a /// reference to the underlying guard to allow access regardless. - #[unstable(feature = "std_misc")] + #[unstable(feature = "sync_poison")] pub fn get_ref(&self) -> &T { &self.guard } /// Reaches into this error indicating that a lock is poisoned, returning a /// mutable reference to the underlying guard to allow access regardless. - #[unstable(feature = "std_misc")] + #[unstable(feature = "sync_poi")] pub fn get_mut(&mut self) -> &mut T { &mut self.guard } } diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 69a26cdc490f6..2b5e3fb18eb16 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -154,7 +154,7 @@ macro_rules! __thread_local_inner { } /// Indicator of the state of a thread local storage key. -#[unstable(feature = "std_misc", +#[unstable(feature = "thread_local_state", reason = "state querying was recently added")] #[derive(Eq, PartialEq, Copy, Clone)] pub enum LocalKeyState { @@ -249,7 +249,7 @@ impl LocalKey { /// initialization does not panic. Keys in the `Valid` state are guaranteed /// to be able to be accessed. Keys in the `Destroyed` state will panic on /// any call to `with`. - #[unstable(feature = "std_misc", + #[unstable(feature = "thread_local_state", reason = "state querying was recently added")] pub fn state(&'static self) -> LocalKeyState { unsafe { diff --git a/src/libstd/thunk.rs b/src/libstd/thunk.rs index 6091794ed4286..084893314a8e5 100644 --- a/src/libstd/thunk.rs +++ b/src/libstd/thunk.rs @@ -10,7 +10,7 @@ // Because this module is temporary... #![allow(missing_docs)] -#![unstable(feature = "std_misc")] +#![unstable(feature = "thunk")] use alloc::boxed::{Box, FnBox}; use core::marker::Send; diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index 3affb37ba5b9f..5131e0b34e380 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -56,10 +56,10 @@ #![deny(missing_docs)] #![feature(box_syntax)] +#![feature(owned_ascii_ext)] #![feature(path_ext)] #![feature(rustc_private)] #![feature(staged_api)] -#![feature(std_misc)] #![feature(str_char)] #![feature(vec_push_all)] #![cfg_attr(windows, feature(libc))] From ce1a965cf54ce65fc43b535c27029ce183214063 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 13:33:52 -0700 Subject: [PATCH 05/48] Fallout in tests and docs from feature renamings --- src/compiletest/compiletest.rs | 11 +- src/liballoc/arc.rs | 20 +-- src/liballoc/boxed.rs | 8 +- src/liballoc/lib.rs | 2 +- src/liballoc/rc.rs | 33 +++-- src/libcollections/bit.rs | 125 +++++++++--------- src/libcollections/btree/map.rs | 4 +- src/libcollections/btree/set.rs | 2 +- src/libcollections/fmt.rs | 3 +- src/libcollections/lib.rs | 4 +- src/libcollections/linked_list.rs | 4 +- src/libcollections/slice.rs | 12 +- src/libcollections/str.rs | 16 +-- src/libcollections/vec.rs | 8 +- src/libcollections/vec_deque.rs | 18 +-- src/libcollections/vec_map.rs | 42 +++--- src/libcollectionstest/lib.rs | 45 +++++-- src/libcollectionstest/str.rs | 3 +- src/libcollectionstest/string.rs | 3 +- src/libcollectionstest/vec.rs | 3 + src/libcollectionstest/vec_deque.rs | 2 - src/libcore/cell.rs | 2 +- src/libcore/cmp.rs | 8 +- src/libcore/fmt/num.rs | 2 +- src/libcore/hash/mod.rs | 4 +- src/libcore/iter.rs | 18 +-- src/libcore/marker.rs | 2 +- src/libcore/option.rs | 2 +- src/libcore/ptr.rs | 2 +- src/libcore/raw.rs | 4 +- src/libcore/result.rs | 2 +- src/libcore/simd.rs | 2 +- src/libcoretest/lib.rs | 48 ++++--- src/libcoretest/option.rs | 4 +- src/libflate/lib.rs | 2 +- src/librand/lib.rs | 2 +- src/librustc/lib.rs | 3 +- src/librustc_bitflags/lib.rs | 2 +- src/librustc_driver/lib.rs | 1 - src/librustc_lint/lib.rs | 1 - src/librustc_trans/lib.rs | 2 +- src/librustc_typeck/lib.rs | 2 +- src/librustc_unicode/lib.rs | 2 +- src/librustdoc/lib.rs | 15 ++- src/libstd/lib.rs | 4 +- src/libstd/sync/future.rs | 2 +- src/libstd/sync/mutex.rs | 2 + src/libstd/sync/semaphore.rs | 2 +- src/libtest/lib.rs | 3 +- src/rustbook/main.rs | 2 +- src/test/auxiliary/linkage-visibility.rs | 2 +- src/test/bench/core-set.rs | 1 + src/test/bench/core-std.rs | 2 +- src/test/bench/msgsend-ring-mutex-arcs.rs | 2 +- src/test/bench/shootout-k-nucleotide.rs | 2 +- src/test/bench/shootout-mandelbrot.rs | 2 +- src/test/bench/shootout-meteor.rs | 2 +- src/test/bench/shootout-spectralnorm.rs | 5 +- src/test/bench/std-smallintmap.rs | 2 +- src/test/bench/task-perf-alloc-unwind.rs | 2 +- .../compile-fail/feature-gate-simd-ffi.rs | 2 +- src/test/compile-fail/lint-dead-code-4.rs | 9 +- .../compile-fail/lint-exceeding-bitshifts.rs | 2 +- src/test/debuginfo/constant-debug-locs.rs | 2 +- src/test/debuginfo/simd.rs | 2 +- src/test/run-make/extern-fn-reachable/main.rs | 2 +- .../intrinsic-unreachable/exit-unreachable.rs | 2 +- src/test/run-make/volatile-intrinsics/main.rs | 2 +- src/test/run-pass/binary-heap-panic-safe.rs | 2 +- src/test/run-pass/bitv-perf-test.rs | 10 +- src/test/run-pass/deriving-hash.rs | 2 +- src/test/run-pass/discriminant_value.rs | 2 +- src/test/run-pass/dst-coerce-custom.rs | 2 +- src/test/run-pass/enum-null-pointer-opt.rs | 3 +- src/test/run-pass/fat-ptr-cast.rs | 2 +- src/test/run-pass/for-loop-no-std.rs | 2 +- src/test/run-pass/format-no-std.rs | 2 - .../into-iterator-type-inference-shift.rs | 6 +- src/test/run-pass/intrinsic-assume.rs | 3 +- .../run-pass/intrinsic-move-val-cleanups.rs | 2 +- src/test/run-pass/intrinsic-unreachable.rs | 3 +- src/test/run-pass/issue-11709.rs | 2 +- src/test/run-pass/issue-11736.rs | 2 +- src/test/run-pass/issue-11958.rs | 2 +- src/test/run-pass/issue-13494.rs | 4 +- src/test/run-pass/issue-13763.rs | 2 +- src/test/run-pass/issue-15673.rs | 3 +- src/test/run-pass/issue-16530.rs | 3 +- src/test/run-pass/issue-17897.rs | 2 +- src/test/run-pass/issue-18188.rs | 2 +- src/test/run-pass/issue-21058.rs | 3 +- src/test/run-pass/issue-2190-1.rs | 2 +- src/test/run-pass/issue-23037.rs | 2 +- src/test/run-pass/issue-23550.rs | 2 +- src/test/run-pass/issue-6898.rs | 6 +- .../run-pass/iter-cloned-type-inference.rs | 3 +- src/test/run-pass/linkage-visibility.rs | 2 - ...thod-mut-self-modifies-mut-slice-lvalue.rs | 2 +- .../run-pass/minmax-stability-issue-23687.rs | 3 +- src/test/run-pass/new-box-syntax.rs | 4 +- src/test/run-pass/realloc-16687.rs | 2 +- src/test/run-pass/running-with-no-runtime.rs | 8 +- .../run-pass/send-is-not-static-par-for.rs | 2 - src/test/run-pass/simd-binop.rs | 2 +- src/test/run-pass/simd-issue-10604.rs | 3 +- .../run-pass/slice-of-zero-size-elements.rs | 2 +- .../run-pass/std-sync-right-kind-impls.rs | 3 +- .../sync-send-iterators-in-libcollections.rs | 4 +- .../sync-send-iterators-in-libcore.rs | 1 + src/test/run-pass/tydesc-name.rs | 2 +- src/test/run-pass/typeid-intrinsic.rs | 2 +- src/test/run-pass/ufcs-polymorphic-paths.rs | 3 +- src/test/run-pass/unfold-cross-crate.rs | 2 +- src/test/run-pass/unsized3.rs | 4 +- src/test/run-pass/vec-concat.rs | 2 +- src/test/run-pass/vec-macro-no-std.rs | 4 +- src/test/run-pass/vector-sort-panic-safe.rs | 2 +- src/test/run-pass/wrapping-int-api.rs | 2 +- 118 files changed, 364 insertions(+), 338 deletions(-) diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 1471e30baa6b0..92a94d23f0842 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -11,13 +11,14 @@ #![crate_type = "bin"] #![feature(box_syntax)] -#![feature(collections)] -#![feature(rustc_private)] -#![feature(std_misc)] -#![feature(test)] +#![feature(dynamic_lib)] +#![feature(libc)] #![feature(path_ext)] +#![feature(rustc_private)] +#![feature(slice_extras)] #![feature(str_char)] -#![feature(libc)] +#![feature(test)] +#![feature(vec_push_all)] #![deny(warnings)] diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index e0d459d877fd2..c1ad367c234b3 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -191,7 +191,7 @@ impl Arc { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(arc_weak)] /// use std::sync::Arc; /// /// let five = Arc::new(5); @@ -236,12 +236,12 @@ impl Arc { /// Get the number of weak references to this value. #[inline] -#[unstable(feature = "arc_extras")] +#[unstable(feature = "arc_counts")] pub fn weak_count(this: &Arc) -> usize { this.inner().weak.load(SeqCst) - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable(feature = "arc_extras")] +#[unstable(feature = "arc_counts")] pub fn strong_count(this: &Arc) -> usize { this.inner().strong.load(SeqCst) } @@ -255,7 +255,7 @@ pub fn strong_count(this: &Arc) -> usize { this.inner().strong.loa /// # Examples /// /// ``` -/// # #![feature(alloc)] +/// # #![feature(arc_unique, alloc)] /// extern crate alloc; /// # fn main() { /// use alloc::arc::{Arc, get_mut}; @@ -271,7 +271,7 @@ pub fn strong_count(this: &Arc) -> usize { this.inner().strong.loa /// # } /// ``` #[inline] -#[unstable(feature = "arc_extras")] +#[unstable(feature = "arc_unique")] pub unsafe fn get_mut(this: &mut Arc) -> Option<&mut T> { // FIXME(#24880) potential race with upgraded weak pointers here if strong_count(this) == 1 && weak_count(this) == 0 { @@ -342,7 +342,7 @@ impl Arc { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(arc_unique)] /// use std::sync::Arc; /// /// # unsafe { @@ -352,7 +352,7 @@ impl Arc { /// # } /// ``` #[inline] - #[unstable(feature = "arc_extras")] + #[unstable(feature = "arc_unique")] pub unsafe fn make_unique(&mut self) -> &mut T { // FIXME(#24880) potential race with upgraded weak pointers here // @@ -451,7 +451,7 @@ impl Weak { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(arc_weak)] /// use std::sync::Arc; /// /// let five = Arc::new(5); @@ -489,7 +489,7 @@ impl Clone for Weak { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(arc_weak)] /// use std::sync::Arc; /// /// let weak_five = Arc::new(5).downgrade(); @@ -513,7 +513,7 @@ impl Drop for Weak { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(arc_weak)] /// use std::sync::Arc; /// /// { diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index ffc4186dee8d9..b59a5685f0d8f 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -71,7 +71,7 @@ use core::raw::{TraitObject}; /// The following two examples are equivalent: /// /// ``` -/// # #![feature(alloc)] +/// # #![feature(box_heap)] /// #![feature(box_syntax)] /// use std::boxed::HEAP; /// @@ -139,7 +139,7 @@ impl Box { /// /// # Examples /// ``` -/// # #![feature(alloc)] +/// # #![feature(box_raw)] /// use std::boxed; /// /// let seventeen = Box::new(17u32); @@ -183,7 +183,7 @@ impl Clone for Box { /// # Examples /// /// ``` - /// # #![feature(alloc, core)] + /// # #![feature(box_raw)] /// let x = Box::new(5); /// let mut y = Box::new(10); /// @@ -336,7 +336,7 @@ impl ExactSizeIterator for Box {} /// -> i32>`. /// /// ``` -/// #![feature(core)] +/// #![feature(fnbox)] /// /// use std::boxed::FnBox; /// use std::collections::HashMap; diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index e297d4cbf7762..7dcf7a76da083 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -89,7 +89,7 @@ #![feature(unsafe_no_drop_flag, filling_drop)] #![feature(unsize)] -#![cfg_attr(test, feature(test, alloc, rustc_private))] +#![cfg_attr(test, feature(test, alloc, rustc_private, box_raw))] #![cfg_attr(all(not(feature = "external_funcs"), not(feature = "external_crate")), feature(libc))] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 04dde7a07f920..802591a6171d5 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -32,7 +32,6 @@ //! and have the `Owner` remain allocated as long as any `Gadget` points at it. //! //! ```rust -//! # #![feature(alloc)] //! use std::rc::Rc; //! //! struct Owner { @@ -92,7 +91,7 @@ //! documentation for more details on interior mutability. //! //! ```rust -//! # #![feature(alloc)] +//! # #![feature(rc_weak)] //! use std::rc::Rc; //! use std::rc::Weak; //! use std::cell::RefCell; @@ -229,7 +228,7 @@ impl Rc { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(rc_weak)] /// use std::rc::Rc; /// /// let five = Rc::new(5); @@ -246,12 +245,12 @@ impl Rc { /// Get the number of weak references to this value. #[inline] -#[unstable(feature = "rc_extras")] +#[unstable(feature = "rc_counts")] pub fn weak_count(this: &Rc) -> usize { this.weak() - 1 } /// Get the number of strong references to this value. #[inline] -#[unstable(feature = "rc_extras")] +#[unstable(feature = "rc_counts")] pub fn strong_count(this: &Rc) -> usize { this.strong() } /// Returns true if there are no other `Rc` or `Weak` values that share the @@ -260,7 +259,7 @@ pub fn strong_count(this: &Rc) -> usize { this.strong() } /// # Examples /// /// ``` -/// # #![feature(alloc)] +/// # #![feature(rc_unique)] /// use std::rc; /// use std::rc::Rc; /// @@ -269,7 +268,7 @@ pub fn strong_count(this: &Rc) -> usize { this.strong() } /// rc::is_unique(&five); /// ``` #[inline] -#[unstable(feature = "rc_extras")] +#[unstable(feature = "rc_unique")] pub fn is_unique(rc: &Rc) -> bool { weak_count(rc) == 0 && strong_count(rc) == 1 } @@ -281,7 +280,7 @@ pub fn is_unique(rc: &Rc) -> bool { /// # Examples /// /// ``` -/// # #![feature(alloc)] +/// # #![feature(rc_unique)] /// use std::rc::{self, Rc}; /// /// let x = Rc::new(3); @@ -292,7 +291,7 @@ pub fn is_unique(rc: &Rc) -> bool { /// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); /// ``` #[inline] -#[unstable(feature = "rc_extras")] +#[unstable(feature = "rc_unique")] pub fn try_unwrap(rc: Rc) -> Result> { if is_unique(&rc) { unsafe { @@ -316,7 +315,7 @@ pub fn try_unwrap(rc: Rc) -> Result> { /// # Examples /// /// ``` -/// # #![feature(alloc)] +/// # #![feature(rc_unique)] /// use std::rc::{self, Rc}; /// /// let mut x = Rc::new(3); @@ -327,7 +326,7 @@ pub fn try_unwrap(rc: Rc) -> Result> { /// assert!(rc::get_mut(&mut x).is_none()); /// ``` #[inline] -#[unstable(feature = "rc_extras")] +#[unstable(feature = "rc_unique")] pub fn get_mut(rc: &mut Rc) -> Option<&mut T> { if is_unique(rc) { let inner = unsafe { &mut **rc._ptr }; @@ -346,7 +345,7 @@ impl Rc { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(rc_unique)] /// use std::rc::Rc; /// /// let mut five = Rc::new(5); @@ -354,7 +353,7 @@ impl Rc { /// let mut_five = five.make_unique(); /// ``` #[inline] - #[unstable(feature = "rc_extras")] + #[unstable(feature = "rc_unique")] pub fn make_unique(&mut self) -> &mut T { if !is_unique(self) { *self = Rc::new((**self).clone()) @@ -390,7 +389,6 @@ impl Drop for Rc { /// # Examples /// /// ``` - /// # #![feature(alloc)] /// use std::rc::Rc; /// /// { @@ -443,7 +441,6 @@ impl Clone for Rc { /// # Examples /// /// ``` - /// # #![feature(alloc)] /// use std::rc::Rc; /// /// let five = Rc::new(5); @@ -677,7 +674,7 @@ impl Weak { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(rc_weak)] /// use std::rc::Rc; /// /// let five = Rc::new(5); @@ -705,7 +702,7 @@ impl Drop for Weak { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(rc_weak)] /// use std::rc::Rc; /// /// { @@ -752,7 +749,7 @@ impl Clone for Weak { /// # Examples /// /// ``` - /// # #![feature(alloc)] + /// # #![feature(rc_weak)] /// use std::rc::Rc; /// /// let weak_five = Rc::new(5).downgrade(); diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 5709ed7a29499..6a07c2c47eb24 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -38,7 +38,7 @@ //! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes //! //! ``` -//! # #![feature(collections, core, step_by)] +//! # #![feature(bitset, bitvec, range_inclusive, step_by)] //! use std::collections::{BitSet, BitVec}; //! use std::iter; //! @@ -133,7 +133,7 @@ const FALSE: &'static bool = &false; /// # Examples /// /// ``` -/// # #![feature(collections)] +/// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(10, false); @@ -250,7 +250,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// let mut bv = BitVec::new(); /// ``` @@ -265,7 +265,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let bv = BitVec::from_elem(10, false); @@ -306,7 +306,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b10100000, 0b00010010]); @@ -349,7 +349,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let bv = BitVec::from_fn(5, |i| { i % 2 == 0 }); @@ -368,7 +368,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b01100000]); @@ -401,7 +401,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(5, false); @@ -424,7 +424,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let before = 0b01100000; @@ -445,7 +445,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let before = 0b01100000; @@ -474,7 +474,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let a = 0b01100100; @@ -505,7 +505,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let a = 0b01100100; @@ -536,7 +536,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let a = 0b01100100; @@ -566,7 +566,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(5, true); @@ -591,7 +591,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b01110100, 0b10010010]); @@ -712,7 +712,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(10, false); @@ -730,7 +730,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(10, false); @@ -752,7 +752,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(3, true); @@ -800,7 +800,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b10100000]); @@ -821,7 +821,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_bytes(&[0b01001011]); @@ -848,7 +848,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(3, false); @@ -879,7 +879,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(3, false); @@ -902,7 +902,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::new(); @@ -924,7 +924,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_bytes(&[0b01001011]); @@ -975,7 +975,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_bytes(&[0b01001001]); @@ -1006,7 +1006,7 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitvec)] /// use std::collections::BitVec; /// /// let mut bv = BitVec::new(); @@ -1224,7 +1224,7 @@ impl<'a> IntoIterator for &'a BitVec { /// # Examples /// /// ``` -/// # #![feature(collections)] +/// # #![feature(bitvec, bitset)] /// use std::collections::{BitSet, BitVec}; /// /// // It's a regular set @@ -1328,7 +1328,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1345,7 +1345,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::with_capacity(100); @@ -1363,7 +1363,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitVec, BitSet}; /// /// let bv = BitVec::from_bytes(&[0b01100000]); @@ -1385,7 +1385,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::with_capacity(100); @@ -1397,9 +1397,9 @@ impl BitSet { self.bit_vec.capacity() } - /// Reserves capacity for the given `BitSet` to contain `len` distinct elements. In the case - /// of `BitSet` this means reallocations will not occur as long as all inserted elements - /// are less than `len`. + /// Reserves capacity for the given `BitSet` to contain `len` distinct + /// elements. In the case of `BitSet` this means reallocations will not + /// occur as long as all inserted elements are less than `len`. /// /// The collection may reserve more space to avoid frequent reallocations. /// @@ -1407,7 +1407,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1422,19 +1422,19 @@ impl BitSet { } } - /// Reserves the minimum capacity for the given `BitSet` to contain `len` distinct elements. - /// In the case of `BitSet` this means reallocations will not occur as long as all inserted - /// elements are less than `len`. + /// Reserves the minimum capacity for the given `BitSet` to contain `len` + /// distinct elements. In the case of `BitSet` this means reallocations + /// will not occur as long as all inserted elements are less than `len`. /// - /// Note that the allocator may give the collection more space than it requests. Therefore - /// capacity can not be relied upon to be precisely minimal. Prefer `reserve_len` if future - /// insertions are expected. + /// Note that the allocator may give the collection more space than it + /// requests. Therefore capacity can not be relied upon to be precisely + /// minimal. Prefer `reserve_len` if future insertions are expected. /// /// /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1455,7 +1455,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1476,7 +1476,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1523,7 +1523,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset)] /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1556,7 +1556,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitVec, BitSet}; /// /// let s = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01001010])); @@ -1578,7 +1578,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitVec, BitSet}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1602,12 +1602,13 @@ impl BitSet { } /// Iterator over each usize stored in `self` intersect `other`. - /// See [intersect_with](#method.intersect_with) for an efficient in-place version. + /// See [intersect_with](#method.intersect_with) for an efficient in-place + /// version. /// /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitVec, BitSet}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1632,12 +1633,13 @@ impl BitSet { } /// Iterator over each usize stored in the `self` setminus `other`. - /// See [difference_with](#method.difference_with) for an efficient in-place version. + /// See [difference_with](#method.difference_with) for an efficient in-place + /// version. /// /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitSet, BitVec}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1667,14 +1669,15 @@ impl BitSet { })) } - /// Iterator over each usize stored in the symmetric difference of `self` and `other`. - /// See [symmetric_difference_with](#method.symmetric_difference_with) for - /// an efficient in-place version. + /// Iterator over each usize stored in the symmetric difference of `self` + /// and `other`. See + /// [symmetric_difference_with](#method.symmetric_difference_with) for an + /// efficient in-place version. /// /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitSet, BitVec}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1702,7 +1705,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1726,7 +1729,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1751,7 +1754,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1784,7 +1787,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(bitset, bitvec)] /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1808,7 +1811,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(collections, append)] + /// # #![feature(bitset, bitvec, append)] /// use std::collections::{BitVec, BitSet}; /// /// let mut a = BitSet::new(); @@ -1839,7 +1842,7 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, split_off)] + /// # #![feature(bitset, bitvec, split_off)] /// use std::collections::{BitSet, BitVec}; /// let mut a = BitSet::new(); /// a.insert(2); diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 95a6fe14ef60c..d27d04c3a6cec 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -1507,7 +1507,7 @@ impl BTreeMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(btree_range, collections_bound)] /// use std::collections::BTreeMap; /// use std::collections::Bound::{Included, Unbounded}; /// @@ -1534,7 +1534,7 @@ impl BTreeMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(btree_range, collections_bound)] /// use std::collections::BTreeMap; /// use std::collections::Bound::{Included, Excluded}; /// diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 5914e2f296a33..7c4cda305adf2 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -141,7 +141,7 @@ impl BTreeSet { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(btree_range, collections_bound)] /// use std::collections::BTreeSet; /// use std::collections::Bound::{Included, Unbounded}; /// diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 817a5baf3d1be..72d0ca85357a4 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -172,9 +172,8 @@ //! like: //! //! ``` -//! # #![feature(core, std_misc)] +//! # #![feature(fmt_flags)] //! use std::fmt; -//! use std::f64; //! //! #[derive(Debug)] //! struct Vector2D { diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 9762381381c60..b08a3b85e4cbf 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -44,8 +44,8 @@ #![feature(iter_cmp)] #![feature(iter_idx)] #![feature(iter_order)] -#![feature(iter_product)] -#![feature(iter_sum)] +#![feature(iter_arith)] +#![feature(iter_arith)] #![feature(lang_items)] #![feature(num_bits_bytes)] #![feature(oom)] diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index a732ce9e81df7..a02cb44896ad3 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -784,7 +784,7 @@ impl<'a, A> IterMut<'a, A> { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(linked_list_extras)] /// use std::collections::LinkedList; /// /// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect(); @@ -812,7 +812,7 @@ impl<'a, A> IterMut<'a, A> { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(linked_list_extras)] /// use std::collections::LinkedList; /// /// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect(); diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index c5418c9a0db8e..be678d4a55c86 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -851,7 +851,7 @@ impl [T] { /// # Examples /// /// ```rust - /// # #![feature(collections)] + /// # #![feature(permutations)] /// let v = [1, 2, 3]; /// let mut perms = v.permutations(); /// @@ -863,7 +863,7 @@ impl [T] { /// Iterating through permutations one by one. /// /// ```rust - /// # #![feature(collections)] + /// # #![feature(permutations)] /// let v = [1, 2, 3]; /// let mut perms = v.permutations(); /// @@ -886,7 +886,7 @@ impl [T] { /// # Example /// /// ```rust - /// # #![feature(collections)] + /// # #![feature(permutations)] /// let v: &mut [_] = &mut [0, 1, 2]; /// v.next_permutation(); /// let b: &mut [_] = &mut [0, 2, 1]; @@ -909,7 +909,7 @@ impl [T] { /// # Example /// /// ```rust - /// # #![feature(collections)] + /// # #![feature(permutations)] /// let v: &mut [_] = &mut [1, 0, 2]; /// v.prev_permutation(); /// let b: &mut [_] = &mut [0, 2, 1]; @@ -931,7 +931,7 @@ impl [T] { /// # Example /// /// ```rust - /// # #![feature(collections)] + /// # #![feature(clone_from_slice)] /// let mut dst = [0, 0, 0]; /// let src = [1, 2]; /// @@ -962,7 +962,7 @@ impl [T] { /// # Examples /// /// ```rust - /// # #![feature(collections)] + /// # #![feature(move_from)] /// let mut a = [1, 2, 3, 4, 5]; /// let b = vec![6, 7, 8]; /// let num_moved = a.move_from(b, 0, 3); diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 61e09a2670ab3..d41e062cac3d8 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -585,7 +585,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(slice_chars)] /// let s = "Löwe 老虎 Léopard"; /// /// assert_eq!(s.slice_chars(0, 4), "Löwe"); @@ -1520,7 +1520,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(str_matches)] /// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect(); /// assert_eq!(v, ["abc", "abc", "abc"]); /// @@ -1553,7 +1553,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(str_matches)] /// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect(); /// assert_eq!(v, ["abc", "abc", "abc"]); /// @@ -1595,7 +1595,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(str_matches)] /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect(); /// assert_eq!(v, [(0, 3), (6, 9), (12, 15)]); /// @@ -1639,7 +1639,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(str_matches)] /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".rmatch_indices("abc").collect(); /// assert_eq!(v, [(12, 15), (6, 9), (0, 3)]); /// @@ -1669,7 +1669,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(subslice_offset)] /// let string = "a\nb\nc"; /// let lines: Vec<&str> = string.lines().collect(); /// @@ -1863,7 +1863,7 @@ impl str { /// # Examples /// /// ``` - /// #![feature(collections)] + /// #![feature(str_casing)] /// /// let s = "HELLO"; /// assert_eq!(s.to_lowercase(), "hello"); @@ -1909,7 +1909,7 @@ impl str { /// # Examples /// /// ``` - /// #![feature(collections)] + /// #![feature(str_casing)] /// /// let s = "hello"; /// assert_eq!(s.to_uppercase(), "HELLO"); diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 1409ececfc7a5..3d7c82c9a94a6 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -696,7 +696,7 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(append)] /// let mut vec = vec![1, 2, 3]; /// let mut vec2 = vec![4, 5, 6]; /// vec.append(&mut vec2); @@ -840,7 +840,7 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(map_in_place)] /// let v = vec![0, 1, 2]; /// let w = v.map_in_place(|i| i + 3); /// assert_eq!(&w[..], &[3, 4, 5]); @@ -1082,7 +1082,7 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vec_resize)] /// let mut vec = vec!["hello"]; /// vec.resize(3, "world"); /// assert_eq!(vec, ["hello", "world", "world"]); @@ -1111,7 +1111,7 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vec_push_all)] /// let mut vec = vec![1]; /// vec.push_all(&[2, 3, 4]); /// assert_eq!(vec, [1, 2, 3, 4]); diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 54127ea8a9ef2..c80fcfc5fedcc 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -480,7 +480,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(deque_extras)] /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -629,7 +629,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(drain)] /// use std::collections::VecDeque; /// /// let mut v = VecDeque::new(); @@ -868,7 +868,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(deque_extras)] /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -892,8 +892,8 @@ impl VecDeque { self.pop_back() } - /// Removes an element from anywhere in the ringbuf and returns it, replacing it with the first - /// element. + /// Removes an element from anywhere in the ringbuf and returns it, + /// replacing it with the first element. /// /// This does not preserve ordering, but is O(1). /// @@ -902,7 +902,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(deque_extras)] /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -1310,7 +1310,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(split_off)] /// use std::collections::VecDeque; /// /// let mut buf: VecDeque<_> = vec![1,2,3].into_iter().collect(); @@ -1373,7 +1373,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(append)] /// use std::collections::VecDeque; /// /// let mut buf: VecDeque<_> = vec![1, 2, 3].into_iter().collect(); @@ -1434,7 +1434,7 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(deque_extras)] /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 3fd2455a00443..98ecd045b9ace 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -35,7 +35,7 @@ use vec::Vec; /// # Examples /// /// ``` -/// # #![feature(collections)] +/// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut months = VecMap::new(); @@ -135,7 +135,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::new(); /// ``` @@ -148,7 +148,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::with_capacity(10); /// ``` @@ -163,7 +163,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// let map: VecMap = VecMap::with_capacity(10); /// assert!(map.capacity() >= 10); @@ -183,7 +183,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::new(); /// map.reserve_len(10); @@ -208,7 +208,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::new(); /// map.reserve_len_exact(10); @@ -248,7 +248,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -277,7 +277,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -307,7 +307,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap, append)] /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -343,7 +343,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap, split_off)] /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -400,7 +400,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap, drain)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -428,7 +428,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -446,7 +446,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -464,7 +464,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -480,7 +480,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -505,7 +505,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -524,7 +524,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -552,7 +552,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -578,7 +578,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -600,7 +600,7 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap, entry)] /// use std::collections::VecMap; /// /// let mut count: VecMap = VecMap::new(); @@ -779,7 +779,7 @@ impl IntoIterator for VecMap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// # #![feature(vecmap)] /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 0e3f9d5aaddf6..437657cec1658 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -8,23 +8,52 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(bit_set_append_split_off)] +#![feature(append)] #![feature(bit_vec_append_split_off)] +#![feature(bitset)] +#![feature(bitvec)] #![feature(box_syntax)] +#![feature(btree_range)] #![feature(collections)] -#![feature(collections_drain)] -#![feature(core)] +#![feature(collections_bound)] #![feature(const_fn)] -#![feature(hash)] +#![feature(core)] +#![feature(deque_extras)] +#![feature(drain)] +#![feature(enumset)] +#![feature(hash_default)] +#![feature(into_cow)] +#![feature(iter_idx)] +#![feature(iter_order)] +#![feature(iter_arith)] +#![feature(iter_to_vec)] +#![feature(map_in_place)] +#![feature(move_from)] +#![feature(num_bits_bytes)] +#![feature(pattern)] +#![feature(permutations)] #![feature(rand)] +#![feature(range_inclusive)] #![feature(rustc_private)] +#![feature(slice_bytes)] +#![feature(slice_chars)] +#![feature(slice_extras)] +#![feature(slice_position_elem)] +#![feature(split_off)] +#![feature(step_by)] +#![feature(str_char)] +#![feature(str_escape)] +#![feature(str_matches)] +#![feature(str_utf16)] +#![feature(subslice_offset)] #![feature(test)] #![feature(unboxed_closures)] #![feature(unicode)] -#![feature(into_cow)] -#![feature(step_by)] -#![cfg_attr(test, feature(str_char))] -#![cfg_attr(test, feature(vec_deque_retain))] +#![feature(vec_deque_retain)] +#![feature(vec_from_raw_buf)] +#![feature(vec_push_all)] +#![feature(vec_split_off)] +#![feature(vecmap)] #[macro_use] extern crate log; diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs index f8bc1ceaf7dc3..3f32136bc2639 100644 --- a/src/libcollectionstest/str.rs +++ b/src/libcollectionstest/str.rs @@ -9,7 +9,7 @@ // except according to those terms. use std::cmp::Ordering::{Equal, Greater, Less}; -use std::str::{Utf8Error, from_utf8}; +use std::str::from_utf8; #[test] fn test_le() { @@ -1753,6 +1753,7 @@ mod pattern { macro_rules! make_test { ($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => { + #[allow(unused_imports)] mod $name { use std::str::pattern::SearchStep::{Match, Reject}; use super::{cmp_search_to_vec}; diff --git a/src/libcollectionstest/string.rs b/src/libcollectionstest/string.rs index 2df0c7a3a8a23..257caca4016df 100644 --- a/src/libcollectionstest/string.rs +++ b/src/libcollectionstest/string.rs @@ -10,12 +10,13 @@ use std::borrow::{IntoCow, Cow}; use std::iter::repeat; -use std::str::Utf8Error; +#[allow(deprecated)] use std::string::as_string; use test::Bencher; #[test] +#[allow(deprecated)] fn test_as_string() { let x = "foo"; assert_eq!(x, &**as_string(x)); diff --git a/src/libcollectionstest/vec.rs b/src/libcollectionstest/vec.rs index 3f07c3697ef3c..df63fbc62fcf4 100644 --- a/src/libcollectionstest/vec.rs +++ b/src/libcollectionstest/vec.rs @@ -10,6 +10,7 @@ use std::iter::{FromIterator, repeat}; use std::mem::size_of; +#[allow(deprecated)] use std::vec::as_vec; use test::Bencher; @@ -25,12 +26,14 @@ impl<'a> Drop for DropCounter<'a> { } #[test] +#[allow(deprecated)] fn test_as_vec() { let xs = [1u8, 2u8, 3u8]; assert_eq!(&**as_vec(&xs), xs); } #[test] +#[allow(deprecated)] fn test_as_vec_dtor() { let (mut count_x, mut count_y) = (0, 0); { diff --git a/src/libcollectionstest/vec_deque.rs b/src/libcollectionstest/vec_deque.rs index 14a36b7c4db79..95368de3bf3d9 100644 --- a/src/libcollectionstest/vec_deque.rs +++ b/src/libcollectionstest/vec_deque.rs @@ -537,8 +537,6 @@ fn test_drain() { #[test] fn test_from_iter() { - use std::iter; - let v = vec!(1,2,3,4,5,6,7); let deq: VecDeque<_> = v.iter().cloned().collect(); let u: Vec<_> = deq.iter().cloned().collect(); diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 56dfd922dc188..37f37654c1fee 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -221,7 +221,7 @@ impl Cell { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(as_unsafe_cell)] /// use std::cell::Cell; /// /// let c = Cell::new(5); diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index b12b59760106a..0269499ad5414 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -381,7 +381,7 @@ pub fn max(v1: T, v2: T) -> T { /// # Examples /// /// ``` -/// # #![feature(core)] +/// # #![feature(cmp_partial)] /// use std::cmp; /// /// assert_eq!(Some(1), cmp::partial_min(1, 2)); @@ -391,7 +391,7 @@ pub fn max(v1: T, v2: T) -> T { /// When comparison is impossible: /// /// ``` -/// # #![feature(core)] +/// # #![feature(cmp_partial)] /// use std::cmp; /// /// let result = cmp::partial_min(std::f64::NAN, 1.0); @@ -414,7 +414,7 @@ pub fn partial_min(v1: T, v2: T) -> Option { /// # Examples /// /// ``` -/// # #![feature(core)] +/// # #![feature(cmp_partial)] /// use std::cmp; /// /// assert_eq!(Some(2), cmp::partial_max(1, 2)); @@ -424,7 +424,7 @@ pub fn partial_min(v1: T, v2: T) -> Option { /// When comparison is impossible: /// /// ``` -/// # #![feature(core)] +/// # #![feature(cmp_partial)] /// use std::cmp; /// /// let result = cmp::partial_max(std::f64::NAN, 1.0); diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 6aaec20382ecf..fc49f87d10769 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -162,7 +162,7 @@ pub struct RadixFmt(T, R); /// # Examples /// /// ``` -/// # #![feature(core)] +/// # #![feature(fmt_radix)] /// use std::fmt::radix; /// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string()); /// ``` diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index cbf2828a7dc18..abf9e55a1f2fb 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -16,7 +16,7 @@ //! # Examples //! //! ```rust -//! # #![feature(hash)] +//! # #![feature(hash_default)] //! use std::hash::{hash, Hash, SipHasher}; //! //! #[derive(Hash)] @@ -36,7 +36,7 @@ //! the trait `Hash`: //! //! ```rust -//! # #![feature(hash)] +//! # #![feature(hash_default)] //! use std::hash::{hash, Hash, Hasher, SipHasher}; //! //! struct Person { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index da714671c5723..30c2d3fcb6d5d 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -822,7 +822,7 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(iter_min_max)] /// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax}; /// /// let a: [i32; 0] = []; @@ -894,7 +894,7 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(iter_cmp)] /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10); /// ``` @@ -922,7 +922,7 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(iter_cmp)] /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0); /// ``` @@ -1061,12 +1061,12 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(iter_arith)] /// let a = [1, 2, 3, 4, 5]; /// let it = a.iter(); /// assert_eq!(it.sum::(), 15); /// ``` - #[unstable(feature="iter_sum", reason = "bounds recently changed")] + #[unstable(feature="iter_arith", reason = "bounds recently changed")] fn sum::Item>(self) -> S where S: Add + Zero, Self: Sized, @@ -1079,7 +1079,7 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(iter_arith)] /// fn factorial(n: u32) -> u32 { /// (1..).take_while(|&i| i <= n).product() /// } @@ -1087,7 +1087,7 @@ pub trait Iterator { /// assert_eq!(factorial(1), 1); /// assert_eq!(factorial(5), 120); /// ``` - #[unstable(feature="iter_product", reason = "bounds recently changed")] + #[unstable(feature="iter_arith", reason = "bounds recently changed")] fn product::Item>(self) -> P where P: Mul + One, Self: Sized, @@ -1353,7 +1353,7 @@ impl MinMaxResult { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(iter_min_max)] /// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax}; /// /// let r: MinMaxResult = NoElements; @@ -2509,7 +2509,7 @@ impl RandomAccessIterator for Inspect /// An iterator that yields sequential Fibonacci numbers, and stops on overflow. /// /// ``` -/// #![feature(core)] +/// #![feature(iter_unfold)] /// use std::iter::Unfold; /// /// // This iterator will yield up to the last Fibonacci number before the max diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index dc3b06977d6c6..dd60164a114db 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -388,7 +388,7 @@ mod impls { /// that function. Here is an example: /// /// ``` -/// #![feature(core)] +/// #![feature(reflect_marker)] /// use std::marker::Reflect; /// use std::any::Any; /// fn foo(x: &T) { diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 9a00d1071473f..c5203c5111b64 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -274,7 +274,7 @@ impl Option { /// # Examples /// /// ``` - /// # #![feature(core)] + /// # #![feature(as_slice)] /// let mut x = Some("Diamonds"); /// { /// let v = x.as_mut_slice(); diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 0f1831e8314d3..31cdb6093c8d9 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -49,7 +49,7 @@ //! the raw pointer. It doesn't destroy `T` or deallocate any memory. //! //! ``` -//! # #![feature(alloc)] +//! # #![feature(box_raw)] //! use std::boxed; //! //! unsafe { diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 85e1318d7a115..43535ddd1d5c5 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -49,7 +49,7 @@ use mem; /// # Examples /// /// ``` -/// # #![feature(core)] +/// # #![feature(raw)] /// use std::raw::{self, Repr}; /// /// let slice: &[u16] = &[1, 2, 3, 4]; @@ -98,7 +98,7 @@ impl Clone for Slice { /// # Examples /// /// ``` -/// # #![feature(core)] +/// # #![feature(raw)] /// use std::mem; /// use std::raw; /// diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 998657a236dec..7fd845edc3f84 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -420,7 +420,7 @@ impl Result { /// Converts from `Result` to `&mut [T]` (without copying) /// /// ``` - /// # #![feature(core)] + /// # #![feature(as_slice)] /// let mut x: Result<&str, u32> = Ok("Gold"); /// { /// let v = x.as_mut_slice(); diff --git a/src/libcore/simd.rs b/src/libcore/simd.rs index c3447867ce598..7ecd08bea3574 100644 --- a/src/libcore/simd.rs +++ b/src/libcore/simd.rs @@ -19,7 +19,7 @@ //! provided beyond this module. //! //! ```rust -//! # #![feature(core)] +//! # #![feature(core_simd)] //! fn main() { //! use std::simd::f32x4; //! let a = f32x4(40.0, 41.0, 42.0, 43.0); diff --git a/src/libcoretest/lib.rs b/src/libcoretest/lib.rs index 64e34883ee7df..08536e6320475 100644 --- a/src/libcoretest/lib.rs +++ b/src/libcoretest/lib.rs @@ -8,27 +8,45 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364) -#![cfg_attr(stage0, feature(custom_attribute))] - +#![feature(as_unsafe_cell)] +#![feature(borrow_state)] #![feature(box_syntax)] -#![feature(unboxed_closures)] -#![feature(core)] +#![feature(cell_extras)] +#![feature(cmp_partial)] #![feature(const_fn)] -#![feature(test)] -#![feature(rand)] -#![feature(unicode)] -#![feature(std_misc)] -#![feature(libc)] -#![feature(hash)] -#![feature(unique)] -#![feature(step_by)] -#![feature(slice_patterns)] +#![feature(core)] +#![feature(core_float)] +#![feature(float_extras)] #![feature(float_from_str_radix)] -#![feature(cell_extras)] +#![feature(flt2dec)] +#![feature(fmt_radix)] +#![feature(hash_default)] +#![feature(hasher_write)] +#![feature(iter_arith)] +#![feature(iter_arith)] +#![feature(iter_cmp)] #![feature(iter_empty)] +#![feature(iter_idx)] +#![feature(iter_iterate)] +#![feature(iter_min_max)] #![feature(iter_once)] +#![feature(iter_order)] +#![feature(iter_unfold)] +#![feature(libc)] +#![feature(nonzero)] +#![feature(num_bits_bytes)] +#![feature(ptr_as_ref)] +#![feature(rand)] +#![feature(range_inclusive)] +#![feature(raw)] #![feature(result_expect)] +#![feature(slice_bytes)] +#![feature(slice_patterns)] +#![feature(step_by)] +#![feature(test)] +#![feature(unboxed_closures)] +#![feature(unicode)] +#![feature(unique)] extern crate core; extern crate test; diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs index 4b445c84e8f58..04271ed5dd1a1 100644 --- a/src/libcoretest/option.rs +++ b/src/libcoretest/option.rs @@ -9,7 +9,6 @@ // except according to those terms. use core::option::*; -use core::marker; use core::mem; use core::clone::Clone; @@ -81,7 +80,8 @@ fn test_option_dance() { #[test] #[should_panic] fn test_option_too_much_dance() { - let mut y = Some(marker::NoCopy); + struct A; + let mut y = Some(A); let _y2 = y.take().unwrap(); let _y3 = y.take().unwrap(); } diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 606352ea14b22..58cdf1133ec6a 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -28,7 +28,7 @@ #![feature(libc)] #![feature(staged_api)] #![feature(unique)] -#![cfg_attr(test, feature(rustc_private, rand, collections))] +#![cfg_attr(test, feature(rustc_private, rand, vec_push_all))] #[cfg(test)] #[macro_use] extern crate log; diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 6a6adb0db6b45..ec510b4a5bdfb 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -37,7 +37,7 @@ #![feature(staged_api)] #![feature(step_by)] -#![cfg_attr(test, feature(test, rand, rustc_private))] +#![cfg_attr(test, feature(test, rand, rustc_private, iter_order))] #![allow(deprecated)] diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index b557b0f564941..377b60570e5fa 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -40,7 +40,8 @@ #![feature(hash_default)] #![feature(hashmap_hasher)] #![feature(into_cow)] -#![feature(iter_sum)] +#![feature(iter_cmp)] +#![feature(iter_arith)] #![feature(libc)] #![feature(map_in_place)] #![feature(num_bits_bytes)] diff --git a/src/librustc_bitflags/lib.rs b/src/librustc_bitflags/lib.rs index 6d23cad26cb37..b59c24cf12bdb 100644 --- a/src/librustc_bitflags/lib.rs +++ b/src/librustc_bitflags/lib.rs @@ -19,7 +19,7 @@ #![feature(no_std)] #![no_std] #![unstable(feature = "rustc_private")] -#![cfg_attr(test, feature(hash))] +#![cfg_attr(test, feature(hash_default))] //! A typesafe bitmask flag generator. diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index e369ca46b2c02..052ec4897d131 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -33,7 +33,6 @@ #![feature(rustc_private)] #![feature(set_stdio)] #![feature(staged_api)] -#![feature(str_casing)] #![feature(vec_push_all)] extern crate arena; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index d53689bb1d164..c680906dd135b 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -39,7 +39,6 @@ #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] #![feature(staged_api)] -#![feature(str_casing)] #![feature(str_char)] extern crate syntax; diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 978fa4e745b99..a1e1b395d987d 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -30,7 +30,7 @@ #![feature(const_fn)] #![feature(fs)] #![feature(iter_cmp)] -#![feature(iter_sum)] +#![feature(iter_arith)] #![feature(iter_unfold)] #![feature(libc)] #![feature(once_new)] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index f204fa2b1fd01..764910100360a 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -79,7 +79,7 @@ This API is completely unstable and subject to change. #![feature(box_syntax)] #![feature(drain)] #![feature(iter_cmp)] -#![feature(iter_sum)] +#![feature(iter_arith)] #![feature(quote)] #![feature(ref_slice)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_unicode/lib.rs b/src/librustc_unicode/lib.rs index 750df19047d73..b420444d1f5c8 100644 --- a/src/librustc_unicode/lib.rs +++ b/src/librustc_unicode/lib.rs @@ -38,7 +38,7 @@ #![feature(core_prelude)] #![feature(core_slice_ext)] #![feature(core_str_ext)] -#![feature(iter_sum)] +#![feature(iter_arith)] #![feature(lang_items)] #![feature(no_std)] #![feature(staged_api)] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 38cc120698431..9db9af32baa15 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -22,18 +22,21 @@ #![feature(box_patterns)] #![feature(box_syntax)] -#![feature(collections)] +#![feature(dynamic_lib)] #![feature(exit_status)] -#![feature(set_stdio)] #![feature(libc)] +#![feature(owned_ascii_ext)] +#![feature(path_ext)] +#![feature(path_relative_from)] #![feature(rustc_private)] +#![feature(set_stdio)] +#![feature(slice_extras)] +#![feature(slice_patterns)] #![feature(staged_api)] -#![feature(std_misc)] +#![feature(subslice_offset)] #![feature(test)] #![feature(unicode)] -#![feature(path_ext)] -#![feature(path_relative_from)] -#![feature(slice_patterns)] +#![feature(vec_push_all)] extern crate arena; extern crate getopts; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index fb510ed678271..9f9435f412339 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -149,8 +149,8 @@ #![feature(vec_push_all)] #![feature(wrapping)] #![feature(zero_one)] -#![cfg_attr(test, feature(float_from_str_radix))] -#![cfg_attr(test, feature(test, rustc_private))] +#![cfg_attr(test, feature(float_from_str_radix, range_inclusive, float_extras))] +#![cfg_attr(test, feature(test, rustc_private, float_consts))] // Don't link to std. We are std. #![no_std] diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 76b07999280d0..f5b6650a49833 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -14,7 +14,7 @@ //! # Examples //! //! ``` -//! # #![feature(std_misc)] +//! # #![feature(future)] //! use std::sync::Future; //! //! // a fake, for now diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 5f77ee2054591..1d63014295922 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -85,6 +85,8 @@ use sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; /// To recover from a poisoned mutex: /// /// ``` +/// #![feature(sync_poison)] +/// /// use std::sync::{Arc, Mutex}; /// use std::thread; /// diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index 0278a6c95b982..dc9e467a8b135 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -25,7 +25,7 @@ use sync::{Mutex, Condvar}; /// # Examples /// /// ``` -/// # #![feature(std_misc)] +/// # #![feature(semaphore)] /// use std::sync::Semaphore; /// /// // Create a semaphore that represents 5 resources diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 4664968913466..1507226c3a133 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -41,11 +41,12 @@ #![feature(fnbox)] #![feature(iter_cmp)] #![feature(libc)] +#![feature(rt)] #![feature(rustc_private)] #![feature(set_stdio)] #![feature(slice_extras)] #![feature(staged_api)] -#![feature(std_misc)] +#![feature(thunk)] extern crate getopts; extern crate serialize; diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs index e79462a4aafe2..707493e85189c 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -11,7 +11,7 @@ #![deny(warnings)] #![feature(exit_status)] -#![feature(iter_sum)] +#![feature(iter_arith)] #![feature(path_relative_from)] #![feature(rustc_private)] #![feature(rustdoc)] diff --git a/src/test/auxiliary/linkage-visibility.rs b/src/test/auxiliary/linkage-visibility.rs index 9196a156ad1c9..ce3360787136a 100644 --- a/src/test/auxiliary/linkage-visibility.rs +++ b/src/test/auxiliary/linkage-visibility.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(std_misc)] +#![feature(dynamic_lib)] // We're testing linkage visibility; the compiler warns us, but we want to // do the runtime check that these functions aren't exported. diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index eebf6feaffac3..d2537e09901cb 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -11,6 +11,7 @@ // ignore-pretty very bad with line comments #![feature(unboxed_closures, rand, std_misc, collections, duration, duration_span)] +#![feature(bitset)] extern crate collections; extern crate rand; diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 95d74c6aa7f45..3cc03f5218ceb 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -10,7 +10,7 @@ // Microbenchmarks for various functions in std and extra -#![feature(rand, collections, std_misc, duration, duration_span)] +#![feature(rand, vec_push_all, duration, duration_span)] use std::iter::repeat; use std::mem::swap; diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index 93e3394097bc5..24ecaf4b02471 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -17,7 +17,7 @@ // no-pretty-expanded FIXME #15189 -#![feature(duration, duration_span, std_misc)] +#![feature(duration, duration_span, future)] use std::env; use std::sync::{Arc, Future, Mutex, Condvar}; diff --git a/src/test/bench/shootout-k-nucleotide.rs b/src/test/bench/shootout-k-nucleotide.rs index 0cbef937e726d..8ae07558c168f 100644 --- a/src/test/bench/shootout-k-nucleotide.rs +++ b/src/test/bench/shootout-k-nucleotide.rs @@ -40,7 +40,7 @@ // ignore-android: FIXME(#10393) hangs without output -#![feature(box_syntax, std_misc, collections)] +#![feature(box_syntax, owned_ascii_ext, vec_push_all)] use std::ascii::OwnedAsciiExt; use std::env; diff --git a/src/test/bench/shootout-mandelbrot.rs b/src/test/bench/shootout-mandelbrot.rs index 4ae788454e3e8..232d6b414f580 100644 --- a/src/test/bench/shootout-mandelbrot.rs +++ b/src/test/bench/shootout-mandelbrot.rs @@ -38,7 +38,7 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED // OF THE POSSIBILITY OF SUCH DAMAGE. -#![feature(simd, core)] +#![feature(core_simd, core)] // ignore-pretty very bad with line comments diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index cb89f51210ca7..aa40f6f868c30 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -40,7 +40,7 @@ // no-pretty-expanded FIXME #15189 -#![feature(core)] +#![feature(iter_cmp)] use std::iter::repeat; use std::sync::Arc; diff --git a/src/test/bench/shootout-spectralnorm.rs b/src/test/bench/shootout-spectralnorm.rs index 6ddf232810461..1598b20922338 100644 --- a/src/test/bench/shootout-spectralnorm.rs +++ b/src/test/bench/shootout-spectralnorm.rs @@ -41,14 +41,11 @@ // no-pretty-expanded FIXME #15189 #![allow(non_snake_case)] -#![feature(unboxed_closures, core, os, scoped)] +#![feature(unboxed_closures, iter_arith, core_simd, scoped)] use std::iter::repeat; use std::thread; -use std::mem; -use std::os; use std::env; -use std::raw::Repr; use std::simd::f64x2; fn main() { diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index d7e556a124fe1..6a39a6db0c728 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -10,7 +10,7 @@ // Microbenchmark for the smallintmap library -#![feature(collections, duration, duration_span)] +#![feature(vecmap, duration, duration_span)] use std::collections::VecMap; use std::env; diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index babae4d149f52..3bd7b78125112 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax, duration, duration_span, collections)] +#![feature(box_syntax, duration, duration_span, vec_push_all)] use std::env; use std::thread; diff --git a/src/test/compile-fail/feature-gate-simd-ffi.rs b/src/test/compile-fail/feature-gate-simd-ffi.rs index dcd7a0ded812f..32c50b1b8c159 100644 --- a/src/test/compile-fail/feature-gate-simd-ffi.rs +++ b/src/test/compile-fail/feature-gate-simd-ffi.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(simd, core)] +#![feature(simd, core_simd)] #![allow(dead_code)] use std::simd::f32x4; diff --git a/src/test/compile-fail/lint-dead-code-4.rs b/src/test/compile-fail/lint-dead-code-4.rs index 3a9baecb9c60e..529113ace4ef9 100644 --- a/src/test/compile-fail/lint-dead-code-4.rs +++ b/src/test/compile-fail/lint-dead-code-4.rs @@ -11,15 +11,10 @@ #![allow(unused_variables)] #![allow(non_camel_case_types)] #![deny(dead_code)] -#![feature(libc)] -#![feature(core)] - -extern crate libc; struct Foo { x: usize, b: bool, //~ ERROR: struct field is never used - marker: std::marker::NoCopy } fn field_read(f: Foo) -> usize { @@ -50,7 +45,7 @@ struct Bar { #[repr(C)] struct Baz { - x: libc::c_uint + x: u32, } fn field_match_in_let(f: Bar) -> bool { @@ -59,7 +54,7 @@ fn field_match_in_let(f: Bar) -> bool { } fn main() { - field_read(Foo { x: 1, b: false, marker: std::marker::NoCopy }); + field_read(Foo { x: 1, b: false }); field_match_in_patterns(XYZ::Z); field_match_in_let(Bar { x: 42, b: true, _guard: () }); let _ = Baz { x: 0 }; diff --git a/src/test/compile-fail/lint-exceeding-bitshifts.rs b/src/test/compile-fail/lint-exceeding-bitshifts.rs index 1f70828e411ef..5867bc2f09deb 100644 --- a/src/test/compile-fail/lint-exceeding-bitshifts.rs +++ b/src/test/compile-fail/lint-exceeding-bitshifts.rs @@ -12,7 +12,7 @@ #![deny(exceeding_bitshifts)] #![allow(unused_variables)] #![allow(dead_code)] -#![feature(core, negate_unsigned)] +#![feature(num_bits_bytes, negate_unsigned)] fn main() { let n = 1u8 << 7; diff --git a/src/test/debuginfo/constant-debug-locs.rs b/src/test/debuginfo/constant-debug-locs.rs index 8032b53e9dd7c..ec5a6fa3d3f16 100644 --- a/src/test/debuginfo/constant-debug-locs.rs +++ b/src/test/debuginfo/constant-debug-locs.rs @@ -14,8 +14,8 @@ #![allow(dead_code, unused_variables)] #![omit_gdb_pretty_printer_section] -#![feature(std_misc, core)] #![feature(const_fn)] +#![feature(static_mutex)] // This test makes sure that the compiler doesn't crash when trying to assign // debug locations to const-expressions. diff --git a/src/test/debuginfo/simd.rs b/src/test/debuginfo/simd.rs index 7b337ba2cc8a6..6bc8892a83a69 100644 --- a/src/test/debuginfo/simd.rs +++ b/src/test/debuginfo/simd.rs @@ -42,7 +42,7 @@ #![allow(unused_variables)] #![omit_gdb_pretty_printer_section] -#![feature(core)] +#![feature(core_simd)] use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2}; diff --git a/src/test/run-make/extern-fn-reachable/main.rs b/src/test/run-make/extern-fn-reachable/main.rs index 244f32b8ee5fc..b53a870e2001c 100644 --- a/src/test/run-make/extern-fn-reachable/main.rs +++ b/src/test/run-make/extern-fn-reachable/main.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(std_misc)] +#![feature(dynamic_lib)] use std::dynamic_lib::DynamicLibrary; use std::path::Path; diff --git a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs b/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs index 81ed446595ab0..f58d2cd8f91d8 100644 --- a/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs +++ b/src/test/run-make/intrinsic-unreachable/exit-unreachable.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(asm, core)] +#![feature(asm, core_intrinsics)] #![crate_type="lib"] use std::intrinsics; diff --git a/src/test/run-make/volatile-intrinsics/main.rs b/src/test/run-make/volatile-intrinsics/main.rs index 217dee4b881c7..6c6afdc13030c 100644 --- a/src/test/run-make/volatile-intrinsics/main.rs +++ b/src/test/run-make/volatile-intrinsics/main.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(core_intrinsics)] use std::intrinsics::{volatile_load, volatile_store}; diff --git a/src/test/run-pass/binary-heap-panic-safe.rs b/src/test/run-pass/binary-heap-panic-safe.rs index 4888a8b84fc42..61a7fab130928 100644 --- a/src/test/run-pass/binary-heap-panic-safe.rs +++ b/src/test/run-pass/binary-heap-panic-safe.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(std_misc, collections, catch_panic, rand)] +#![feature(std_misc, collections, catch_panic, rand, sync_poison)] use std::__rand::{thread_rng, Rng}; use std::thread; diff --git a/src/test/run-pass/bitv-perf-test.rs b/src/test/run-pass/bitv-perf-test.rs index c9a2e07dd8398..3ab154356c4b6 100644 --- a/src/test/run-pass/bitv-perf-test.rs +++ b/src/test/run-pass/bitv-perf-test.rs @@ -10,16 +10,14 @@ // pretty-expanded FIXME #23616 -#![allow(unknown_features)] -#![feature(box_syntax, collections)] +#![feature(bitvec)] -extern crate collections; use std::collections::BitVec; fn bitv_test() { - let mut v1: Box<_> = box BitVec::from_elem(31, false); - let v2: Box<_> = box BitVec::from_elem(31, true); - v1.union(&*v2); + let mut v1 = BitVec::from_elem(31, false); + let v2 = BitVec::from_elem(31, true); + v1.union(&v2); } pub fn main() { diff --git a/src/test/run-pass/deriving-hash.rs b/src/test/run-pass/deriving-hash.rs index b5fb5205d7c38..ba1d8228863ad 100644 --- a/src/test/run-pass/deriving-hash.rs +++ b/src/test/run-pass/deriving-hash.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![feature(hash)] +#![feature(hash_default)] use std::hash::{Hash, SipHasher}; diff --git a/src/test/run-pass/discriminant_value.rs b/src/test/run-pass/discriminant_value.rs index 217e696f09538..13257529ed9f8 100644 --- a/src/test/run-pass/discriminant_value.rs +++ b/src/test/run-pass/discriminant_value.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(core, core_intrinsics)] extern crate core; use core::intrinsics::discriminant_value; diff --git a/src/test/run-pass/dst-coerce-custom.rs b/src/test/run-pass/dst-coerce-custom.rs index aa28ae00e2772..6eb01e879df57 100644 --- a/src/test/run-pass/dst-coerce-custom.rs +++ b/src/test/run-pass/dst-coerce-custom.rs @@ -10,7 +10,7 @@ // Test a very simple custom DST coercion. -#![feature(core)] +#![feature(unsize, coerce_unsized)] use std::ops::CoerceUnsized; use std::marker::Unsize; diff --git a/src/test/run-pass/enum-null-pointer-opt.rs b/src/test/run-pass/enum-null-pointer-opt.rs index 499d131947a38..dd88dc11ea70e 100644 --- a/src/test/run-pass/enum-null-pointer-opt.rs +++ b/src/test/run-pass/enum-null-pointer-opt.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(core)] +#![feature(nonzero, core)] extern crate core; diff --git a/src/test/run-pass/fat-ptr-cast.rs b/src/test/run-pass/fat-ptr-cast.rs index 0926386ef93c4..58296c3f95ef9 100644 --- a/src/test/run-pass/fat-ptr-cast.rs +++ b/src/test/run-pass/fat-ptr-cast.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(raw)] use std::mem; use std::raw; diff --git a/src/test/run-pass/for-loop-no-std.rs b/src/test/run-pass/for-loop-no-std.rs index 6deaec1905960..a1bd77a74f725 100644 --- a/src/test/run-pass/for-loop-no-std.rs +++ b/src/test/run-pass/for-loop-no-std.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(lang_items, start, no_std, core, collections)] +#![feature(lang_items, start, no_std, core_slice_ext, core, collections)] #![no_std] extern crate std as other; diff --git a/src/test/run-pass/format-no-std.rs b/src/test/run-pass/format-no-std.rs index 9204cdfd755b6..1452cefbd5c2b 100644 --- a/src/test/run-pass/format-no-std.rs +++ b/src/test/run-pass/format-no-std.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - #![feature(lang_items, start, no_std, core, collections)] #![no_std] diff --git a/src/test/run-pass/into-iterator-type-inference-shift.rs b/src/test/run-pass/into-iterator-type-inference-shift.rs index 9ccf1c3bbb803..7ec18ef127690 100644 --- a/src/test/run-pass/into-iterator-type-inference-shift.rs +++ b/src/test/run-pass/into-iterator-type-inference-shift.rs @@ -15,10 +15,6 @@ // pretty-expanded FIXME #23616 -#![feature(core)] - -use std::u8; - trait IntoIterator { type Iter: Iterator; @@ -35,7 +31,7 @@ impl IntoIterator for I where I: Iterator { fn desugared_for_loop_bad(byte: u8) -> u8 { let mut result = 0; - let mut x = IntoIterator::into_iter(0..u8::BITS); + let mut x = IntoIterator::into_iter(0..8); let mut y = Iterator::next(&mut x); let mut z = y.unwrap(); byte >> z; diff --git a/src/test/run-pass/intrinsic-assume.rs b/src/test/run-pass/intrinsic-assume.rs index ff7d799f64c5f..41ef62b0ced3d 100644 --- a/src/test/run-pass/intrinsic-assume.rs +++ b/src/test/run-pass/intrinsic-assume.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(core)] +#![feature(core_intrinsics)] use std::intrinsics::assume; diff --git a/src/test/run-pass/intrinsic-move-val-cleanups.rs b/src/test/run-pass/intrinsic-move-val-cleanups.rs index bc7a654f867ea..9fd4f2133b70d 100644 --- a/src/test/run-pass/intrinsic-move-val-cleanups.rs +++ b/src/test/run-pass/intrinsic-move-val-cleanups.rs @@ -18,7 +18,7 @@ // introduce temporaries that require cleanup, and SOURCE panics, then // make sure the cleanups still occur. -#![feature(core, std_misc)] +#![feature(core_intrinsics, sync_poison)] use std::cell::RefCell; use std::intrinsics; diff --git a/src/test/run-pass/intrinsic-unreachable.rs b/src/test/run-pass/intrinsic-unreachable.rs index a86fc110ae4eb..0ce446e445c73 100644 --- a/src/test/run-pass/intrinsic-unreachable.rs +++ b/src/test/run-pass/intrinsic-unreachable.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(core)] +#![feature(core_intrinsics)] use std::intrinsics; diff --git a/src/test/run-pass/issue-11709.rs b/src/test/run-pass/issue-11709.rs index 3ad78f088f9c9..3eaa5632395b7 100644 --- a/src/test/run-pass/issue-11709.rs +++ b/src/test/run-pass/issue-11709.rs @@ -15,7 +15,7 @@ // when this bug was opened. The cases where the compiler // panics before the fix have a comment. -#![feature(std_misc)] +#![feature(thunk)] use std::thunk::Thunk; diff --git a/src/test/run-pass/issue-11736.rs b/src/test/run-pass/issue-11736.rs index b4621a2d053b1..9b30305a1969d 100644 --- a/src/test/run-pass/issue-11736.rs +++ b/src/test/run-pass/issue-11736.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(collections)] +#![feature(bitvec)] use std::collections::BitVec; diff --git a/src/test/run-pass/issue-11958.rs b/src/test/run-pass/issue-11958.rs index def85b4766783..e0c43422c2823 100644 --- a/src/test/run-pass/issue-11958.rs +++ b/src/test/run-pass/issue-11958.rs @@ -11,7 +11,7 @@ // pretty-expanded FIXME #23616 #![forbid(warnings)] -#![feature(std_misc)] +#![feature(thunk)] // Pretty printing tests complain about `use std::predule::*` #![allow(unused_imports)] diff --git a/src/test/run-pass/issue-13494.rs b/src/test/run-pass/issue-13494.rs index 71897ea68c209..e94368925abee 100644 --- a/src/test/run-pass/issue-13494.rs +++ b/src/test/run-pass/issue-13494.rs @@ -11,9 +11,7 @@ // This test may not always fail, but it can be flaky if the race it used to // expose is still present. -// pretty-expanded FIXME #23616 - -#![feature(std_misc)] +#![feature(mpsc_select)] use std::sync::mpsc::{channel, Sender, Receiver}; use std::thread; diff --git a/src/test/run-pass/issue-13763.rs b/src/test/run-pass/issue-13763.rs index e11270c94ca54..0ea38596335d8 100644 --- a/src/test/run-pass/issue-13763.rs +++ b/src/test/run-pass/issue-13763.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(core)] +#![feature(num_bits_bytes)] use std::u8; diff --git a/src/test/run-pass/issue-15673.rs b/src/test/run-pass/issue-15673.rs index c478ca041148a..ff9a17323e433 100644 --- a/src/test/run-pass/issue-15673.rs +++ b/src/test/run-pass/issue-15673.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(core)] +#![feature(iter_arith)] fn main() { let x: [u64; 3] = [1, 2, 3]; diff --git a/src/test/run-pass/issue-16530.rs b/src/test/run-pass/issue-16530.rs index bc144ee33306d..1f96f071e9d11 100644 --- a/src/test/run-pass/issue-16530.rs +++ b/src/test/run-pass/issue-16530.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(hash)] +#![feature(hash_default)] use std::hash::{SipHasher, hash}; diff --git a/src/test/run-pass/issue-17897.rs b/src/test/run-pass/issue-17897.rs index cf8c54fdd8086..227c81e2766fd 100644 --- a/src/test/run-pass/issue-17897.rs +++ b/src/test/run-pass/issue-17897.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(unboxed_closures, std_misc)] +#![feature(thunk)] use std::thunk::Thunk; diff --git a/src/test/run-pass/issue-18188.rs b/src/test/run-pass/issue-18188.rs index 059d25173c2ad..5bcb052282c19 100644 --- a/src/test/run-pass/issue-18188.rs +++ b/src/test/run-pass/issue-18188.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(unboxed_closures, std_misc)] +#![feature(thunk)] use std::thunk::Thunk; diff --git a/src/test/run-pass/issue-21058.rs b/src/test/run-pass/issue-21058.rs index c384757c5e4fb..9e8bfc884c984 100644 --- a/src/test/run-pass/issue-21058.rs +++ b/src/test/run-pass/issue-21058.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - -#![feature(core)] +#![feature(core_intrinsics)] struct NT(str); struct DST { a: u32, b: str } diff --git a/src/test/run-pass/issue-2190-1.rs b/src/test/run-pass/issue-2190-1.rs index 5c84c30aa7fa3..eeca4498328d3 100644 --- a/src/test/run-pass/issue-2190-1.rs +++ b/src/test/run-pass/issue-2190-1.rs @@ -10,7 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(std_misc)] +#![feature(thunk)] use std::thread::Builder; use std::thunk::Thunk; diff --git a/src/test/run-pass/issue-23037.rs b/src/test/run-pass/issue-23037.rs index 5257daa047af8..a8abbda32bdfc 100644 --- a/src/test/run-pass/issue-23037.rs +++ b/src/test/run-pass/issue-23037.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(core_simd)] use std::simd::i32x4; fn main() { diff --git a/src/test/run-pass/issue-23550.rs b/src/test/run-pass/issue-23550.rs index 9b5ca23565e0d..4b6d593f592d9 100644 --- a/src/test/run-pass/issue-23550.rs +++ b/src/test/run-pass/issue-23550.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(core_intrinsics)] #![allow(warnings)] use std::intrinsics; diff --git a/src/test/run-pass/issue-6898.rs b/src/test/run-pass/issue-6898.rs index 3138aad2c8cc9..8ea0804af18bf 100644 --- a/src/test/run-pass/issue-6898.rs +++ b/src/test/run-pass/issue-6898.rs @@ -10,9 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(core)] - -use std::intrinsics; +use std::mem; /// Returns the size of a type pub fn size_of() -> usize { @@ -32,7 +30,7 @@ pub trait TypeInfo { impl TypeInfo for T { /// The size of the type in bytes. fn size_of(_lame_type_hint: Option) -> usize { - unsafe { intrinsics::size_of::() } + mem::size_of::() } /// Returns the size of the type of `self` in bytes. diff --git a/src/test/run-pass/iter-cloned-type-inference.rs b/src/test/run-pass/iter-cloned-type-inference.rs index 59f7569d8c62b..e3351bda3354d 100644 --- a/src/test/run-pass/iter-cloned-type-inference.rs +++ b/src/test/run-pass/iter-cloned-type-inference.rs @@ -11,8 +11,7 @@ // Test to see that the element type of .cloned() can be inferred // properly. Previously this would fail to deduce the type of `sum`. - -#![feature(core)] +#![feature(iter_arith)] fn square_sum(v: &[i64]) -> i64 { let sum: i64 = v.iter().cloned().sum(); diff --git a/src/test/run-pass/linkage-visibility.rs b/src/test/run-pass/linkage-visibility.rs index b8ad7162d2868..e6eaefb049080 100644 --- a/src/test/run-pass/linkage-visibility.rs +++ b/src/test/run-pass/linkage-visibility.rs @@ -13,8 +13,6 @@ // ignore-windows: std::dynamic_lib does not work on Windows well // ignore-musl -#![feature(std_misc)] - extern crate linkage_visibility as foo; pub fn main() { diff --git a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs index 5b104d4bb0c7e..405a3549cf18c 100644 --- a/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs +++ b/src/test/run-pass/method-mut-self-modifies-mut-slice-lvalue.rs @@ -13,7 +13,7 @@ // temporary. Issue #19147. -#![feature(core)] +#![feature(slice_bytes)] use std::slice; diff --git a/src/test/run-pass/minmax-stability-issue-23687.rs b/src/test/run-pass/minmax-stability-issue-23687.rs index 86dd1a04532b4..62bde45cd3dc0 100644 --- a/src/test/run-pass/minmax-stability-issue-23687.rs +++ b/src/test/run-pass/minmax-stability-issue-23687.rs @@ -8,7 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(iter_min_max, cmp_partial, iter_cmp)] + use std::fmt::Debug; use std::cmp::{self, PartialOrd, Ordering}; use std::iter::MinMaxResult::MinMax; diff --git a/src/test/run-pass/new-box-syntax.rs b/src/test/run-pass/new-box-syntax.rs index 95168b1bff788..b5a54a90ae758 100644 --- a/src/test/run-pass/new-box-syntax.rs +++ b/src/test/run-pass/new-box-syntax.rs @@ -13,8 +13,8 @@ /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -#![allow(unknown_features)] -#![feature(box_syntax, alloc)] +#![allow(warnings)] +#![feature(box_syntax, box_heap)] // Tests that the new `box` syntax works with unique pointers. diff --git a/src/test/run-pass/realloc-16687.rs b/src/test/run-pass/realloc-16687.rs index cd9cc0901202c..a9bd967ca765a 100644 --- a/src/test/run-pass/realloc-16687.rs +++ b/src/test/run-pass/realloc-16687.rs @@ -13,7 +13,7 @@ // Ideally this would be revised to use no_std, but for now it serves // well enough to reproduce (and illustrate) the bug from #16687. -#![feature(alloc)] +#![feature(heap_api, alloc, oom)] extern crate alloc; diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index db543116d17a5..2b2dcb6efb5d4 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(start, std_misc)] +#![feature(catch_panic, start)] use std::ffi::CStr; use std::process::{Command, Output}; -use std::rt::unwind::try; +use std::thread; use std::str; #[start] @@ -22,8 +22,8 @@ fn start(argc: isize, argv: *const *const u8) -> isize { match **argv.offset(1) as char { '1' => {} '2' => println!("foo"), - '3' => assert!(try(|| {}).is_ok()), - '4' => assert!(try(|| panic!()).is_err()), + '3' => assert!(thread::catch_panic(|| {}).is_ok()), + '4' => assert!(thread::catch_panic(|| panic!()).is_err()), '5' => assert!(Command::new("test").spawn().is_err()), _ => panic!() } diff --git a/src/test/run-pass/send-is-not-static-par-for.rs b/src/test/run-pass/send-is-not-static-par-for.rs index 5f0902d34d3e8..e40f4d30eb978 100644 --- a/src/test/run-pass/send-is-not-static-par-for.rs +++ b/src/test/run-pass/send-is-not-static-par-for.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - #![feature(core, std_misc, scoped)] use std::thread; use std::sync::Mutex; diff --git a/src/test/run-pass/simd-binop.rs b/src/test/run-pass/simd-binop.rs index 3ebf2a87361f6..4f5119f6a84e9 100644 --- a/src/test/run-pass/simd-binop.rs +++ b/src/test/run-pass/simd-binop.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![feature(core)] +#![feature(core_simd)] use std::simd::{i32x4, f32x4, u32x4}; diff --git a/src/test/run-pass/simd-issue-10604.rs b/src/test/run-pass/simd-issue-10604.rs index 8dca78b28e802..c3eef0f9c3217 100644 --- a/src/test/run-pass/simd-issue-10604.rs +++ b/src/test/run-pass/simd-issue-10604.rs @@ -10,8 +10,7 @@ // pretty-expanded FIXME #23616 -#![feature(core)] -#![feature(simd)] +#![feature(core_simd)] pub fn main() { let _o = None::; diff --git a/src/test/run-pass/slice-of-zero-size-elements.rs b/src/test/run-pass/slice-of-zero-size-elements.rs index 6fe510586c748..ab22b820503af 100644 --- a/src/test/run-pass/slice-of-zero-size-elements.rs +++ b/src/test/run-pass/slice-of-zero-size-elements.rs @@ -10,7 +10,7 @@ // compile-flags: -C debug-assertions -#![feature(core)] +#![feature(iter_to_slice)] use std::slice; diff --git a/src/test/run-pass/std-sync-right-kind-impls.rs b/src/test/run-pass/std-sync-right-kind-impls.rs index 36314c5e14ac2..b8e05c06c83b7 100644 --- a/src/test/run-pass/std-sync-right-kind-impls.rs +++ b/src/test/run-pass/std-sync-right-kind-impls.rs @@ -10,7 +10,8 @@ // pretty-expanded FIXME #23616 -#![feature(std_misc, alloc, static_condvar)] +#![feature(static_mutex, static_rwlock, static_condvar)] +#![feature(arc_weak, semaphore)] use std::sync; diff --git a/src/test/run-pass/sync-send-iterators-in-libcollections.rs b/src/test/run-pass/sync-send-iterators-in-libcollections.rs index 7a84578859229..0ee04c4463b0f 100644 --- a/src/test/run-pass/sync-send-iterators-in-libcollections.rs +++ b/src/test/run-pass/sync-send-iterators-in-libcollections.rs @@ -10,9 +10,9 @@ // pretty-expanded FIXME #23616 -#![allow(unused_mut)] +#![allow(warnings)] #![feature(collections)] -#![feature(collections_drain)] +#![feature(drain, enumset, collections_bound, btree_range, vecmap)] extern crate collections; diff --git a/src/test/run-pass/sync-send-iterators-in-libcore.rs b/src/test/run-pass/sync-send-iterators-in-libcore.rs index cd99b39fdd068..8dda2365ac704 100644 --- a/src/test/run-pass/sync-send-iterators-in-libcore.rs +++ b/src/test/run-pass/sync-send-iterators-in-libcore.rs @@ -18,6 +18,7 @@ #![feature(iter_once)] use std::iter::{empty, once, range_inclusive, repeat, Unfold}; +>>>>>>> Fallout in tests and docs from feature renamings fn is_sync(_: T) where T: Sync {} fn is_send(_: T) where T: Send {} diff --git a/src/test/run-pass/tydesc-name.rs b/src/test/run-pass/tydesc-name.rs index 1534c301c996c..4a169c0a384aa 100644 --- a/src/test/run-pass/tydesc-name.rs +++ b/src/test/run-pass/tydesc-name.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![feature(core)] +#![feature(core_intrinsics)] use std::intrinsics::type_name; diff --git a/src/test/run-pass/typeid-intrinsic.rs b/src/test/run-pass/typeid-intrinsic.rs index 9741ed0fddec8..feb43dfb9ade2 100644 --- a/src/test/run-pass/typeid-intrinsic.rs +++ b/src/test/run-pass/typeid-intrinsic.rs @@ -12,7 +12,7 @@ // aux-build:typeid-intrinsic2.rs -#![feature(hash, core)] +#![feature(hash_default, core_intrinsics)] extern crate typeid_intrinsic as other1; extern crate typeid_intrinsic2 as other2; diff --git a/src/test/run-pass/ufcs-polymorphic-paths.rs b/src/test/run-pass/ufcs-polymorphic-paths.rs index a8240dfbd1f8b..27f11d0411c47 100644 --- a/src/test/run-pass/ufcs-polymorphic-paths.rs +++ b/src/test/run-pass/ufcs-polymorphic-paths.rs @@ -9,7 +9,8 @@ // except according to those terms. -#![feature(collections, rand, into_cow)] +#![feature(collections, rand, into_cow, map_in_place, bitvec)] +#![allow(warnings)] use std::borrow::{Cow, IntoCow}; use std::collections::BitVec; diff --git a/src/test/run-pass/unfold-cross-crate.rs b/src/test/run-pass/unfold-cross-crate.rs index 938b5dc616729..9d5383fe0603f 100644 --- a/src/test/run-pass/unfold-cross-crate.rs +++ b/src/test/run-pass/unfold-cross-crate.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(iter_unfold)] use std::iter::Unfold; diff --git a/src/test/run-pass/unsized3.rs b/src/test/run-pass/unsized3.rs index 07eec85672aae..6d378cb294e32 100644 --- a/src/test/run-pass/unsized3.rs +++ b/src/test/run-pass/unsized3.rs @@ -11,8 +11,8 @@ // Test structs with always-unsized fields. -#![allow(unknown_features)] -#![feature(box_syntax, core)] +#![allow(warnings)] +#![feature(box_syntax, unsize, raw)] use std::mem; use std::raw; diff --git a/src/test/run-pass/vec-concat.rs b/src/test/run-pass/vec-concat.rs index 658c35ae8d5ea..25c1cfe1f4d42 100644 --- a/src/test/run-pass/vec-concat.rs +++ b/src/test/run-pass/vec-concat.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(collections)] +#![feature(vec_push_all)] use std::vec; diff --git a/src/test/run-pass/vec-macro-no-std.rs b/src/test/run-pass/vec-macro-no-std.rs index 948fe28cc621a..cf3a8796d32c9 100644 --- a/src/test/run-pass/vec-macro-no-std.rs +++ b/src/test/run-pass/vec-macro-no-std.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - -#![feature(lang_items, start, no_std, core, libc, collections)] +#![feature(lang_items, start, no_std, core, core_slice_ext, libc, collections)] #![no_std] extern crate std as other; diff --git a/src/test/run-pass/vector-sort-panic-safe.rs b/src/test/run-pass/vector-sort-panic-safe.rs index 209fe22207f49..42b05aeea2910 100644 --- a/src/test/run-pass/vector-sort-panic-safe.rs +++ b/src/test/run-pass/vector-sort-panic-safe.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![feature(rand, core)] +#![feature(rand, num_bits_bytes)] #![feature(const_fn)] use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/test/run-pass/wrapping-int-api.rs b/src/test/run-pass/wrapping-int-api.rs index e195d624fe529..48eea1206230e 100644 --- a/src/test/run-pass/wrapping-int-api.rs +++ b/src/test/run-pass/wrapping-int-api.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core)] +#![feature(num_wrapping)] // Test inherent wrapping_* methods for {i,u}{size,8,16,32,64}. From 02a8d5b57057a5c76667e85e92ea2c8a95303150 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 17:59:02 -0700 Subject: [PATCH 06/48] std: Deprecate the RandomAccessIterator trait This trait has not proven itself over time as being core and fundamentally useful to iterators, so it's being deprecated to allow time to iterate on it out of tree. --- src/libcore/iter.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 30c2d3fcb6d5d..9d7585993c33b 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1230,6 +1230,10 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I { #[unstable(feature = "iter_idx", reason = "not widely used, may be better decomposed into Index \ and ExactSizeIterator")] +#[deprecated(since = "1.2.0", + reason = "trait has not proven itself as a widely useful \ + abstraction for iterators, and more time may be needed \ + for iteration on the design")] pub trait RandomAccessIterator: Iterator { /// Returns the number of indexable elements. At most `std::usize::MAX` /// elements are indexable, even if the iterator represents a longer range. From 669d1cd9e28aa6a6aa181c29b9d68edd33491f6f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:01:59 -0700 Subject: [PATCH 07/48] std: Deprecate iter::{Unfold, Iterate} Neither of these iterators has seen enough usage to justify their position in the standard library, so these unstable iterators are being slated for deletion. --- src/libcore/iter.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 9d7585993c33b..053a85a7c51a6 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -2542,6 +2542,9 @@ impl RandomAccessIterator for Inspect /// ``` #[unstable(feature = "iter_unfold")] #[derive(Clone)] +#[deprecated(since = "1.2.0", + reason = "has gained enough traction to retain its position \ + in the standard library")] pub struct Unfold { f: F, /// Internal state that will be passed to the closure on the next iteration @@ -2550,6 +2553,9 @@ pub struct Unfold { } #[unstable(feature = "iter_unfold")] +#[deprecated(since = "1.2.0", + reason = "has gained enough traction to retain its position \ + in the standard library")] impl Unfold where F: FnMut(&mut St) -> Option { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the closure @@ -2995,11 +3001,17 @@ type IterateState = (F, Option, bool); /// An iterator that repeatedly applies a given function, starting /// from a given seed value. #[unstable(feature = "iter_iterate")] +#[deprecated(since = "1.2.0", + reason = "has gained enough traction to retain its position \ + in the standard library")] pub type Iterate = Unfold, fn(&mut IterateState) -> Option>; /// Creates a new iterator that produces an infinite sequence of /// repeated applications of the given function `f`. #[unstable(feature = "iter_iterate")] +#[deprecated(since = "1.2.0", + reason = "has gained enough traction to retain its position \ + in the standard library")] pub fn iterate(seed: T, f: F) -> Iterate where T: Clone, F: FnMut(T) -> T, From 153de4c5d9e7846a029f9c79fb9940f72f5961f9 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:03:13 -0700 Subject: [PATCH 08/48] std: Deprecate the copy_{,mut_}lifetime functions Unsafe patterns such as `slice::from_raw_parts` and `CStr::from_ptr` have shown that dealing with lifetimes, while useful, is often a hindrance. Consequently these functions are rarely called today and are being deprecated. --- src/libcore/mem.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 4e9613454ab97..15e7cdbde408d 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -462,6 +462,10 @@ pub unsafe fn transmute_copy(src: &T) -> U { #[unstable(feature = "copy_lifetime", reason = "this function may be removed in the future due to its \ questionable utility")] +#[deprecated(since = "1.2.0", + reason = "unclear that this function buys more safety and \ + lifetimes are generally not handled as such in unsafe \ + code today")] pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, ptr: &T) -> &'a T { transmute(ptr) @@ -472,6 +476,10 @@ pub unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, #[unstable(feature = "copy_lifetime", reason = "this function may be removed in the future due to its \ questionable utility")] +#[deprecated(since = "1.2.0", + reason = "unclear that this function buys more safety and \ + lifetimes are generally not handled as such in unsafe \ + code today")] pub unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, ptr: &mut T) -> &'a mut T From c72e01ef7f317a0bad3c3e780cb02858f2017f43 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:04:49 -0700 Subject: [PATCH 09/48] std: Deprecate result::fold This function has seen very little use and it seems better to explore this functionality through iterator adaptors instead of specialized functions. --- src/libcore/result.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 7fd845edc3f84..d87c1020dcc2f 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -968,6 +968,9 @@ impl> FromIterator> for Result { #[inline] #[unstable(feature = "result_fold", reason = "unclear if this function should exist")] +#[deprecated(since = "1.2.0", + reason = "has not seen enough usage to justify its position in \ + the standard library")] pub fn fold Date: Wed, 10 Jun 2015 18:06:12 -0700 Subject: [PATCH 10/48] std: Deprecate the IntSliceExt trait This trait has seen very little usage and while safe, may not belong in the standard library. --- src/libcore/slice.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index c979b97731b4f..91acb0d695545 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1501,6 +1501,10 @@ impl PartialOrd for [T] { /// Extension methods for slices containing integers. #[unstable(feature = "int_slice")] +#[deprecated(since = "1.2.0", + reason = "has not seen much usage and may want to live in the \ + standard library now that most slice methods are \ + on an inherent implementation block")] pub trait IntSliceExt { /// Converts the slice to an immutable slice of unsigned integers with the same width. fn as_unsigned<'a>(&'a self) -> &'a [U]; From a05ed9936d97414efdfd460f1e25505c366689d3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:10:12 -0700 Subject: [PATCH 11/48] std: Remove two internal `str_internals` functions These were just exposed to be used elsewhere at some point, but neither is currently being used so just make them private again. --- src/libcore/str/mod.rs | 6 ++---- src/libstd/sys/common/wtf8.rs | 25 ------------------------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 13c6ad367257d..7092df7b4c2c4 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -227,9 +227,8 @@ pub fn next_code_point(bytes: &mut slice::Iter) -> Option { /// Reads the last code point out of a byte iterator (assuming a /// UTF-8-like encoding). -#[unstable(feature = "str_internals")] #[inline] -pub fn next_code_point_reverse(bytes: &mut slice::Iter) -> Option { +fn next_code_point_reverse(bytes: &mut slice::Iter) -> Option { // Decode UTF-8 let w = match bytes.next_back() { None => return None, @@ -1873,8 +1872,7 @@ impl AsRef<[u8]> for str { /// Pluck a code point out of a UTF-8-like byte slice and return the /// index of the next code point. #[inline] -#[unstable(feature = "str_internals")] -pub fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) { +fn char_range_at_raw(bytes: &[u8], i: usize) -> (u32, usize) { if bytes[i] < 128 { return (bytes[i] as u32, i + 1); } diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index b2dc01e3ccb19..428c8560d8847 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -480,31 +480,6 @@ impl Wtf8 { } } - /// Returns the code point at `position`. - /// - /// # Panics - /// - /// Panics if `position` is not at a code point boundary, - /// or is beyond the end of the string. - #[inline] - pub fn code_point_at(&self, position: usize) -> CodePoint { - let (code_point, _) = self.code_point_range_at(position); - code_point - } - - /// Returns the code point at `position` - /// and the position of the next code point. - /// - /// # Panics - /// - /// Panics if `position` is not at a code point boundary, - /// or is beyond the end of the string. - #[inline] - pub fn code_point_range_at(&self, position: usize) -> (CodePoint, usize) { - let (c, n) = char_range_at_raw(&self.bytes, position); - (CodePoint { value: c }, n) - } - /// Returns an iterator for the string’s code points. #[inline] pub fn code_points(&self) -> Wtf8CodePoints { From 8797c9ec6ee2a00e2398ab736b0467c8e38cb496 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:27:58 -0700 Subject: [PATCH 12/48] std: Deprecate f{32,64}::consts::PI_2 These constants have been unstable for some time now already --- src/libcore/num/f32.rs | 1 + src/libcore/num/f64.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 229414fe76664..aade9061657b7 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -73,6 +73,7 @@ pub mod consts { /// pi * 2.0 #[unstable(feature = "float_consts", reason = "unclear naming convention/usefulness")] + #[deprecated(since = "1.2.0", reason = "unclear on usefulness")] pub const PI_2: f32 = 6.28318530717958647692528676655900576_f32; /// pi/2.0 diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index bbc1bdacde713..7c9e846af9b10 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -73,6 +73,7 @@ pub mod consts { /// pi * 2.0 #[unstable(feature = "float_consts", reason = "unclear naming convention/usefulness")] + #[deprecated(since = "1.2.0", reason = "unclear on usefulness")] pub const PI_2: f64 = 6.28318530717958647692528676655900576_f64; /// pi/2.0 From cdb69e2747e41db25d64cf77e99721e9134aa5b7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:31:15 -0700 Subject: [PATCH 13/48] std: Stabilize the remaining wrapping_* functions This commit stabilizes the remaining `wrapping_*` functions on the primitive integer types as they follow the same conventions as other wrapping methods are were likely just initially unstable to be conservative. --- src/libcore/num/mod.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index c8a0ae47637d2..6af2148d4ed3d 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -468,7 +468,7 @@ macro_rules! int_impl { /// to `-MIN`, a positive value that is too large to represent /// in the type. In such a case, this function returns `MIN` /// itself.. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_div(self, rhs: Self) -> Self { self.overflowing_div(rhs).0 @@ -481,7 +481,7 @@ macro_rules! int_impl { /// implementation artifacts make `x % y` illegal for `MIN / /// -1` on a signed type illegal (where `MIN` is the negative /// minimal value). In such a case, this function returns `0`. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_rem(self, rhs: Self) -> Self { self.overflowing_rem(rhs).0 @@ -495,7 +495,7 @@ macro_rules! int_impl { /// negative minimal value for the type); this is a positive /// value that is too large to represent in the type. In such /// a case, this function returns `MIN` itself. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_neg(self) -> Self { self.overflowing_neg().0 @@ -504,7 +504,7 @@ macro_rules! int_impl { /// Panic-free bitwise shift-left; yields `self << mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_shl(self, rhs: u32) -> Self { self.overflowing_shl(rhs).0 @@ -513,7 +513,7 @@ macro_rules! int_impl { /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_shr(self, rhs: u32) -> Self { self.overflowing_shr(rhs).0 @@ -1038,7 +1038,7 @@ macro_rules! uint_impl { /// to `-MIN`, a positive value that is too large to represent /// in the type. In such a case, this function returns `MIN` /// itself.. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_div(self, rhs: Self) -> Self { self.overflowing_div(rhs).0 @@ -1051,7 +1051,7 @@ macro_rules! uint_impl { /// implementation artifacts make `x % y` illegal for `MIN / /// -1` on a signed type illegal (where `MIN` is the negative /// minimal value). In such a case, this function returns `0`. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_rem(self, rhs: Self) -> Self { self.overflowing_rem(rhs).0 @@ -1065,7 +1065,7 @@ macro_rules! uint_impl { /// negative minimal value for the type); this is a positive /// value that is too large to represent in the type. In such /// a case, this function returns `MIN` itself. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_neg(self) -> Self { self.overflowing_neg().0 @@ -1074,7 +1074,7 @@ macro_rules! uint_impl { /// Panic-free bitwise shift-left; yields `self << mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_shl(self, rhs: u32) -> Self { self.overflowing_shl(rhs).0 @@ -1083,7 +1083,7 @@ macro_rules! uint_impl { /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. - #[unstable(feature = "num_wrapping")] + #[stable(feature = "num_wrapping", since = "1.2.0")] #[inline(always)] pub fn wrapping_shr(self, rhs: u32) -> Self { self.overflowing_shr(rhs).0 From f85c4f62d8e3f703f9d7c801b982d5cd5afbd081 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:33:55 -0700 Subject: [PATCH 14/48] std: Deprecate all permutation-related slice methods These methods have been unstable for quite some time, and it's not clear that these should remain in the standard library. --- src/libcollections/slice.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index be678d4a55c86..7d74f83552d07 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -872,6 +872,7 @@ impl [T] { /// assert_eq!(Some(vec![3, 1, 2]), perms.next()); /// ``` #[unstable(feature = "permutations")] + #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] #[inline] pub fn permutations(&self) -> Permutations where T: Clone { // NB see hack module in this file @@ -897,6 +898,7 @@ impl [T] { /// ``` #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] + #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] pub fn next_permutation(&mut self) -> bool where T: Ord { core_slice::SliceExt::next_permutation(self) } @@ -920,6 +922,7 @@ impl [T] { /// ``` #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] + #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] pub fn prev_permutation(&mut self) -> bool where T: Ord { core_slice::SliceExt::prev_permutation(self) } @@ -1066,6 +1069,7 @@ impl> SliceConcatExt for [V] { /// sequence to its initial order. #[unstable(feature = "permutations")] #[derive(Clone)] +#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] pub struct ElementSwaps { sdir: Vec, /// If `true`, emit the last swap that returns the sequence to initial @@ -1077,6 +1081,7 @@ pub struct ElementSwaps { impl ElementSwaps { /// Creates an `ElementSwaps` iterator for a sequence of `length` elements. #[unstable(feature = "permutations")] + #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] pub fn new(length: usize) -> ElementSwaps { // Initialize `sdir` with a direction that position should move in // (all negative at the beginning) and the `size` of the @@ -1199,6 +1204,7 @@ impl Iterator for ElementSwaps { /// /// Generates even and odd permutations alternately. #[unstable(feature = "permutations")] +#[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] pub struct Permutations { swaps: ElementSwaps, v: Vec, From 68b628b165c91e6abe1bccf9d94eb7c7ef7cdda3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:40:20 -0700 Subject: [PATCH 15/48] std: Deprecate Vec::from_raw_buf This function is more naturally expressed as slice::from_raw_buf plus a call to to_vec. --- src/libcollections/vec.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 3d7c82c9a94a6..6b1e4bb4f8e6f 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -278,6 +278,8 @@ impl Vec { #[inline] #[unstable(feature = "vec_from_raw_buf", reason = "may be better expressed via composition")] + #[deprecated(since = "1.2.0", + reason = "use slice::from_raw_parts + .to_vec() instead")] pub unsafe fn from_raw_buf(ptr: *const T, elts: usize) -> Vec { let mut dst = Vec::with_capacity(elts); dst.set_len(elts); From c032d6fd397d95ccfa7c9bbefc8cc508906b8d34 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:43:08 -0700 Subject: [PATCH 16/48] std: Stabilize the sync_poison feature These accessor/constructor methods for a `PoisonError` are quite standard for a wrapper type and enable manipulation of the underlying type. --- src/libstd/sync/mutex.rs | 2 +- src/libstd/sync/rwlock.rs | 2 +- src/libstd/sys/common/poison.rs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 1d63014295922..64a5027cc8937 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -238,7 +238,7 @@ impl Mutex { /// time. You should not trust a `false` value for program correctness /// without additional synchronization. #[inline] - #[unstable(feature = "sync_poison")] + #[stable(feature = "sync_poison", since = "1.2.0")] pub fn is_poisoned(&self) -> bool { self.inner.poison.get() } diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 5a6bf987fd717..4ca2e282f707d 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -253,7 +253,7 @@ impl RwLock { /// time. You should not trust a `false` value for program correctness /// without additional synchronization. #[inline] - #[unstable(feature = "sync_poison")] + #[stable(feature = "sync_poison", since = "1.2.0")] pub fn is_poisoned(&self) -> bool { self.inner.poison.get() } diff --git a/src/libstd/sys/common/poison.rs b/src/libstd/sys/common/poison.rs index 75f85879fd1f4..065b1d6c9acfc 100644 --- a/src/libstd/sys/common/poison.rs +++ b/src/libstd/sys/common/poison.rs @@ -120,24 +120,24 @@ impl Error for PoisonError { impl PoisonError { /// Creates a `PoisonError`. - #[unstable(feature = "sync_poison")] + #[stable(feature = "sync_poison", since = "1.2.0")] pub fn new(guard: T) -> PoisonError { PoisonError { guard: guard } } /// Consumes this error indicating that a lock is poisoned, returning the /// underlying guard to allow access regardless. - #[unstable(feature = "sync_poison")] + #[stable(feature = "sync_poison", since = "1.2.0")] pub fn into_inner(self) -> T { self.guard } /// Reaches into this error indicating that a lock is poisoned, returning a /// reference to the underlying guard to allow access regardless. - #[unstable(feature = "sync_poison")] + #[stable(feature = "sync_poison", since = "1.2.0")] pub fn get_ref(&self) -> &T { &self.guard } /// Reaches into this error indicating that a lock is poisoned, returning a /// mutable reference to the underlying guard to allow access regardless. - #[unstable(feature = "sync_poi")] + #[stable(feature = "sync_poison", since = "1.2.0")] pub fn get_mut(&mut self) -> &mut T { &mut self.guard } } From f3580879b90f451b24b9d6008f571745fc6cbd6c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:44:11 -0700 Subject: [PATCH 17/48] std: Stabilize the `once_new` feature This function follows the well-established "constructor" pattern and the initialization constant will likely be deprecated in favor of it once `const_fn` is stabilized. --- src/libstd/sync/once.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 1e0aa271b4dcd..0bda6a975a244 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -48,7 +48,7 @@ pub const ONCE_INIT: Once = Once::new(); impl Once { /// Creates a new `Once` value. - #[unstable(feature = "once_new")] + #[stable(feature = "once_new", since = "1.2.0")] pub const fn new() -> Once { Once { mutex: StaticMutex::new(), From 17a1059d8343ffd66fe3f3c51e3bf9b493cdf2f3 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:45:48 -0700 Subject: [PATCH 18/48] std: Stabilize the `iter_{once,empty}` features This commit stabilizes these two iterator primitives as they have gone through the RFC process and had some time to bake now. --- src/libcore/iter.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 053a85a7c51a6..2f45ffd141820 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -3043,10 +3043,10 @@ pub fn repeat(elt: T) -> Repeat { } /// An iterator that yields nothing. -#[unstable(feature="iter_empty", reason = "new addition")] +#[stable(feature = "iter_empty", since = "1.2.0")] pub struct Empty(marker::PhantomData); -#[unstable(feature="iter_empty", reason = "new addition")] +#[stable(feature = "iter_empty", since = "1.2.0")] impl Iterator for Empty { type Item = T; @@ -3059,14 +3059,14 @@ impl Iterator for Empty { } } -#[unstable(feature="iter_empty", reason = "new addition")] +#[stable(feature = "iter_empty", since = "1.2.0")] impl DoubleEndedIterator for Empty { fn next_back(&mut self) -> Option { None } } -#[unstable(feature="iter_empty", reason = "new addition")] +#[stable(feature = "iter_empty", since = "1.2.0")] impl ExactSizeIterator for Empty { fn len(&self) -> usize { 0 @@ -3075,7 +3075,7 @@ impl ExactSizeIterator for Empty { // not #[derive] because that adds a Clone bound on T, // which isn't necessary. -#[unstable(feature="iter_empty", reason = "new addition")] +#[stable(feature = "iter_empty", since = "1.2.0")] impl Clone for Empty { fn clone(&self) -> Empty { Empty(marker::PhantomData) @@ -3084,7 +3084,7 @@ impl Clone for Empty { // not #[derive] because that adds a Default bound on T, // which isn't necessary. -#[unstable(feature="iter_empty", reason = "new addition")] +#[stable(feature = "iter_empty", since = "1.2.0")] impl Default for Empty { fn default() -> Empty { Empty(marker::PhantomData) @@ -3092,19 +3092,19 @@ impl Default for Empty { } /// Creates an iterator that yields nothing. -#[unstable(feature="iter_empty", reason = "new addition")] +#[stable(feature = "iter_empty", since = "1.2.0")] pub fn empty() -> Empty { Empty(marker::PhantomData) } /// An iterator that yields an element exactly once. #[derive(Clone)] -#[unstable(feature="iter_once", reason = "new addition")] +#[stable(feature = "iter_once", since = "1.2.0")] pub struct Once { inner: ::option::IntoIter } -#[unstable(feature="iter_once", reason = "new addition")] +#[stable(feature = "iter_once", since = "1.2.0")] impl Iterator for Once { type Item = T; @@ -3117,14 +3117,14 @@ impl Iterator for Once { } } -#[unstable(feature="iter_once", reason = "new addition")] +#[stable(feature = "iter_once", since = "1.2.0")] impl DoubleEndedIterator for Once { fn next_back(&mut self) -> Option { self.inner.next_back() } } -#[unstable(feature="iter_once", reason = "new addition")] +#[stable(feature = "iter_once", since = "1.2.0")] impl ExactSizeIterator for Once { fn len(&self) -> usize { self.inner.len() @@ -3132,7 +3132,7 @@ impl ExactSizeIterator for Once { } /// Creates an iterator that yields an element exactly once. -#[unstable(feature="iter_once", reason = "new addition")] +#[stable(feature = "iter_once", since = "1.2.0")] pub fn once(value: T) -> Once { Once { inner: Some(value).into_iter() } } From 2d389c125e2ba7fdb6762120e1fa4e783fa7adad Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:49:26 -0700 Subject: [PATCH 19/48] std: Stabilize the `str_matches` feature This commit stabilizes the `str::{matches, rmatches}` functions and iterators, but renames the unstable feature for the `str::{matches,rmatches}_indices` function to `str_match_indices` due to the comment present on the functions about the iterator's return value. --- src/libcollections/str.rs | 10 ++++------ src/libcore/str/mod.rs | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index d41e062cac3d8..55265aac99f8e 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1527,8 +1527,7 @@ impl str { /// let v: Vec<&str> = "1abc2abc3".matches(char::is_numeric).collect(); /// assert_eq!(v, ["1", "2", "3"]); /// ``` - #[unstable(feature = "str_matches", - reason = "method got recently added")] + #[stable(feature = "str_matches", since = "1.2.0")] pub fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P> { core_str::StrExt::matches(self, pat) } @@ -1560,8 +1559,7 @@ impl str { /// let v: Vec<&str> = "1abc2abc3".rmatches(char::is_numeric).collect(); /// assert_eq!(v, ["3", "2", "1"]); /// ``` - #[unstable(feature = "str_matches", - reason = "method got recently added")] + #[stable(feature = "str_matches", since = "1.2.0")] pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P> where P::Searcher: ReverseSearcher<'a> { @@ -1605,7 +1603,7 @@ impl str { /// let v: Vec<(usize, usize)> = "ababa".match_indices("aba").collect(); /// assert_eq!(v, [(0, 3)]); // only the first `aba` /// ``` - #[unstable(feature = "str_matches", + #[unstable(feature = "str_match_indices", reason = "might have its iterator type changed")] // NB: Right now MatchIndices yields `(usize, usize)`, but it would // be more consistent with `matches` and `char_indices` to return `(usize, &str)` @@ -1649,7 +1647,7 @@ impl str { /// let v: Vec<(usize, usize)> = "ababa".rmatch_indices("aba").collect(); /// assert_eq!(v, [(2, 5)]); // only the last `aba` /// ``` - #[unstable(feature = "str_matches", + #[unstable(feature = "str_match_indices", reason = "might have its iterator type changed")] // NB: Right now RMatchIndices yields `(usize, usize)`, but it would // be more consistent with `rmatches` and `char_indices` to return `(usize, &str)` diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 7092df7b4c2c4..5a621176c4a81 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -738,7 +738,7 @@ generate_pattern_iterators! { #[doc="Created with the method `.rmatch_indices()`."] struct RMatchIndices; stability: - #[unstable(feature = "str_internals", + #[unstable(feature = "str_match_indices", reason = "type may be removed or have its iterator impl changed")] internal: MatchIndicesInternal yielding ((usize, usize)); @@ -779,7 +779,7 @@ generate_pattern_iterators! { #[doc="Created with the method `.rmatches()`."] struct RMatches; stability: - #[unstable(feature = "str_internals", reason = "type got recently added")] + #[stable(feature = "str_matches", since = "1.2.0")] internal: MatchesInternal yielding (&'a str); delegate double ended; From 0d818b4ee4a978babc8781ece028a7d0e9ed2e36 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:52:57 -0700 Subject: [PATCH 20/48] std: Deprecate the io::BufStream type Questions about the utility of this type has caused it to move to crates.io in the `bufstream` crate, so this type can be deprecated. --- src/libstd/io/buffered.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index c355be9bc78d2..95363870cd08f 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -454,6 +454,8 @@ impl Read for InternalBufWriter { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[deprecated(since = "1.2.0", + reason = "use the crates.io `bufstream` crate instead")] pub struct BufStream { inner: BufReader> } @@ -461,6 +463,8 @@ pub struct BufStream { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[deprecated(since = "1.2.0", + reason = "use the crates.io `bufstream` crate instead")] impl BufStream { /// Creates a new buffered stream with explicitly listed capacities for the /// reader/writer buffer. From 96cce02924b83227b53799c2992f5040340528fc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:54:35 -0700 Subject: [PATCH 21/48] std: Deprecate the `exit_status` feature These two functions should be replaceable with the `process::exit` function. --- src/libstd/env.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 7f83f0763c640..2e00e126e2378 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -486,6 +486,7 @@ static EXIT_STATUS: AtomicIsize = AtomicIsize::new(0); /// /// Note that this is not synchronized against modifications of other threads. #[unstable(feature = "exit_status", reason = "managing the exit status may change")] +#[deprecated(since = "1.2.0", reason = "use process::exit instead")] pub fn set_exit_status(code: i32) { EXIT_STATUS.store(code as isize, Ordering::SeqCst) } @@ -493,6 +494,7 @@ pub fn set_exit_status(code: i32) { /// Fetches the process's current exit code. This defaults to 0 and can change /// by calling `set_exit_status`. #[unstable(feature = "exit_status", reason = "managing the exit status may change")] +#[deprecated(since = "1.2.0", reason = "use process::exit instead")] pub fn get_exit_status() -> i32 { EXIT_STATUS.load(Ordering::SeqCst) as i32 } From 04f7eba909ffc5a6473087391c92a7a1489ae94b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 18:56:10 -0700 Subject: [PATCH 22/48] std: Deprecate the `future` feature This commit deprecates the `sync::Future` type to be developed outside in crates.io instead. --- src/libstd/sync/future.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index f5b6650a49833..e3ddc1034a540 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -32,6 +32,10 @@ reason = "futures as-is have yet to be deeply reevaluated with recent \ core changes to Rust's synchronization story, and will likely \ become stable in the future but are unstable until that time")] +#[deprecated(since = "1.2.0", + reason = "implementation does not match the quality of the \ + standard library and this will likely be prototyped \ + outside in crates.io first")] use core::prelude::*; use core::mem::replace; From d645f8fc286af1841f1a352ddc7282c6e9a7dd8f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 19:04:51 -0700 Subject: [PATCH 23/48] std: Deprecate the `scoped` feature The `thread::scoped` function will never be stabilized as-is and the API will likely change significantly if it does, so this function is deprecated for removal. --- src/libstd/thread/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 153b04360877b..da9cde8e3cd34 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -297,6 +297,9 @@ impl Builder { /// the OS level. #[unstable(feature = "scoped", reason = "memory unsafe if destructor is avoided, see #24292")] + #[deprecated(since = "1.2.0", + reason = "this unsafe API is unlikely to ever be stabilized \ + in this form")] pub fn scoped<'a, T, F>(self, f: F) -> io::Result> where T: Send + 'a, F: FnOnce() -> T, F: Send + 'a { @@ -398,6 +401,9 @@ pub fn spawn(f: F) -> JoinHandle where /// to recover from such errors. #[unstable(feature = "scoped", reason = "memory unsafe if destructor is avoided, see #24292")] +#[deprecated(since = "1.2.0", + reason = "this unsafe API is unlikely to ever be stabilized \ + in this form")] pub fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where T: Send + 'a, F: FnOnce() -> T, F: Send + 'a { From 3346fb044285c0b10480099ca3af921a053c38be Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 19:06:45 -0700 Subject: [PATCH 24/48] std: Deprecate the `thunk` module This has been replaced with `FnBox` --- src/libstd/thunk.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libstd/thunk.rs b/src/libstd/thunk.rs index 084893314a8e5..f1dc91f135fe5 100644 --- a/src/libstd/thunk.rs +++ b/src/libstd/thunk.rs @@ -11,6 +11,7 @@ // Because this module is temporary... #![allow(missing_docs)] #![unstable(feature = "thunk")] +#![deprecated(since = "1.2.0", reason = "use FnBox instead")] use alloc::boxed::{Box, FnBox}; use core::marker::Send; From aa931e9c6f92557b99978f1cc562c99051190f79 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 19:14:35 -0700 Subject: [PATCH 25/48] std: Move free-functions to associated functions This commit moves the free functions in the `rc`, `arc`, and `boxed` modules to associated functions on their respective types, following the recent trend towards this pattern. The previous free functions are all left in-place with `#[deprecated]` pointers towards the new locations. This commit also deprecates `arc::get_mut` and `Arc::make_unique` with no replacement as they are racy in the face of weak pointers. --- src/liballoc/arc.rs | 26 +++++++-- src/liballoc/boxed.rs | 29 ++++++++- src/liballoc/rc.rs | 133 +++++++++++++++++++++++++++++++++--------- 3 files changed, 153 insertions(+), 35 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index c1ad367c234b3..282fca8d6c29e 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -205,9 +205,21 @@ impl Arc { self.inner().weak.fetch_add(1, Relaxed); Weak { _ptr: self._ptr } } -} -impl Arc { + /// Get the number of weak references to this value. + #[inline] + #[unstable(feature = "arc_counts")] + pub fn weak_count(this: &Arc) -> usize { + this.inner().weak.load(SeqCst) - 1 + } + + /// Get the number of strong references to this value. + #[inline] + #[unstable(feature = "arc_counts")] + pub fn strong_count(this: &Arc) -> usize { + this.inner().strong.load(SeqCst) + } + #[inline] fn inner(&self) -> &ArcInner { // This unsafety is ok because while this arc is alive we're guaranteed @@ -237,12 +249,14 @@ impl Arc { /// Get the number of weak references to this value. #[inline] #[unstable(feature = "arc_counts")] -pub fn weak_count(this: &Arc) -> usize { this.inner().weak.load(SeqCst) - 1 } +#[deprecated(since = "1.2.0", reason = "renamed to Arc::weak_count")] +pub fn weak_count(this: &Arc) -> usize { Arc::weak_count(this) } /// Get the number of strong references to this value. #[inline] #[unstable(feature = "arc_counts")] -pub fn strong_count(this: &Arc) -> usize { this.inner().strong.load(SeqCst) } +#[deprecated(since = "1.2.0", reason = "renamed to Arc::strong_count")] +pub fn strong_count(this: &Arc) -> usize { Arc::strong_count(this) } /// Returns a mutable reference to the contained value if the `Arc` is unique. @@ -272,6 +286,8 @@ pub fn strong_count(this: &Arc) -> usize { this.inner().strong.loa /// ``` #[inline] #[unstable(feature = "arc_unique")] +#[deprecated(since = "1.2.0", + reason = "this function is unsafe with weak pointers")] pub unsafe fn get_mut(this: &mut Arc) -> Option<&mut T> { // FIXME(#24880) potential race with upgraded weak pointers here if strong_count(this) == 1 && weak_count(this) == 0 { @@ -353,6 +369,8 @@ impl Arc { /// ``` #[inline] #[unstable(feature = "arc_unique")] + #[deprecated(since = "1.2.0", + reason = "this function is unsafe with weak pointers")] pub unsafe fn make_unique(&mut self) -> &mut T { // FIXME(#24880) potential race with upgraded weak pointers here // diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index b59a5685f0d8f..0e6554702bef9 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -127,6 +127,29 @@ impl Box { pub unsafe fn from_raw(raw: *mut T) -> Self { mem::transmute(raw) } + + /// Consumes the `Box`, returning the wrapped raw pointer. + /// + /// After call to this function, caller is responsible for the memory + /// previously managed by `Box`, in particular caller should properly + /// destroy `T` and release memory. The proper way to do it is to + /// convert pointer back to `Box` with `Box::from_raw` function, because + /// `Box` does not specify, how memory is allocated. + /// + /// # Examples + /// ``` + /// # #![feature(box_raw)] + /// use std::boxed; + /// + /// let seventeen = Box::new(17u32); + /// let raw = boxed::into_raw(seventeen); + /// let boxed_again = unsafe { Box::from_raw(raw) }; + /// ``` + #[unstable(feature = "box_raw", reason = "may be renamed")] + #[inline] + pub fn into_raw(b: Box) -> *mut T { + unsafe { mem::transmute(b) } + } } /// Consumes the `Box`, returning the wrapped raw pointer. @@ -146,11 +169,11 @@ impl Box { /// let raw = boxed::into_raw(seventeen); /// let boxed_again = unsafe { Box::from_raw(raw) }; /// ``` -#[unstable(feature = "box_raw", - reason = "may be renamed")] +#[unstable(feature = "box_raw", reason = "may be renamed")] +#[deprecated(since = "1.2.0", reason = "renamed to Box::into_raw")] #[inline] pub fn into_raw(b: Box) -> *mut T { - unsafe { mem::transmute(b) } + Box::into_raw(b) } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 802591a6171d5..bdf02b23ff489 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -220,6 +220,42 @@ impl Rc { } } } + + /// Unwraps the contained value if the `Rc` is unique. + /// + /// If the `Rc` is not unique, an `Err` is returned with the same + /// `Rc`. + /// + /// # Examples + /// + /// ``` + /// # #![feature(rc_unique)] + /// use std::rc::{self, Rc}; + /// + /// let x = Rc::new(3); + /// assert_eq!(rc::try_unwrap(x), Ok(3)); + /// + /// let x = Rc::new(4); + /// let _y = x.clone(); + /// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); + /// ``` + #[inline] + #[unstable(feature = "rc_unique")] + pub fn try_unwrap(rc: Rc) -> Result> { + if Rc::is_unique(&rc) { + unsafe { + let val = ptr::read(&*rc); // copy the contained object + // destruct the box and skip our Drop + // we can ignore the refcounts because we know we're unique + deallocate(*rc._ptr as *mut u8, size_of::>(), + min_align_of::>()); + forget(rc); + Ok(val) + } + } else { + Err(rc) + } + } } impl Rc { @@ -241,17 +277,78 @@ impl Rc { self.inc_weak(); Weak { _ptr: self._ptr } } + + /// Get the number of weak references to this value. + #[inline] + #[unstable(feature = "rc_counts")] + pub fn weak_count(this: &Rc) -> usize { this.weak() - 1 } + + /// Get the number of strong references to this value. + #[inline] + #[unstable(feature = "rc_counts")] + pub fn strong_count(this: &Rc) -> usize { this.strong() } + + /// Returns true if there are no other `Rc` or `Weak` values that share + /// the same inner value. + /// + /// # Examples + /// + /// ``` + /// # #![feature(rc_unique)] + /// use std::rc; + /// use std::rc::Rc; + /// + /// let five = Rc::new(5); + /// + /// rc::is_unique(&five); + /// ``` + #[inline] + #[unstable(feature = "rc_unique")] + pub fn is_unique(rc: &Rc) -> bool { + weak_count(rc) == 0 && strong_count(rc) == 1 + } + + /// Returns a mutable reference to the contained value if the `Rc` is + /// unique. + /// + /// Returns `None` if the `Rc` is not unique. + /// + /// # Examples + /// + /// ``` + /// # #![feature(rc_unique)] + /// use std::rc::{self, Rc}; + /// + /// let mut x = Rc::new(3); + /// *rc::get_mut(&mut x).unwrap() = 4; + /// assert_eq!(*x, 4); + /// + /// let _y = x.clone(); + /// assert!(rc::get_mut(&mut x).is_none()); + /// ``` + #[inline] + #[unstable(feature = "rc_unique")] + pub fn get_mut(rc: &mut Rc) -> Option<&mut T> { + if Rc::is_unique(rc) { + let inner = unsafe { &mut **rc._ptr }; + Some(&mut inner.value) + } else { + None + } + } } /// Get the number of weak references to this value. #[inline] #[unstable(feature = "rc_counts")] -pub fn weak_count(this: &Rc) -> usize { this.weak() - 1 } +#[deprecated(since = "1.2.0", reason = "renamed to Rc::weak_count")] +pub fn weak_count(this: &Rc) -> usize { Rc::weak_count(this) } /// Get the number of strong references to this value. #[inline] #[unstable(feature = "rc_counts")] -pub fn strong_count(this: &Rc) -> usize { this.strong() } +#[deprecated(since = "1.2.0", reason = "renamed to Rc::strong_count")] +pub fn strong_count(this: &Rc) -> usize { Rc::strong_count(this) } /// Returns true if there are no other `Rc` or `Weak` values that share the /// same inner value. @@ -269,9 +366,8 @@ pub fn strong_count(this: &Rc) -> usize { this.strong() } /// ``` #[inline] #[unstable(feature = "rc_unique")] -pub fn is_unique(rc: &Rc) -> bool { - weak_count(rc) == 0 && strong_count(rc) == 1 -} +#[deprecated(since = "1.2.0", reason = "renamed to Rc::is_unique")] +pub fn is_unique(rc: &Rc) -> bool { Rc::is_unique(rc) } /// Unwraps the contained value if the `Rc` is unique. /// @@ -292,21 +388,8 @@ pub fn is_unique(rc: &Rc) -> bool { /// ``` #[inline] #[unstable(feature = "rc_unique")] -pub fn try_unwrap(rc: Rc) -> Result> { - if is_unique(&rc) { - unsafe { - let val = ptr::read(&*rc); // copy the contained object - // destruct the box and skip our Drop - // we can ignore the refcounts because we know we're unique - deallocate(*rc._ptr as *mut u8, size_of::>(), - min_align_of::>()); - forget(rc); - Ok(val) - } - } else { - Err(rc) - } -} +#[deprecated(since = "1.2.0", reason = "renamed to Rc::try_unwrap")] +pub fn try_unwrap(rc: Rc) -> Result> { Rc::try_unwrap(rc) } /// Returns a mutable reference to the contained value if the `Rc` is unique. /// @@ -327,14 +410,8 @@ pub fn try_unwrap(rc: Rc) -> Result> { /// ``` #[inline] #[unstable(feature = "rc_unique")] -pub fn get_mut(rc: &mut Rc) -> Option<&mut T> { - if is_unique(rc) { - let inner = unsafe { &mut **rc._ptr }; - Some(&mut inner.value) - } else { - None - } -} +#[deprecated(since = "1.2.0", reason = "renamed to Rc::get_mut")] +pub fn get_mut(rc: &mut Rc) -> Option<&mut T> { Rc::get_mut(rc) } impl Rc { /// Make a mutable reference from the given `Rc`. From b4a2823cd6c6f1a560469587f902f3a1f49d3c79 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 10 Jun 2015 19:33:04 -0700 Subject: [PATCH 26/48] More test fixes and fallout of stability changes --- src/liballoc/arc.rs | 2 +- src/liballoc/boxed.rs | 2 +- src/liballoc/rc.rs | 41 ++++++++++++++---------------- src/libcollections/bit.rs | 2 ++ src/libcollections/btree/map.rs | 5 +--- src/libcollections/lib.rs | 3 +-- src/libcollections/slice.rs | 9 +++++++ src/libcollections/str.rs | 6 ++--- src/libcollections/vec.rs | 2 ++ src/libcollections/vec_deque.rs | 1 + src/libcollectionstest/lib.rs | 2 +- src/libcore/iter.rs | 22 ++++++++++++++-- src/libcore/slice.rs | 4 +++ src/liblog/lib.rs | 6 ++--- src/librustc/lib.rs | 2 +- src/librustc_driver/lib.rs | 4 +-- src/librustc_trans/back/write.rs | 4 +-- src/librustc_trans/lib.rs | 2 -- src/librustdoc/lib.rs | 4 +-- src/libserialize/lib.rs | 1 - src/libstd/error.rs | 4 +-- src/libstd/ffi/c_str.rs | 5 ++-- src/libstd/io/buffered.rs | 5 ++++ src/libstd/io/lazy.rs | 3 +-- src/libstd/lib.rs | 1 - src/libstd/rt/at_exit_imp.rs | 11 ++++---- src/libstd/rt/mod.rs | 4 ++- src/libstd/rt/unwind/gcc.rs | 3 +-- src/libstd/sync/future.rs | 9 ++++--- src/libstd/sync/mod.rs | 1 + src/libstd/sync/mpsc/mpsc_queue.rs | 3 +-- src/libstd/sync/mpsc/spsc_queue.rs | 3 +-- src/libstd/sync/mutex.rs | 2 -- src/libstd/sys/common/wtf8.rs | 26 +------------------ src/libstd/thread/local.rs | 3 +-- src/libstd/thread/mod.rs | 1 + src/libtest/lib.rs | 7 ++--- src/rustbook/main.rs | 6 ++++- src/rustbook/term.rs | 4 +-- src/test/run-pass/issue-11958.rs | 8 ------ 40 files changed, 111 insertions(+), 122 deletions(-) diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 282fca8d6c29e..7bfeaec36d729 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -290,7 +290,7 @@ pub fn strong_count(this: &Arc) -> usize { Arc::strong_count(this) reason = "this function is unsafe with weak pointers")] pub unsafe fn get_mut(this: &mut Arc) -> Option<&mut T> { // FIXME(#24880) potential race with upgraded weak pointers here - if strong_count(this) == 1 && weak_count(this) == 0 { + if Arc::strong_count(this) == 1 && Arc::weak_count(this) == 0 { // This unsafety is ok because we're guaranteed that the pointer // returned is the *only* pointer that will ever be returned to T. Our // reference count is guaranteed to be 1 at this point, and we required diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 0e6554702bef9..1a360ebc05c71 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -267,7 +267,7 @@ impl Box { if self.is::() { unsafe { // Get the raw representation of the trait object - let raw = into_raw(self); + let raw = Box::into_raw(self); let to: TraitObject = mem::transmute::<*mut Any, TraitObject>(raw); diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index bdf02b23ff489..d5b6c86ef359a 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -148,26 +148,24 @@ //! ``` #![stable(feature = "rust1", since = "1.0.0")] + +use core::prelude::*; + #[cfg(not(test))] -use boxed; +use boxed::Box; #[cfg(test)] -use std::boxed; +use std::boxed::Box; + use core::cell::Cell; -use core::clone::Clone; -use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering}; -use core::default::Default; +use core::cmp::Ordering; use core::fmt; use core::hash::{Hasher, Hash}; use core::intrinsics::{assume, drop_in_place}; -use core::marker::{self, Sized, Unsize}; +use core::marker::{self, Unsize}; use core::mem::{self, min_align_of, size_of, min_align_of_val, size_of_val, forget}; use core::nonzero::NonZero; -use core::ops::{CoerceUnsized, Deref, Drop}; -use core::option::Option; -use core::option::Option::{Some, None}; +use core::ops::{CoerceUnsized, Deref}; use core::ptr; -use core::result::Result; -use core::result::Result::{Ok, Err}; use heap::deallocate; @@ -212,7 +210,7 @@ impl Rc { // pointers, which ensures that the weak destructor never frees // the allocation while the strong destructor is running, even // if the weak pointer is stored inside the strong one. - _ptr: NonZero::new(boxed::into_raw(box RcBox { + _ptr: NonZero::new(Box::into_raw(box RcBox { strong: Cell::new(1), weak: Cell::new(1), value: value @@ -230,14 +228,14 @@ impl Rc { /// /// ``` /// # #![feature(rc_unique)] - /// use std::rc::{self, Rc}; + /// use std::rc::Rc; /// /// let x = Rc::new(3); - /// assert_eq!(rc::try_unwrap(x), Ok(3)); + /// assert_eq!(Rc::try_unwrap(x), Ok(3)); /// /// let x = Rc::new(4); /// let _y = x.clone(); - /// assert_eq!(rc::try_unwrap(x), Err(Rc::new(4))); + /// assert_eq!(Rc::try_unwrap(x), Err(Rc::new(4))); /// ``` #[inline] #[unstable(feature = "rc_unique")] @@ -295,17 +293,16 @@ impl Rc { /// /// ``` /// # #![feature(rc_unique)] - /// use std::rc; /// use std::rc::Rc; /// /// let five = Rc::new(5); /// - /// rc::is_unique(&five); + /// assert!(Rc::is_unique(&five)); /// ``` #[inline] #[unstable(feature = "rc_unique")] pub fn is_unique(rc: &Rc) -> bool { - weak_count(rc) == 0 && strong_count(rc) == 1 + Rc::weak_count(rc) == 0 && Rc::strong_count(rc) == 1 } /// Returns a mutable reference to the contained value if the `Rc` is @@ -317,14 +314,14 @@ impl Rc { /// /// ``` /// # #![feature(rc_unique)] - /// use std::rc::{self, Rc}; + /// use std::rc::Rc; /// /// let mut x = Rc::new(3); - /// *rc::get_mut(&mut x).unwrap() = 4; + /// *Rc::get_mut(&mut x).unwrap() = 4; /// assert_eq!(*x, 4); /// /// let _y = x.clone(); - /// assert!(rc::get_mut(&mut x).is_none()); + /// assert!(Rc::get_mut(&mut x).is_none()); /// ``` #[inline] #[unstable(feature = "rc_unique")] @@ -432,7 +429,7 @@ impl Rc { #[inline] #[unstable(feature = "rc_unique")] pub fn make_unique(&mut self) -> &mut T { - if !is_unique(self) { + if !Rc::is_unique(self) { *self = Rc::new((**self).clone()) } // This unsafety is ok because we're guaranteed that the pointer diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 6a07c2c47eb24..51914900fdd99 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -86,6 +86,7 @@ use core::cmp::Ordering; use core::cmp; use core::fmt; use core::hash; +#[allow(deprecated)] use core::iter::RandomAccessIterator; use core::iter::{Chain, Enumerate, Repeat, Skip, Take, repeat, Cloned}; use core::iter::{self, FromIterator}; @@ -1188,6 +1189,7 @@ impl<'a> DoubleEndedIterator for Iter<'a> { impl<'a> ExactSizeIterator for Iter<'a> {} #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl<'a> RandomAccessIterator for Iter<'a> { #[inline] fn indexable(&self) -> usize { diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index d27d04c3a6cec..27b10213ecd7c 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -685,10 +685,7 @@ mod stack { /// tied to the original tree. pub fn into_top(mut self) -> &'a mut V { unsafe { - mem::copy_mut_lifetime( - self.map, - self.top.from_raw_mut().val_mut() - ) + &mut *(self.top.from_raw_mut().val_mut() as *mut V) } } } diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index b08a3b85e4cbf..8d0f57de4c595 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -34,7 +34,6 @@ #![feature(box_patterns)] #![feature(box_raw)] #![feature(box_syntax)] -#![feature(copy_lifetime)] #![feature(core)] #![feature(core_intrinsics)] #![feature(core_prelude)] @@ -56,7 +55,7 @@ #![feature(staged_api)] #![feature(step_by)] #![feature(str_char)] -#![feature(str_internals)] +#![feature(str_match_indices)] #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 7d74f83552d07..d49463911e66e 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -151,6 +151,7 @@ mod hack { } } + #[allow(deprecated)] pub fn permutations(s: &[T]) -> Permutations where T: Clone { Permutations{ swaps: ElementSwaps::new(s.len()), @@ -871,6 +872,7 @@ impl [T] { /// assert_eq!(Some(vec![1, 3, 2]), perms.next()); /// assert_eq!(Some(vec![3, 1, 2]), perms.next()); /// ``` + #[allow(deprecated)] #[unstable(feature = "permutations")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] #[inline] @@ -896,6 +898,7 @@ impl [T] { /// let b: &mut [_] = &mut [1, 0, 2]; /// assert!(v == b); /// ``` + #[allow(deprecated)] #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] @@ -920,6 +923,7 @@ impl [T] { /// let b: &mut [_] = &mut [0, 1, 2]; /// assert!(v == b); /// ``` + #[allow(deprecated)] #[unstable(feature = "permutations", reason = "uncertain if this merits inclusion in std")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] @@ -1067,6 +1071,7 @@ impl> SliceConcatExt for [V] { /// /// The last generated swap is always (0, 1), and it returns the /// sequence to its initial order. +#[allow(deprecated)] #[unstable(feature = "permutations")] #[derive(Clone)] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] @@ -1078,6 +1083,7 @@ pub struct ElementSwaps { swaps_made : usize, } +#[allow(deprecated)] impl ElementSwaps { /// Creates an `ElementSwaps` iterator for a sequence of `length` elements. #[unstable(feature = "permutations")] @@ -1137,6 +1143,7 @@ struct SizeDirection { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl Iterator for ElementSwaps { type Item = (usize, usize); @@ -1205,12 +1212,14 @@ impl Iterator for ElementSwaps { /// Generates even and odd permutations alternately. #[unstable(feature = "permutations")] #[deprecated(since = "1.2.0", reason = "not clear this should be in the stdlib")] +#[allow(deprecated)] pub struct Permutations { swaps: ElementSwaps, v: Vec, } #[unstable(feature = "permutations", reason = "trait is unstable")] +#[allow(deprecated)] impl Iterator for Permutations { type Item = Vec; diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 55265aac99f8e..5e8a9bca342b0 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1520,7 +1520,6 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] /// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect(); /// assert_eq!(v, ["abc", "abc", "abc"]); /// @@ -1552,7 +1551,6 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] /// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect(); /// assert_eq!(v, ["abc", "abc", "abc"]); /// @@ -1593,7 +1591,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] + /// # #![feature(str_match_indices)] /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect(); /// assert_eq!(v, [(0, 3), (6, 9), (12, 15)]); /// @@ -1637,7 +1635,7 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_matches)] + /// # #![feature(str_match_indices)] /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".rmatch_indices("abc").collect(); /// assert_eq!(v, [(12, 15), (6, 9), (0, 3)]); /// diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 6b1e4bb4f8e6f..54528c50f1d1e 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1709,12 +1709,14 @@ impl<'a, T> FromIterator for Cow<'a, [T]> where T: Clone { } } +#[allow(deprecated)] impl<'a, T: 'a> IntoCow<'a, [T]> for Vec where T: Clone { fn into_cow(self) -> Cow<'a, [T]> { Cow::Owned(self) } } +#[allow(deprecated)] impl<'a, T> IntoCow<'a, [T]> for &'a [T] where T: Clone { fn into_cow(self) -> Cow<'a, [T]> { Cow::Borrowed(self) diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index c80fcfc5fedcc..edcd1008747fd 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -1530,6 +1530,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> { impl<'a, T> ExactSizeIterator for Iter<'a, T> {} #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Iter<'a, T> { #[inline] fn indexable(&self) -> usize { diff --git a/src/libcollectionstest/lib.rs b/src/libcollectionstest/lib.rs index 437657cec1658..20a3625fe5add 100644 --- a/src/libcollectionstest/lib.rs +++ b/src/libcollectionstest/lib.rs @@ -43,7 +43,7 @@ #![feature(step_by)] #![feature(str_char)] #![feature(str_escape)] -#![feature(str_matches)] +#![feature(str_match_indices)] #![feature(str_utf16)] #![feature(subslice_offset)] #![feature(test)] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 2f45ffd141820..3026f91e853ee 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -1234,6 +1234,7 @@ impl<'a, I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for &'a mut I { reason = "trait has not proven itself as a widely useful \ abstraction for iterators, and more time may be needed \ for iteration on the design")] +#[allow(deprecated)] pub trait RandomAccessIterator: Iterator { /// Returns the number of indexable elements. At most `std::usize::MAX` /// elements are indexable, even if the iterator represents a longer range. @@ -1313,6 +1314,7 @@ impl DoubleEndedIterator for Rev where I: DoubleEndedIterator { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Rev where I: DoubleEndedIterator + RandomAccessIterator { @@ -1416,6 +1418,7 @@ impl<'a, I, T: 'a> ExactSizeIterator for Cloned {} #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, I, T: 'a> RandomAccessIterator for Cloned where I: RandomAccessIterator, T: Clone { @@ -1463,6 +1466,7 @@ impl Iterator for Cycle where I: Clone + Iterator { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Cycle where I: Clone + RandomAccessIterator, { @@ -1577,6 +1581,7 @@ impl DoubleEndedIterator for Chain where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Chain where A: RandomAccessIterator, B: RandomAccessIterator, @@ -1665,6 +1670,7 @@ impl DoubleEndedIterator for Zip where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Zip where A: RandomAccessIterator, B: RandomAccessIterator @@ -1719,6 +1725,7 @@ impl DoubleEndedIterator for Map where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Map where F: FnMut(I::Item) -> B, { @@ -1893,6 +1900,7 @@ impl DoubleEndedIterator for Enumerate where } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Enumerate where I: RandomAccessIterator { #[inline] fn indexable(&self) -> usize { @@ -2143,6 +2151,7 @@ impl Iterator for Skip where I: Iterator { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Skip where I: RandomAccessIterator{ #[inline] fn indexable(&self) -> usize { @@ -2215,6 +2224,7 @@ impl Iterator for Take where I: Iterator{ } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Take where I: RandomAccessIterator{ #[inline] fn indexable(&self) -> usize { @@ -2416,6 +2426,7 @@ impl DoubleEndedIterator for Fuse where I: DoubleEndedIterator { // Allow RandomAccessIterators to be fused without affecting random-access behavior #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Fuse where I: RandomAccessIterator { #[inline] fn indexable(&self) -> usize { @@ -2491,6 +2502,7 @@ impl DoubleEndedIterator for Inspect } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Inspect where F: FnMut(&I::Item), { @@ -2545,6 +2557,7 @@ impl RandomAccessIterator for Inspect #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] pub struct Unfold { f: F, /// Internal state that will be passed to the closure on the next iteration @@ -2556,6 +2569,7 @@ pub struct Unfold { #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] impl Unfold where F: FnMut(&mut St) -> Option { /// Creates a new iterator with the specified closure as the "iterator /// function" and an initial state to eventually pass to the closure @@ -2569,6 +2583,7 @@ impl Unfold where F: FnMut(&mut St) -> Option { } #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] impl Iterator for Unfold where F: FnMut(&mut St) -> Option { type Item = A; @@ -2977,7 +2992,7 @@ impl Iterator for Repeat { type Item = A; #[inline] - fn next(&mut self) -> Option { self.idx(0) } + fn next(&mut self) -> Option { Some(self.element.clone()) } #[inline] fn size_hint(&self) -> (usize, Option) { (usize::MAX, None) } } @@ -2985,10 +3000,11 @@ impl Iterator for Repeat { #[stable(feature = "rust1", since = "1.0.0")] impl DoubleEndedIterator for Repeat { #[inline] - fn next_back(&mut self) -> Option { self.idx(0) } + fn next_back(&mut self) -> Option { Some(self.element.clone()) } } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl RandomAccessIterator for Repeat { #[inline] fn indexable(&self) -> usize { usize::MAX } @@ -3004,6 +3020,7 @@ type IterateState = (F, Option, bool); #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] pub type Iterate = Unfold, fn(&mut IterateState) -> Option>; /// Creates a new iterator that produces an infinite sequence of @@ -3012,6 +3029,7 @@ pub type Iterate = Unfold, fn(&mut IterateState) #[deprecated(since = "1.2.0", reason = "has gained enough traction to retain its position \ in the standard library")] +#[allow(deprecated)] pub fn iterate(seed: T, f: F) -> Iterate where T: Clone, F: FnMut(T) -> T, diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 91acb0d695545..a8c995f37cce4 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -802,6 +802,7 @@ impl<'a, T> Clone for Iter<'a, T> { } #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Iter<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1174,6 +1175,7 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> { impl<'a, T> ExactSizeIterator for Windows<'a, T> {} #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Windows<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1261,6 +1263,7 @@ impl<'a, T> DoubleEndedIterator for Chunks<'a, T> { impl<'a, T> ExactSizeIterator for Chunks<'a, T> {} #[unstable(feature = "iter_idx", reason = "trait is experimental")] +#[allow(deprecated)] impl<'a, T> RandomAccessIterator for Chunks<'a, T> { #[inline] fn indexable(&self) -> usize { @@ -1520,6 +1523,7 @@ pub trait IntSliceExt { macro_rules! impl_int_slice { ($u:ty, $s:ty, $t:ty) => { #[unstable(feature = "int_slice")] + #[allow(deprecated)] impl IntSliceExt<$u, $s> for [$t] { #[inline] fn as_unsigned(&self) -> &[$u] { unsafe { transmute(self) } } diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 246b59098658a..7bafd9382f059 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -173,12 +173,10 @@ #![feature(box_syntax)] #![feature(const_fn)] #![feature(iter_cmp)] -#![feature(once_new)] #![feature(rt)] #![feature(staged_api)] #![feature(static_mutex)] -use std::boxed; use std::cell::RefCell; use std::fmt; use std::io::{self, Stderr}; @@ -437,12 +435,12 @@ fn init() { assert!(FILTER.is_null()); match filter { - Some(f) => FILTER = boxed::into_raw(box f), + Some(f) => FILTER = Box::into_raw(box f), None => {} } assert!(DIRECTIVES.is_null()); - DIRECTIVES = boxed::into_raw(box directives); + DIRECTIVES = Box::into_raw(box directives); // Schedule the cleanup for the globals for when the runtime exits. let _ = rt::at_exit(move || { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 377b60570e5fa..240aaae0e55af 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -57,7 +57,7 @@ #![feature(slice_position_elem)] #![feature(staged_api)] #![feature(str_char)] -#![feature(str_matches)] +#![feature(str_match_indices)] #![feature(vec_push_all)] #![feature(wrapping)] #![cfg_attr(test, feature(test))] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 052ec4897d131..fe3ffe9798151 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -26,7 +26,6 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![feature(box_syntax)] -#![feature(exit_status)] #![feature(libc)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] @@ -73,6 +72,7 @@ use std::env; use std::io::{self, Read, Write}; use std::iter::repeat; use std::path::PathBuf; +use std::process; use std::str; use std::sync::{Arc, Mutex}; use std::thread; @@ -861,5 +861,5 @@ pub fn diagnostics_registry() -> diagnostics::registry::Registry { pub fn main() { let result = run(env::args().collect()); - std::env::set_exit_status(result as i32); + process::exit(result as i32); } diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 1b8f049972f21..267f0b6d95329 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -25,7 +25,6 @@ use syntax::diagnostic::{Emitter, Handler, Level}; use std::ffi::{CStr, CString}; use std::fs; -use std::iter::Unfold; use std::mem; use std::path::Path; use std::process::{Command, Stdio}; @@ -913,11 +912,10 @@ fn run_work_singlethreaded(sess: &Session, reachable: &[String], work_items: Vec) { let cgcx = CodegenContext::new_with_session(sess, reachable); - let mut work_items = work_items; // Since we're running single-threaded, we can pass the session to // the proc, allowing `optimize_and_codegen` to perform LTO. - for work in Unfold::new((), |_| work_items.pop()) { + for work in work_items.into_iter().rev() { execute_work_item(&cgcx, work); } } diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index a1e1b395d987d..8ced85d336b74 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -31,9 +31,7 @@ #![feature(fs)] #![feature(iter_cmp)] #![feature(iter_arith)] -#![feature(iter_unfold)] #![feature(libc)] -#![feature(once_new)] #![feature(path_ext)] #![feature(path_ext)] #![feature(path_relative_from)] diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 9db9af32baa15..17d912dd4cb33 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -23,7 +23,6 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(dynamic_lib)] -#![feature(exit_status)] #![feature(libc)] #![feature(owned_ascii_ext)] #![feature(path_ext)] @@ -61,6 +60,7 @@ use std::env; use std::fs::File; use std::io::{self, Read, Write}; use std::path::PathBuf; +use std::process; use std::rc::Rc; use std::sync::mpsc::channel; @@ -134,7 +134,7 @@ pub fn main() { let s = env::args().collect::>(); main_args(&s) }).unwrap().join().unwrap(); - env::set_exit_status(res as i32); + process::exit(res as i32); } pub fn opts() -> Vec { diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 5951e4f823e7c..e7d9751cf4bc6 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -32,7 +32,6 @@ Core encoding and decoding interfaces. #![feature(enumset)] #![feature(hashmap_hasher)] #![feature(num_bits_bytes)] -#![feature(num_wrapping)] #![feature(rustc_private)] #![feature(staged_api)] #![feature(str_char)] diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 1677f95ca9039..17e8859d63f28 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -48,7 +48,7 @@ // reconsider what crate these items belong in. use any::TypeId; -use boxed::{self, Box}; +use boxed::Box; use convert::From; use fmt::{self, Debug, Display}; use marker::{Send, Sync, Reflect}; @@ -249,7 +249,7 @@ impl Error { if self.is::() { unsafe { // Get the raw representation of the trait object - let raw = boxed::into_raw(self); + let raw = Box::into_raw(self); let to: TraitObject = transmute::<*mut Error, TraitObject>(raw); diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index d5df9b3aa72b2..becc697bcd9a0 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -8,9 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. - use borrow::{Cow, ToOwned}; -use boxed::{self, Box}; +use boxed::Box; use clone::Clone; use convert::{Into, From}; use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering}; @@ -226,7 +225,7 @@ impl CString { // It is important that the bytes be sized to fit - we need // the capacity to be determinable from the string length, and // shrinking to fit is the only way to be sure. - boxed::into_raw(self.inner) as *const libc::c_char + Box::into_raw(self.inner) as *const libc::c_char } /// Returns the contents of this `CString` as a slice of bytes. diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 95363870cd08f..1d0152e275117 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -465,6 +465,7 @@ pub struct BufStream { leading to issues like #17136")] #[deprecated(since = "1.2.0", reason = "use the crates.io `bufstream` crate instead")] +#[allow(deprecated)] impl BufStream { /// Creates a new buffered stream with explicitly listed capacities for the /// reader/writer buffer. @@ -516,6 +517,7 @@ impl BufStream { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl BufRead for BufStream { fn fill_buf(&mut self) -> io::Result<&[u8]> { self.inner.fill_buf() } fn consume(&mut self, amt: usize) { self.inner.consume(amt) } @@ -524,6 +526,7 @@ impl BufRead for BufStream { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl Read for BufStream { fn read(&mut self, buf: &mut [u8]) -> io::Result { self.inner.read(buf) @@ -533,6 +536,7 @@ impl Read for BufStream { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl Write for BufStream { fn write(&mut self, buf: &[u8]) -> io::Result { self.inner.inner.get_mut().write(buf) @@ -545,6 +549,7 @@ impl Write for BufStream { #[unstable(feature = "buf_stream", reason = "unsure about semantics of buffering two directions, \ leading to issues like #17136")] +#[allow(deprecated)] impl fmt::Debug for BufStream where S: fmt::Debug { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { let reader = &self.inner; diff --git a/src/libstd/io/lazy.rs b/src/libstd/io/lazy.rs index d398cb88af458..c3e309d182b95 100644 --- a/src/libstd/io/lazy.rs +++ b/src/libstd/io/lazy.rs @@ -10,7 +10,6 @@ use prelude::v1::*; -use boxed; use cell::Cell; use rt; use sync::{StaticMutex, Arc}; @@ -60,7 +59,7 @@ impl Lazy { }); let ret = (self.init)(); if registered.is_ok() { - self.ptr.set(boxed::into_raw(Box::new(ret.clone()))); + self.ptr.set(Box::into_raw(Box::new(ret.clone()))); } return ret } diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 9f9435f412339..251f962c5e35e 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -106,7 +106,6 @@ #![feature(alloc)] #![feature(allow_internal_unstable)] #![feature(associated_consts)] -#![feature(borrow_state)] #![feature(box_raw)] #![feature(box_syntax)] #![feature(char_internals)] diff --git a/src/libstd/rt/at_exit_imp.rs b/src/libstd/rt/at_exit_imp.rs index 19a17be4ccf49..17d2940a6f10c 100644 --- a/src/libstd/rt/at_exit_imp.rs +++ b/src/libstd/rt/at_exit_imp.rs @@ -16,13 +16,12 @@ // segfaults (the queue's memory is mysteriously gone), so // instead the cleanup is tied to the `std::rt` entry point. -use boxed; +use alloc::boxed::FnBox; use boxed::Box; -use vec::Vec; -use thunk::Thunk; use sys_common::mutex::Mutex; +use vec::Vec; -type Queue = Vec>; +type Queue = Vec>; // NB these are specifically not types from `std::sync` as they currently rely // on poisoning and this module needs to operate at a lower level than requiring @@ -40,7 +39,7 @@ const ITERS: usize = 10; unsafe fn init() -> bool { if QUEUE.is_null() { let state: Box = box Vec::new(); - QUEUE = boxed::into_raw(state); + QUEUE = Box::into_raw(state); } else if QUEUE as usize == 1 { // can't re-init after a cleanup return false @@ -71,7 +70,7 @@ pub fn cleanup() { } } -pub fn push(f: Thunk<'static>) -> bool { +pub fn push(f: Box) -> bool { let mut ret = true; unsafe { LOCK.lock(); diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 1b8e81e2b7913..1729d20da205c 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -139,7 +139,9 @@ fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize { if failed { rt::DEFAULT_ERROR_CODE } else { - env::get_exit_status() as isize + #[allow(deprecated)] + fn exit_status() -> isize { env::get_exit_status() as isize } + exit_status() } } diff --git a/src/libstd/rt/unwind/gcc.rs b/src/libstd/rt/unwind/gcc.rs index 39b32a3f08e49..84c6d6864a9e5 100644 --- a/src/libstd/rt/unwind/gcc.rs +++ b/src/libstd/rt/unwind/gcc.rs @@ -11,7 +11,6 @@ use prelude::v1::*; use any::Any; -use boxed; use libc::c_void; use rt::libunwind as uw; @@ -29,7 +28,7 @@ pub unsafe fn panic(data: Box) -> ! { }, cause: Some(data), }; - let exception_param = boxed::into_raw(exception) as *mut uw::_Unwind_Exception; + let exception_param = Box::into_raw(exception) as *mut uw::_Unwind_Exception; let error = uw::_Unwind_RaiseException(exception_param); rtabort!("Could not unwind stack, error = {}", error as isize); diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index e3ddc1034a540..28dc124f0334f 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -32,10 +32,11 @@ reason = "futures as-is have yet to be deeply reevaluated with recent \ core changes to Rust's synchronization story, and will likely \ become stable in the future but are unstable until that time")] -#[deprecated(since = "1.2.0", - reason = "implementation does not match the quality of the \ - standard library and this will likely be prototyped \ - outside in crates.io first")] +#![deprecated(since = "1.2.0", + reason = "implementation does not match the quality of the \ + standard library and this will likely be prototyped \ + outside in crates.io first")] +#![allow(deprecated)] use core::prelude::*; use core::mem::replace; diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 91e9714fbef48..ab8d4587cfd3d 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -30,6 +30,7 @@ pub use self::rwlock::{RwLockReadGuard, RwLockWriteGuard}; pub use self::rwlock::{RwLock, StaticRwLock, RW_LOCK_INIT}; pub use self::semaphore::{Semaphore, SemaphoreGuard}; +#[allow(deprecated)] pub use self::future::Future; pub mod mpsc; diff --git a/src/libstd/sync/mpsc/mpsc_queue.rs b/src/libstd/sync/mpsc/mpsc_queue.rs index f3edf0d68c759..d6d173e5e7e7e 100644 --- a/src/libstd/sync/mpsc/mpsc_queue.rs +++ b/src/libstd/sync/mpsc/mpsc_queue.rs @@ -42,7 +42,6 @@ pub use self::PopResult::*; use core::prelude::*; -use alloc::boxed; use alloc::boxed::Box; use core::ptr; use core::cell::UnsafeCell; @@ -80,7 +79,7 @@ unsafe impl Sync for Queue { } impl Node { unsafe fn new(v: Option) -> *mut Node { - boxed::into_raw(box Node { + Box::into_raw(box Node { next: AtomicPtr::new(ptr::null_mut()), value: v, }) diff --git a/src/libstd/sync/mpsc/spsc_queue.rs b/src/libstd/sync/mpsc/spsc_queue.rs index 770068a66bec6..3cf75de5a46dd 100644 --- a/src/libstd/sync/mpsc/spsc_queue.rs +++ b/src/libstd/sync/mpsc/spsc_queue.rs @@ -35,7 +35,6 @@ use core::prelude::*; -use alloc::boxed; use alloc::boxed::Box; use core::ptr; use core::cell::UnsafeCell; @@ -78,7 +77,7 @@ unsafe impl Sync for Queue { } impl Node { fn new() -> *mut Node { - boxed::into_raw(box Node { + Box::into_raw(box Node { value: None, next: AtomicPtr::new(ptr::null_mut::>()), }) diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 64a5027cc8937..41cd11e4c6900 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -85,8 +85,6 @@ use sys_common::poison::{self, TryLockError, TryLockResult, LockResult}; /// To recover from a poisoned mutex: /// /// ``` -/// #![feature(sync_poison)] -/// /// use std::sync::{Arc, Mutex}; /// use std::thread; /// diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 428c8560d8847..8ea673d2162d1 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -28,7 +28,7 @@ use core::prelude::*; use core::char::{encode_utf8_raw, encode_utf16_raw}; -use core::str::{char_range_at_raw, next_code_point}; +use core::str::next_code_point; use ascii::*; use borrow::Cow; @@ -1148,30 +1148,6 @@ mod tests { assert_eq!(slice.ascii_byte_at(4), b'\xFF'); } - #[test] - fn wtf8_code_point_at() { - let mut string = Wtf8Buf::from_str("aé "); - string.push(CodePoint::from_u32(0xD83D).unwrap()); - string.push_char('💩'); - assert_eq!(string.code_point_at(0), CodePoint::from_char('a')); - assert_eq!(string.code_point_at(1), CodePoint::from_char('é')); - assert_eq!(string.code_point_at(3), CodePoint::from_char(' ')); - assert_eq!(string.code_point_at(4), CodePoint::from_u32(0xD83D).unwrap()); - assert_eq!(string.code_point_at(7), CodePoint::from_char('💩')); - } - - #[test] - fn wtf8_code_point_range_at() { - let mut string = Wtf8Buf::from_str("aé "); - string.push(CodePoint::from_u32(0xD83D).unwrap()); - string.push_char('💩'); - assert_eq!(string.code_point_range_at(0), (CodePoint::from_char('a'), 1)); - assert_eq!(string.code_point_range_at(1), (CodePoint::from_char('é'), 3)); - assert_eq!(string.code_point_range_at(3), (CodePoint::from_char(' '), 4)); - assert_eq!(string.code_point_range_at(4), (CodePoint::from_u32(0xD83D).unwrap(), 7)); - assert_eq!(string.code_point_range_at(7), (CodePoint::from_char('💩'), 11)); - } - #[test] fn wtf8_code_points() { fn c(value: u32) -> CodePoint { CodePoint::from_u32(value).unwrap() } diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 2b5e3fb18eb16..2c4b716cc6e94 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -326,7 +326,6 @@ mod imp { // Due to rust-lang/rust#18804, make sure this is not generic! #[cfg(target_os = "linux")] unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) { - use boxed; use mem; use ptr; use libc; @@ -360,7 +359,7 @@ mod imp { type List = Vec<(*mut u8, unsafe extern fn(*mut u8))>; if DTORS.get().is_null() { let v: Box = box Vec::new(); - DTORS.set(boxed::into_raw(v) as *mut u8); + DTORS.set(Box::into_raw(v) as *mut u8); } let list: &mut List = &mut *(DTORS.get() as *mut List); list.push((t, dtor)); diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index da9cde8e3cd34..dbb7d3233bc39 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -404,6 +404,7 @@ pub fn spawn(f: F) -> JoinHandle where #[deprecated(since = "1.2.0", reason = "this unsafe API is unlikely to ever be stabilized \ in this form")] +#[allow(deprecated)] pub fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where T: Send + 'a, F: FnOnce() -> T, F: Send + 'a { diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 1507226c3a133..f800b4863c669 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -46,7 +46,6 @@ #![feature(set_stdio)] #![feature(slice_extras)] #![feature(staged_api)] -#![feature(thunk)] extern crate getopts; extern crate serialize; @@ -82,7 +81,6 @@ use std::path::PathBuf; use std::sync::mpsc::{channel, Sender}; use std::sync::{Arc, Mutex}; use std::thread; -use std::thunk::Thunk; use std::time::Duration; // to be used by rustc to compile tests in libtest @@ -155,7 +153,7 @@ pub enum TestFn { StaticTestFn(fn()), StaticBenchFn(fn(&mut Bencher)), StaticMetricFn(fn(&mut MetricMap)), - DynTestFn(Thunk<'static>), + DynTestFn(Box), DynMetricFn(Box), DynBenchFn(Box) } @@ -961,7 +959,7 @@ pub fn run_test(opts: &TestOpts, fn run_test_inner(desc: TestDesc, monitor_ch: Sender, nocapture: bool, - testfn: Thunk<'static>) { + testfn: Box) { struct Sink(Arc>>); impl Write for Sink { fn write(&mut self, data: &[u8]) -> io::Result { @@ -1229,7 +1227,6 @@ mod tests { TestDesc, TestDescAndFn, TestOpts, run_test, MetricMap, StaticTestName, DynTestName, DynTestFn, ShouldPanic}; - use std::thunk::Thunk; use std::sync::mpsc::channel; #[test] diff --git a/src/rustbook/main.rs b/src/rustbook/main.rs index 707493e85189c..acb1c5cbd90ba 100644 --- a/src/rustbook/main.rs +++ b/src/rustbook/main.rs @@ -10,7 +10,6 @@ #![deny(warnings)] -#![feature(exit_status)] #![feature(iter_arith)] #![feature(path_relative_from)] #![feature(rustc_private)] @@ -21,6 +20,8 @@ extern crate rustc_back; use std::env; use std::error::Error; +use std::process; +use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT, Ordering}; use subcommand::Subcommand; use term::Term; @@ -37,6 +38,8 @@ mod test; mod css; mod javascript; +static EXIT_STATUS: AtomicIsize = ATOMIC_ISIZE_INIT; + #[cfg(not(test))] // thanks #12327 fn main() { let mut term = Term::new(); @@ -70,4 +73,5 @@ fn main() { } } } + process::exit(EXIT_STATUS.load(Ordering::SeqCst) as i32); } diff --git a/src/rustbook/term.rs b/src/rustbook/term.rs index 060297beb758b..cdd25e67c8ff1 100644 --- a/src/rustbook/term.rs +++ b/src/rustbook/term.rs @@ -11,9 +11,9 @@ //! An abstraction of the terminal. Eventually, provide color and //! verbosity support. For now, just a wrapper around stdout/stderr. -use std::env; use std::io; use std::io::prelude::*; +use std::sync::atomic::Ordering; pub struct Term { err: Box @@ -29,6 +29,6 @@ impl Term { pub fn err(&mut self, msg: &str) { // swallow any errors let _ = writeln!(&mut self.err, "{}", msg); - env::set_exit_status(101); + ::EXIT_STATUS.store(101, Ordering::SeqCst); } } diff --git a/src/test/run-pass/issue-11958.rs b/src/test/run-pass/issue-11958.rs index e0c43422c2823..05de69cb966ad 100644 --- a/src/test/run-pass/issue-11958.rs +++ b/src/test/run-pass/issue-11958.rs @@ -8,19 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - #![forbid(warnings)] -#![feature(thunk)] - -// Pretty printing tests complain about `use std::predule::*` -#![allow(unused_imports)] // We shouldn't need to rebind a moved upvar as mut if it's already // marked as mut -use std::thunk::Thunk; - pub fn main() { let mut x = 1; let _thunk = Box::new(move|| { x = 2; }); From 252ef28593458b2479735b4f85c8568bb0f0a3d5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 11 Jun 2015 09:54:43 -0700 Subject: [PATCH 27/48] std: Update stable since for `core::char` Also add `#[doc(hidden)]` to a few internal functions. --- src/libcore/char.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 9f5944d3c9c71..12aa06667a1dd 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -14,7 +14,7 @@ #![allow(non_snake_case)] #![doc(primitive = "char")] -#![stable(feature = "rust1", since = "1.0.0")] +#![stable(feature = "core_char", since = "1.2.0")] use iter::Iterator; use mem::transmute; @@ -225,6 +225,7 @@ impl CharExt for char { #[inline] #[unstable(feature = "char_internals", reason = "this function should not be exposed publicly")] +#[doc(hidden)] pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option { // Marked #[inline] to allow llvm optimizing it away if code < MAX_ONE_B && !dst.is_empty() { @@ -258,6 +259,7 @@ pub fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> Option { #[inline] #[unstable(feature = "char_internals", reason = "this function should not be exposed publicly")] +#[doc(hidden)] pub fn encode_utf16_raw(mut ch: u32, dst: &mut [u16]) -> Option { // Marked #[inline] to allow llvm optimizing it away if (ch & 0xFFFF) == ch && !dst.is_empty() { From edf933538bc508052320889f9c05f24d75dd6b07 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 11 Jun 2015 09:56:13 -0700 Subject: [PATCH 28/48] std: Hide some internal functions more aggressively * Add `#[doc(hidden)]` * Rename away from `Error::description` --- src/libcore/num/mod.rs | 6 ++++-- src/libstd/error.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 6af2148d4ed3d..c1297d3c19c1a 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1514,7 +1514,8 @@ impl ParseIntError { #[unstable(feature = "int_error_internals", reason = "available through Error trait and this method should \ not be exposed publicly")] - pub fn description(&self) -> &str { + #[doc(hidden)] + pub fn __description(&self) -> &str { match self.kind { IntErrorKind::Empty => "cannot parse integer from empty string", IntErrorKind::InvalidDigit => "invalid digit found in string", @@ -1527,7 +1528,7 @@ impl ParseIntError { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Display for ParseIntError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - self.description().fmt(f) + self.__description().fmt(f) } } @@ -1544,6 +1545,7 @@ pub struct ParseFloatError { #[derive(Debug, Clone, PartialEq)] #[unstable(feature = "float_error_internals", reason = "should not be exposed publicly")] +#[doc(hidden)] pub enum FloatErrorKind { Empty, Invalid, diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 17e8859d63f28..b21b2edf2ecd8 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -140,7 +140,7 @@ impl Error for str::Utf8Error { #[stable(feature = "rust1", since = "1.0.0")] impl Error for num::ParseIntError { fn description(&self) -> &str { - self.description() + self.__description() } } From c9b40a30c0a8c5776920aec54039d0571e903f5a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 11 Jun 2015 11:15:19 -0700 Subject: [PATCH 29/48] std: Stabilize vec_map::Entry::or_insert{,_with} These functions mirror the other Entry APIs of other maps, and were mistakenly just not stabilized the first time around. --- src/libcollections/vec_map.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 98ecd045b9ace..685bb5dc4b4f3 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -646,10 +646,9 @@ impl<'a, V> Entry<'a, V> { } } - #[unstable(feature = "entry", - reason = "matches entry v3 specification, waiting for dust to settle")] - /// Ensures a value is in the entry by inserting the default if empty, and returns - /// a mutable reference to the value in the entry. + #[stable(feature = "vecmap_entry", since = "1.2.0")] + /// Ensures a value is in the entry by inserting the default if empty, and + /// returns a mutable reference to the value in the entry. pub fn or_insert(self, default: V) -> &'a mut V { match self { Occupied(entry) => entry.into_mut(), @@ -657,10 +656,10 @@ impl<'a, V> Entry<'a, V> { } } - #[unstable(feature = "entry", - reason = "matches entry v3 specification, waiting for dust to settle")] - /// Ensures a value is in the entry by inserting the result of the default function if empty, - /// and returns a mutable reference to the value in the entry. + #[stable(feature = "vecmap_entry", since = "1.2.0")] + /// Ensures a value is in the entry by inserting the result of the default + /// function if empty, and returns a mutable reference to the value in the + /// entry. pub fn or_insert_with V>(self, default: F) -> &'a mut V { match self { Occupied(entry) => entry.into_mut(), From 913c2273eba32c7a33e068a5ac68007d7f8419d1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 11 Jun 2015 11:26:16 -0700 Subject: [PATCH 30/48] Add comment about stabilizing CString::from_ptr This naming needs to consider the raw vs ptr naming of Box/CStr/CString/slice/etc. --- src/liballoc/boxed.rs | 2 ++ src/libstd/ffi/c_str.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 1a360ebc05c71..1039756363e9f 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -124,6 +124,7 @@ impl Box { #[unstable(feature = "box_raw", reason = "may be renamed or moved out of Box scope")] #[inline] + // NB: may want to be called from_ptr, see comments on CStr::from_ptr pub unsafe fn from_raw(raw: *mut T) -> Self { mem::transmute(raw) } @@ -147,6 +148,7 @@ impl Box { /// ``` #[unstable(feature = "box_raw", reason = "may be renamed")] #[inline] + // NB: may want to be called into_ptr, see comments on CStr::from_ptr pub fn into_raw(b: Box) -> *mut T { unsafe { mem::transmute(b) } } diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index becc697bcd9a0..ffc204ada60fb 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -206,6 +206,9 @@ impl CString { /// `into_ptr`. The length of the string will be recalculated /// using the pointer. #[unstable(feature = "cstr_memory", reason = "recently added")] + // NB: may want to be called from_raw, needs to consider CStr::from_ptr, + // Box::from_raw (or whatever it's currently called), and + // slice::from_raw_parts pub unsafe fn from_ptr(ptr: *const libc::c_char) -> CString { let len = libc::strlen(ptr) + 1; // Including the NUL byte let slice = slice::from_raw_parts(ptr, len as usize); @@ -221,6 +224,7 @@ impl CString { /// /// Failure to call `from_ptr` will lead to a memory leak. #[unstable(feature = "cstr_memory", reason = "recently added")] + // NB: may want to be called into_raw, see comments on from_ptr pub fn into_ptr(self) -> *const libc::c_char { // It is important that the bytes be sized to fit - we need // the capacity to be determinable from the string length, and From b637f6b1bdee12e0cf18bd8fefbebe058518726f Mon Sep 17 00:00:00 2001 From: Nick Hamann Date: Wed, 17 Jun 2015 19:41:55 -0500 Subject: [PATCH 31/48] Fix the E0252 error message to use better names for things. Currently in the E0252 message, traits and modules are all called types (as in "a type named `Foo` has already been imported", even when `Foo` was a trait or module). This commit changes that to additionally detect when the import in question is a trait or module and report it accordingly. Fixes #25396. --- src/librustc_resolve/resolve_imports.rs | 15 +++++++++- src/test/compile-fail/issue-25396.rs | 37 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/issue-25396.rs diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 71a63e24faf7c..57d0c98d50e99 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -12,6 +12,7 @@ use self::ImportDirectiveSubclass::*; use DefModifiers; use Module; +use ModuleKind; use Namespace::{self, TypeNS, ValueNS}; use NameBindings; use NamespaceResult::{BoundResult, UnboundResult, UnknownResult}; @@ -899,7 +900,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> { match target { Some(ref target) if target.shadowable != Shadowable::Always => { let ns_word = match namespace { - TypeNS => "type", + TypeNS => { + if let Some(ref ty_def) = *target.bindings.type_def.borrow() { + match ty_def.module_def { + Some(ref module) + if module.kind.get() == ModuleKind::NormalModuleKind => + "module", + Some(ref module) + if module.kind.get() == ModuleKind::TraitModuleKind => + "trait", + _ => "type", + } + } else { "type" } + }, ValueNS => "value", }; span_err!(self.resolver.session, import_span, E0252, diff --git a/src/test/compile-fail/issue-25396.rs b/src/test/compile-fail/issue-25396.rs new file mode 100644 index 0000000000000..3ada57c999305 --- /dev/null +++ b/src/test/compile-fail/issue-25396.rs @@ -0,0 +1,37 @@ +// Copyright 2015 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. + +use foo::baz; +use bar::baz; //~ ERROR a module named `baz` has already been imported + +use foo::Quux; +use bar::Quux; //~ ERROR a trait named `Quux` has already been imported + +use foo::blah; +use bar::blah; //~ ERROR a type named `blah` has already been imported + +use foo::WOMP; +use bar::WOMP; //~ ERROR a value named `WOMP` has already been imported + +fn main() {} + +mod foo { + pub mod baz {} + pub trait Quux { } + pub type blah = (f64, u32); + pub const WOMP: u8 = 5; +} + +mod bar { + pub mod baz {} + pub type Quux = i32; + struct blah { x: i8 } + pub const WOMP: i8 = -5; +} From ec333380e03eb1fb94c4938db888d5bed40b8fd6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 12 Jun 2015 10:49:39 -0700 Subject: [PATCH 32/48] Fix libstd tests --- src/librustc_trans/lib.rs | 1 - src/librustc_typeck/lib.rs | 1 + src/libstd/lib.rs | 5 ++++- src/libstd/sys/windows/thread_local.rs | 3 +-- src/libstd/thread/local.rs | 3 +-- src/test/run-pass/issue-13259-windows-tcb-trash.rs | 2 -- src/test/run-pass/sync-send-iterators-in-libcore.rs | 10 +++++----- src/test/run-pass/x86stdcall2.rs | 2 -- 8 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 8ced85d336b74..bb7e95cd4ae44 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -28,7 +28,6 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![feature(const_fn)] -#![feature(fs)] #![feature(iter_cmp)] #![feature(iter_arith)] #![feature(libc)] diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 764910100360a..7519cd0519569 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -75,6 +75,7 @@ This API is completely unstable and subject to change. #![allow(non_camel_case_types)] +#![feature(append)] #![feature(box_patterns)] #![feature(box_syntax)] #![feature(drain)] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 251f962c5e35e..e5242c5bf861a 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -106,6 +106,7 @@ #![feature(alloc)] #![feature(allow_internal_unstable)] #![feature(associated_consts)] +#![feature(borrow_state)] #![feature(box_raw)] #![feature(box_syntax)] #![feature(char_internals)] @@ -130,7 +131,6 @@ #![feature(slice_concat_ext)] #![feature(slice_position_elem)] #![feature(no_std)] -#![feature(num_bits_bytes)] #![feature(oom)] #![feature(optin_builtin_traits)] #![feature(rand)] @@ -148,6 +148,9 @@ #![feature(vec_push_all)] #![feature(wrapping)] #![feature(zero_one)] +#![cfg_attr(all(unix, not(target_os = "macos"), not(target_os = "ios")), + feature(num_bits_bytes))] +#![cfg_attr(windows, feature(str_utf16))] #![cfg_attr(test, feature(float_from_str_radix, range_inclusive, float_extras))] #![cfg_attr(test, feature(test, rustc_private, float_consts))] diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs index a3d522d1757a9..5002de559884d 100644 --- a/src/libstd/sys/windows/thread_local.rs +++ b/src/libstd/sys/windows/thread_local.rs @@ -12,7 +12,6 @@ use prelude::v1::*; use libc::types::os::arch::extra::{DWORD, LPVOID, BOOL}; -use boxed; use ptr; use rt; use sys_common::mutex::Mutex; @@ -143,7 +142,7 @@ unsafe fn init_dtors() { DTOR_LOCK.unlock(); }); if res.is_ok() { - DTORS = boxed::into_raw(dtors); + DTORS = Box::into_raw(dtors); } else { DTORS = 1 as *mut _; } diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index 2c4b716cc6e94..60563340d1021 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -405,7 +405,6 @@ mod imp { mod imp { use prelude::v1::*; - use alloc::boxed; use cell::{Cell, UnsafeCell}; use marker; use ptr; @@ -447,7 +446,7 @@ mod imp { key: self, value: UnsafeCell::new(None), }; - let ptr = boxed::into_raw(ptr); + let ptr = Box::into_raw(ptr); self.os.set(ptr as *mut u8); Some(&(*ptr).value) } diff --git a/src/test/run-pass/issue-13259-windows-tcb-trash.rs b/src/test/run-pass/issue-13259-windows-tcb-trash.rs index 9ebbddf5141b7..2e03a9a724420 100644 --- a/src/test/run-pass/issue-13259-windows-tcb-trash.rs +++ b/src/test/run-pass/issue-13259-windows-tcb-trash.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - #![feature(libc, std_misc)] extern crate libc; diff --git a/src/test/run-pass/sync-send-iterators-in-libcore.rs b/src/test/run-pass/sync-send-iterators-in-libcore.rs index 8dda2365ac704..d76bf89d05396 100644 --- a/src/test/run-pass/sync-send-iterators-in-libcore.rs +++ b/src/test/run-pass/sync-send-iterators-in-libcore.rs @@ -10,15 +10,15 @@ // pretty-expanded FIXME #23616 -#![allow(unused_mut)] -#![feature(core)] -#![feature(collections)] -#![feature(step_by)] +#![allow(warnings)] #![feature(iter_empty)] #![feature(iter_once)] +#![feature(iter_unfold)] +#![feature(range_inclusive)] +#![feature(step_by)] +#![feature(str_escape)] use std::iter::{empty, once, range_inclusive, repeat, Unfold}; ->>>>>>> Fallout in tests and docs from feature renamings fn is_sync(_: T) where T: Sync {} fn is_send(_: T) where T: Send {} diff --git a/src/test/run-pass/x86stdcall2.rs b/src/test/run-pass/x86stdcall2.rs index 62da9c9d14be2..c9742b0645e1d 100644 --- a/src/test/run-pass/x86stdcall2.rs +++ b/src/test/run-pass/x86stdcall2.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - #![feature(std_misc)] pub type HANDLE = u32; From 2e997ef2d487525ea41e78ba793cb6e7c61cb204 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Sun, 14 Jun 2015 01:49:28 +0300 Subject: [PATCH 33/48] rustc: remove ownership of tcx from trans' context. --- src/librustc/middle/ty.rs | 3 +- src/librustc_driver/driver.rs | 43 ++++---- src/librustc_driver/lib.rs | 10 +- src/librustc_driver/pretty.rs | 34 +++--- src/librustc_trans/save/dump_csv.rs | 116 +++++++++------------ src/librustc_trans/save/mod.rs | 88 ++++++++-------- src/librustc_trans/trans/base.rs | 13 +-- src/librustc_trans/trans/context.rs | 28 +++-- src/librustdoc/core.rs | 18 ++-- src/test/run-make/execution-engine/test.rs | 4 +- 10 files changed, 161 insertions(+), 196 deletions(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index f5fcb72c5c1c9..fa7b1aa4fbe89 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -101,11 +101,10 @@ pub const INITIAL_DISCRIMINANT_VALUE: Disr = 0; /// The complete set of all analyses described in this module. This is /// produced by the driver and fed to trans and later passes. -pub struct CrateAnalysis<'tcx> { +pub struct CrateAnalysis { pub export_map: ExportMap, pub exported_items: middle::privacy::ExportedItems, pub public_items: middle::privacy::PublicItems, - pub ty_cx: ty::ctxt<'tcx>, pub reachable: NodeSet, pub name: String, pub glob_map: Option, diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index eaac1eb6f2cb0..7297d9c00b4d7 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -119,26 +119,26 @@ pub fn compile_input(sess: Session, &ast_map.krate(), &id[..])); - let analysis = phase_3_run_analysis_passes(sess, - ast_map, - &arenas, - id, - control.make_glob_map); + let (tcx, analysis) = phase_3_run_analysis_passes(sess, + ast_map, + &arenas, + id, + control.make_glob_map); controller_entry_point!(after_analysis, - analysis.ty_cx.sess, + tcx.sess, CompileState::state_after_analysis(input, - &analysis.ty_cx.sess, + &tcx.sess, outdir, - analysis.ty_cx.map.krate(), + tcx.map.krate(), &analysis, - &analysis.ty_cx)); + &tcx)); if log_enabled!(::log::INFO) { println!("Pre-trans"); - analysis.ty_cx.print_debug_stats(); + tcx.print_debug_stats(); } - let (tcx, trans) = phase_4_translate_to_llvm(analysis); + let trans = phase_4_translate_to_llvm(&tcx, analysis); if log_enabled!(::log::INFO) { println!("Post-trans"); @@ -240,7 +240,7 @@ pub struct CompileState<'a, 'ast: 'a, 'tcx: 'a> { pub out_dir: Option<&'a Path>, pub expanded_crate: Option<&'a ast::Crate>, pub ast_map: Option<&'a ast_map::Map<'ast>>, - pub analysis: Option<&'a ty::CrateAnalysis<'tcx>>, + pub analysis: Option<&'a ty::CrateAnalysis>, pub tcx: Option<&'a ty::ctxt<'tcx>>, pub trans: Option<&'a trans::CrateTranslation>, } @@ -309,7 +309,7 @@ impl<'a, 'ast, 'tcx> CompileState<'a, 'ast, 'tcx> { session: &'a Session, out_dir: &'a Option, expanded_crate: &'a ast::Crate, - analysis: &'a ty::CrateAnalysis<'tcx>, + analysis: &'a ty::CrateAnalysis, tcx: &'a ty::ctxt<'tcx>) -> CompileState<'a, 'ast, 'tcx> { CompileState { @@ -583,7 +583,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, arenas: &'tcx ty::CtxtArenas<'tcx>, name: String, make_glob_map: resolve::MakeGlobMap) - -> ty::CrateAnalysis<'tcx> { + -> (ty::ctxt<'tcx>, ty::CrateAnalysis) { let time_passes = sess.time_passes(); let krate = ast_map.krate(); @@ -704,29 +704,28 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, // The above three passes generate errors w/o aborting ty_cx.sess.abort_if_errors(); - ty::CrateAnalysis { + (ty_cx, ty::CrateAnalysis { export_map: export_map, - ty_cx: ty_cx, exported_items: exported_items, public_items: public_items, reachable: reachable_map, name: name, glob_map: glob_map, - } + }) } /// Run the translation phase to LLVM, after which the AST and analysis can /// be discarded. -pub fn phase_4_translate_to_llvm<'tcx>(analysis: ty::CrateAnalysis<'tcx>) - -> (ty::ctxt<'tcx>, trans::CrateTranslation) { - let time_passes = analysis.ty_cx.sess.time_passes(); +pub fn phase_4_translate_to_llvm(tcx: &ty::ctxt, analysis: ty::CrateAnalysis) + -> trans::CrateTranslation { + let time_passes = tcx.sess.time_passes(); time(time_passes, "resolving dependency formats", (), |_| - dependency_format::calculate(&analysis.ty_cx)); + dependency_format::calculate(tcx)); // Option dance to work around the lack of stack once closures. time(time_passes, "translation", analysis, |analysis| - trans::trans_crate(analysis)) + trans::trans_crate(tcx, analysis)) } /// Run LLVM itself, producing a bitcode file, assembly file or object file diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index fe3ffe9798151..96d1ab23ad523 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -377,12 +377,10 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls { if sess.opts.debugging_opts.save_analysis { control.after_analysis.callback = box |state| { time(state.session.time_passes(), - "save analysis", - state.expanded_crate.unwrap(), - |krate| save::process_crate(state.session, - krate, - state.analysis.unwrap(), - state.out_dir)); + "save analysis", (), + |_| save::process_crate(state.tcx.unwrap(), + state.analysis.unwrap(), + state.out_dir)); }; control.make_glob_map = resolve::MakeGlobMap::Yes; } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index c98052825e1dd..0dc636eb3ec9c 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -148,12 +148,12 @@ impl PpSourceMode { } PpmTyped => { let ast_map = ast_map.expect("--pretty=typed missing ast_map"); - let analysis = driver::phase_3_run_analysis_passes(sess, + let (tcx, _) = driver::phase_3_run_analysis_passes(sess, ast_map, arenas, id, resolve::MakeGlobMap::No); - let annotation = TypedAnnotation { analysis: analysis }; + let annotation = TypedAnnotation { tcx: tcx }; f(&annotation, payload) } } @@ -285,14 +285,14 @@ impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> { struct TypedAnnotation<'tcx> { - analysis: ty::CrateAnalysis<'tcx>, + tcx: ty::ctxt<'tcx>, } impl<'tcx> PrinterSupport<'tcx> for TypedAnnotation<'tcx> { - fn sess<'a>(&'a self) -> &'a Session { &self.analysis.ty_cx.sess } + fn sess<'a>(&'a self) -> &'a Session { &self.tcx.sess } fn ast_map<'a>(&'a self) -> Option<&'a ast_map::Map<'tcx>> { - Some(&self.analysis.ty_cx.map) + Some(&self.tcx.map) } fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn { self } @@ -310,7 +310,6 @@ impl<'tcx> pprust::PpAnn for TypedAnnotation<'tcx> { fn post(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> { - let tcx = &self.analysis.ty_cx; match node { pprust::NodeExpr(expr) => { try!(pp::space(&mut s.s)); @@ -318,8 +317,8 @@ impl<'tcx> pprust::PpAnn for TypedAnnotation<'tcx> { try!(pp::space(&mut s.s)); try!(pp::word(&mut s.s, &ppaux::ty_to_string( - tcx, - ty::expr_ty(tcx, expr)))); + &self.tcx, + ty::expr_ty(&self.tcx, expr)))); s.pclose() } _ => Ok(()) @@ -646,12 +645,12 @@ pub fn pretty_print_input(sess: Session, match code { Some(code) => { let variants = gather_flowgraph_variants(&sess); - let analysis = driver::phase_3_run_analysis_passes(sess, + let (tcx, _) = driver::phase_3_run_analysis_passes(sess, ast_map, &arenas, id, resolve::MakeGlobMap::No); - print_flowgraph(variants, analysis, code, mode, out) + print_flowgraph(variants, &tcx, code, mode, out) } None => { let message = format!("--pretty=flowgraph needs \ @@ -682,18 +681,17 @@ pub fn pretty_print_input(sess: Session, } fn print_flowgraph(variants: Vec, - analysis: ty::CrateAnalysis, + tcx: &ty::ctxt, code: blocks::Code, mode: PpFlowGraphMode, mut out: W) -> io::Result<()> { - let ty_cx = &analysis.ty_cx; let cfg = match code { - blocks::BlockCode(block) => cfg::CFG::new(ty_cx, &*block), - blocks::FnLikeCode(fn_like) => cfg::CFG::new(ty_cx, &*fn_like.body()), + blocks::BlockCode(block) => cfg::CFG::new(tcx, &*block), + blocks::FnLikeCode(fn_like) => cfg::CFG::new(tcx, &*fn_like.body()), }; let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges; let lcfg = LabelledCFG { - ast_map: &ty_cx.map, + ast_map: &tcx.map, cfg: &cfg, name: format!("node_{}", code.id()), labelled_edges: labelled_edges, @@ -705,14 +703,14 @@ fn print_flowgraph(variants: Vec, return expand_err_details(r); } blocks::BlockCode(_) => { - ty_cx.sess.err("--pretty flowgraph with -Z flowgraph-print \ - annotations requires fn-like node id."); + tcx.sess.err("--pretty flowgraph with -Z flowgraph-print \ + annotations requires fn-like node id."); return Ok(()) } blocks::FnLikeCode(fn_like) => { let fn_parts = borrowck::FnPartsWithCFG::from_fn_like(&fn_like, &cfg); let (bccx, analysis_data) = - borrowck::build_borrowck_dataflow_data_for_fn(ty_cx, fn_parts); + borrowck::build_borrowck_dataflow_data_for_fn(tcx, fn_parts); let lcfg = borrowck_dot::DataflowLabeller { inner: lcfg, diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index cbc40af4b524e..f68024656e03d 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -67,7 +67,8 @@ macro_rules! down_cast_data { pub struct DumpCsvVisitor<'l, 'tcx: 'l> { save_ctxt: SaveContext<'l, 'tcx>, sess: &'l Session, - analysis: &'l ty::CrateAnalysis<'tcx>, + tcx: &'l ty::ctxt<'tcx>, + analysis: &'l ty::CrateAnalysis, span: SpanUtils<'l>, fmt: FmtStrs<'l>, @@ -76,28 +77,23 @@ pub struct DumpCsvVisitor<'l, 'tcx: 'l> { } impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { - pub fn new(sess: &'l Session, - analysis: &'l ty::CrateAnalysis<'tcx>, + pub fn new(tcx: &'l ty::ctxt<'tcx>, + analysis: &'l ty::CrateAnalysis, output_file: Box) -> DumpCsvVisitor<'l, 'tcx> { + let span_utils = SpanUtils { + sess: &tcx.sess, + err_count: Cell::new(0) + }; DumpCsvVisitor { - sess: sess, - save_ctxt: SaveContext::new(sess, analysis, SpanUtils { - sess: sess, - err_count: Cell::new(0) - }), + sess: &tcx.sess, + tcx: tcx, + save_ctxt: SaveContext::new(tcx, span_utils.clone()), analysis: analysis, - span: SpanUtils { - sess: sess, - err_count: Cell::new(0) - }, + span: span_utils.clone(), fmt: FmtStrs::new(box Recorder { out: output_file, dump_spans: false, - }, - SpanUtils { - sess: sess, - err_count: Cell::new(0) - }), + }, span_utils), cur_scope: 0 } } @@ -237,11 +233,11 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { // looks up anything, not just a type fn lookup_type_ref(&self, ref_id: NodeId) -> Option { - if !self.analysis.ty_cx.def_map.borrow().contains_key(&ref_id) { + if !self.tcx.def_map.borrow().contains_key(&ref_id) { self.sess.bug(&format!("def_map has no key for {} in lookup_type_ref", ref_id)); } - let def = self.analysis.ty_cx.def_map.borrow().get(&ref_id).unwrap().full_def(); + let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def(); match def { def::DefPrimTy(_) => None, _ => Some(def.def_id()), @@ -249,7 +245,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { } fn lookup_def_kind(&self, ref_id: NodeId, span: Span) -> Option { - let def_map = self.analysis.ty_cx.def_map.borrow(); + let def_map = self.tcx.def_map.borrow(); if !def_map.contains_key(&ref_id) { self.sess.span_bug(span, &format!("def_map has no key for {} in lookup_def_kind", ref_id)); @@ -293,8 +289,8 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { for &(id, ref p, _, _) in &collector.collected_paths { let typ = ppaux::ty_to_string( - &self.analysis.ty_cx, - *self.analysis.ty_cx.node_types().get(&id).unwrap()); + self.tcx, + *self.tcx.node_types().get(&id).unwrap()); // get the span only for the name of the variable (I hope the path is only ever a // variable name, but who knows?) self.fmt.formal_str(p.span, @@ -320,9 +316,8 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { let mut scope_id; // The qualname for a method is the trait name or name of the struct in an impl in // which the method is declared in, followed by the method's name. - let qualname = match ty::impl_of_method(&self.analysis.ty_cx, - ast_util::local_def(id)) { - Some(impl_id) => match self.analysis.ty_cx.map.get(impl_id.node) { + let qualname = match ty::impl_of_method(self.tcx, ast_util::local_def(id)) { + Some(impl_id) => match self.tcx.map.get(impl_id.node) { NodeItem(item) => { scope_id = item.id; match item.node { @@ -330,12 +325,11 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { let mut result = String::from("<"); result.push_str(&ty_to_string(&**ty)); - match ty::trait_of_item(&self.analysis.ty_cx, - ast_util::local_def(id)) { + match ty::trait_of_item(self.tcx, ast_util::local_def(id)) { Some(def_id) => { result.push_str(" as "); result.push_str( - &ty::item_path_str(&self.analysis.ty_cx, def_id)); + &ty::item_path_str(self.tcx, def_id)); }, None => {} } @@ -352,16 +346,15 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { _ => { self.sess.span_bug(span, &format!("Container {} for method {} is not a node item {:?}", - impl_id.node, id, self.analysis.ty_cx.map.get(impl_id.node))); + impl_id.node, id, self.tcx.map.get(impl_id.node))); }, }, - None => match ty::trait_of_item(&self.analysis.ty_cx, - ast_util::local_def(id)) { + None => match ty::trait_of_item(self.tcx, ast_util::local_def(id)) { Some(def_id) => { scope_id = def_id.node; - match self.analysis.ty_cx.map.get(def_id.node) { + match self.tcx.map.get(def_id.node) { NodeItem(_) => { - format!("::{}", ty::item_path_str(&self.analysis.ty_cx, def_id)) + format!("::{}", ty::item_path_str(self.tcx, def_id)) } _ => { self.sess.span_bug(span, @@ -380,8 +373,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { let qualname = &format!("{}::{}", qualname, &token::get_name(name)); // record the decl for this def (if it has one) - let decl_id = ty::trait_item_of_item(&self.analysis.ty_cx, - ast_util::local_def(id)) + let decl_id = ty::trait_item_of_item(self.tcx, ast_util::local_def(id)) .and_then(|new_id| { let def_id = new_id.def_id(); if def_id.node != 0 && def_id != ast_util::local_def(id) { @@ -538,7 +530,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { typ: &ast::Ty, expr: &ast::Expr) { - let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(id)); + let qualname = format!("::{}", self.tcx.map.path_to_string(id)); let sub_span = self.span.sub_span_after_keyword(span, keywords::Const); @@ -561,7 +553,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { item: &ast::Item, def: &ast::StructDef, ty_params: &ast::Generics) { - let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let ctor_id = match def.ctor_id { Some(node_id) => node_id, @@ -691,7 +683,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { generics: &ast::Generics, trait_refs: &OwnedSlice, methods: &[P]) { - let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let val = self.span.snippet(item.span); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Trait); self.fmt.trait_str(item.span, @@ -758,7 +750,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { return } - let def_map = self.analysis.ty_cx.def_map.borrow(); + let def_map = self.tcx.def_map.borrow(); if !def_map.contains_key(&id) { self.sess.span_bug(span, &format!("def_map has no key for {} in visit_expr", id)); @@ -789,12 +781,10 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { def::DefMethod(declid, provenence) => { let sub_span = self.span.sub_span_for_meth_name(span); let defid = if declid.krate == ast::LOCAL_CRATE { - let ti = ty::impl_or_trait_item(&self.analysis.ty_cx, - declid); + let ti = ty::impl_or_trait_item(self.tcx, declid); match provenence { def::FromTrait(def_id) => { - Some(ty::trait_items(&self.analysis.ty_cx, - def_id) + Some(ty::trait_items(self.tcx, def_id) .iter() .find(|mr| { mr.name() == ti.name() @@ -803,16 +793,13 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { .def_id()) } def::FromImpl(def_id) => { - let impl_items = self.analysis - .ty_cx - .impl_items - .borrow(); + let impl_items = self.tcx.impl_items.borrow(); Some(impl_items.get(&def_id) .unwrap() .iter() .find(|mr| { ty::impl_or_trait_item( - &self.analysis.ty_cx, + self.tcx, mr.def_id() ).name() == ti.name() }) @@ -844,7 +831,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { // modules or types in the path prefix match def { def::DefMethod(did, _) => { - let ti = ty::impl_or_trait_item(&self.analysis.ty_cx, did); + let ti = ty::impl_or_trait_item(self.tcx, did); if let ty::MethodTraitItem(m) = ti { if m.explicit_self == ty::StaticExplicitSelfCategory { self.write_sub_path_trait_truncated(path); @@ -906,24 +893,21 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { fn process_method_call(&mut self, ex: &ast::Expr, args: &Vec>) { - let method_map = self.analysis.ty_cx.method_map.borrow(); + let method_map = self.tcx.method_map.borrow(); let method_callee = method_map.get(&ty::MethodCall::expr(ex.id)).unwrap(); let (def_id, decl_id) = match method_callee.origin { ty::MethodStatic(def_id) | ty::MethodStaticClosure(def_id) => { // method invoked on an object with a concrete type (not a static method) let decl_id = - match ty::trait_item_of_item(&self.analysis.ty_cx, - def_id) { + match ty::trait_item_of_item(self.tcx, def_id) { None => None, Some(decl_id) => Some(decl_id.def_id()), }; // This incantation is required if the method referenced is a // trait's default implementation. - let def_id = match ty::impl_or_trait_item(&self.analysis - .ty_cx, - def_id) { + let def_id = match ty::impl_or_trait_item(self.tcx, def_id) { ty::MethodTraitItem(method) => { method.provided_source.unwrap_or(def_id) } @@ -936,14 +920,14 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { } ty::MethodTypeParam(ref mp) => { // method invoked on a type parameter - let trait_item = ty::trait_item(&self.analysis.ty_cx, + let trait_item = ty::trait_item(self.tcx, mp.trait_ref.def_id, mp.method_num); (None, Some(trait_item.def_id())) } ty::MethodTraitObject(ref mo) => { // method invoked on a trait instance - let trait_item = ty::trait_item(&self.analysis.ty_cx, + let trait_item = ty::trait_item(self.tcx, mo.trait_ref.def_id, mo.method_num); (None, Some(trait_item.def_id())) @@ -969,12 +953,12 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { ast::PatStruct(ref path, ref fields, _) => { visit::walk_path(self, path); - let def = self.analysis.ty_cx.def_map.borrow().get(&p.id).unwrap().full_def(); + let def = self.tcx.def_map.borrow().get(&p.id).unwrap().full_def(); let struct_def = match def { def::DefConst(..) | def::DefAssociatedConst(..) => None, def::DefVariant(_, variant_id, _) => Some(variant_id), _ => { - match ty::ty_to_def_id(ty::node_id_to_type(&self.analysis.ty_cx, p.id)) { + match ty::ty_to_def_id(ty::node_id_to_type(self.tcx, p.id)) { None => { self.sess.span_bug(p.span, &format!("Could not find struct_def for `{}`", @@ -986,7 +970,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { }; if let Some(struct_def) = struct_def { - let struct_fields = ty::lookup_struct_fields(&self.analysis.ty_cx, struct_def); + let struct_fields = ty::lookup_struct_fields(self.tcx, struct_def); for &Spanned { node: ref field, span } in fields { let sub_span = self.span.span_for_first_ident(span); for f in &struct_fields { @@ -1145,7 +1129,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { self.nest(item.id, |v| visit::walk_mod(v, m)); } ast::ItemTy(ref ty, ref ty_params) => { - let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let value = ty_to_string(&**ty); let sub_span = self.span.sub_span_after_keyword(item.span, keywords::Type); self.fmt.typedef_str(item.span, @@ -1273,10 +1257,10 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { self.visit_expr(&**sub_ex); - let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, &**sub_ex).sty; + let ty = &ty::expr_ty_adjusted(self.tcx, &**sub_ex).sty; match *ty { ty::TyStruct(def_id, _) => { - let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, def_id); + let fields = ty::lookup_struct_fields(self.tcx, def_id); for (i, f) in fields.iter().enumerate() { if i == idx.node { let sub_span = self.span.sub_span_after_token(ex.span, token::Dot); @@ -1342,7 +1326,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { let mut paths_to_process = vec![]; // process collected paths for &(id, ref p, immut, ref_kind) in &collector.collected_paths { - let def_map = self.analysis.ty_cx.def_map.borrow(); + let def_map = self.tcx.def_map.borrow(); if !def_map.contains_key(&id) { self.sess.span_bug(p.span, &format!("def_map has no key for {} in visit_arm", @@ -1410,8 +1394,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { } else { "".to_string() }; - let types = self.analysis.ty_cx.node_types(); - let typ = ppaux::ty_to_string(&self.analysis.ty_cx, *types.get(&id).unwrap()); + let types = self.tcx.node_types(); + let typ = ppaux::ty_to_string(self.tcx, *types.get(&id).unwrap()); // Get the span only for the name of the variable (I hope the path // is only ever a variable name, but who knows?). let sub_span = self.span.span_for_last_ident(p.span); diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 3ea628704ebc6..5d5dbbd90a779 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use session::Session; use middle::ty; use middle::def; @@ -35,8 +34,7 @@ mod recorder; mod dump_csv; pub struct SaveContext<'l, 'tcx: 'l> { - sess: &'l Session, - analysis: &'l ty::CrateAnalysis<'tcx>, + tcx: &'l ty::ctxt<'tcx>, span_utils: SpanUtils<'l>, } @@ -143,13 +141,11 @@ pub struct TypeRefData { impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { - pub fn new(sess: &'l Session, - analysis: &'l ty::CrateAnalysis<'tcx>, + pub fn new(tcx: &'l ty::ctxt<'tcx>, span_utils: SpanUtils<'l>) -> SaveContext<'l, 'tcx> { SaveContext { - sess: sess, - analysis: analysis, + tcx: tcx, span_utils: span_utils, } } @@ -158,7 +154,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_external_crates(&self) -> Vec { let mut result = Vec::new(); - self.sess.cstore.iter_crate_data(|n, cmd| { + self.tcx.sess.cstore.iter_crate_data(|n, cmd| { result.push(CrateData { name: cmd.name.clone(), number: n }); }); @@ -168,7 +164,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_item_data(&self, item: &ast::Item) -> Data { match item.node { ast::ItemFn(..) => { - let name = self.analysis.ty_cx.map.path_to_string(item.id); + let name = self.tcx.map.path_to_string(item.id); let qualname = format!("::{}", name); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Fn); @@ -178,11 +174,11 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { qualname: qualname, declaration: None, span: sub_span.unwrap(), - scope: self.analysis.ty_cx.map.get_parent(item.id), + scope: self.tcx.map.get_parent(item.id), }) } ast::ItemStatic(ref typ, mt, ref expr) => { - let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); // If the variable is immutable, save the initialising expression. let (value, keyword) = match mt { @@ -197,13 +193,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { name: get_ident(item.ident).to_string(), qualname: qualname, span: sub_span.unwrap(), - scope: self.analysis.ty_cx.map.get_parent(item.id), + scope: self.tcx.map.get_parent(item.id), value: value, type_value: ty_to_string(&typ), }) } ast::ItemConst(ref typ, ref expr) => { - let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Const); Data::VariableData(VariableData { @@ -211,15 +207,15 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { name: get_ident(item.ident).to_string(), qualname: qualname, span: sub_span.unwrap(), - scope: self.analysis.ty_cx.map.get_parent(item.id), + scope: self.tcx.map.get_parent(item.id), value: self.span_utils.snippet(expr.span), type_value: ty_to_string(&typ), }) } ast::ItemMod(ref m) => { - let qualname = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id)); + let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); - let cm = self.sess.codemap(); + let cm = self.tcx.sess.codemap(); let filename = cm.span_to_filename(m.inner); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Mod); @@ -229,12 +225,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { name: get_ident(item.ident).to_string(), qualname: qualname, span: sub_span.unwrap(), - scope: self.analysis.ty_cx.map.get_parent(item.id), + scope: self.tcx.map.get_parent(item.id), filename: filename, }) }, ast::ItemEnum(..) => { - let enum_name = format!("::{}", self.analysis.ty_cx.map.path_to_string(item.id)); + let enum_name = format!("::{}", self.tcx.map.path_to_string(item.id)); let val = self.span_utils.snippet(item.span); let sub_span = self.span_utils.sub_span_after_keyword(item.span, keywords::Enum); @@ -243,14 +239,14 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { value: val, span: sub_span.unwrap(), qualname: enum_name, - scope: self.analysis.ty_cx.map.get_parent(item.id), + scope: self.tcx.map.get_parent(item.id), }) }, ast::ItemImpl(_, _, _, ref trait_ref, ref typ, _) => { let mut type_data = None; let sub_span; - let parent = self.analysis.ty_cx.map.get_parent(item.id); + let parent = self.tcx.map.get_parent(item.id); match typ.node { // Common case impl for a struct or something basic. @@ -294,10 +290,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { ast::NamedField(ident, _) => { let name = get_ident(ident); let qualname = format!("::{}::{}", - self.analysis.ty_cx.map.path_to_string(parent), + self.tcx.map.path_to_string(parent), name); - let typ = ppaux::ty_to_string(&self.analysis.ty_cx, - *self.analysis.ty_cx.node_types() + let typ = ppaux::ty_to_string(&self.tcx, + *self.tcx.node_types() .get(&field.node.id).unwrap()); let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); Some(Data::VariableData(VariableData { @@ -334,26 +330,25 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { pub fn get_expr_data(&self, expr: &ast::Expr) -> Option { match expr.node { ast::ExprField(ref sub_ex, ident) => { - let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, &sub_ex).sty; + let ty = &ty::expr_ty_adjusted(self.tcx, &sub_ex).sty; match *ty { ty::TyStruct(def_id, _) => { - let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, def_id); + let fields = ty::lookup_struct_fields(self.tcx, def_id); for f in &fields { if f.name == ident.node.name { let sub_span = self.span_utils.span_for_last_ident(expr.span); return Some(Data::VariableRefData(VariableRefData { name: get_ident(ident.node).to_string(), span: sub_span.unwrap(), - scope: self.analysis.ty_cx.map.get_parent(expr.id), + scope: self.tcx.map.get_parent(expr.id), ref_id: f.id, })); } } - self.sess.span_bug(expr.span, - &format!("Couldn't find field {} on {:?}", - &get_ident(ident.node), - ty)) + self.tcx.sess.span_bug(expr.span, + &format!("Couldn't find field {} on {:?}", + &get_ident(ident.node), ty)) } _ => { debug!("Expected struct type, found {:?}", ty); @@ -362,13 +357,13 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } ast::ExprStruct(ref path, _, _) => { - let ty = &ty::expr_ty_adjusted(&self.analysis.ty_cx, expr).sty; + let ty = &ty::expr_ty_adjusted(&self.tcx, expr).sty; match *ty { ty::TyStruct(def_id, _) => { let sub_span = self.span_utils.span_for_last_ident(path.span); Some(Data::TypeRefData(TypeRefData { span: sub_span.unwrap(), - scope: self.analysis.ty_cx.map.get_parent(expr.id), + scope: self.tcx.map.get_parent(expr.id), ref_id: def_id, })) } @@ -392,7 +387,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { struct_id: DefId, parent: NodeId) -> VariableRefData { - let fields = ty::lookup_struct_fields(&self.analysis.ty_cx, struct_id); + let fields = ty::lookup_struct_fields(&self.tcx, struct_id); let field_name = get_ident(field_ref.ident.node).to_string(); for f in &fields { if f.name == field_ref.ident.node.name { @@ -407,8 +402,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } } - self.sess.span_bug(field_ref.span, - &format!("Couldn't find field {}", field_name)); + self.tcx.sess.span_bug(field_ref.span, + &format!("Couldn't find field {}", field_name)); } pub fn get_data_for_id(&self, _id: &NodeId) -> Data { @@ -417,11 +412,11 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { } fn lookup_ref_id(&self, ref_id: NodeId) -> Option { - if !self.analysis.ty_cx.def_map.borrow().contains_key(&ref_id) { - self.sess.bug(&format!("def_map has no key for {} in lookup_type_ref", - ref_id)); + if !self.tcx.def_map.borrow().contains_key(&ref_id) { + self.tcx.sess.bug(&format!("def_map has no key for {} in lookup_type_ref", + ref_id)); } - let def = self.analysis.ty_cx.def_map.borrow().get(&ref_id).unwrap().full_def(); + let def = self.tcx.def_map.borrow().get(&ref_id).unwrap().full_def(); match def { def::DefPrimTy(_) => None, _ => Some(def.def_id()), @@ -484,10 +479,10 @@ impl<'v> Visitor<'v> for PathCollector { } #[allow(deprecated)] -pub fn process_crate(sess: &Session, - krate: &ast::Crate, +pub fn process_crate(tcx: &ty::ctxt, analysis: &ty::CrateAnalysis, odir: Option<&Path>) { + let krate = tcx.map.krate(); if generated_code(krate.span) { return; } @@ -512,10 +507,9 @@ pub fn process_crate(sess: &Session, }, }; - match fs::create_dir_all(&root_path) { - Err(e) => sess.err(&format!("Could not create directory {}: {}", - root_path.display(), e)), - _ => (), + if let Err(e) = fs::create_dir_all(&root_path) { + tcx.sess.err(&format!("Could not create directory {}: {}", + root_path.display(), e)); } { @@ -531,12 +525,12 @@ pub fn process_crate(sess: &Session, Ok(f) => box f, Err(e) => { let disp = root_path.display(); - sess.fatal(&format!("Could not open {}: {}", disp, e)); + tcx.sess.fatal(&format!("Could not open {}: {}", disp, e)); } }; root_path.pop(); - let mut visitor = dump_csv::DumpCsvVisitor::new(sess, analysis, output_file); + let mut visitor = dump_csv::DumpCsvVisitor::new(tcx, analysis, output_file); visitor.dump_crate_info(&cratename, krate); visit::walk_crate(&mut visitor, krate); diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index c2293dcc6d483..ec92076d9c1b5 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -2491,7 +2491,7 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId, } } -pub fn crate_ctxt_to_encode_parms<'a, 'tcx>(cx: &'a SharedCrateContext<'tcx>, +pub fn crate_ctxt_to_encode_parms<'a, 'tcx>(cx: &'a SharedCrateContext<'a, 'tcx>, ie: encoder::EncodeInlinedItem<'a>) -> encoder::EncodeParams<'a, 'tcx> { encoder::EncodeParams { @@ -2627,9 +2627,8 @@ fn internalize_symbols(cx: &SharedCrateContext, reachable: &HashSet) { } } -pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>) - -> (ty::ctxt<'tcx>, CrateTranslation) { - let ty::CrateAnalysis { ty_cx: tcx, export_map, reachable, name, .. } = analysis; +pub fn trans_crate(tcx: &ty::ctxt, analysis: ty::CrateAnalysis) -> CrateTranslation { + let ty::CrateAnalysis { export_map, reachable, name, .. } = analysis; let krate = tcx.map.krate(); let check_overflow = if let Some(v) = tcx.sess.opts.debugging_opts.force_overflow_checks { @@ -2769,7 +2768,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>) let formats = shared_ccx.tcx().dependency_formats.borrow().clone(); let no_builtins = attr::contains_name(&krate.attrs, "no_builtins"); - let translation = CrateTranslation { + CrateTranslation { modules: modules, metadata_module: metadata_module, link: link_meta, @@ -2777,7 +2776,5 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>) reachable: reachable, crate_formats: formats, no_builtins: no_builtins, - }; - - (shared_ccx.take_tcx(), translation) + } } diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 663a01e19f342..6bb6916176deb 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -57,7 +57,7 @@ pub struct Stats { /// per crate. The data here is shared between all compilation units of the /// crate, so it must not contain references to any LLVM data structures /// (aside from metadata-related ones). -pub struct SharedCrateContext<'tcx> { +pub struct SharedCrateContext<'a, 'tcx: 'a> { local_ccxs: Vec>, metadata_llmod: ModuleRef, @@ -68,7 +68,7 @@ pub struct SharedCrateContext<'tcx> { item_symbols: RefCell>, link_meta: LinkMeta, symbol_hasher: RefCell, - tcx: ty::ctxt<'tcx>, + tcx: &'a ty::ctxt<'tcx>, stats: Stats, check_overflow: bool, check_drop_flag_for_sanity: bool, @@ -159,7 +159,7 @@ pub struct LocalCrateContext<'tcx> { } pub struct CrateContext<'a, 'tcx: 'a> { - shared: &'a SharedCrateContext<'tcx>, + shared: &'a SharedCrateContext<'a, 'tcx>, local: &'a LocalCrateContext<'tcx>, /// The index of `local` in `shared.local_ccxs`. This is used in /// `maybe_iter(true)` to identify the original `LocalCrateContext`. @@ -167,7 +167,7 @@ pub struct CrateContext<'a, 'tcx: 'a> { } pub struct CrateContextIterator<'a, 'tcx: 'a> { - shared: &'a SharedCrateContext<'tcx>, + shared: &'a SharedCrateContext<'a, 'tcx>, index: usize, } @@ -192,7 +192,7 @@ impl<'a, 'tcx> Iterator for CrateContextIterator<'a,'tcx> { /// The iterator produced by `CrateContext::maybe_iter`. pub struct CrateContextMaybeIterator<'a, 'tcx: 'a> { - shared: &'a SharedCrateContext<'tcx>, + shared: &'a SharedCrateContext<'a, 'tcx>, index: usize, single: bool, origin: usize, @@ -237,17 +237,17 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR (llcx, llmod) } -impl<'tcx> SharedCrateContext<'tcx> { +impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { pub fn new(crate_name: &str, local_count: usize, - tcx: ty::ctxt<'tcx>, + tcx: &'b ty::ctxt<'tcx>, export_map: ExportMap, symbol_hasher: Sha256, link_meta: LinkMeta, reachable: NodeSet, check_overflow: bool, check_drop_flag_for_sanity: bool) - -> SharedCrateContext<'tcx> { + -> SharedCrateContext<'b, 'tcx> { let (metadata_llcx, metadata_llmod) = unsafe { create_context_and_module(&tcx.sess, "metadata") }; @@ -397,10 +397,6 @@ impl<'tcx> SharedCrateContext<'tcx> { } pub fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { - &self.tcx - } - - pub fn take_tcx(self) -> ty::ctxt<'tcx> { self.tcx } @@ -418,7 +414,7 @@ impl<'tcx> SharedCrateContext<'tcx> { } impl<'tcx> LocalCrateContext<'tcx> { - fn new(shared: &SharedCrateContext<'tcx>, + fn new<'a>(shared: &SharedCrateContext<'a, 'tcx>, name: &str) -> LocalCrateContext<'tcx> { unsafe { @@ -505,7 +501,7 @@ impl<'tcx> LocalCrateContext<'tcx> { /// This is used in the `LocalCrateContext` constructor to allow calling /// functions that expect a complete `CrateContext`, even before the local /// portion is fully initialized and attached to the `SharedCrateContext`. - fn dummy_ccx<'a>(&'a self, shared: &'a SharedCrateContext<'tcx>) + fn dummy_ccx<'a>(&'a self, shared: &'a SharedCrateContext<'a, 'tcx>) -> CrateContext<'a, 'tcx> { CrateContext { shared: shared, @@ -516,7 +512,7 @@ impl<'tcx> LocalCrateContext<'tcx> { } impl<'b, 'tcx> CrateContext<'b, 'tcx> { - pub fn shared(&self) -> &'b SharedCrateContext<'tcx> { + pub fn shared(&self) -> &'b SharedCrateContext<'b, 'tcx> { self.shared } @@ -548,7 +544,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { pub fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { - &self.shared.tcx + self.shared.tcx } pub fn sess<'a>(&'a self) -> &'a Session { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 3183307250cf4..7d66253b37888 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -133,17 +133,17 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec, externs: Externs, let arenas = ty::CtxtArenas::new(); let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest); - let ty::CrateAnalysis { - exported_items, public_items, ty_cx, .. - } = driver::phase_3_run_analysis_passes(sess, - ast_map, - &arenas, - name, - resolve::MakeGlobMap::No); + let (tcx, ty::CrateAnalysis { + exported_items, public_items, .. + }) = driver::phase_3_run_analysis_passes(sess, + ast_map, + &arenas, + name, + resolve::MakeGlobMap::No); let ctxt = DocContext { - krate: ty_cx.map.krate(), - maybe_typed: Typed(ty_cx), + krate: tcx.map.krate(), + maybe_typed: Typed(tcx), input: input, external_traits: RefCell::new(Some(HashMap::new())), external_typarams: RefCell::new(Some(HashMap::new())), diff --git a/src/test/run-make/execution-engine/test.rs b/src/test/run-make/execution-engine/test.rs index 5c15a56c6efba..64f66a6ea07b8 100644 --- a/src/test/run-make/execution-engine/test.rs +++ b/src/test/run-make/execution-engine/test.rs @@ -221,10 +221,10 @@ fn compile_program(input: &str, sysroot: PathBuf) let arenas = ty::CtxtArenas::new(); let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest); - let analysis = driver::phase_3_run_analysis_passes( + let (tcx, analysis) = driver::phase_3_run_analysis_passes( sess, ast_map, &arenas, id, MakeGlobMap::No); - let (tcx, trans) = driver::phase_4_translate_to_llvm(analysis); + let trans = driver::phase_4_translate_to_llvm(&tcx, analysis); let crates = tcx.sess.cstore.get_used_crates(RequireDynamic); From 84b49b2d355e49c429703eade10f93680cc3bd47 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Sun, 14 Jun 2015 02:35:18 +0300 Subject: [PATCH 34/48] rustc_resolve: don't require redundant arguments to resolve_crate. --- src/librustc_driver/driver.rs | 6 +----- src/librustc_driver/test.rs | 2 +- src/librustc_resolve/lib.rs | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7297d9c00b4d7..8640bcfe50696 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -602,11 +602,7 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, glob_map, } = time(time_passes, "resolution", (), - |_| resolve::resolve_crate(&sess, - &ast_map, - &lang_items, - krate, - make_glob_map)); + |_| resolve::resolve_crate(&sess, &ast_map, make_glob_map)); // Discard MTWT tables that aren't required past resolution. syntax::ext::mtwt::clear_tables(); diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 4091351b5a5c4..5991fc5c19358 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -126,7 +126,7 @@ fn test_env(source_string: &str, // run just enough stuff to build a tcx: let lang_items = lang_items::collect_language_items(krate, &sess); let resolve::CrateMap { def_map, freevars, .. } = - resolve::resolve_crate(&sess, &ast_map, &lang_items, krate, resolve::MakeGlobMap::No); + resolve::resolve_crate(&sess, &ast_map, resolve::MakeGlobMap::No); let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map); let region_map = region::resolve_crate(&sess, krate); let tcx = ty::mk_ctxt(sess, diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 787f914718d4b..5d10b0d9a57b8 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -55,7 +55,6 @@ use rustc::lint; use rustc::metadata::csearch; use rustc::metadata::decoder::{DefLike, DlDef, DlField, DlImpl}; use rustc::middle::def::*; -use rustc::middle::lang_items::LanguageItems; use rustc::middle::pat_util::pat_bindings; use rustc::middle::privacy::*; use rustc::middle::subst::{ParamSpace, FnSpace, TypeSpace}; @@ -3689,10 +3688,9 @@ pub enum MakeGlobMap { /// Entry point to crate resolution. pub fn resolve_crate<'a, 'tcx>(session: &'a Session, ast_map: &'a ast_map::Map<'tcx>, - _: &LanguageItems, - krate: &Crate, make_glob_map: MakeGlobMap) -> CrateMap { + let krate = ast_map.krate(); let mut resolver = Resolver::new(session, ast_map, krate.span, make_glob_map); build_reduced_graph::build_reduced_graph(&mut resolver, krate); From bc383f62941ae079188a9725eb49f3b8a42e35ae Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Sun, 14 Jun 2015 04:50:23 +0300 Subject: [PATCH 35/48] rustc: enforce stack discipline on ty::ctxt. --- src/librustc/middle/ty.rs | 26 ++- src/librustc_driver/driver.rs | 249 +++++++++++---------- src/librustc_driver/pretty.rs | 38 ++-- src/librustc_driver/test.rs | 30 +-- src/librustdoc/core.rs | 103 ++++----- src/librustdoc/visit_ast.rs | 4 +- src/test/run-make/execution-engine/test.rs | 27 +-- 7 files changed, 255 insertions(+), 222 deletions(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index fa7b1aa4fbe89..6cbfe7616147c 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2810,20 +2810,22 @@ impl<'tcx> CommonTypes<'tcx> { } } -pub fn mk_ctxt<'tcx>(s: Session, - arenas: &'tcx CtxtArenas<'tcx>, - def_map: DefMap, - named_region_map: resolve_lifetime::NamedRegionMap, - map: ast_map::Map<'tcx>, - freevars: RefCell, - region_maps: RegionMaps, - lang_items: middle::lang_items::LanguageItems, - stability: stability::Index<'tcx>) -> ctxt<'tcx> +pub fn with_ctxt<'tcx, F, R>(s: Session, + arenas: &'tcx CtxtArenas<'tcx>, + def_map: DefMap, + named_region_map: resolve_lifetime::NamedRegionMap, + map: ast_map::Map<'tcx>, + freevars: RefCell, + region_maps: RegionMaps, + lang_items: middle::lang_items::LanguageItems, + stability: stability::Index<'tcx>, + f: F) -> (Session, R) + where F: FnOnce(&ctxt<'tcx>) -> R { let mut interner = FnvHashMap(); let common_types = CommonTypes::new(&arenas.type_, &mut interner); - ctxt { + let tcx = ctxt { arenas: arenas, interner: RefCell::new(interner), substs_interner: RefCell::new(FnvHashMap()), @@ -2885,7 +2887,9 @@ pub fn mk_ctxt<'tcx>(s: Session, const_qualif_map: RefCell::new(NodeMap()), custom_coerce_unsized_kinds: RefCell::new(DefIdMap()), cast_kinds: RefCell::new(NodeMap()), - } + }; + let result = f(&tcx); + (tcx.sess, result) } // Type constructors diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 8640bcfe50696..a834ed4cb5f67 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -65,7 +65,7 @@ pub fn compile_input(sess: Session, // We need nested scopes here, because the intermediate results can keep // large chunks of memory alive and we want to free them as soon as // possible to keep the peak memory usage low - let (outputs, trans, sess) = { + let (sess, result) = { let (outputs, expanded_crate, id) = { let krate = phase_1_parse_input(&sess, cfg, input); @@ -119,37 +119,52 @@ pub fn compile_input(sess: Session, &ast_map.krate(), &id[..])); - let (tcx, analysis) = phase_3_run_analysis_passes(sess, - ast_map, - &arenas, - id, - control.make_glob_map); - - controller_entry_point!(after_analysis, - tcx.sess, - CompileState::state_after_analysis(input, - &tcx.sess, - outdir, - tcx.map.krate(), - &analysis, - &tcx)); - - if log_enabled!(::log::INFO) { - println!("Pre-trans"); - tcx.print_debug_stats(); - } - let trans = phase_4_translate_to_llvm(&tcx, analysis); + phase_3_run_analysis_passes(sess, + ast_map, + &arenas, + id, + control.make_glob_map, + |tcx, analysis| { + + { + let state = CompileState::state_after_analysis(input, + &tcx.sess, + outdir, + tcx.map.krate(), + &analysis, + tcx); + (control.after_analysis.callback)(state); + + tcx.sess.abort_if_errors(); + if control.after_analysis.stop == Compilation::Stop { + return Err(()); + } + } - if log_enabled!(::log::INFO) { - println!("Post-trans"); - tcx.print_debug_stats(); - } + if log_enabled!(::log::INFO) { + println!("Pre-trans"); + tcx.print_debug_stats(); + } + let trans = phase_4_translate_to_llvm(tcx, analysis); + + if log_enabled!(::log::INFO) { + println!("Post-trans"); + tcx.print_debug_stats(); + } - // Discard interned strings as they are no longer required. - token::get_ident_interner().clear(); + // Discard interned strings as they are no longer required. + token::get_ident_interner().clear(); - (outputs, trans, tcx.sess) + Ok((outputs, trans)) + }) }; + + let (outputs, trans) = if let Ok(out) = result { + out + } else { + return; + }; + phase_5_run_llvm_passes(&sess, &trans, &outputs); controller_entry_point!(after_llvm, @@ -578,12 +593,16 @@ pub fn assign_node_ids_and_map<'ast>(sess: &Session, /// Run the resolution, typechecking, region checking and other /// miscellaneous analysis passes on the crate. Return various /// structures carrying the results of the analysis. -pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, - ast_map: ast_map::Map<'tcx>, - arenas: &'tcx ty::CtxtArenas<'tcx>, - name: String, - make_glob_map: resolve::MakeGlobMap) - -> (ty::ctxt<'tcx>, ty::CrateAnalysis) { +pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: Session, + ast_map: ast_map::Map<'tcx>, + arenas: &'tcx ty::CtxtArenas<'tcx>, + name: String, + make_glob_map: resolve::MakeGlobMap, + f: F) + -> (Session, R) + where F: FnOnce(&ty::ctxt<'tcx>, + ty::CrateAnalysis) -> R +{ let time_passes = sess.time_passes(); let krate = ast_map.krate(); @@ -627,86 +646,88 @@ pub fn phase_3_run_analysis_passes<'tcx>(sess: Session, time(time_passes, "static item recursion checking", (), |_| middle::check_static_recursion::check_crate(&sess, krate, &def_map, &ast_map)); - let ty_cx = ty::mk_ctxt(sess, - arenas, - def_map, - named_region_map, - ast_map, - freevars, - region_map, - lang_items, - stability::Index::new(krate)); - - // passes are timed inside typeck - typeck::check_crate(&ty_cx, trait_map); - - time(time_passes, "const checking", (), |_| - middle::check_const::check_crate(&ty_cx)); - - let (exported_items, public_items) = - time(time_passes, "privacy checking", (), |_| - rustc_privacy::check_crate(&ty_cx, &export_map, external_exports)); - - // Do not move this check past lint - time(time_passes, "stability index", (), |_| - ty_cx.stability.borrow_mut().build(&ty_cx, krate, &public_items)); - - time(time_passes, "intrinsic checking", (), |_| - middle::intrinsicck::check_crate(&ty_cx)); - - time(time_passes, "effect checking", (), |_| - middle::effect::check_crate(&ty_cx)); - - time(time_passes, "match checking", (), |_| - middle::check_match::check_crate(&ty_cx)); - - time(time_passes, "liveness checking", (), |_| - middle::liveness::check_crate(&ty_cx)); - - time(time_passes, "borrow checking", (), |_| - borrowck::check_crate(&ty_cx)); - - time(time_passes, "rvalue checking", (), |_| - middle::check_rvalues::check_crate(&ty_cx, krate)); - - // Avoid overwhelming user with errors if type checking failed. - // I'm not sure how helpful this is, to be honest, but it avoids a - // lot of annoying errors in the compile-fail tests (basically, - // lint warnings and so on -- kindck used to do this abort, but - // kindck is gone now). -nmatsakis - ty_cx.sess.abort_if_errors(); - - let reachable_map = - time(time_passes, "reachability checking", (), |_| - reachable::find_reachable(&ty_cx, &exported_items)); - - time(time_passes, "death checking", (), |_| { - middle::dead::check_crate(&ty_cx, - &exported_items, - &reachable_map) - }); - - let ref lib_features_used = - time(time_passes, "stability checking", (), |_| - stability::check_unstable_api_usage(&ty_cx)); - - time(time_passes, "unused lib feature checking", (), |_| - stability::check_unused_or_stable_features( - &ty_cx.sess, lib_features_used)); - - time(time_passes, "lint checking", (), |_| - lint::check_crate(&ty_cx, &exported_items)); - - // The above three passes generate errors w/o aborting - ty_cx.sess.abort_if_errors(); - - (ty_cx, ty::CrateAnalysis { - export_map: export_map, - exported_items: exported_items, - public_items: public_items, - reachable: reachable_map, - name: name, - glob_map: glob_map, + ty::with_ctxt(sess, + arenas, + def_map, + named_region_map, + ast_map, + freevars, + region_map, + lang_items, + stability::Index::new(krate), + |tcx| { + + // passes are timed inside typeck + typeck::check_crate(tcx, trait_map); + + time(time_passes, "const checking", (), |_| + middle::check_const::check_crate(tcx)); + + let (exported_items, public_items) = + time(time_passes, "privacy checking", (), |_| + rustc_privacy::check_crate(tcx, &export_map, external_exports)); + + // Do not move this check past lint + time(time_passes, "stability index", (), |_| + tcx.stability.borrow_mut().build(tcx, krate, &public_items)); + + time(time_passes, "intrinsic checking", (), |_| + middle::intrinsicck::check_crate(tcx)); + + time(time_passes, "effect checking", (), |_| + middle::effect::check_crate(tcx)); + + time(time_passes, "match checking", (), |_| + middle::check_match::check_crate(tcx)); + + time(time_passes, "liveness checking", (), |_| + middle::liveness::check_crate(tcx)); + + time(time_passes, "borrow checking", (), |_| + borrowck::check_crate(tcx)); + + time(time_passes, "rvalue checking", (), |_| + middle::check_rvalues::check_crate(tcx, krate)); + + // Avoid overwhelming user with errors if type checking failed. + // I'm not sure how helpful this is, to be honest, but it avoids a + // lot of annoying errors in the compile-fail tests (basically, + // lint warnings and so on -- kindck used to do this abort, but + // kindck is gone now). -nmatsakis + tcx.sess.abort_if_errors(); + + let reachable_map = + time(time_passes, "reachability checking", (), |_| + reachable::find_reachable(tcx, &exported_items)); + + time(time_passes, "death checking", (), |_| { + middle::dead::check_crate(tcx, + &exported_items, + &reachable_map) + }); + + let ref lib_features_used = + time(time_passes, "stability checking", (), |_| + stability::check_unstable_api_usage(tcx)); + + time(time_passes, "unused lib feature checking", (), |_| + stability::check_unused_or_stable_features( + &tcx.sess, lib_features_used)); + + time(time_passes, "lint checking", (), |_| + lint::check_crate(tcx, &exported_items)); + + // The above three passes generate errors w/o aborting + tcx.sess.abort_if_errors(); + + f(tcx, ty::CrateAnalysis { + export_map: export_map, + exported_items: exported_items, + public_items: public_items, + reachable: reachable_map, + name: name, + glob_map: glob_map, + }) }) } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 0dc636eb3ec9c..b5ae498bedf4e 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -148,13 +148,15 @@ impl PpSourceMode { } PpmTyped => { let ast_map = ast_map.expect("--pretty=typed missing ast_map"); - let (tcx, _) = driver::phase_3_run_analysis_passes(sess, - ast_map, - arenas, - id, - resolve::MakeGlobMap::No); - let annotation = TypedAnnotation { tcx: tcx }; - f(&annotation, payload) + driver::phase_3_run_analysis_passes(sess, + ast_map, + arenas, + id, + resolve::MakeGlobMap::No, + |tcx, _| { + let annotation = TypedAnnotation { tcx: tcx }; + f(&annotation, payload) + }).1 } } } @@ -284,11 +286,11 @@ impl<'ast> pprust::PpAnn for HygieneAnnotation<'ast> { } -struct TypedAnnotation<'tcx> { - tcx: ty::ctxt<'tcx>, +struct TypedAnnotation<'a, 'tcx: 'a> { + tcx: &'a ty::ctxt<'tcx>, } -impl<'tcx> PrinterSupport<'tcx> for TypedAnnotation<'tcx> { +impl<'b, 'tcx> PrinterSupport<'tcx> for TypedAnnotation<'b, 'tcx> { fn sess<'a>(&'a self) -> &'a Session { &self.tcx.sess } fn ast_map<'a>(&'a self) -> Option<&'a ast_map::Map<'tcx>> { @@ -298,7 +300,7 @@ impl<'tcx> PrinterSupport<'tcx> for TypedAnnotation<'tcx> { fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn { self } } -impl<'tcx> pprust::PpAnn for TypedAnnotation<'tcx> { +impl<'a, 'tcx> pprust::PpAnn for TypedAnnotation<'a, 'tcx> { fn pre(&self, s: &mut pprust::State, node: pprust::AnnNode) -> io::Result<()> { @@ -645,12 +647,14 @@ pub fn pretty_print_input(sess: Session, match code { Some(code) => { let variants = gather_flowgraph_variants(&sess); - let (tcx, _) = driver::phase_3_run_analysis_passes(sess, - ast_map, - &arenas, - id, - resolve::MakeGlobMap::No); - print_flowgraph(variants, &tcx, code, mode, out) + driver::phase_3_run_analysis_passes(sess, + ast_map, + &arenas, + id, + resolve::MakeGlobMap::No, + |tcx, _| { + print_flowgraph(variants, tcx, code, mode, out) + }).1 } None => { let message = format!("--pretty=flowgraph needs \ diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 5991fc5c19358..4668b3d1c25ec 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -129,20 +129,22 @@ fn test_env(source_string: &str, resolve::resolve_crate(&sess, &ast_map, resolve::MakeGlobMap::No); let named_region_map = resolve_lifetime::krate(&sess, krate, &def_map); let region_map = region::resolve_crate(&sess, krate); - let tcx = ty::mk_ctxt(sess, - &arenas, - def_map, - named_region_map, - ast_map, - freevars, - region_map, - lang_items, - stability::Index::new(krate)); - let infcx = infer::new_infer_ctxt(&tcx); - body(Env { infcx: &infcx }); - let free_regions = FreeRegionMap::new(); - infcx.resolve_regions_and_report_errors(&free_regions, ast::CRATE_NODE_ID); - assert_eq!(tcx.sess.err_count(), expected_err_count); + ty::with_ctxt(sess, + &arenas, + def_map, + named_region_map, + ast_map, + freevars, + region_map, + lang_items, + stability::Index::new(krate), + |tcx| { + let infcx = infer::new_infer_ctxt(tcx); + body(Env { infcx: &infcx }); + let free_regions = FreeRegionMap::new(); + infcx.resolve_regions_and_report_errors(&free_regions, ast::CRATE_NODE_ID); + assert_eq!(tcx.sess.err_count(), expected_err_count); + }); } impl<'a, 'tcx> Env<'a, 'tcx> { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index 7d66253b37888..13022fd43efb8 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -32,17 +32,17 @@ pub use rustc::session::config::Input; pub use rustc::session::search_paths::SearchPaths; /// Are we generating documentation (`Typed`) or tests (`NotTyped`)? -pub enum MaybeTyped<'tcx> { - Typed(ty::ctxt<'tcx>), +pub enum MaybeTyped<'a, 'tcx: 'a> { + Typed(&'a ty::ctxt<'tcx>), NotTyped(session::Session) } pub type ExternalPaths = RefCell, clean::TypeKind)>>>; -pub struct DocContext<'tcx> { +pub struct DocContext<'a, 'tcx: 'a> { pub krate: &'tcx ast::Crate, - pub maybe_typed: MaybeTyped<'tcx>, + pub maybe_typed: MaybeTyped<'a, 'tcx>, pub input: Input, pub external_paths: ExternalPaths, pub external_traits: RefCell>>, @@ -52,17 +52,17 @@ pub struct DocContext<'tcx> { pub deref_trait_did: Cell>, } -impl<'tcx> DocContext<'tcx> { +impl<'b, 'tcx> DocContext<'b, 'tcx> { pub fn sess<'a>(&'a self) -> &'a session::Session { match self.maybe_typed { - Typed(ref tcx) => &tcx.sess, + Typed(tcx) => &tcx.sess, NotTyped(ref sess) => sess } } pub fn tcx_opt<'a>(&'a self) -> Option<&'a ty::ctxt<'tcx>> { match self.maybe_typed { - Typed(ref tcx) => Some(tcx), + Typed(tcx) => Some(tcx), NotTyped(_) => None } } @@ -133,48 +133,49 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec, externs: Externs, let arenas = ty::CtxtArenas::new(); let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest); - let (tcx, ty::CrateAnalysis { - exported_items, public_items, .. - }) = driver::phase_3_run_analysis_passes(sess, - ast_map, - &arenas, - name, - resolve::MakeGlobMap::No); - - let ctxt = DocContext { - krate: tcx.map.krate(), - maybe_typed: Typed(tcx), - input: input, - external_traits: RefCell::new(Some(HashMap::new())), - external_typarams: RefCell::new(Some(HashMap::new())), - external_paths: RefCell::new(Some(HashMap::new())), - inlined: RefCell::new(Some(HashSet::new())), - populated_crate_impls: RefCell::new(HashSet::new()), - deref_trait_did: Cell::new(None), - }; - debug!("crate: {:?}", ctxt.krate); - - let mut analysis = CrateAnalysis { - exported_items: exported_items, - public_items: public_items, - external_paths: RefCell::new(None), - external_typarams: RefCell::new(None), - inlined: RefCell::new(None), - deref_trait_did: None, - }; - - let krate = { - let mut v = RustdocVisitor::new(&ctxt, Some(&analysis)); - v.visit(ctxt.krate); - v.clean(&ctxt) - }; - - let external_paths = ctxt.external_paths.borrow_mut().take(); - *analysis.external_paths.borrow_mut() = external_paths; - let map = ctxt.external_typarams.borrow_mut().take(); - *analysis.external_typarams.borrow_mut() = map; - let map = ctxt.inlined.borrow_mut().take(); - *analysis.inlined.borrow_mut() = map; - analysis.deref_trait_did = ctxt.deref_trait_did.get(); - (krate, analysis) + driver::phase_3_run_analysis_passes(sess, + ast_map, + &arenas, + name, + resolve::MakeGlobMap::No, + |tcx, analysis| { + let ty::CrateAnalysis { exported_items, public_items, .. } = analysis; + + let ctxt = DocContext { + krate: tcx.map.krate(), + maybe_typed: Typed(tcx), + input: input, + external_traits: RefCell::new(Some(HashMap::new())), + external_typarams: RefCell::new(Some(HashMap::new())), + external_paths: RefCell::new(Some(HashMap::new())), + inlined: RefCell::new(Some(HashSet::new())), + populated_crate_impls: RefCell::new(HashSet::new()), + deref_trait_did: Cell::new(None), + }; + debug!("crate: {:?}", ctxt.krate); + + let mut analysis = CrateAnalysis { + exported_items: exported_items, + public_items: public_items, + external_paths: RefCell::new(None), + external_typarams: RefCell::new(None), + inlined: RefCell::new(None), + deref_trait_did: None, + }; + + let krate = { + let mut v = RustdocVisitor::new(&ctxt, Some(&analysis)); + v.visit(ctxt.krate); + v.clean(&ctxt) + }; + + let external_paths = ctxt.external_paths.borrow_mut().take(); + *analysis.external_paths.borrow_mut() = external_paths; + let map = ctxt.external_typarams.borrow_mut().take(); + *analysis.external_typarams.borrow_mut() = map; + let map = ctxt.inlined.borrow_mut().take(); + *analysis.inlined.borrow_mut() = map; + analysis.deref_trait_did = ctxt.deref_trait_did.get(); + (krate, analysis) + }).1 } diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index ff058fa908d6e..305747d12824a 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -38,14 +38,14 @@ use doctree::*; pub struct RustdocVisitor<'a, 'tcx: 'a> { pub module: Module, pub attrs: Vec, - pub cx: &'a core::DocContext<'tcx>, + pub cx: &'a core::DocContext<'a, 'tcx>, pub analysis: Option<&'a core::CrateAnalysis>, view_item_stack: HashSet, inlining_from_glob: bool, } impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { - pub fn new(cx: &'a core::DocContext<'tcx>, + pub fn new(cx: &'a core::DocContext<'a, 'tcx>, analysis: Option<&'a core::CrateAnalysis>) -> RustdocVisitor<'a, 'tcx> { // If the root is reexported, terminate all recursion. let mut stack = HashSet::new(); diff --git a/src/test/run-make/execution-engine/test.rs b/src/test/run-make/execution-engine/test.rs index 64f66a6ea07b8..8af3844e62eef 100644 --- a/src/test/run-make/execution-engine/test.rs +++ b/src/test/run-make/execution-engine/test.rs @@ -221,25 +221,26 @@ fn compile_program(input: &str, sysroot: PathBuf) let arenas = ty::CtxtArenas::new(); let ast_map = driver::assign_node_ids_and_map(&sess, &mut forest); - let (tcx, analysis) = driver::phase_3_run_analysis_passes( - sess, ast_map, &arenas, id, MakeGlobMap::No); + driver::phase_3_run_analysis_passes( + sess, ast_map, &arenas, id, MakeGlobMap::No, |tcx, analysis| { - let trans = driver::phase_4_translate_to_llvm(&tcx, analysis); + let trans = driver::phase_4_translate_to_llvm(tcx, analysis); - let crates = tcx.sess.cstore.get_used_crates(RequireDynamic); + let crates = tcx.sess.cstore.get_used_crates(RequireDynamic); - // Collect crates used in the session. - // Reverse order finds dependencies first. - let deps = crates.into_iter().rev() - .filter_map(|(_, p)| p).collect(); + // Collect crates used in the session. + // Reverse order finds dependencies first. + let deps = crates.into_iter().rev() + .filter_map(|(_, p)| p).collect(); - assert_eq!(trans.modules.len(), 1); - let llmod = trans.modules[0].llmod; + assert_eq!(trans.modules.len(), 1); + let llmod = trans.modules[0].llmod; - // Workaround because raw pointers do not impl Send - let modp = llmod as usize; + // Workaround because raw pointers do not impl Send + let modp = llmod as usize; - (modp, deps) + (modp, deps) + }).1 }).unwrap(); match handle.join() { From 4e0cb86a5c173096b08819af37f57970ac332561 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Sun, 14 Jun 2015 06:46:04 +0300 Subject: [PATCH 36/48] rustc: reduce ppaux's public footprint to 5 functions. --- src/librustc/middle/infer/error_reporting.rs | 20 ++- src/librustc/middle/ty.rs | 6 +- src/librustc/util/ppaux.rs | 170 ++++++++----------- src/librustc_borrowck/borrowck/mod.rs | 34 ++-- src/librustc_trans/trans/glue.rs | 5 +- src/librustc_typeck/check/compare_method.rs | 8 +- 6 files changed, 101 insertions(+), 142 deletions(-) diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 37cc5d342998e..71a56a3ed3b77 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -88,7 +88,6 @@ use syntax::codemap; use syntax::parse::token; use syntax::print::pprust; use syntax::ptr::P; -use util::ppaux::bound_region_to_string; use util::ppaux::note_and_explain_region; // Note: only import UserString, not Repr, since user-facing error @@ -1441,6 +1440,13 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> { fn report_inference_failure(&self, var_origin: RegionVariableOrigin) { + let br_string = |br: ty::BoundRegion| { + let mut s = br.user_string(self.tcx); + if !s.is_empty() { + s.push_str(" "); + } + s + }; let var_description = match var_origin { infer::MiscVariable(_) => "".to_string(), infer::PatternRegion(_) => " for pattern".to_string(), @@ -1448,17 +1454,15 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> { infer::Autoref(_) => " for autoref".to_string(), infer::Coercion(_) => " for automatic coercion".to_string(), infer::LateBoundRegion(_, br, infer::FnCall) => { - format!(" for {}in function call", - bound_region_to_string(self.tcx, "lifetime parameter ", true, br)) + format!(" for lifetime parameter {}in function call", + br_string(br)) } infer::LateBoundRegion(_, br, infer::HigherRankedType) => { - format!(" for {}in generic type", - bound_region_to_string(self.tcx, "lifetime parameter ", true, br)) + format!(" for lifetime parameter {}in generic type", br_string(br)) } infer::LateBoundRegion(_, br, infer::AssocTypeProjection(type_name)) => { - format!(" for {}in trait containing associated type `{}`", - bound_region_to_string(self.tcx, "lifetime parameter ", true, br), - token::get_name(type_name)) + format!(" for lifetime parameter {}in trait containing associated type `{}`", + br_string(br), token::get_name(type_name)) } infer::EarlyBoundRegion(_, name) => { format!(" for lifetime parameter `{}`", diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 6cbfe7616147c..67c4bb841d086 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -61,7 +61,7 @@ use middle::traits; use middle::ty; use middle::ty_fold::{self, TypeFoldable, TypeFolder}; use middle::ty_walk::{self, TypeWalker}; -use util::ppaux::{note_and_explain_region, bound_region_ptr_to_string}; +use util::ppaux::note_and_explain_region; use util::ppaux::ty_to_string; use util::ppaux::{Repr, UserString}; use util::common::{memoized, ErrorReported}; @@ -5205,12 +5205,12 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String { terr_regions_insufficiently_polymorphic(br, _) => { format!("expected bound lifetime parameter {}, \ found concrete lifetime", - bound_region_ptr_to_string(cx, br)) + br.user_string(cx)) } terr_regions_overly_polymorphic(br, _) => { format!("expected concrete lifetime, \ found bound lifetime parameter {}", - bound_region_ptr_to_string(cx, br)) + br.user_string(cx)) } terr_sorts(values) => { // A naive approach to making sure that we're not reporting silly errors such as: diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 7341420c55358..83852eff04c84 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -52,19 +52,13 @@ pub trait UserString<'tcx> : Repr<'tcx> { pub fn note_and_explain_region(cx: &ctxt, prefix: &str, region: ty::Region, - suffix: &str) -> Option { - match explain_region_and_span(cx, region) { - (ref str, Some(span)) => { - cx.sess.span_note( - span, - &format!("{}{}{}", prefix, *str, suffix)); - Some(span) - } - (ref str, None) => { - cx.sess.note( - &format!("{}{}{}", prefix, *str, suffix)); - None - } + suffix: &str) { + let (description, span) = explain_region_and_span(cx, region); + let message = format!("{}{}{}", prefix, description, suffix); + if let Some(span) = span { + cx.sess.span_note(span, &message); + } else { + cx.sess.note(&message); } } @@ -81,8 +75,8 @@ fn item_scope_tag(item: &ast::Item) -> &'static str { } } -pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) - -> (String, Option) { +fn explain_region_and_span(cx: &ctxt, region: ty::Region) + -> (String, Option) { return match region { ReScope(scope) => { let new_string; @@ -138,7 +132,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) BrFresh(_) => "an anonymous lifetime defined on".to_string(), _ => { format!("the lifetime {} as defined on", - bound_region_ptr_to_string(cx, fr.bound_region)) + fr.bound_region.user_string(cx)) } }; @@ -182,61 +176,6 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region) } } -pub fn bound_region_ptr_to_string(cx: &ctxt, br: BoundRegion) -> String { - bound_region_to_string(cx, "", false, br) -} - -pub fn bound_region_to_string(cx: &ctxt, - prefix: &str, space: bool, - br: BoundRegion) -> String { - let space_str = if space { " " } else { "" }; - - if cx.sess.verbose() { - return format!("{}{}{}", prefix, br.repr(cx), space_str) - } - - match br { - BrNamed(_, name) => { - format!("{}{}{}", prefix, token::get_name(name), space_str) - } - BrAnon(_) | BrFresh(_) | BrEnv => prefix.to_string() - } -} - -// In general, if you are giving a region error message, -// you should use `explain_region()` or, better yet, -// `note_and_explain_region()` -pub fn region_ptr_to_string(cx: &ctxt, region: Region) -> String { - region_to_string(cx, "&", true, region) -} - -pub fn region_to_string(cx: &ctxt, prefix: &str, space: bool, region: Region) -> String { - let space_str = if space { " " } else { "" }; - - if cx.sess.verbose() { - return format!("{}{}{}", prefix, region.repr(cx), space_str) - } - - // These printouts are concise. They do not contain all the information - // the user might want to diagnose an error, but there is basically no way - // to fit that into a short string. Hence the recommendation to use - // `explain_region()` or `note_and_explain_region()`. - match region { - ty::ReScope(_) => prefix.to_string(), - ty::ReEarlyBound(ref data) => { - token::get_name(data.name).to_string() - } - ty::ReLateBound(_, br) => bound_region_to_string(cx, prefix, space, br), - ty::ReFree(ref fr) => bound_region_to_string(cx, prefix, space, fr.bound_region), - ty::ReInfer(ReSkolemized(_, br)) => { - bound_region_to_string(cx, prefix, space, br) - } - ty::ReInfer(ReVar(_)) => prefix.to_string(), - ty::ReStatic => format!("{}'static{}", prefix, space_str), - ty::ReEmpty => format!("{}'{}", prefix, space_str), - } -} - pub fn mutability_to_string(m: ast::Mutability) -> String { match m { ast::MutMutable => "mut ".to_string(), @@ -376,7 +315,11 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { }, ty_to_string(cx, tm.ty)) } TyRef(r, ref tm) => { - let mut buf = region_ptr_to_string(cx, *r); + let mut buf = "&".to_owned(); + buf.push_str(&r.user_string(cx)); + if !buf.is_empty() { + buf.push_str(" "); + } buf.push_str(&mt_to_string(cx, tm)); buf } @@ -440,26 +383,13 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { } } -pub fn explicit_self_category_to_str(category: &ty::ExplicitSelfCategory) - -> &'static str { - match *category { - ty::StaticExplicitSelfCategory => "static", - ty::ByValueExplicitSelfCategory => "self", - ty::ByReferenceExplicitSelfCategory(_, ast::MutMutable) => { - "&mut self" - } - ty::ByReferenceExplicitSelfCategory(_, ast::MutImmutable) => "&self", - ty::ByBoxExplicitSelfCategory => "Box", - } -} - -pub fn parameterized<'tcx,GG>(cx: &ctxt<'tcx>, - base: &str, - substs: &subst::Substs<'tcx>, - did: ast::DefId, - projections: &[ty::ProjectionPredicate<'tcx>], - get_generics: GG) - -> String +fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, + base: &str, + substs: &subst::Substs<'tcx>, + did: ast::DefId, + projections: &[ty::ProjectionPredicate<'tcx>], + get_generics: GG) + -> String where GG : FnOnce() -> ty::Generics<'tcx> { if cx.sess.verbose() { @@ -495,7 +425,7 @@ pub fn parameterized<'tcx,GG>(cx: &ctxt<'tcx>, subst::ErasedRegions => { } subst::NonerasedRegions(ref regions) => { for &r in regions { - let s = region_to_string(cx, "", false, r); + let s = r.user_string(cx); if s.is_empty() { // This happens when the value of the region // parameter is not easily serialized. This may be @@ -579,14 +509,6 @@ pub fn parameterized<'tcx,GG>(cx: &ctxt<'tcx>, } } -pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String { - let mut s = typ.repr(cx).to_string(); - if s.len() >= 32 { - s = (&s[0..32]).to_string(); - } - return s; -} - impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Option { fn repr(&self, tcx: &ctxt<'tcx>) -> String { match self { @@ -915,6 +837,19 @@ impl<'tcx> Repr<'tcx> for ty::BoundRegion { } } +impl<'tcx> UserString<'tcx> for ty::BoundRegion { + fn user_string(&self, tcx: &ctxt) -> String { + if tcx.sess.verbose() { + return self.repr(tcx); + } + + match *self { + BrNamed(_, name) => token::get_name(name).to_string(), + BrAnon(_) | BrFresh(_) | BrEnv => String::new() + } + } +} + impl<'tcx> Repr<'tcx> for ty::Region { fn repr(&self, tcx: &ctxt) -> String { match *self { @@ -959,7 +894,28 @@ impl<'tcx> Repr<'tcx> for ty::Region { impl<'tcx> UserString<'tcx> for ty::Region { fn user_string(&self, tcx: &ctxt) -> String { - region_to_string(tcx, "", false, *self) + if tcx.sess.verbose() { + return self.repr(tcx); + } + + // These printouts are concise. They do not contain all the information + // the user might want to diagnose an error, but there is basically no way + // to fit that into a short string. Hence the recommendation to use + // `explain_region()` or `note_and_explain_region()`. + match *self { + ty::ReEarlyBound(ref data) => { + token::get_name(data.name).to_string() + } + ty::ReLateBound(_, br) | + ty::ReFree(ty::FreeRegion { bound_region: br, .. }) | + ty::ReInfer(ReSkolemized(_, br)) => { + br.user_string(tcx) + } + ty::ReScope(_) | + ty::ReInfer(ReVar(_)) => String::new(), + ty::ReStatic => "'static".to_owned(), + ty::ReEmpty => "'".to_owned(), + } } } @@ -1446,7 +1402,15 @@ impl<'tcx> Repr<'tcx> for ast::FloatTy { impl<'tcx> Repr<'tcx> for ty::ExplicitSelfCategory { fn repr(&self, _: &ctxt) -> String { - explicit_self_category_to_str(self).to_string() + match *self { + ty::StaticExplicitSelfCategory => "static", + ty::ByValueExplicitSelfCategory => "self", + ty::ByReferenceExplicitSelfCategory(_, ast::MutMutable) => { + "&mut self" + } + ty::ByReferenceExplicitSelfCategory(_, ast::MutImmutable) => "&self", + ty::ByBoxExplicitSelfCategory => "Box", + }.to_owned() } } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index d704617161689..36f08b3ced977 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -1001,20 +1001,14 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { "reference must be valid for ", sub_scope, "..."); - let suggestion = if is_statement_scope(self.tcx, super_scope) { - Some("consider using a `let` binding to increase its lifetime") - } else { - None - }; - let span = note_and_explain_region( + note_and_explain_region( self.tcx, "...but borrowed value is only valid for ", super_scope, ""); - match (span, suggestion) { - (_, None) => {}, - (Some(span), Some(msg)) => self.tcx.sess.span_help(span, msg), - (None, Some(msg)) => self.tcx.sess.help(msg), + if let Some(span) = statement_scope_span(self.tcx, super_scope) { + self.tcx.sess.span_help(span, + "consider using a `let` binding to increase its lifetime"); } } @@ -1127,16 +1121,16 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } } -fn is_statement_scope(tcx: &ty::ctxt, region: ty::Region) -> bool { - match region { - ty::ReScope(scope) => { - match tcx.map.find(scope.node_id()) { - Some(ast_map::NodeStmt(_)) => true, - _ => false - } - } - _ => false - } +fn statement_scope_span(tcx: &ty::ctxt, region: ty::Region) -> Option { + match region { + ty::ReScope(scope) => { + match tcx.map.find(scope.node_id()) { + Some(ast_map::NodeStmt(stmt)) => Some(stmt.span), + _ => None + } + } + _ => None + } } impl BitwiseOperator for LoanDataFlowOperator { diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index c7f5b86412cae..35dbc72237645 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -39,8 +39,7 @@ use trans::machine::*; use trans::monomorphize; use trans::type_of::{type_of, type_of_dtor, sizing_type_of, align_of}; use trans::type_::Type; -use util::ppaux; -use util::ppaux::{ty_to_short_str, Repr}; +use util::ppaux::{self, Repr}; use arena::TypedArena; use libc::c_uint; @@ -247,7 +246,7 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }); ccx.available_drop_glues().borrow_mut().insert(g, fn_nm); - let _s = StatRecorder::new(ccx, format!("drop {}", ty_to_short_str(ccx.tcx(), t))); + let _s = StatRecorder::new(ccx, format!("drop {}", t.repr(ccx.tcx()))); let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty()); let (arena, fcx): (TypedArena<_>, FunctionContext); diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index c5861be2716b2..11069fdfd698d 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -13,7 +13,7 @@ use middle::infer; use middle::traits; use middle::ty::{self}; use middle::subst::{self, Subst, Substs, VecPerParamSpace}; -use util::ppaux::{self, Repr}; +use util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; @@ -64,8 +64,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, "method `{}` has a `{}` declaration in the impl, \ but not in the trait", token::get_name(trait_m.name), - ppaux::explicit_self_category_to_str( - &impl_m.explicit_self)); + impl_m.explicit_self.repr(tcx)); return; } (_, &ty::StaticExplicitSelfCategory) => { @@ -73,8 +72,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, "method `{}` has a `{}` declaration in the trait, \ but not in the impl", token::get_name(trait_m.name), - ppaux::explicit_self_category_to_str( - &trait_m.explicit_self)); + trait_m.explicit_self.repr(tcx)); return; } _ => { From 96ad4a486381497da00ad12413bfc0fbac201189 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Mon, 15 Jun 2015 05:31:01 +0300 Subject: [PATCH 37/48] rustc: use Repr and UserString instead of ppaux::ty_to_string. --- src/librustc/middle/astencode.rs | 4 +- src/librustc/middle/check_match.rs | 11 ++-- src/librustc/middle/check_rvalues.rs | 6 +-- src/librustc/middle/effect.rs | 10 ++-- src/librustc/middle/infer/mod.rs | 4 +- src/librustc/middle/ty.rs | 54 ++++++++----------- src/librustc/util/ppaux.rs | 32 ++++++----- src/librustc_driver/pretty.rs | 6 +-- src/librustc_driver/test.rs | 4 +- src/librustc_lint/builtin.rs | 4 +- src/librustc_trans/back/link.rs | 5 +- src/librustc_trans/save/dump_csv.rs | 9 ++-- src/librustc_trans/save/mod.rs | 7 ++- src/librustc_trans/trans/adt.rs | 6 +-- src/librustc_trans/trans/base.rs | 10 ++-- src/librustc_trans/trans/callee.rs | 5 +- src/librustc_trans/trans/consts.rs | 12 ++--- src/librustc_trans/trans/datum.rs | 4 +- .../trans/debuginfo/metadata.rs | 16 +++--- .../trans/debuginfo/type_names.rs | 5 +- src/librustc_trans/trans/glue.rs | 11 ++-- src/librustc_trans/trans/intrinsic.rs | 12 ++--- src/librustc_trans/trans/tvec.rs | 4 +- src/librustc_trans/trans/type_of.rs | 3 +- src/librustc_typeck/check/mod.rs | 16 +++--- src/librustc_typeck/check/regionck.rs | 6 +-- src/librustc_typeck/collect.rs | 5 +- src/librustc_typeck/lib.rs | 14 +++-- 28 files changed, 133 insertions(+), 152 deletions(-) diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index ad228404a9cdd..4aa73d871d162 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -31,7 +31,7 @@ use middle::privacy::{AllPublic, LastMod}; use middle::subst; use middle::subst::VecPerParamSpace; use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin}; -use util::ppaux::ty_to_string; +use util::ppaux::Repr; use syntax::{ast, ast_util, codemap, fold}; use syntax::codemap::Span; @@ -1624,7 +1624,7 @@ fn decode_side_tables(dcx: &DecodeContext, c::tag_table_node_type => { let ty = val_dsr.read_ty(dcx); debug!("inserting ty for node {}: {}", - id, ty_to_string(dcx.tcx, ty)); + id, ty.repr(dcx.tcx)); dcx.tcx.node_type_insert(id, ty); } c::tag_table_item_subst => { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index ea95536b811e6..11a1a1582c835 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -36,7 +36,7 @@ use syntax::print::pprust::pat_to_string; use syntax::parse::token; use syntax::ptr::P; use syntax::visit::{self, Visitor, FnKind}; -use util::ppaux::ty_to_string; +use util::ppaux::UserString; use util::nodemap::FnvHashMap; pub const DUMMY_WILD_PAT: &'static Pat = &Pat { @@ -209,9 +209,8 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) { if !type_is_empty(cx.tcx, pat_ty) { // We know the type is inhabited, so this must be wrong span_err!(cx.tcx.sess, ex.span, E0002, - "non-exhaustive patterns: type {} is non-empty", - ty_to_string(cx.tcx, pat_ty) - ); + "non-exhaustive patterns: type {} is non-empty", + pat_ty.user_string(cx.tcx)); } // If the type *is* empty, it's vacuously exhaustive return; @@ -244,11 +243,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat) span_warn!(cx.tcx.sess, p.span, E0170, "pattern binding `{}` is named the same as one \ of the variants of the type `{}`", - &token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty)); + &token::get_ident(ident.node), pat_ty.user_string(cx.tcx)); fileline_help!(cx.tcx.sess, p.span, "if you meant to match on a variant, \ consider making the path in the pattern qualified: `{}::{}`", - ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node)); + pat_ty.user_string(cx.tcx), &token::get_ident(ident.node)); } } } diff --git a/src/librustc/middle/check_rvalues.rs b/src/librustc/middle/check_rvalues.rs index 6985ca27861eb..bd3829cc395e9 100644 --- a/src/librustc/middle/check_rvalues.rs +++ b/src/librustc/middle/check_rvalues.rs @@ -15,7 +15,7 @@ use middle::expr_use_visitor as euv; use middle::mem_categorization as mc; use middle::ty::ParameterEnvironment; use middle::ty; -use util::ppaux::ty_to_string; +use util::ppaux::{Repr, UserString}; use syntax::ast; use syntax::codemap::Span; @@ -59,11 +59,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> { span: Span, cmt: mc::cmt<'tcx>, _: euv::ConsumeMode) { - debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty)); + debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr(self.tcx)); if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) { span_err!(self.tcx.sess, span, E0161, "cannot move a value of type {0}: the size of {0} cannot be statically determined", - ty_to_string(self.tcx, cmt.ty)); + cmt.ty.user_string(self.tcx)); } } diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index d23c8a4bc1e0d..c1a33c3387cde 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -15,7 +15,7 @@ use self::UnsafeContext::*; use middle::def; use middle::ty::{self, Ty}; use middle::ty::MethodCall; -use util::ppaux; +use util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; @@ -67,7 +67,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> { _ => return }; debug!("effect: checking index with base type {}", - ppaux::ty_to_string(self.tcx, base_type)); + base_type.repr(self.tcx)); match base_type.sty { ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty { span_err!(self.tcx.sess, e.span, E0134, @@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { let method_call = MethodCall::expr(expr.id); let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty; debug!("effect: method call case, base type is {}", - ppaux::ty_to_string(self.tcx, base_type)); + base_type.repr(self.tcx)); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "invocation of unsafe method") @@ -152,7 +152,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { ast::ExprCall(ref base, _) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: call case, base type is {}", - ppaux::ty_to_string(self.tcx, base_type)); + base_type.repr(self.tcx)); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "call to unsafe function") } @@ -160,7 +160,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { ast::ExprUnary(ast::UnDeref, ref base) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: unary case, base type is {}", - ppaux::ty_to_string(self.tcx, base_type)); + base_type.repr(self.tcx)); if let ty::TyRawPtr(_) = base_type.sty { self.require_unsafe(expr.span, "dereference of raw pointer") } diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index c0e3a5e89610e..aef2712105874 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -36,7 +36,6 @@ use syntax::ast; use syntax::codemap; use syntax::codemap::Span; use util::nodemap::FnvHashMap; -use util::ppaux::ty_to_string; use util::ppaux::{Repr, UserString}; use self::combine::CombineFields; @@ -862,8 +861,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } pub fn ty_to_string(&self, t: Ty<'tcx>) -> String { - ty_to_string(self.tcx, - self.resolve_type_vars_if_possible(&t)) + self.resolve_type_vars_if_possible(&t).user_string(self.tcx) } pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String { diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 67c4bb841d086..9006777eee37e 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -62,7 +62,6 @@ use middle::ty; use middle::ty_fold::{self, TypeFoldable, TypeFolder}; use middle::ty_walk::{self, TypeWalker}; use util::ppaux::note_and_explain_region; -use util::ppaux::ty_to_string; use util::ppaux::{Repr, UserString}; use util::common::{memoized, ErrorReported}; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; @@ -3568,7 +3567,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { TyArray(ty, _) | TySlice(ty) => ty, TyStr => mk_mach_uint(cx, ast::TyU8), _ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}", - ty_to_string(cx, ty))), + ty.user_string(cx))), } } @@ -4139,24 +4138,20 @@ pub fn is_ffi_safe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool { pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec, r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool { - debug!("type_requires({:?}, {:?})?", - ::util::ppaux::ty_to_string(cx, r_ty), - ::util::ppaux::ty_to_string(cx, ty)); + debug!("type_requires({}, {})?", + r_ty.repr(cx), ty.repr(cx)); let r = r_ty == ty || subtypes_require(cx, seen, r_ty, ty); - debug!("type_requires({:?}, {:?})? {:?}", - ::util::ppaux::ty_to_string(cx, r_ty), - ::util::ppaux::ty_to_string(cx, ty), - r); + debug!("type_requires({}, {})? {:?}", + r_ty.repr(cx), ty.repr(cx), r); return r; } fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec, r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool { - debug!("subtypes_require({:?}, {:?})?", - ::util::ppaux::ty_to_string(cx, r_ty), - ::util::ppaux::ty_to_string(cx, ty)); + debug!("subtypes_require({}, {})?", + r_ty.repr(cx), ty.repr(cx)); let r = match ty.sty { // fixed length vectors need special treatment compared to @@ -4234,10 +4229,8 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { } }; - debug!("subtypes_require({:?}, {:?})? {:?}", - ::util::ppaux::ty_to_string(cx, r_ty), - ::util::ppaux::ty_to_string(cx, ty), - r); + debug!("subtypes_require({}, {})? {:?}", + r_ty.repr(cx), ty.repr(cx), r); return r; } @@ -4343,8 +4336,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span, seen: &mut Vec>, ty: Ty<'tcx>) -> Representability { - debug!("is_type_structurally_recursive: {:?}", - ::util::ppaux::ty_to_string(cx, ty)); + debug!("is_type_structurally_recursive: {}", ty.repr(cx)); match ty.sty { TyStruct(did, _) | TyEnum(did, _) => { @@ -4363,9 +4355,9 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) match iter.next() { Some(&seen_type) => { if same_struct_or_enum_def_id(seen_type, did) { - debug!("SelfRecursive: {:?} contains {:?}", - ::util::ppaux::ty_to_string(cx, seen_type), - ::util::ppaux::ty_to_string(cx, ty)); + debug!("SelfRecursive: {} contains {}", + seen_type.repr(cx), + ty.repr(cx)); return SelfRecursive; } } @@ -4383,9 +4375,9 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) for &seen_type in iter { if same_type(ty, seen_type) { - debug!("ContainsRecursive: {:?} contains {:?}", - ::util::ppaux::ty_to_string(cx, seen_type), - ::util::ppaux::ty_to_string(cx, ty)); + debug!("ContainsRecursive: {} contains {}", + seen_type.repr(cx), + ty.repr(cx)); return ContainsRecursive; } } @@ -4405,16 +4397,14 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) } } - debug!("is_type_representable: {:?}", - ::util::ppaux::ty_to_string(cx, ty)); + debug!("is_type_representable: {}", ty.repr(cx)); // To avoid a stack overflow when checking an enum variant or struct that // contains a different, structurally recursive type, maintain a stack // of seen types and check recursion for each of them (issues #3008, #3779). let mut seen: Vec = Vec::new(); let r = is_type_structurally_recursive(cx, sp, &mut seen, ty); - debug!("is_type_representable: {:?} is {:?}", - ::util::ppaux::ty_to_string(cx, ty), r); + debug!("is_type_representable: {} is {:?}", ty.repr(cx), r); r } @@ -4857,7 +4847,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>, span, &format!("the {}th autoderef failed: {}", i, - ty_to_string(cx, adjusted_ty)) + adjusted_ty.user_string(cx)) ); } } @@ -5102,10 +5092,8 @@ pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem]) pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String { match ty.sty { TyBool | TyChar | TyInt(_) | - TyUint(_) | TyFloat(_) | TyStr => { - ::util::ppaux::ty_to_string(cx, ty) - } - TyTuple(ref tys) if tys.is_empty() => ::util::ppaux::ty_to_string(cx, ty), + TyUint(_) | TyFloat(_) | TyStr => ty.user_string(cx), + TyTuple(ref tys) if tys.is_empty() => ty.user_string(cx), TyEnum(id, _) => format!("enum `{}`", item_path_str(cx, id)), TyBox(_) => "box".to_string(), diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 83852eff04c84..8eaf19eb47415 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -186,7 +186,7 @@ pub fn mutability_to_string(m: ast::Mutability) -> String { pub fn mt_to_string<'tcx>(cx: &ctxt<'tcx>, m: &mt<'tcx>) -> String { format!("{}{}", mutability_to_string(m.mutbl), - ty_to_string(cx, m.ty)) + m.ty.user_string(cx)) } pub fn vec_map_to_string(ts: &[T], f: F) -> String where @@ -196,7 +196,7 @@ pub fn vec_map_to_string(ts: &[T], f: F) -> String where format!("[{}]", tstrs.connect(", ")) } -pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { +fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>, opt_def_id: Option, unsafety: ast::Unsafety, @@ -266,7 +266,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { s.push(bra); let strs = sig.0.inputs .iter() - .map(|a| ty_to_string(cx, *a)) + .map(|a| a.user_string(cx)) .collect::>(); s.push_str(&strs.connect(", ")); if sig.0.variadic { @@ -278,7 +278,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { ty::FnConverging(t) => { if !ty::type_is_nil(t) { s.push_str(" -> "); - s.push_str(&ty_to_string(cx, t)); + s.push_str(& t.user_string(cx)); } } ty::FnDiverging => { @@ -307,12 +307,12 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { TyInt(t) => ast_util::int_ty_to_string(t, None).to_string(), TyUint(t) => ast_util::uint_ty_to_string(t, None).to_string(), TyFloat(t) => ast_util::float_ty_to_string(t).to_string(), - TyBox(typ) => format!("Box<{}>", ty_to_string(cx, typ)), + TyBox(typ) => format!("Box<{}>", typ.user_string(cx)), TyRawPtr(ref tm) => { format!("*{} {}", match tm.mutbl { ast::MutMutable => "mut", ast::MutImmutable => "const", - }, ty_to_string(cx, tm.ty)) + }, tm.ty.user_string(cx)) } TyRef(r, ref tm) => { let mut buf = "&".to_owned(); @@ -326,7 +326,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { TyTuple(ref elems) => { let strs = elems .iter() - .map(|elem| ty_to_string(cx, *elem)) + .map(|elem| elem.user_string(cx)) .collect::>(); match &strs[..] { [ref string] => format!("({},)", string), @@ -375,10 +375,10 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { }) } TyArray(t, sz) => { - format!("[{}; {}]", ty_to_string(cx, t), sz) + format!("[{}; {}]", t.user_string(cx), sz) } TySlice(t) => { - format!("[{}]", ty_to_string(cx, t)) + format!("[{}]", t.user_string(cx)) } } } @@ -475,7 +475,7 @@ fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, }; for t in &tps[..tps.len() - num_defaults] { - strs.push(ty_to_string(cx, *t)) + strs.push(t.user_string(cx)) } for projection in projections { @@ -581,6 +581,12 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec { } } +impl<'a, 'tcx, T: ?Sized +UserString<'tcx>> UserString<'tcx> for &'a T { + fn user_string(&self, tcx: &ctxt<'tcx>) -> String { + UserString::user_string(*self, tcx) + } +} + impl<'tcx, T:UserString<'tcx>> UserString<'tcx> for Vec { fn user_string(&self, tcx: &ctxt<'tcx>) -> String { let strs: Vec = @@ -672,7 +678,7 @@ impl<'tcx> Repr<'tcx> for ty::RegionParameterDef { impl<'tcx> Repr<'tcx> for ty::TyS<'tcx> { fn repr(&self, tcx: &ctxt<'tcx>) -> String { - ty_to_string(tcx, self) + self.user_string(tcx) } } @@ -1290,9 +1296,9 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> { } } -impl<'tcx> UserString<'tcx> for Ty<'tcx> { +impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { fn user_string(&self, tcx: &ctxt<'tcx>) -> String { - ty_to_string(tcx, *self) + ty_to_string(tcx, self) } } diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index b5ae498bedf4e..597682c89eee8 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -25,7 +25,7 @@ use rustc::middle::cfg; use rustc::middle::cfg::graphviz::LabelledCFG; use rustc::session::Session; use rustc::session::config::Input; -use rustc::util::ppaux; +use rustc::util::ppaux::UserString; use rustc_borrowck as borrowck; use rustc_borrowck::graphviz as borrowck_dot; use rustc_resolve as resolve; @@ -318,9 +318,7 @@ impl<'a, 'tcx> pprust::PpAnn for TypedAnnotation<'a, 'tcx> { try!(pp::word(&mut s.s, "as")); try!(pp::space(&mut s.s)); try!(pp::word(&mut s.s, - &ppaux::ty_to_string( - &self.tcx, - ty::expr_ty(&self.tcx, expr)))); + &ty::expr_ty(self.tcx, expr).user_string(self.tcx))); s.pclose() } _ => Ok(()) diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 4668b3d1c25ec..c3f5dc084fd83 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -28,7 +28,7 @@ use rustc_typeck::middle::infer; use rustc_typeck::middle::infer::lub::Lub; use rustc_typeck::middle::infer::glb::Glb; use rustc_typeck::middle::infer::sub::Sub; -use rustc_typeck::util::ppaux::{ty_to_string, Repr, UserString}; +use rustc_typeck::util::ppaux::{Repr, UserString}; use rustc::ast_map; use rustc::session::{self,config}; use syntax::{abi, ast}; @@ -253,7 +253,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { } pub fn ty_to_string(&self, a: Ty<'tcx>) -> String { - ty_to_string(self.infcx.tcx, a) + a.user_string(self.infcx.tcx) } pub fn t_fn(&self, diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index cc1924071606d..755d7af9d4f63 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -36,8 +36,8 @@ use middle::{def, pat_util, stability}; use middle::const_eval::{eval_const_expr_partial, const_int, const_uint}; use middle::cfg; use rustc::ast_map; -use util::ppaux::ty_to_string; use util::nodemap::{FnvHashMap, NodeSet}; +use util::ppaux::UserString; use lint::{Level, Context, LintPass, LintArray, Lint}; use std::collections::{HashSet, BitSet}; @@ -495,7 +495,7 @@ impl BoxPointers { }); if n_uniq > 0 { - let s = ty_to_string(cx.tcx, ty); + let s = ty.user_string(cx.tcx); let m = format!("type uses owned (Box type) pointers: {}", s); cx.span_lint(BOX_POINTERS, span, &m[..]); } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index e2c816bb84df6..a5bca132e02d0 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -25,7 +25,7 @@ use middle::ty::{self, Ty}; use rustc::ast_map::{PathElem, PathElems, PathName}; use trans::{CrateContext, CrateTranslation, gensym_name}; use util::common::time; -use util::ppaux; +use util::ppaux::UserString; use util::sha2::{Digest, Sha256}; use util::fs::fix_windows_verbatim_for_gcc; use rustc_back::tempdir::TempDir; @@ -347,8 +347,7 @@ pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathEl pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, name: &str) -> String { - let s = ppaux::ty_to_string(ccx.tcx(), t); - let path = [PathName(token::intern(&s[..])), + let path = [PathName(token::intern(&t.user_string(ccx.tcx()))), gensym_name(name)]; let hash = get_symbol_hash(ccx, t); mangle(path.iter().cloned(), Some(&hash[..])) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index f68024656e03d..6ec58337e723e 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -52,7 +52,7 @@ use syntax::ptr::P; use super::span_utils::SpanUtils; use super::recorder::{Recorder, FmtStrs}; -use util::ppaux; +use util::ppaux::UserString; macro_rules! down_cast_data { ($id:ident, $kind:ident, $this:ident, $sp:expr) => { @@ -287,10 +287,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { collector.visit_pat(&arg.pat); let span_utils = self.span.clone(); for &(id, ref p, _, _) in &collector.collected_paths { - let typ = - ppaux::ty_to_string( - self.tcx, - *self.tcx.node_types().get(&id).unwrap()); + let typ = self.tcx.node_types().get(&id).unwrap().user_string(self.tcx); // get the span only for the name of the variable (I hope the path is only ever a // variable name, but who knows?) self.fmt.formal_str(p.span, @@ -1395,7 +1392,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { "".to_string() }; let types = self.tcx.node_types(); - let typ = ppaux::ty_to_string(self.tcx, *types.get(&id).unwrap()); + let typ = types.get(&id).unwrap().user_string(self.tcx); // Get the span only for the name of the variable (I hope the path // is only ever a variable name, but who knows?). let sub_span = self.span.span_for_last_ident(p.span); diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 5d5dbbd90a779..4116e6637aea6 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -23,7 +23,7 @@ use syntax::parse::token::{self, get_ident, keywords}; use syntax::visit::{self, Visitor}; use syntax::print::pprust::ty_to_string; -use util::ppaux; +use util::ppaux::UserString; use self::span_utils::SpanUtils; @@ -292,9 +292,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { let qualname = format!("::{}::{}", self.tcx.map.path_to_string(parent), name); - let typ = ppaux::ty_to_string(&self.tcx, - *self.tcx.node_types() - .get(&field.node.id).unwrap()); + let typ = self.tcx.node_types().get(&field.node.id).unwrap() + .user_string(self.tcx); let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); Some(Data::VariableData(VariableData { id: field.node.id, diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index 68d72ab4241ad..5b8986878c7ab 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -66,7 +66,7 @@ use trans::machine; use trans::monomorphize; use trans::type_::Type; use trans::type_of; -use util::ppaux::ty_to_string; +use util::ppaux::Repr as PrettyPrintRepr; type Hint = attr::ReprAttr; @@ -143,7 +143,7 @@ pub fn represent_node<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Rc> { - debug!("Representing: {}", ty_to_string(cx.tcx(), t)); + debug!("Representing: {}", t.repr(cx.tcx())); match cx.adt_reprs().borrow().get(&t) { Some(repr) => return repr.clone(), None => {} @@ -382,7 +382,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, General(ity, fields, dtor_to_init_u8(dtor)) } _ => cx.sess().bug(&format!("adt::represent_type called on non-ADT type: {}", - ty_to_string(cx.tcx(), t))) + t.repr(cx.tcx()))) } } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index ec92076d9c1b5..f66188dcfb0c8 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -80,7 +80,7 @@ use trans::type_of; use trans::type_of::*; use trans::value::Value; use util::common::indenter; -use util::ppaux::{Repr, ty_to_string}; +use util::ppaux::Repr; use util::sha2::Sha256; use util::nodemap::NodeMap; @@ -531,7 +531,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, } _ => { cx.sess().unimpl(&format!("type in iter_structural_ty: {}", - ty_to_string(cx.tcx(), t))) + t.repr(cx.tcx()))) } } return cx; @@ -641,7 +641,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>( } _ => { cx.sess().bug(&format!("fail-if-zero on unexpected type: {}", - ty_to_string(cx.tcx(), rhs_t))); + rhs_t.repr(cx.tcx()))); } }; let bcx = with_cond(cx, is_zero, |bcx| { @@ -1554,7 +1554,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }; for monomorphized_arg_type in &monomorphized_arg_types { debug!("trans_closure: monomorphized_arg_type: {}", - ty_to_string(ccx.tcx(), *monomorphized_arg_type)); + monomorphized_arg_type.repr(ccx.tcx())); } debug!("trans_closure: function lltype: {}", bcx.fcx.ccx.tn().val_to_string(bcx.fcx.llfn)); @@ -1758,7 +1758,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx _ => ccx.sess().bug( &format!("trans_enum_variant_or_tuple_like_struct: \ unexpected ctor return type {}", - ty_to_string(ccx.tcx(), ctor_ty))) + ctor_ty.repr(ccx.tcx()))) }; let (arena, fcx): (TypedArena<_>, FunctionContext); diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 0aeb4046dc64c..610ac6a113bd6 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -55,7 +55,6 @@ use middle::ty::{self, Ty}; use middle::ty::MethodCall; use rustc::ast_map; use util::ppaux::Repr; -use util::ppaux::ty_to_string; use syntax::abi as synabi; use syntax::ast; @@ -1166,8 +1165,8 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty); debug!("casting actual type ({}) to match formal ({})", bcx.val_to_string(val), bcx.llty_str(llformal_arg_ty)); - debug!("Rust types: {}; {}", ty_to_string(bcx.tcx(), arg_datum_ty), - ty_to_string(bcx.tcx(), formal_arg_ty)); + debug!("Rust types: {}; {}", arg_datum_ty.repr(bcx.tcx()), + formal_arg_ty.repr(bcx.tcx())); val = PointerCast(bcx, val, llformal_arg_ty); } diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index f7d1fad19a166..54f7e381f5e5c 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -32,7 +32,7 @@ use trans::type_of; use middle::cast::{CastTy,IntTy}; use middle::subst::Substs; use middle::ty::{self, Ty}; -use util::ppaux::{Repr, ty_to_string}; +use util::ppaux::Repr; use util::nodemap::NodeMap; use std::iter::repeat; @@ -68,7 +68,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit) _ => cx.sess().span_bug(lit.span, &format!("integer literal has type {} (expected int \ or usize)", - ty_to_string(cx.tcx(), lit_int_ty))) + lit_int_ty.repr(cx.tcx()))) } } ast::LitFloat(ref fs, t) => { @@ -161,7 +161,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } None => { cx.sess().bug(&format!("unexpected dereferenceable type {}", - ty_to_string(cx.tcx(), ty))) + ty.repr(cx.tcx()))) } } } @@ -369,7 +369,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, llvm::LLVMDumpValue(C_undef(llty)); } cx.sess().bug(&format!("const {} of type {} has size {} instead of {}", - e.repr(cx.tcx()), ty_to_string(cx.tcx(), ety_adjusted), + e.repr(cx.tcx()), ety_adjusted.repr(cx.tcx()), csize, tsize)); } (llconst, ety_adjusted) @@ -621,12 +621,12 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, _ => cx.sess().span_bug(base.span, &format!("index-expr base must be a vector \ or string type, found {}", - ty_to_string(cx.tcx(), bt))) + bt.repr(cx.tcx()))) }, _ => cx.sess().span_bug(base.span, &format!("index-expr base must be a vector \ or string type, found {}", - ty_to_string(cx.tcx(), bt))) + bt.repr(cx.tcx()))) }; let len = llvm::LLVMConstIntGetZExtValue(len) as u64; diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index dd32ed3bc1e59..d73bc28ba1967 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -102,7 +102,7 @@ use trans::expr; use trans::tvec; use trans::type_of; use middle::ty::{self, Ty}; -use util::ppaux::ty_to_string; +use util::ppaux::Repr; use std::fmt; use syntax::ast; @@ -616,7 +616,7 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> { pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { format!("Datum({}, {}, {:?})", ccx.tn().val_to_string(self.val), - ty_to_string(ccx.tcx(), self.ty), + self.ty.repr(ccx.tcx()), self.kind) } diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 5e35e5c67f396..842631ed94031 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -34,7 +34,7 @@ use trans::type_::Type; use middle::ty::{self, Ty, ClosureTyper}; use session::config::{self, FullDebugInfo}; use util::nodemap::FnvHashMap; -use util::ppaux; +use util::ppaux::{Repr, UserString}; use util::common::path2cstr; use libc::{c_uint, c_longlong}; @@ -105,7 +105,7 @@ impl<'tcx> TypeMap<'tcx> { metadata: DIType) { if self.type_to_metadata.insert(type_, metadata).is_some() { cx.sess().bug(&format!("Type metadata for Ty '{}' is already in the TypeMap!", - ppaux::ty_to_string(cx.tcx(), type_))); + type_.repr(cx.tcx()))); } } @@ -298,8 +298,7 @@ impl<'tcx> TypeMap<'tcx> { }, _ => { cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}", - &ppaux::ty_to_string(cx.tcx(), type_), - type_.sty)) + type_.repr(cx.tcx()), type_.sty)) } }; @@ -490,7 +489,7 @@ impl<'tcx> RecursiveTypeDescription<'tcx> { type_map.find_metadata_for_type(unfinished_type).is_none() { cx.sess().bug(&format!("Forward declaration of potentially recursive type \ '{}' was not found in TypeMap!", - ppaux::ty_to_string(cx.tcx(), unfinished_type)) + unfinished_type.repr(cx.tcx())) ); } } @@ -676,10 +675,9 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let def_id = match trait_type.sty { ty::TyTrait(ref data) => data.principal_def_id(), _ => { - let pp_type_name = ppaux::ty_to_string(cx.tcx(), trait_type); cx.sess().bug(&format!("debuginfo: Unexpected trait-object type in \ trait_pointer_metadata(): {}", - &pp_type_name[..])); + trait_type.repr(cx.tcx()))); } }; @@ -841,7 +839,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, the debuginfo::TypeMap but it \ was not. (Ty = {})", &unique_type_id_str[..], - ppaux::ty_to_string(cx.tcx(), t)); + t.user_string(cx.tcx())); cx.sess().span_bug(usage_site_span, &error_message[..]); } }; @@ -856,7 +854,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, debuginfo::TypeMap. \ UniqueTypeId={}, Ty={}", &unique_type_id_str[..], - ppaux::ty_to_string(cx.tcx(), t)); + t.user_string(cx.tcx())); cx.sess().span_bug(usage_site_span, &error_message[..]); } } diff --git a/src/librustc_trans/trans/debuginfo/type_names.rs b/src/librustc_trans/trans/debuginfo/type_names.rs index 7d6c053cd1bf4..c5dd2c17822d3 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/trans/debuginfo/type_names.rs @@ -15,9 +15,10 @@ use super::namespace::crate_root_namespace; use trans::common::CrateContext; use middle::subst::{self, Substs}; use middle::ty::{self, Ty, ClosureTyper}; +use util::ppaux::Repr; + use syntax::ast; use syntax::parse::token; -use util::ppaux; // Compute the name of the type as it should be stored in debuginfo. Does not do @@ -162,7 +163,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::TyProjection(..) | ty::TyParam(_) => { cx.sess().bug(&format!("debuginfo: Trying to create type name for \ - unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t))); + unexpected type: {}", t.repr(cx.tcx()))); } } diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index 35dbc72237645..a8e4783fbdd29 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -39,7 +39,7 @@ use trans::machine::*; use trans::monomorphize; use trans::type_of::{type_of, type_of_dtor, sizing_type_of, align_of}; use trans::type_::Type; -use util::ppaux::{self, Repr}; +use util::ppaux::Repr; use arena::TypedArena; use libc::c_uint; @@ -205,10 +205,13 @@ impl<'tcx> DropGlueKind<'tcx> { } fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { - let t_str = ppaux::ty_to_string(ccx.tcx(), self.ty()); match *self { - DropGlueKind::Ty(_) => format!("DropGlueKind::Ty({})", t_str), - DropGlueKind::TyContents(_) => format!("DropGlueKind::TyContents({})", t_str), + DropGlueKind::Ty(ty) => { + format!("DropGlueKind::Ty({})", ty.repr(ccx.tcx())) + } + DropGlueKind::TyContents(ty) => { + format!("DropGlueKind::TyContents({})", ty.repr(ccx.tcx())) + } } } } diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 419ab1bb05d6e..41780e08b909a 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -34,7 +34,7 @@ use middle::ty::{self, Ty}; use syntax::abi::RustIntrinsic; use syntax::ast; use syntax::parse::token; -use util::ppaux::{Repr, ty_to_string}; +use util::ppaux::{Repr, UserString}; pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Option { let name = match &token::get_ident(item.ident)[..] { @@ -121,10 +121,10 @@ pub fn check_intrinsics(ccx: &CrateContext) { transmute_restriction.span, &format!("transmute called on types with potentially different sizes: \ {} (could be {} bit{}) to {} (could be {} bit{})", - ty_to_string(ccx.tcx(), transmute_restriction.original_from), + transmute_restriction.original_from.user_string(ccx.tcx()), from_type_size as usize, if from_type_size == 1 {""} else {"s"}, - ty_to_string(ccx.tcx(), transmute_restriction.original_to), + transmute_restriction.original_to.user_string(ccx.tcx()), to_type_size as usize, if to_type_size == 1 {""} else {"s"})); } else { @@ -132,10 +132,10 @@ pub fn check_intrinsics(ccx: &CrateContext) { transmute_restriction.span, &format!("transmute called on types with different sizes: \ {} ({} bit{}) to {} ({} bit{})", - ty_to_string(ccx.tcx(), transmute_restriction.original_from), + transmute_restriction.original_from.user_string(ccx.tcx()), from_type_size as usize, if from_type_size == 1 {""} else {"s"}, - ty_to_string(ccx.tcx(), transmute_restriction.original_to), + transmute_restriction.original_to.user_string(ccx.tcx()), to_type_size as usize, if to_type_size == 1 {""} else {"s"})); } @@ -405,7 +405,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } (_, "type_name") => { let tp_ty = *substs.types.get(FnSpace, 0); - let ty_name = token::intern_and_get_ident(&ty_to_string(ccx.tcx(), tp_ty)); + let ty_name = token::intern_and_get_ident(&tp_ty.user_string(ccx.tcx())); C_str_slice(ccx, ty_name) } (_, "type_id") => { diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 3df6c904c7bc0..df3fd72cc4623 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -28,7 +28,7 @@ use trans::machine::llsize_of_alloc; use trans::type_::Type; use trans::type_of; use middle::ty::{self, Ty}; -use util::ppaux::ty_to_string; +use util::ppaux::UserString; use syntax::ast; use syntax::parse::token::InternedString; @@ -42,7 +42,7 @@ struct VecTypes<'tcx> { impl<'tcx> VecTypes<'tcx> { pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { format!("VecTypes {{unit_ty={}, llunit_ty={}}}", - ty_to_string(ccx.tcx(), self.unit_ty), + self.unit_ty.user_string(ccx.tcx()), ccx.tn().type_to_string(self.llunit_ty)) } } diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 763d0581d6fb4..ecbeb714b4a94 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -16,7 +16,6 @@ use trans::common::*; use trans::foreign; use trans::machine; use middle::ty::{self, RegionEscape, Ty}; -use util::ppaux; use util::ppaux::Repr; use trans::type_::Type; @@ -230,7 +229,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ ty::TyProjection(..) | ty::TyInfer(..) | ty::TyParam(..) | ty::TyError(..) => { cx.sess().bug(&format!("fictitious type {} in sizing_type_of()", - ppaux::ty_to_string(cx.tcx(), t))) + t.repr(cx.tcx()))) } ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!() }; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9df0d4aa56b8a..41dcb12395259 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -106,7 +106,7 @@ use {CrateCtxt, lookup_full_def, require_same_types}; use TypeAndSubsts; use lint; use util::common::{block_query, ErrorReported, indenter, loop_query}; -use util::ppaux::{self, Repr}; +use util::ppaux::{Repr, UserString}; use util::nodemap::{DefIdMap, FnvHashMap, NodeMap}; use util::lev_distance::lev_distance; @@ -1396,7 +1396,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[inline] pub fn write_ty(&self, node_id: ast::NodeId, ty: Ty<'tcx>) { debug!("write_ty({}, {}) in fcx {}", - node_id, ppaux::ty_to_string(self.tcx(), ty), self.tag()); + node_id, ty.repr(self.tcx()), self.tag()); self.inh.node_types.borrow_mut().insert(node_id, ty); } @@ -2746,7 +2746,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, |base_t, _| { match base_t.sty { ty::TyStruct(base_id, substs) => { - debug!("struct named {}", ppaux::ty_to_string(tcx, base_t)); + debug!("struct named {}", base_t.repr(tcx)); let fields = ty::lookup_struct_fields(tcx, base_id); fcx.lookup_field_ty(expr.span, base_id, &fields[..], field.node.name, &(*substs)) @@ -2850,7 +2850,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, ty::TyStruct(base_id, substs) => { tuple_like = ty::is_tuple_struct(tcx, base_id); if tuple_like { - debug!("tuple struct named {}", ppaux::ty_to_string(tcx, base_t)); + debug!("tuple struct named {}", base_t.repr(tcx)); let fields = ty::lookup_struct_fields(tcx, base_id); fcx.lookup_tup_field_ty(expr.span, base_id, &fields[..], idx.node, &(*substs)) @@ -3749,7 +3749,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, debug!("type of expr({}) {} is...", expr.id, syntax::print::pprust::expr_to_string(expr)); debug!("... {}, expected is {}", - ppaux::ty_to_string(tcx, fcx.expr_ty(expr)), + fcx.expr_ty(expr).repr(tcx), expected.repr(tcx)); unifier(); @@ -4198,7 +4198,7 @@ pub fn check_instantiable(tcx: &ty::ctxt, "this type cannot be instantiated without an \ instance of itself"); fileline_help!(tcx.sess, sp, "consider using `Option<{}>`", - ppaux::ty_to_string(tcx, item_ty)); + item_ty.repr(tcx)); false } else { true @@ -4950,7 +4950,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, tps: &OwnedSlice, ty: Ty<'tcx>) { debug!("check_bounds_are_used(n_tps={}, ty={})", - tps.len(), ppaux::ty_to_string(ccx.tcx, ty)); + tps.len(), ty.repr(ccx.tcx)); // make a vector of booleans initially false, set to true when used if tps.is_empty() { return; } @@ -5273,7 +5273,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) { fty, || { format!("intrinsic has wrong type: expected `{}`", - ppaux::ty_to_string(ccx.tcx, fty)) + fty.user_string(ccx.tcx)) }); } } diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index cb4d048ab374b..04dd7f46b834b 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -94,7 +94,7 @@ use middle::traits; use middle::ty::{self, ClosureTyper, ReScope, Ty, MethodCall}; use middle::infer::{self, GenericKind}; use middle::pat_util; -use util::ppaux::{ty_to_string, Repr}; +use util::ppaux::{Repr, UserString}; use std::mem; use syntax::{ast, ast_util}; @@ -1025,7 +1025,7 @@ fn type_of_node_must_outlive<'a, 'tcx>( |method_call| rcx.resolve_method_type(method_call)); debug!("constrain_regions_in_type_of_node(\ ty={}, ty0={}, id={}, minimum_lifetime={:?})", - ty_to_string(tcx, ty), ty_to_string(tcx, ty0), + ty.user_string(tcx), ty0.user_string(tcx), id, minimum_lifetime); type_must_outlive(rcx, origin, ty, minimum_lifetime); } @@ -1178,7 +1178,7 @@ fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, let rptr_ty = rcx.resolve_node_type(id); if !ty::type_is_error(rptr_ty) { let tcx = rcx.fcx.ccx.tcx; - debug!("rptr_ty={}", ty_to_string(tcx, rptr_ty)); + debug!("rptr_ty={}", rptr_ty.user_string(tcx)); let r = ty::ty_region(tcx, span, rptr_ty); link_region(rcx, span, &r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index aabd33d9c1d3a..03a0c2f5b62e5 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -80,8 +80,7 @@ use rscope::*; use rustc::ast_map; use util::common::{ErrorReported, memoized}; use util::nodemap::{FnvHashMap, FnvHashSet}; -use util::ppaux; -use util::ppaux::{Repr,UserString}; +use util::ppaux::{Repr, UserString}; use write_ty_to_tcx; use std::cell::{Cell, RefCell}; @@ -2217,7 +2216,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( required_type_free, || { format!("mismatched self type: expected `{}`", - ppaux::ty_to_string(tcx, required_type)) + required_type.user_string(tcx)) })); // We could conceviably add more free-region relations here, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 7519cd0519569..0ea5073bb2490 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -109,8 +109,7 @@ use middle::ty::{self, Ty}; use rustc::ast_map; use session::config; use util::common::time; -use util::ppaux::Repr; -use util::ppaux; +use util::ppaux::{Repr, UserString}; use syntax::codemap::Span; use syntax::print::pprust::*; @@ -149,7 +148,7 @@ pub struct CrateCtxt<'a, 'tcx: 'a> { // Functions that write types into the node type table fn write_ty_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, node_id: ast::NodeId, ty: Ty<'tcx>) { - debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_string(tcx, ty)); + debug!("write_ty_to_tcx({}, {})", node_id, ty.repr(tcx)); assert!(!ty::type_needs_infer(ty)); tcx.node_type_insert(node_id, ty); } @@ -245,15 +244,14 @@ fn check_main_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, main_span, main_t, se_ty, || { format!("main function expects type: `{}`", - ppaux::ty_to_string(ccx.tcx, se_ty)) + se_ty.user_string(ccx.tcx)) }); } _ => { tcx.sess.span_bug(main_span, &format!("main has a non-function type: found \ `{}`", - ppaux::ty_to_string(tcx, - main_t))); + main_t.repr(tcx))); } } } @@ -296,7 +294,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, start_span, start_t, se_ty, || { format!("start function expects type: `{}`", - ppaux::ty_to_string(ccx.tcx, se_ty)) + se_ty.user_string(ccx.tcx)) }); } @@ -304,7 +302,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, tcx.sess.span_bug(start_span, &format!("start has a non-function type: found \ `{}`", - ppaux::ty_to_string(tcx, start_t))); + start_t.repr(tcx))); } } } From 6061707348ada3245de306c9d38d07250293e58e Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 16 Jun 2015 01:10:55 +0300 Subject: [PATCH 38/48] rustc: leave only one free top-level function in ppaux, and private. --- src/librustc/middle/infer/error_reporting.rs | 128 ++++- src/librustc/middle/ty.rs | 2 +- src/librustc/util/ppaux.rs | 545 +++++++------------ src/librustc_borrowck/borrowck/mod.rs | 5 +- src/librustc_trans/trans/_match.rs | 10 +- src/librustc_typeck/astconv.rs | 8 +- 6 files changed, 331 insertions(+), 367 deletions(-) diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 71a56a3ed3b77..515e8b82a78f9 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -75,6 +75,7 @@ use std::collections::HashSet; use ast_map; use middle::def; use middle::infer; +use middle::region; use middle::subst; use middle::ty::{self, Ty}; use middle::ty::{Region, ReFree}; @@ -84,16 +85,135 @@ use std::string::String; use syntax::ast; use syntax::ast_util::name_to_dummy_lifetime; use syntax::owned_slice::OwnedSlice; -use syntax::codemap; +use syntax::codemap::{Pos, Span}; use syntax::parse::token; use syntax::print::pprust; use syntax::ptr::P; -use util::ppaux::note_and_explain_region; // Note: only import UserString, not Repr, since user-facing error // messages shouldn't include debug serializations. use util::ppaux::UserString; +pub fn note_and_explain_region(tcx: &ty::ctxt, + prefix: &str, + region: ty::Region, + suffix: &str) { + fn item_scope_tag(item: &ast::Item) -> &'static str { + match item.node { + ast::ItemImpl(..) => "impl", + ast::ItemStruct(..) => "struct", + ast::ItemEnum(..) => "enum", + ast::ItemTrait(..) => "trait", + ast::ItemFn(..) => "function body", + _ => "item" + } + } + + fn explain_span(tcx: &ty::ctxt, heading: &str, span: Span) + -> (String, Option) { + let lo = tcx.sess.codemap().lookup_char_pos_adj(span.lo); + (format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()), + Some(span)) + } + + let (description, span) = match region { + ty::ReScope(scope) => { + let new_string; + let unknown_scope = || { + format!("{}unknown scope: {:?}{}. Please report a bug.", + prefix, scope, suffix) + }; + let span = match scope.span(&tcx.map) { + Some(s) => s, + None => return tcx.sess.note(&unknown_scope()) + }; + let tag = match tcx.map.find(scope.node_id()) { + Some(ast_map::NodeBlock(_)) => "block", + Some(ast_map::NodeExpr(expr)) => match expr.node { + ast::ExprCall(..) => "call", + ast::ExprMethodCall(..) => "method call", + ast::ExprMatch(_, _, ast::MatchSource::IfLetDesugar { .. }) => "if let", + ast::ExprMatch(_, _, ast::MatchSource::WhileLetDesugar) => "while let", + ast::ExprMatch(_, _, ast::MatchSource::ForLoopDesugar) => "for", + ast::ExprMatch(..) => "match", + _ => "expression", + }, + Some(ast_map::NodeStmt(_)) => "statement", + Some(ast_map::NodeItem(it)) => item_scope_tag(&*it), + Some(_) | None => { + return tcx.sess.span_note(span, &unknown_scope()); + } + }; + let scope_decorated_tag = match scope { + region::CodeExtent::Misc(_) => tag, + region::CodeExtent::ParameterScope { .. } => { + "scope of parameters for function" + } + region::CodeExtent::DestructionScope(_) => { + new_string = format!("destruction scope surrounding {}", tag); + &new_string[..] + } + region::CodeExtent::Remainder(r) => { + new_string = format!("block suffix following statement {}", + r.first_statement_index); + &new_string[..] + } + }; + explain_span(tcx, scope_decorated_tag, span) + } + + ty::ReFree(ref fr) => { + let prefix = match fr.bound_region { + ty::BrAnon(idx) => { + format!("the anonymous lifetime #{} defined on", idx + 1) + } + ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(), + _ => { + format!("the lifetime {} as defined on", + fr.bound_region.user_string(tcx)) + } + }; + + match tcx.map.find(fr.scope.node_id) { + Some(ast_map::NodeBlock(ref blk)) => { + let (msg, opt_span) = explain_span(tcx, "block", blk.span); + (format!("{} {}", prefix, msg), opt_span) + } + Some(ast_map::NodeItem(it)) => { + let tag = item_scope_tag(&*it); + let (msg, opt_span) = explain_span(tcx, tag, it.span); + (format!("{} {}", prefix, msg), opt_span) + } + Some(_) | None => { + // this really should not happen + (format!("{} unknown free region bounded by scope {:?}", + prefix, fr.scope), None) + } + } + } + + ty::ReStatic => ("the static lifetime".to_owned(), None), + + ty::ReEmpty => ("the empty lifetime".to_owned(), None), + + ty::ReEarlyBound(ref data) => { + (format!("{}", token::get_name(data.name)), None) + } + + // I believe these cases should not occur (except when debugging, + // perhaps) + ty::ReInfer(_) | ty::ReLateBound(..) => { + (format!("lifetime {:?}", region), None) + } + }; + let message = format!("{}{}{}", prefix, description, suffix); + if let Some(span) = span { + tcx.sess.span_note(span, &message); + } else { + tcx.sess.note(&message); + } +} + pub trait ErrorReporting<'tcx> { fn report_region_errors(&self, errors: &Vec>); @@ -161,7 +281,7 @@ trait ErrorReportingHelpers<'tcx> { ident: ast::Ident, opt_explicit_self: Option<&ast::ExplicitSelf_>, generics: &ast::Generics, - span: codemap::Span); + span: Span); } impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { @@ -1430,7 +1550,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> { ident: ast::Ident, opt_explicit_self: Option<&ast::ExplicitSelf_>, generics: &ast::Generics, - span: codemap::Span) { + span: Span) { let suggested_fn = pprust::fun_to_string(decl, unsafety, constness, ident, opt_explicit_self, generics); let msg = format!("consider using an explicit lifetime \ diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 9006777eee37e..474865305a075 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -48,6 +48,7 @@ use middle::def::{self, DefMap, ExportMap}; use middle::dependency_format; use middle::fast_reject; use middle::free_region::FreeRegionMap; +use middle::infer::error_reporting::note_and_explain_region; use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem}; use middle::mem_categorization as mc; use middle::region; @@ -61,7 +62,6 @@ use middle::traits; use middle::ty; use middle::ty_fold::{self, TypeFoldable, TypeFolder}; use middle::ty_walk::{self, TypeWalker}; -use util::ppaux::note_and_explain_region; use util::ppaux::{Repr, UserString}; use util::common::{memoized, ErrorReported}; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 8eaf19eb47415..c4f69a7f5fe93 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -32,7 +32,7 @@ use std::collections::hash_state::HashState; use std::hash::Hash; use std::rc::Rc; use syntax::abi; -use syntax::codemap::{Span, Pos}; +use syntax::codemap::Span; use syntax::parse::token; use syntax::print::pprust; use syntax::ptr::P; @@ -49,342 +49,7 @@ pub trait UserString<'tcx> : Repr<'tcx> { fn user_string(&self, tcx: &ctxt<'tcx>) -> String; } -pub fn note_and_explain_region(cx: &ctxt, - prefix: &str, - region: ty::Region, - suffix: &str) { - let (description, span) = explain_region_and_span(cx, region); - let message = format!("{}{}{}", prefix, description, suffix); - if let Some(span) = span { - cx.sess.span_note(span, &message); - } else { - cx.sess.note(&message); - } -} - -/// When a free region is associated with `item`, how should we describe the item in the error -/// message. -fn item_scope_tag(item: &ast::Item) -> &'static str { - match item.node { - ast::ItemImpl(..) => "impl", - ast::ItemStruct(..) => "struct", - ast::ItemEnum(..) => "enum", - ast::ItemTrait(..) => "trait", - ast::ItemFn(..) => "function body", - _ => "item" - } -} - -fn explain_region_and_span(cx: &ctxt, region: ty::Region) - -> (String, Option) { - return match region { - ReScope(scope) => { - let new_string; - let on_unknown_scope = || { - (format!("unknown scope: {:?}. Please report a bug.", scope), None) - }; - let span = match scope.span(&cx.map) { - Some(s) => s, - None => return on_unknown_scope(), - }; - let tag = match cx.map.find(scope.node_id()) { - Some(ast_map::NodeBlock(_)) => "block", - Some(ast_map::NodeExpr(expr)) => match expr.node { - ast::ExprCall(..) => "call", - ast::ExprMethodCall(..) => "method call", - ast::ExprMatch(_, _, ast::MatchSource::IfLetDesugar { .. }) => "if let", - ast::ExprMatch(_, _, ast::MatchSource::WhileLetDesugar) => "while let", - ast::ExprMatch(_, _, ast::MatchSource::ForLoopDesugar) => "for", - ast::ExprMatch(..) => "match", - _ => "expression", - }, - Some(ast_map::NodeStmt(_)) => "statement", - Some(ast_map::NodeItem(it)) => item_scope_tag(&*it), - Some(_) | None => { - // this really should not happen - return on_unknown_scope(); - } - }; - let scope_decorated_tag = match scope { - region::CodeExtent::Misc(_) => tag, - region::CodeExtent::ParameterScope { .. } => { - "scope of parameters for function" - } - region::CodeExtent::DestructionScope(_) => { - new_string = format!("destruction scope surrounding {}", tag); - &*new_string - } - region::CodeExtent::Remainder(r) => { - new_string = format!("block suffix following statement {}", - r.first_statement_index); - &*new_string - } - }; - explain_span(cx, scope_decorated_tag, span) - - } - - ReFree(ref fr) => { - let prefix = match fr.bound_region { - BrAnon(idx) => { - format!("the anonymous lifetime #{} defined on", idx + 1) - } - BrFresh(_) => "an anonymous lifetime defined on".to_string(), - _ => { - format!("the lifetime {} as defined on", - fr.bound_region.user_string(cx)) - } - }; - - match cx.map.find(fr.scope.node_id) { - Some(ast_map::NodeBlock(ref blk)) => { - let (msg, opt_span) = explain_span(cx, "block", blk.span); - (format!("{} {}", prefix, msg), opt_span) - } - Some(ast_map::NodeItem(it)) => { - let tag = item_scope_tag(&*it); - let (msg, opt_span) = explain_span(cx, tag, it.span); - (format!("{} {}", prefix, msg), opt_span) - } - Some(_) | None => { - // this really should not happen - (format!("{} unknown free region bounded by scope {:?}", prefix, fr.scope), None) - } - } - } - - ReStatic => { ("the static lifetime".to_string(), None) } - - ReEmpty => { ("the empty lifetime".to_string(), None) } - - ReEarlyBound(ref data) => { - (format!("{}", token::get_name(data.name)), None) - } - - // I believe these cases should not occur (except when debugging, - // perhaps) - ty::ReInfer(_) | ty::ReLateBound(..) => { - (format!("lifetime {:?}", region), None) - } - }; - - fn explain_span(cx: &ctxt, heading: &str, span: Span) - -> (String, Option) { - let lo = cx.sess.codemap().lookup_char_pos_adj(span.lo); - (format!("the {} at {}:{}", heading, lo.line, lo.col.to_usize()), - Some(span)) - } -} - -pub fn mutability_to_string(m: ast::Mutability) -> String { - match m { - ast::MutMutable => "mut ".to_string(), - ast::MutImmutable => "".to_string(), - } -} - -pub fn mt_to_string<'tcx>(cx: &ctxt<'tcx>, m: &mt<'tcx>) -> String { - format!("{}{}", - mutability_to_string(m.mutbl), - m.ty.user_string(cx)) -} - -pub fn vec_map_to_string(ts: &[T], f: F) -> String where - F: FnMut(&T) -> String, -{ - let tstrs = ts.iter().map(f).collect::>(); - format!("[{}]", tstrs.connect(", ")) -} - -fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String { - fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>, - opt_def_id: Option, - unsafety: ast::Unsafety, - abi: abi::Abi, - ident: Option, - sig: &ty::PolyFnSig<'tcx>) - -> String { - let mut s = String::new(); - - match unsafety { - ast::Unsafety::Normal => {} - ast::Unsafety::Unsafe => { - s.push_str(&unsafety.to_string()); - s.push(' '); - } - }; - - if abi != abi::Rust { - s.push_str(&format!("extern {} ", abi.to_string())); - }; - - s.push_str("fn"); - - match ident { - Some(i) => { - s.push(' '); - s.push_str(&token::get_ident(i)); - } - _ => { } - } - - push_sig_to_string(cx, &mut s, '(', ')', sig); - - match opt_def_id { - Some(def_id) => { - s.push_str(" {"); - let path_str = ty::item_path_str(cx, def_id); - s.push_str(&path_str[..]); - s.push_str("}"); - } - None => { } - } - - s - } - - fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, - cty: &ty::ClosureTy<'tcx>, - did: &ast::DefId) - -> String { - let mut s = String::new(); - s.push_str("[closure"); - push_sig_to_string(cx, &mut s, '(', ')', &cty.sig); - if cx.sess.verbose() { - s.push_str(&format!(" id={:?}]", did)); - } else { - s.push(']'); - } - s - } - - fn push_sig_to_string<'tcx>(cx: &ctxt<'tcx>, - s: &mut String, - bra: char, - ket: char, - sig: &ty::PolyFnSig<'tcx>) { - s.push(bra); - let strs = sig.0.inputs - .iter() - .map(|a| a.user_string(cx)) - .collect::>(); - s.push_str(&strs.connect(", ")); - if sig.0.variadic { - s.push_str(", ..."); - } - s.push(ket); - - match sig.0.output { - ty::FnConverging(t) => { - if !ty::type_is_nil(t) { - s.push_str(" -> "); - s.push_str(& t.user_string(cx)); - } - } - ty::FnDiverging => { - s.push_str(" -> !"); - } - } - } - - fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String { - let print_var_ids = cx.sess.verbose(); - match ty { - ty::TyVar(ref vid) if print_var_ids => vid.repr(cx), - ty::IntVar(ref vid) if print_var_ids => vid.repr(cx), - ty::FloatVar(ref vid) if print_var_ids => vid.repr(cx), - ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => format!("_"), - ty::FreshTy(v) => format!("FreshTy({})", v), - ty::FreshIntTy(v) => format!("FreshIntTy({})", v), - ty::FreshFloatTy(v) => format!("FreshFloatTy({})", v) - } - } - - // pretty print the structural type representation: - match typ.sty { - TyBool => "bool".to_string(), - TyChar => "char".to_string(), - TyInt(t) => ast_util::int_ty_to_string(t, None).to_string(), - TyUint(t) => ast_util::uint_ty_to_string(t, None).to_string(), - TyFloat(t) => ast_util::float_ty_to_string(t).to_string(), - TyBox(typ) => format!("Box<{}>", typ.user_string(cx)), - TyRawPtr(ref tm) => { - format!("*{} {}", match tm.mutbl { - ast::MutMutable => "mut", - ast::MutImmutable => "const", - }, tm.ty.user_string(cx)) - } - TyRef(r, ref tm) => { - let mut buf = "&".to_owned(); - buf.push_str(&r.user_string(cx)); - if !buf.is_empty() { - buf.push_str(" "); - } - buf.push_str(&mt_to_string(cx, tm)); - buf - } - TyTuple(ref elems) => { - let strs = elems - .iter() - .map(|elem| elem.user_string(cx)) - .collect::>(); - match &strs[..] { - [ref string] => format!("({},)", string), - strs => format!("({})", strs.connect(", ")) - } - } - TyBareFn(opt_def_id, ref f) => { - bare_fn_to_string(cx, opt_def_id, f.unsafety, f.abi, None, &f.sig) - } - TyInfer(infer_ty) => infer_ty_to_string(cx, infer_ty), - TyError => "[type error]".to_string(), - TyParam(ref param_ty) => param_ty.user_string(cx), - TyEnum(did, substs) | TyStruct(did, substs) => { - let base = ty::item_path_str(cx, did); - parameterized(cx, &base, substs, did, &[], - || ty::lookup_item_type(cx, did).generics) - } - TyTrait(ref data) => { - data.user_string(cx) - } - ty::TyProjection(ref data) => { - format!("<{} as {}>::{}", - data.trait_ref.self_ty().user_string(cx), - data.trait_ref.user_string(cx), - data.item_name.user_string(cx)) - } - TyStr => "str".to_string(), - TyClosure(ref did, substs) => { - let closure_tys = cx.closure_tys.borrow(); - closure_tys.get(did).map(|closure_type| { - closure_to_string(cx, &closure_type.subst(cx, substs), did) - }).unwrap_or_else(|| { - let id_str = if cx.sess.verbose() { - format!(" id={:?}", did) - } else { - "".to_owned() - }; - - - if did.krate == ast::LOCAL_CRATE { - let span = cx.map.span(did.node); - format!("[closure {}{}]", span.repr(cx), id_str) - } else { - format!("[closure{}]", id_str) - } - }) - } - TyArray(t, sz) => { - format!("[{}; {}]", t.user_string(cx), sz) - } - TySlice(t) => { - format!("[{}]", t.user_string(cx)) - } - } -} - fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, - base: &str, substs: &subst::Substs<'tcx>, did: ast::DefId, projections: &[ty::ProjectionPredicate<'tcx>], @@ -392,6 +57,7 @@ fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, -> String where GG : FnOnce() -> ty::Generics<'tcx> { + let base = ty::item_path_str(cx, did); if cx.sess.verbose() { let mut strings = vec![]; match substs.regions { @@ -557,19 +223,15 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Box { } } -fn repr_vec<'tcx, T:Repr<'tcx>>(tcx: &ctxt<'tcx>, v: &[T]) -> String { - vec_map_to_string(v, |t| t.repr(tcx)) -} - impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for [T] { fn repr(&self, tcx: &ctxt<'tcx>) -> String { - repr_vec(tcx, self) + format!("[{}]", self.iter().map(|t| t.repr(tcx)).collect::>().connect(", ")) } } impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice { fn repr(&self, tcx: &ctxt<'tcx>) -> String { - repr_vec(tcx, &self[..]) + self[..].repr(tcx) } } @@ -577,7 +239,7 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice { // autoderef cannot convert the &[T] handler impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec { fn repr(&self, tcx: &ctxt<'tcx>) -> String { - repr_vec(tcx, &self[..]) + self[..].repr(tcx) } } @@ -618,9 +280,7 @@ type TraitAndProjections<'tcx> = impl<'tcx> UserString<'tcx> for TraitAndProjections<'tcx> { fn user_string(&self, tcx: &ctxt<'tcx>) -> String { let &(ref trait_ref, ref projection_bounds) = self; - let base = ty::item_path_str(tcx, trait_ref.def_id); parameterized(tcx, - &base, trait_ref.substs, trait_ref.def_id, &projection_bounds[..], @@ -684,7 +344,9 @@ impl<'tcx> Repr<'tcx> for ty::TyS<'tcx> { impl<'tcx> Repr<'tcx> for ty::mt<'tcx> { fn repr(&self, tcx: &ctxt<'tcx>) -> String { - mt_to_string(tcx, self) + format!("{}{}", + if self.mutbl == ast::MutMutable { "mut " } else { "" }, + self.ty.user_string(tcx)) } } @@ -751,9 +413,7 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> { // when printing out the debug representation, we don't need // to enumerate the `for<...>` etc because the debruijn index // tells you everything you need to know. - let base = ty::item_path_str(tcx, self.def_id); - let result = parameterized(tcx, &base, self.substs, self.def_id, &[], - || ty::lookup_trait_def(tcx, self.def_id).generics.clone()); + let result = self.user_string(tcx); match self.substs.self_ty() { None => result, Some(sty) => format!("<{} as {}>", sty.repr(tcx), result) @@ -1290,15 +950,196 @@ impl<'tcx, T> UserString<'tcx> for ty::Binder impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> { fn user_string(&self, tcx: &ctxt<'tcx>) -> String { - let path_str = ty::item_path_str(tcx, self.def_id); - parameterized(tcx, &path_str, self.substs, self.def_id, &[], + parameterized(tcx, self.substs, self.def_id, &[], || ty::lookup_trait_def(tcx, self.def_id).generics.clone()) } } impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { fn user_string(&self, tcx: &ctxt<'tcx>) -> String { - ty_to_string(tcx, self) + fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>, + opt_def_id: Option, + unsafety: ast::Unsafety, + abi: abi::Abi, + ident: Option, + sig: &ty::PolyFnSig<'tcx>) + -> String { + let mut s = String::new(); + + match unsafety { + ast::Unsafety::Normal => {} + ast::Unsafety::Unsafe => { + s.push_str(&unsafety.to_string()); + s.push(' '); + } + }; + + if abi != abi::Rust { + s.push_str(&format!("extern {} ", abi.to_string())); + }; + + s.push_str("fn"); + + match ident { + Some(i) => { + s.push(' '); + s.push_str(&token::get_ident(i)); + } + _ => { } + } + + push_sig_to_string(cx, &mut s, '(', ')', sig); + + match opt_def_id { + Some(def_id) => { + s.push_str(" {"); + let path_str = ty::item_path_str(cx, def_id); + s.push_str(&path_str[..]); + s.push_str("}"); + } + None => { } + } + + s + } + + fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, + cty: &ty::ClosureTy<'tcx>, + did: &ast::DefId) + -> String { + let mut s = String::new(); + s.push_str("[closure"); + push_sig_to_string(cx, &mut s, '(', ')', &cty.sig); + if cx.sess.verbose() { + s.push_str(&format!(" id={:?}]", did)); + } else { + s.push(']'); + } + s + } + + fn push_sig_to_string<'tcx>(cx: &ctxt<'tcx>, + s: &mut String, + bra: char, + ket: char, + sig: &ty::PolyFnSig<'tcx>) { + s.push(bra); + let strs = sig.0.inputs + .iter() + .map(|a| a.user_string(cx)) + .collect::>(); + s.push_str(&strs.connect(", ")); + if sig.0.variadic { + s.push_str(", ..."); + } + s.push(ket); + + match sig.0.output { + ty::FnConverging(t) => { + if !ty::type_is_nil(t) { + s.push_str(" -> "); + s.push_str(& t.user_string(cx)); + } + } + ty::FnDiverging => { + s.push_str(" -> !"); + } + } + } + + fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String { + let print_var_ids = cx.sess.verbose(); + match ty { + ty::TyVar(ref vid) if print_var_ids => vid.repr(cx), + ty::IntVar(ref vid) if print_var_ids => vid.repr(cx), + ty::FloatVar(ref vid) if print_var_ids => vid.repr(cx), + ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => format!("_"), + ty::FreshTy(v) => format!("FreshTy({})", v), + ty::FreshIntTy(v) => format!("FreshIntTy({})", v), + ty::FreshFloatTy(v) => format!("FreshFloatTy({})", v) + } + } + + // pretty print the structural type representation: + match self.sty { + TyBool => "bool".to_string(), + TyChar => "char".to_string(), + TyInt(t) => ast_util::int_ty_to_string(t, None).to_string(), + TyUint(t) => ast_util::uint_ty_to_string(t, None).to_string(), + TyFloat(t) => ast_util::float_ty_to_string(t).to_string(), + TyBox(typ) => format!("Box<{}>", typ.user_string(tcx)), + TyRawPtr(ref tm) => { + format!("*{} {}", match tm.mutbl { + ast::MutMutable => "mut", + ast::MutImmutable => "const", + }, tm.ty.user_string(tcx)) + } + TyRef(r, ref tm) => { + let mut buf = "&".to_owned(); + buf.push_str(&r.user_string(tcx)); + if !buf.is_empty() { + buf.push_str(" "); + } + buf.push_str(&tm.repr(tcx)); + buf + } + TyTuple(ref elems) => { + let strs = elems + .iter() + .map(|elem| elem.user_string(tcx)) + .collect::>(); + match &strs[..] { + [ref string] => format!("({},)", string), + strs => format!("({})", strs.connect(", ")) + } + } + TyBareFn(opt_def_id, ref f) => { + bare_fn_to_string(tcx, opt_def_id, f.unsafety, f.abi, None, &f.sig) + } + TyInfer(infer_ty) => infer_ty_to_string(tcx, infer_ty), + TyError => "[type error]".to_string(), + TyParam(ref param_ty) => param_ty.user_string(tcx), + TyEnum(did, substs) | TyStruct(did, substs) => { + parameterized(tcx, substs, did, &[], + || ty::lookup_item_type(tcx, did).generics) + } + TyTrait(ref data) => { + data.user_string(tcx) + } + ty::TyProjection(ref data) => { + format!("<{} as {}>::{}", + data.trait_ref.self_ty().user_string(tcx), + data.trait_ref.user_string(tcx), + data.item_name.user_string(tcx)) + } + TyStr => "str".to_string(), + TyClosure(ref did, substs) => { + let closure_tys = tcx.closure_tys.borrow(); + closure_tys.get(did).map(|closure_type| { + closure_to_string(tcx, &closure_type.subst(tcx, substs), did) + }).unwrap_or_else(|| { + let id_str = if tcx.sess.verbose() { + format!(" id={:?}", did) + } else { + "".to_owned() + }; + + + if did.krate == ast::LOCAL_CRATE { + let span = tcx.map.span(did.node); + format!("[closure {}{}]", span.repr(tcx), id_str) + } else { + format!("[closure{}]", id_str) + } + }) + } + TyArray(t, sz) => { + format!("[{}; {}]", t.user_string(tcx), sz) + } + TySlice(t) => { + format!("[{}]", t.user_string(tcx)) + } + } } } diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 36f08b3ced977..5833386dd1f02 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -28,11 +28,12 @@ use rustc::middle::dataflow::BitwiseOperator; use rustc::middle::dataflow::DataFlowOperator; use rustc::middle::dataflow::KillFrom; use rustc::middle::expr_use_visitor as euv; -use rustc::middle::mem_categorization as mc; use rustc::middle::free_region::FreeRegionMap; +use rustc::middle::infer::error_reporting::note_and_explain_region; +use rustc::middle::mem_categorization as mc; use rustc::middle::region; use rustc::middle::ty::{self, Ty}; -use rustc::util::ppaux::{note_and_explain_region, Repr, UserString}; +use rustc::util::ppaux::{Repr, UserString}; use std::mem; use std::rc::Rc; use std::string::String; diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index d2a7b3198f8dd..898b9b9662db4 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -217,7 +217,7 @@ use middle::ty::{self, Ty}; use session::config::{NoDebugInfo, FullDebugInfo}; use util::common::indenter; use util::nodemap::FnvHashMap; -use util::ppaux::{Repr, vec_map_to_string}; +use util::ppaux::Repr; use std; use std::cmp::Ordering; @@ -937,11 +937,11 @@ fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, chk: &FailureHandler, has_genuine_default: bool) -> Block<'blk, 'tcx> { - debug!("compile_guard(bcx={}, guard_expr={}, m={}, vals={})", + debug!("compile_guard(bcx={}, guard_expr={}, m={}, vals=[{}])", bcx.to_str(), bcx.expr_to_string(guard_expr), m.repr(bcx.tcx()), - vec_map_to_string(vals, |v| bcx.val_to_string(*v))); + vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); let _indenter = indenter(); let mut bcx = insert_lllocals(bcx, &data.bindings_map, None); @@ -983,10 +983,10 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, vals: &[ValueRef], chk: &FailureHandler, has_genuine_default: bool) { - debug!("compile_submatch(bcx={}, m={}, vals={})", + debug!("compile_submatch(bcx={}, m={}, vals=[{}])", bcx.to_str(), m.repr(bcx.tcx()), - vec_map_to_string(vals, |v| bcx.val_to_string(*v))); + vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); let _indenter = indenter(); let _icx = push_ctxt("match::compile_submatch"); let mut bcx = bcx; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index cb3d5bd9bf932..cec267b8f7658 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -61,7 +61,7 @@ use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ExplicitRscope ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope}; use util::common::{ErrorReported, FN_OUTPUT_NAME}; use util::nodemap::FnvHashSet; -use util::ppaux::{self, Repr, UserString}; +use util::ppaux::{Repr, UserString}; use std::iter::repeat; use std::slice; @@ -985,19 +985,21 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>, }); match (&ty.node, full_span) { (&ast::TyRptr(None, ref mut_ty), Some(full_span)) => { + let mutbl_str = if mut_ty.mutbl == ast::MutMutable { "mut " } else { "" }; this.tcx().sess .span_suggestion(full_span, "try adding parentheses (per RFC 438):", format!("&{}({} +{})", - ppaux::mutability_to_string(mut_ty.mutbl), + mutbl_str, pprust::ty_to_string(&*mut_ty.ty), pprust::bounds_to_string(bounds))); } (&ast::TyRptr(Some(ref lt), ref mut_ty), Some(full_span)) => { + let mutbl_str = if mut_ty.mutbl == ast::MutMutable { "mut " } else { "" }; this.tcx().sess .span_suggestion(full_span, "try adding parentheses (per RFC 438):", format!("&{} {}({} +{})", pprust::lifetime_to_string(lt), - ppaux::mutability_to_string(mut_ty.mutbl), + mutbl_str, pprust::ty_to_string(&*mut_ty.ty), pprust::bounds_to_string(bounds))); } From d8952e7932823a3f3aa9d4af0ab9fa6f08b18cef Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 17 Jun 2015 00:33:10 +0300 Subject: [PATCH 39/48] rustc: store the type context in TLS and allow safe access to it. --- src/librustc/lib.rs | 1 + src/librustc/middle/ty.rs | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 240aaae0e55af..c19ba19f5b76b 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -51,6 +51,7 @@ #![feature(ref_slice)] #![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] +#![feature(scoped_tls)] #![feature(slice_bytes)] #![feature(slice_extras)] #![feature(slice_patterns)] diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 474865305a075..84d874909aa38 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -804,6 +804,29 @@ impl<'tcx> ctxt<'tcx> { } } +pub mod tls { + use middle::ty; + use session::Session; + + /// Marker type used for the scoped TLS slot. + /// The type context cannot be used directly because the scoped TLS + /// in libstd doesn't allow types generic over lifetimes. + struct ThreadLocalTyCx; + + scoped_thread_local!(static TLS_TCX: ThreadLocalTyCx); + + pub fn enter<'tcx, F: FnOnce(&ty::ctxt<'tcx>) -> R, R>(tcx: ty::ctxt<'tcx>, f: F) + -> (Session, R) { + let tls_ptr = &tcx as *const _ as *const ThreadLocalTyCx; + let result = TLS_TCX.set(unsafe { &*tls_ptr }, || f(&tcx)); + (tcx.sess, result) + } + + pub fn with R, R>(f: F) -> R { + TLS_TCX.with(|tcx| f(unsafe { &*(tcx as *const _ as *const ty::ctxt) })) + } +} + // Flags that we track on types. These flags are propagated upwards // through the type during type construction, so that we can quickly // check whether the type has various kinds of types in it without @@ -2824,7 +2847,7 @@ pub fn with_ctxt<'tcx, F, R>(s: Session, let mut interner = FnvHashMap(); let common_types = CommonTypes::new(&arenas.type_, &mut interner); - let tcx = ctxt { + tls::enter(ctxt { arenas: arenas, interner: RefCell::new(interner), substs_interner: RefCell::new(FnvHashMap()), @@ -2886,9 +2909,7 @@ pub fn with_ctxt<'tcx, F, R>(s: Session, const_qualif_map: RefCell::new(NodeMap()), custom_coerce_unsized_kinds: RefCell::new(DefIdMap()), cast_kinds: RefCell::new(NodeMap()), - }; - let result = f(&tcx); - (tcx.sess, result) + }, f) } // Type constructors From 1f70a2e370e2c0d69403ccadc6b55caee27a73c1 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 17 Jun 2015 00:33:36 +0300 Subject: [PATCH 40/48] rustc: allow "lifting" T<'a> to T<'tcx> if the value is part of ty::ctxt<'tcx>. --- src/librustc/middle/ty.rs | 122 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 84d874909aa38..2a0c224ad807a 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -802,6 +802,128 @@ impl<'tcx> ctxt<'tcx> { pub fn free_region_map(&self, id: NodeId) -> FreeRegionMap { self.free_region_maps.borrow()[&id].clone() } + + pub fn lift>(&self, value: &T) -> Option { + value.lift_to_tcx(self) + } +} + +/// A trait implemented for all X<'a> types which can be safely and +/// efficiently converted to X<'tcx> as long as they are part of the +/// provided ty::ctxt<'tcx>. +/// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx> +/// by looking them up in their respective interners. +pub trait Lift<'tcx> { + type Lifted; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option; +} + +impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) { + type Lifted = (A::Lifted, B::Lifted); + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option { + tcx.lift(&self.0).and_then(|a| tcx.lift(&self.1).map(|b| (a, b))) + } +} + +impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec { + type Lifted = Vec; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option { + let mut result = Vec::with_capacity(self.len()); + for x in self { + if let Some(value) = tcx.lift(x) { + result.push(value); + } else { + return None; + } + } + Some(result) + } +} + +impl<'tcx> Lift<'tcx> for Region { + type Lifted = Self; + fn lift_to_tcx(&self, _: &ctxt<'tcx>) -> Option { + Some(*self) + } +} + +impl<'a, 'tcx> Lift<'tcx> for Ty<'a> { + type Lifted = Ty<'tcx>; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option> { + if let Some(&ty) = tcx.interner.borrow().get(&self.sty) { + if *self as *const _ == ty as *const _ { + return Some(ty); + } + } + None + } +} + +impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { + type Lifted = &'tcx Substs<'tcx>; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option<&'tcx Substs<'tcx>> { + if let Some(&substs) = tcx.substs_interner.borrow().get(*self) { + if *self as *const _ == substs as *const _ { + return Some(substs); + } + } + None + } +} + +impl<'a, 'tcx> Lift<'tcx> for TraitRef<'a> { + type Lifted = TraitRef<'tcx>; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option> { + tcx.lift(&self.substs).map(|substs| TraitRef { + def_id: self.def_id, + substs: substs + }) + } +} + +impl<'a, 'tcx> Lift<'tcx> for TraitPredicate<'a> { + type Lifted = TraitPredicate<'tcx>; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option> { + tcx.lift(&self.trait_ref).map(|trait_ref| TraitPredicate { + trait_ref: trait_ref + }) + } +} + +impl<'a, 'tcx> Lift<'tcx> for EquatePredicate<'a> { + type Lifted = EquatePredicate<'tcx>; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option> { + tcx.lift(&(self.0, self.1)).map(|(a, b)| EquatePredicate(a, b)) + } +} + +impl<'tcx, A: Copy+Lift<'tcx>, B: Copy+Lift<'tcx>> Lift<'tcx> for OutlivesPredicate { + type Lifted = OutlivesPredicate; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option { + tcx.lift(&(self.0, self.1)).map(|(a, b)| OutlivesPredicate(a, b)) + } +} + +impl<'a, 'tcx> Lift<'tcx> for ProjectionPredicate<'a> { + type Lifted = ProjectionPredicate<'tcx>; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option> { + tcx.lift(&(self.projection_ty.trait_ref, self.ty)).map(|(trait_ref, ty)| { + ProjectionPredicate { + projection_ty: ProjectionTy { + trait_ref: trait_ref, + item_name: self.projection_ty.item_name + }, + ty: ty + } + }) + } +} + +impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Binder { + type Lifted = Binder; + fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option { + tcx.lift(&self.0).map(|x| Binder(x)) + } } pub mod tls { From a3727559c6eee465893f400ec4edad77be868f3c Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 17 Jun 2015 01:39:06 +0300 Subject: [PATCH 41/48] rustc: use the TLS type context in Repr and UserString. --- src/librustc/middle/astconv_util.rs | 2 +- src/librustc/middle/astencode.rs | 2 +- src/librustc/middle/check_const.rs | 2 +- src/librustc/middle/check_match.rs | 6 +- src/librustc/middle/check_rvalues.rs | 4 +- src/librustc/middle/const_eval.rs | 4 +- src/librustc/middle/effect.rs | 8 +- src/librustc/middle/expr_use_visitor.rs | 50 +- src/librustc/middle/free_region.rs | 8 +- src/librustc/middle/implicator.rs | 38 +- src/librustc/middle/infer/bivariate.rs | 2 +- src/librustc/middle/infer/combine.rs | 10 +- src/librustc/middle/infer/equate.rs | 6 +- src/librustc/middle/infer/error_reporting.rs | 24 +- src/librustc/middle/infer/glb.rs | 4 +- .../middle/infer/higher_ranked/mod.rs | 56 +- src/librustc/middle/infer/lattice.rs | 4 +- src/librustc/middle/infer/lub.rs | 4 +- src/librustc/middle/infer/mod.rs | 150 +-- .../middle/infer/region_inference/graphviz.rs | 4 +- .../middle/infer/region_inference/mod.rs | 134 +- src/librustc/middle/infer/resolve.rs | 2 +- src/librustc/middle/infer/sub.rs | 6 +- src/librustc/middle/intrinsicck.rs | 18 +- src/librustc/middle/mem_categorization.rs | 100 +- src/librustc/middle/stability.rs | 4 +- src/librustc/middle/subst.rs | 14 +- src/librustc/middle/traits/coherence.rs | 34 +- src/librustc/middle/traits/error_reporting.rs | 62 +- src/librustc/middle/traits/fulfill.rs | 26 +- src/librustc/middle/traits/mod.rs | 22 +- src/librustc/middle/traits/object_safety.rs | 12 +- src/librustc/middle/traits/project.rs | 86 +- src/librustc/middle/traits/select.rs | 194 +-- src/librustc/middle/traits/util.rs | 102 +- src/librustc/middle/ty.rs | 172 +-- src/librustc/middle/ty_fold.rs | 20 +- src/librustc/middle/ty_match.rs | 6 +- src/librustc/middle/ty_relate/mod.rs | 16 +- src/librustc/util/ppaux.rs | 1084 +++++++++-------- src/librustc_borrowck/borrowck/check_loans.rs | 28 +- src/librustc_borrowck/borrowck/fragments.rs | 14 +- .../borrowck/gather_loans/gather_moves.rs | 6 +- .../borrowck/gather_loans/lifetime.rs | 6 +- .../borrowck/gather_loans/mod.rs | 22 +- .../borrowck/gather_loans/move_error.rs | 4 +- .../borrowck/gather_loans/restrictions.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 56 +- src/librustc_borrowck/borrowck/move_data.rs | 12 +- src/librustc_driver/pretty.rs | 2 +- src/librustc_driver/test.rs | 38 +- src/librustc_lint/builtin.rs | 2 +- src/librustc_trans/back/link.rs | 2 +- src/librustc_trans/save/dump_csv.rs | 4 +- src/librustc_trans/save/mod.rs | 2 +- src/librustc_trans/trans/_match.rs | 26 +- src/librustc_trans/trans/adt.rs | 4 +- src/librustc_trans/trans/base.rs | 16 +- src/librustc_trans/trans/callee.rs | 34 +- src/librustc_trans/trans/cleanup.rs | 8 +- src/librustc_trans/trans/closure.rs | 8 +- src/librustc_trans/trans/common.rs | 40 +- src/librustc_trans/trans/consts.rs | 20 +- src/librustc_trans/trans/context.rs | 2 +- src/librustc_trans/trans/controlflow.rs | 4 +- src/librustc_trans/trans/datum.rs | 2 +- .../trans/debuginfo/metadata.rs | 12 +- .../trans/debuginfo/type_names.rs | 2 +- src/librustc_trans/trans/declare.rs | 8 +- src/librustc_trans/trans/expr.rs | 30 +- src/librustc_trans/trans/foreign.rs | 18 +- src/librustc_trans/trans/glue.rs | 8 +- src/librustc_trans/trans/intrinsic.rs | 12 +- src/librustc_trans/trans/meth.rs | 50 +- src/librustc_trans/trans/monomorphize.rs | 24 +- src/librustc_trans/trans/tvec.rs | 2 +- src/librustc_trans/trans/type_of.rs | 16 +- src/librustc_typeck/astconv.rs | 54 +- src/librustc_typeck/check/_match.rs | 6 +- src/librustc_typeck/check/assoc.rs | 8 +- src/librustc_typeck/check/callee.rs | 22 +- src/librustc_typeck/check/cast.rs | 6 +- src/librustc_typeck/check/closure.rs | 28 +- src/librustc_typeck/check/coercion.rs | 28 +- src/librustc_typeck/check/compare_method.rs | 42 +- src/librustc_typeck/check/demand.rs | 4 +- src/librustc_typeck/check/dropck.rs | 36 +- src/librustc_typeck/check/method/confirm.rs | 50 +- src/librustc_typeck/check/method/mod.rs | 26 +- src/librustc_typeck/check/method/probe.rs | 122 +- src/librustc_typeck/check/method/suggest.rs | 8 +- src/librustc_typeck/check/mod.rs | 114 +- src/librustc_typeck/check/op.rs | 28 +- src/librustc_typeck/check/regionck.rs | 108 +- src/librustc_typeck/check/upvar.rs | 18 +- src/librustc_typeck/check/wf.rs | 12 +- src/librustc_typeck/check/writeback.rs | 12 +- src/librustc_typeck/coherence/mod.rs | 34 +- src/librustc_typeck/coherence/orphan.rs | 14 +- src/librustc_typeck/coherence/overlap.rs | 10 +- src/librustc_typeck/coherence/unsafety.rs | 4 +- src/librustc_typeck/collect.rs | 50 +- src/librustc_typeck/lib.rs | 12 +- src/librustc_typeck/variance.rs | 20 +- 104 files changed, 1991 insertions(+), 1933 deletions(-) diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index 698cf105ae53c..d955cda9b77b7 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -63,7 +63,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty) let def = match tcx.def_map.borrow().get(&ast_ty.id) { None => { tcx.sess.span_bug(ast_ty.span, - &format!("unbound path {}", path.repr(tcx))) + &format!("unbound path {}", path.repr())) } Some(d) => d.full_def() }; diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 4aa73d871d162..a6386d941f5fe 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1624,7 +1624,7 @@ fn decode_side_tables(dcx: &DecodeContext, c::tag_table_node_type => { let ty = val_dsr.read_ty(dcx); debug!("inserting ty for node {}: {}", - id, ty.repr(dcx.tcx)); + id, ty.repr()); dcx.tcx.node_type_insert(id, ty); } c::tag_table_item_subst => { diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index d80eedf354a0e..9100f45a5de89 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -300,7 +300,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { fn visit_item(&mut self, i: &ast::Item) { - debug!("visit_item(item={})", i.repr(self.tcx)); + debug!("visit_item(item={})", i.repr()); match i.node { ast::ItemStatic(_, ast::MutImmutable, ref expr) => { self.check_static_type(&**expr); diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 11a1a1582c835..8982a45cee8f4 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -210,7 +210,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) { // We know the type is inhabited, so this must be wrong span_err!(cx.tcx.sess, ex.span, E0002, "non-exhaustive patterns: type {} is non-empty", - pat_ty.user_string(cx.tcx)); + pat_ty.user_string()); } // If the type *is* empty, it's vacuously exhaustive return; @@ -243,11 +243,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat) span_warn!(cx.tcx.sess, p.span, E0170, "pattern binding `{}` is named the same as one \ of the variants of the type `{}`", - &token::get_ident(ident.node), pat_ty.user_string(cx.tcx)); + &token::get_ident(ident.node), pat_ty.user_string()); fileline_help!(cx.tcx.sess, p.span, "if you meant to match on a variant, \ consider making the path in the pattern qualified: `{}::{}`", - pat_ty.user_string(cx.tcx), &token::get_ident(ident.node)); + pat_ty.user_string(), &token::get_ident(ident.node)); } } } diff --git a/src/librustc/middle/check_rvalues.rs b/src/librustc/middle/check_rvalues.rs index bd3829cc395e9..a3881327b96ad 100644 --- a/src/librustc/middle/check_rvalues.rs +++ b/src/librustc/middle/check_rvalues.rs @@ -59,11 +59,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> { span: Span, cmt: mc::cmt<'tcx>, _: euv::ConsumeMode) { - debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr(self.tcx)); + debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr()); if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) { span_err!(self.tcx.sess, span, E0161, "cannot move a value of type {0}: the size of {0} cannot be statically determined", - cmt.ty.user_string(self.tcx)); + cmt.ty.user_string()); } } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index f64765f909028..657115e781925 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -1031,7 +1031,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, Vec::new())); let trait_substs = tcx.mk_substs(trait_substs); debug!("resolve_trait_associated_const: trait_substs={}", - trait_substs.repr(tcx)); + trait_substs.repr()); let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id, substs: trait_substs }); @@ -1055,7 +1055,7 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, &format!("Encountered error `{}` when trying \ to select an implementation for \ constant trait item reference.", - e.repr(tcx))) + e.repr())) } }; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index c1a33c3387cde..7a593da3432c9 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -67,7 +67,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> { _ => return }; debug!("effect: checking index with base type {}", - base_type.repr(self.tcx)); + base_type.repr()); match base_type.sty { ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty { span_err!(self.tcx.sess, e.span, E0134, @@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { let method_call = MethodCall::expr(expr.id); let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty; debug!("effect: method call case, base type is {}", - base_type.repr(self.tcx)); + base_type.repr()); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "invocation of unsafe method") @@ -152,7 +152,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { ast::ExprCall(ref base, _) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: call case, base type is {}", - base_type.repr(self.tcx)); + base_type.repr()); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "call to unsafe function") } @@ -160,7 +160,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { ast::ExprUnary(ast::UnDeref, ref base) => { let base_type = ty::node_id_to_type(self.tcx, base.id); debug!("effect: unary case, base type is {}", - base_type.repr(self.tcx)); + base_type.repr()); if let ty::TyRawPtr(_) = base_type.sty { self.require_unsafe(expr.span, "dereference of raw pointer") } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 3c9a4def5c856..7d4f93fb1326f 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -363,7 +363,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { consume_span: Span, cmt: mc::cmt<'tcx>) { debug!("delegate_consume(consume_id={}, cmt={})", - consume_id, cmt.repr(self.tcx())); + consume_id, cmt.repr()); let mode = copy_or_move(self.typer, &cmt, DirectRefMove); self.delegate.consume(consume_id, consume_span, cmt, mode); @@ -376,7 +376,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } pub fn consume_expr(&mut self, expr: &ast::Expr) { - debug!("consume_expr(expr={})", expr.repr(self.tcx())); + debug!("consume_expr(expr={})", expr.repr()); let cmt = return_if_err!(self.mc.cat_expr(expr)); self.delegate_consume(expr.id, expr.span, cmt); @@ -398,7 +398,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { bk: ty::BorrowKind, cause: LoanCause) { debug!("borrow_expr(expr={}, r={}, bk={})", - expr.repr(self.tcx()), r.repr(self.tcx()), bk.repr(self.tcx())); + expr.repr(), r.repr(), bk.repr()); let cmt = return_if_err!(self.mc.cat_expr(expr)); self.delegate.borrow(expr.id, expr.span, cmt, r, bk, cause); @@ -414,7 +414,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } pub fn walk_expr(&mut self, expr: &ast::Expr) { - debug!("walk_expr(expr={})", expr.repr(self.tcx())); + debug!("walk_expr(expr={})", expr.repr()); self.walk_adjustment(expr); @@ -619,7 +619,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) { let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee)); debug!("walk_callee: callee={} callee_ty={}", - callee.repr(self.tcx()), callee_ty.repr(self.tcx())); + callee.repr(), callee_ty.repr()); let call_scope = region::CodeExtent::from_node_id(call.id); match callee_ty.sty { ty::TyBareFn(..) => { @@ -637,7 +637,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { None => { self.tcx().sess.span_bug( callee.span, - &format!("unexpected callee type {}", callee_ty.repr(self.tcx()))) + &format!("unexpected callee type {}", callee_ty.repr())) } }; match overloaded_call_type { @@ -811,7 +811,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { fn walk_autoderefs(&mut self, expr: &ast::Expr, autoderefs: usize) { - debug!("walk_autoderefs expr={} autoderefs={}", expr.repr(self.tcx()), autoderefs); + debug!("walk_autoderefs expr={} autoderefs={}", expr.repr(), autoderefs); for i in 0..autoderefs { let deref_id = ty::MethodCall::autoderef(expr.id, i as u32); @@ -829,7 +829,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { ty::TyRef(r, ref m) => (m.mutbl, r), _ => self.tcx().sess.span_bug(expr.span, &format!("bad overloaded deref type {}", - method_ty.repr(self.tcx()))) + method_ty.repr())) }; let bk = ty::BorrowKind::from_mutbl(m); self.delegate.borrow(expr.id, expr.span, cmt, @@ -843,8 +843,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { expr: &ast::Expr, adj: &ty::AutoDerefRef<'tcx>) { debug!("walk_autoderefref expr={} adj={}", - expr.repr(self.tcx()), - adj.repr(self.tcx())); + expr.repr(), + adj.repr()); self.walk_autoderefs(expr, adj.autoderefs); @@ -877,7 +877,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { { debug!("walk_autoref(expr.id={} cmt_derefd={} opt_autoref={:?})", expr.id, - cmt_base.repr(self.tcx()), + cmt_base.repr(), opt_autoref); let cmt_base_ty = cmt_base.ty; @@ -903,7 +903,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { ty::AutoUnsafe(m) => { debug!("walk_autoref: expr.id={} cmt_base={}", expr.id, - cmt_base.repr(self.tcx())); + cmt_base.repr()); // Converting from a &T to *T (or &mut T to *mut T) is // treated as borrowing it for the enclosing temporary @@ -1011,8 +1011,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { cmt_discr: mc::cmt<'tcx>, pat: &ast::Pat, mode: &mut TrackMatchMode) { - debug!("determine_pat_move_mode cmt_discr={} pat={}", cmt_discr.repr(self.tcx()), - pat.repr(self.tcx())); + debug!("determine_pat_move_mode cmt_discr={} pat={}", cmt_discr.repr(), + pat.repr()); return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| { let tcx = self.tcx(); let def_map = &self.tcx().def_map; @@ -1043,8 +1043,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { cmt_discr: mc::cmt<'tcx>, pat: &ast::Pat, match_mode: MatchMode) { - debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(self.tcx()), - pat.repr(self.tcx())); + debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(), + pat.repr()); let mc = &self.mc; let typer = self.typer; @@ -1055,8 +1055,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { let tcx = typer.tcx(); debug!("binding cmt_pat={} pat={} match_mode={:?}", - cmt_pat.repr(tcx), - pat.repr(tcx), + cmt_pat.repr(), + pat.repr(), match_mode); // pat_ty: the type of the binding being produced. @@ -1161,8 +1161,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { }; debug!("variant downcast_cmt={} pat={}", - downcast_cmt.repr(tcx), - pat.repr(tcx)); + downcast_cmt.repr(), + pat.repr()); delegate.matched_pat(pat, downcast_cmt, match_mode); } @@ -1173,8 +1173,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { // e.g. patterns for unit structs). debug!("struct cmt_pat={} pat={}", - cmt_pat.repr(tcx), - pat.repr(tcx)); + cmt_pat.repr(), + pat.repr()); delegate.matched_pat(pat, cmt_pat, match_mode); } @@ -1194,7 +1194,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { if !tcx.sess.has_errors() { let msg = format!("Pattern has unexpected type: {:?} and type {}", def, - cmt_pat.ty.repr(tcx)); + cmt_pat.ty.repr()); tcx.sess.span_bug(pat.span, &msg) } } @@ -1211,7 +1211,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { if !tcx.sess.has_errors() { let msg = format!("Pattern has unexpected def: {:?} and type {}", def, - cmt_pat.ty.repr(tcx)); + cmt_pat.ty.repr()); tcx.sess.span_bug(pat.span, &msg[..]) } } @@ -1237,7 +1237,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } fn walk_captures(&mut self, closure_expr: &ast::Expr) { - debug!("walk_captures({})", closure_expr.repr(self.tcx())); + debug!("walk_captures({})", closure_expr.repr()); ty::with_freevars(self.tcx(), closure_expr.id, |freevars| { for freevar in freevars { diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index 0c8a956f686a2..a245de3deae38 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -33,7 +33,7 @@ impl FreeRegionMap { implications: &[Implication<'tcx>]) { for implication in implications { - debug!("implication: {}", implication.repr(tcx)); + debug!("implication: {}", implication.repr()); match *implication { Implication::RegionSubRegion(_, ty::ReFree(free_a), ty::ReFree(free_b)) => { self.relate_free_regions(free_a, free_b); @@ -50,7 +50,7 @@ impl FreeRegionMap { pub fn relate_free_regions_from_predicates<'tcx>(&mut self, tcx: &ty::ctxt<'tcx>, predicates: &[ty::Predicate<'tcx>]) { - debug!("relate_free_regions_from_predicates(predicates={})", predicates.repr(tcx)); + debug!("relate_free_regions_from_predicates(predicates={})", predicates.repr()); for predicate in predicates { match *predicate { ty::Predicate::Projection(..) | @@ -69,8 +69,8 @@ impl FreeRegionMap { // All named regions are instantiated with free regions. tcx.sess.bug( &format!("record_region_bounds: non free region: {} / {}", - r_a.repr(tcx), - r_b.repr(tcx))); + r_a.repr(), + r_b.repr())); } } } diff --git a/src/librustc/middle/implicator.rs b/src/librustc/middle/implicator.rs index fc9636ae3665f..599ecc6e7a97a 100644 --- a/src/librustc/middle/implicator.rs +++ b/src/librustc/middle/implicator.rs @@ -55,8 +55,8 @@ pub fn implications<'a,'tcx>( { debug!("implications(body_id={}, ty={}, outer_region={})", body_id, - ty.repr(closure_typer.tcx()), - outer_region.repr(closure_typer.tcx())); + ty.repr(), + outer_region.repr()); let mut stack = Vec::new(); stack.push((outer_region, None)); @@ -68,7 +68,7 @@ pub fn implications<'a,'tcx>( out: Vec::new(), visited: FnvHashSet() }; wf.accumulate_from_ty(ty); - debug!("implications: out={}", wf.out.repr(closure_typer.tcx())); + debug!("implications: out={}", wf.out.repr()); wf.out } @@ -79,7 +79,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) { debug!("accumulate_from_ty(ty={})", - ty.repr(self.tcx())); + ty.repr()); // When expanding out associated types, we can visit a cyclic // set of types. Issue #23003. @@ -313,7 +313,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { data: &ty::PolyTraitPredicate<'tcx>) { debug!("accumulate_from_assoc_types_transitive({})", - data.repr(self.tcx())); + data.repr()); for poly_trait_ref in traits::supertraits(self.tcx(), data.to_poly_trait_ref()) { match ty::no_late_bound_regions(self.tcx(), &poly_trait_ref) { @@ -327,7 +327,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { trait_ref: ty::TraitRef<'tcx>) { debug!("accumulate_from_assoc_types({})", - trait_ref.repr(self.tcx())); + trait_ref.repr()); let trait_def_id = trait_ref.def_id; let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id); @@ -337,7 +337,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { .map(|&name| ty::mk_projection(self.tcx(), trait_ref.clone(), name)) .collect(); debug!("accumulate_from_assoc_types: assoc_type_projections={}", - assoc_type_projections.repr(self.tcx())); + assoc_type_projections.repr()); let tys = match self.fully_normalize(&assoc_type_projections) { Ok(tys) => { tys } Err(ErrorReported) => { return; } @@ -400,7 +400,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { } fn fully_normalize(&self, value: &T) -> Result - where T : TypeFoldable<'tcx> + ty::HasProjectionTypes + Clone + Repr<'tcx> + where T : TypeFoldable<'tcx> + ty::HasProjectionTypes + Clone + Repr { let value = traits::fully_normalize(self.infcx, @@ -455,32 +455,32 @@ pub fn object_region_bounds<'tcx>( ty::required_region_bounds(tcx, open_ty, predicates) } -impl<'tcx> Repr<'tcx> for Implication<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for Implication<'tcx> { + fn repr(&self) -> String { match *self { Implication::RegionSubRegion(_, ref r_a, ref r_b) => { format!("RegionSubRegion({}, {})", - r_a.repr(tcx), - r_b.repr(tcx)) + r_a.repr(), + r_b.repr()) } Implication::RegionSubGeneric(_, ref r, ref p) => { format!("RegionSubGeneric({}, {})", - r.repr(tcx), - p.repr(tcx)) + r.repr(), + p.repr()) } Implication::RegionSubClosure(_, ref a, ref b, ref c) => { format!("RegionSubClosure({}, {}, {})", - a.repr(tcx), - b.repr(tcx), - c.repr(tcx)) + a.repr(), + b.repr(), + c.repr()) } Implication::Predicate(ref def_id, ref p) => { format!("Predicate({}, {})", - def_id.repr(tcx), - p.repr(tcx)) + def_id.repr(), + p.repr()) } } } diff --git a/src/librustc/middle/infer/bivariate.rs b/src/librustc/middle/infer/bivariate.rs index 1ab01453c0f1a..87eb08955117f 100644 --- a/src/librustc/middle/infer/bivariate.rs +++ b/src/librustc/middle/infer/bivariate.rs @@ -74,7 +74,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> { fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { debug!("{}.tys({}, {})", self.tag(), - a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx)); + a.repr(), b.repr()); if a == b { return Ok(a); } let infcx = self.fields.infcx; diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 864e9ed0b978f..decd07b87c07a 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -214,9 +214,9 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> { }; debug!("instantiate(a_ty={} dir={:?} b_vid={})", - a_ty.repr(tcx), + a_ty.repr(), dir, - b_vid.repr(tcx)); + b_vid.repr()); // Check whether `vid` has been instantiated yet. If not, // make a generalized form of `ty` and instantiate with @@ -232,8 +232,8 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> { }); debug!("instantiate(a_ty={}, dir={:?}, \ b_vid={}, generalized_ty={})", - a_ty.repr(tcx), dir, b_vid.repr(tcx), - generalized_ty.repr(tcx)); + a_ty.repr(), dir, b_vid.repr(), + generalized_ty.repr()); self.infcx.type_variables .borrow_mut() .instantiate_and_push( @@ -336,7 +336,7 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> { self.tcx().sess.span_bug( self.span, &format!("Encountered early bound region when generalizing: {}", - r.repr(self.tcx()))); + r.repr())); } // Always make a fresh region variable for skolemized regions; diff --git a/src/librustc/middle/infer/equate.rs b/src/librustc/middle/infer/equate.rs index da0bca8904223..0d97535ed3abe 100644 --- a/src/librustc/middle/infer/equate.rs +++ b/src/librustc/middle/infer/equate.rs @@ -46,7 +46,7 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> { fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { debug!("{}.tys({}, {})", self.tag(), - a.repr(self.fields.infcx.tcx), b.repr(self.fields.infcx.tcx)); + a.repr(), b.repr()); if a == b { return Ok(a); } let infcx = self.fields.infcx; @@ -77,8 +77,8 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> { fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { debug!("{}.regions({}, {})", self.tag(), - a.repr(self.fields.infcx.tcx), - b.repr(self.fields.infcx.tcx)); + a.repr(), + b.repr()); let origin = Subtype(self.fields.trace.clone()); self.fields.infcx.region_vars.make_eqregion(origin, a, b); Ok(a) diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 515e8b82a78f9..fa324c57bcd06 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -170,7 +170,7 @@ pub fn note_and_explain_region(tcx: &ty::ctxt, ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(), _ => { format!("the lifetime {} as defined on", - fr.bound_region.user_string(tcx)) + fr.bound_region.user_string()) } }; @@ -229,7 +229,7 @@ pub trait ErrorReporting<'tcx> { fn values_str(&self, values: &ValuePairs<'tcx>) -> Option; - fn expected_found_str + Resolvable<'tcx>>( + fn expected_found_str>( &self, exp_found: &ty::expected_found) -> Option; @@ -507,7 +507,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { } } - fn expected_found_str + Resolvable<'tcx>>( + fn expected_found_str>( &self, exp_found: &ty::expected_found) -> Option @@ -523,8 +523,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { } Some(format!("expected `{}`, found `{}`", - expected.user_string(self.tcx), - found.user_string(self.tcx))) + expected.user_string(), + found.user_string())) } fn report_generic_bound_failure(&self, @@ -540,9 +540,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { let labeled_user_string = match bound_kind { GenericKind::Param(ref p) => - format!("the parameter type `{}`", p.user_string(self.tcx)), + format!("the parameter type `{}`", p.user_string()), GenericKind::Projection(ref p) => - format!("the associated type `{}`", p.user_string(self.tcx)), + format!("the associated type `{}`", p.user_string()), }; match sub { @@ -554,8 +554,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { origin.span(), &format!( "consider adding an explicit lifetime bound `{}: {}`...", - bound_kind.user_string(self.tcx), - sub.user_string(self.tcx))); + bound_kind.user_string(), + sub.user_string())); } ty::ReStatic => { @@ -566,7 +566,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { origin.span(), &format!( "consider adding an explicit lifetime bound `{}: 'static`...", - bound_kind.user_string(self.tcx))); + bound_kind.user_string())); } _ => { @@ -578,7 +578,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { origin.span(), &format!( "consider adding an explicit lifetime bound for `{}`", - bound_kind.user_string(self.tcx))); + bound_kind.user_string())); note_and_explain_region( self.tcx, &format!("{} must be valid for ", labeled_user_string), @@ -1561,7 +1561,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> { fn report_inference_failure(&self, var_origin: RegionVariableOrigin) { let br_string = |br: ty::BoundRegion| { - let mut s = br.user_string(self.tcx); + let mut s = br.user_string(); if !s.is_empty() { s.push_str(" "); } diff --git a/src/librustc/middle/infer/glb.rs b/src/librustc/middle/infer/glb.rs index 5822fb0f2d432..b611565c151ca 100644 --- a/src/librustc/middle/infer/glb.rs +++ b/src/librustc/middle/infer/glb.rs @@ -57,8 +57,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> { fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { debug!("{}.regions({}, {})", self.tag(), - a.repr(self.fields.infcx.tcx), - b.repr(self.fields.infcx.tcx)); + a.repr(), + b.repr()); let origin = Subtype(self.fields.trace.clone()); Ok(self.fields.infcx.region_vars.glb_regions(origin, a, b)) diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index 3d946aa2fbc8b..d38de0f5a3f65 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -49,7 +49,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { let tcx = self.infcx.tcx; debug!("higher_ranked_sub(a={}, b={})", - a.repr(tcx), b.repr(tcx)); + a.repr(), b.repr()); // Rather than checking the subtype relationship between `a` and `b` // as-is, we need to do some extra work here in order to make sure @@ -75,8 +75,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { let (b_prime, skol_map) = self.infcx.skolemize_late_bound_regions(b, snapshot); - debug!("a_prime={}", a_prime.repr(tcx)); - debug!("b_prime={}", b_prime.repr(tcx)); + debug!("a_prime={}", a_prime.repr()); + debug!("b_prime={}", b_prime.repr()); // Compare types now that bound regions have been replaced. let result = try!(self.sub().relate(&a_prime, &b_prime)); @@ -99,7 +99,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { } debug!("higher_ranked_sub: OK result={}", - result.repr(tcx)); + result.repr()); Ok(ty::Binder(result)) }); @@ -125,7 +125,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { try!(self.lub().relate(&a_with_fresh, &b_with_fresh)); let result0 = self.infcx.resolve_type_vars_if_possible(&result0); - debug!("lub result0 = {}", result0.repr(self.tcx())); + debug!("lub result0 = {}", result0.repr()); // Generalize the regions appearing in result0 if possible let new_vars = self.infcx.region_vars_confined_to_snapshot(snapshot); @@ -138,9 +138,9 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { &new_vars, &a_map, r)); debug!("lub({},{}) = {}", - a.repr(self.tcx()), - b.repr(self.tcx()), - result1.repr(self.tcx())); + a.repr(), + b.repr(), + result1.repr()); Ok(ty::Binder(result1)) }); @@ -199,7 +199,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { where T: Relate<'a,'tcx> { debug!("higher_ranked_glb({}, {})", - a.repr(self.tcx()), b.repr(self.tcx())); + a.repr(), b.repr()); // Make a snapshot so we can examine "all bindings that were // created as part of this type comparison". @@ -219,7 +219,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { try!(self.glb().relate(&a_with_fresh, &b_with_fresh)); let result0 = self.infcx.resolve_type_vars_if_possible(&result0); - debug!("glb result0 = {}", result0.repr(self.tcx())); + debug!("glb result0 = {}", result0.repr()); // Generalize the regions appearing in result0 if possible let new_vars = self.infcx.region_vars_confined_to_snapshot(snapshot); @@ -234,9 +234,9 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { r)); debug!("glb({},{}) = {}", - a.repr(self.tcx()), - b.repr(self.tcx()), - result1.repr(self.tcx())); + a.repr(), + b.repr(), + result1.repr()); Ok(ty::Binder(result1)) }); @@ -452,8 +452,8 @@ impl<'a,'tcx> InferCtxtExt for InferCtxt<'a,'tcx> { }); debug!("region_vars_confined_to_snapshot: region_vars={} escaping_types={}", - region_vars.repr(self.tcx), - escaping_types.repr(self.tcx)); + region_vars.repr(), + escaping_types.repr()); region_vars } @@ -520,7 +520,7 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, binder: &ty::Binder, snapshot: &CombinedSnapshot) -> (T, SkolemizationMap) - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { /*! * Replace all regions bound by `binder` with skolemized regions and @@ -535,9 +535,9 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, }); debug!("skolemize_bound_regions(binder={}, result={}, map={})", - binder.repr(infcx.tcx), - result.repr(infcx.tcx), - map.repr(infcx.tcx)); + binder.repr(), + result.repr(), + map.repr()); (result, map) } @@ -556,7 +556,7 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, */ debug!("leak_check: skol_map={}", - skol_map.repr(infcx.tcx)); + skol_map.repr()); let new_vars = infcx.region_vars_confined_to_snapshot(snapshot); for (&skol_br, &skol) in skol_map { @@ -574,9 +574,9 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, }; debug!("{} (which replaced {}) is tainted by {}", - skol.repr(infcx.tcx), - skol_br.repr(infcx.tcx), - tainted_region.repr(infcx.tcx)); + skol.repr(), + skol_br.repr(), + tainted_region.repr()); // A is not as polymorphic as B: return Err((skol_br, tainted_region)); @@ -618,13 +618,13 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, snapshot: &CombinedSnapshot, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok()); debug!("plug_leaks(skol_map={}, value={})", - skol_map.repr(infcx.tcx), - value.repr(infcx.tcx)); + skol_map.repr(), + value.repr()); // Compute a mapping from the "taint set" of each skolemized // region back to the `ty::BoundRegion` that it originally @@ -641,7 +641,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, .collect(); debug!("plug_leaks: inv_skol_map={}", - inv_skol_map.repr(infcx.tcx)); + inv_skol_map.repr()); // Remove any instantiated type variables from `value`; those can hide // references to regions from the `fold_regions` code below. @@ -670,7 +670,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, }); debug!("plug_leaks: result={}", - result.repr(infcx.tcx)); + result.repr()); result } diff --git a/src/librustc/middle/infer/lattice.rs b/src/librustc/middle/infer/lattice.rs index d634b8231ebb3..6257b6e6a2579 100644 --- a/src/librustc/middle/infer/lattice.rs +++ b/src/librustc/middle/infer/lattice.rs @@ -53,8 +53,8 @@ pub fn super_lattice_tys<'a,'tcx,L:LatticeDir<'a,'tcx>>(this: &mut L, { debug!("{}.lattice_tys({}, {})", this.tag(), - a.repr(this.tcx()), - b.repr(this.tcx())); + a.repr(), + b.repr()); if a == b { return Ok(a); diff --git a/src/librustc/middle/infer/lub.rs b/src/librustc/middle/infer/lub.rs index f456687be13ac..f4ba639547bf1 100644 --- a/src/librustc/middle/infer/lub.rs +++ b/src/librustc/middle/infer/lub.rs @@ -57,8 +57,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> { fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { debug!("{}.regions({}, {})", self.tag(), - a.repr(self.tcx()), - b.repr(self.tcx())); + a.repr(), + b.repr()); let origin = Subtype(self.fields.trace.clone()); Ok(self.fields.infcx.region_vars.lub_regions(origin, a, b)) diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index aef2712105874..02a73cfb77052 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -331,7 +331,7 @@ pub fn common_supertype<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, -> Ty<'tcx> { debug!("common_supertype({}, {})", - a.repr(cx.tcx), b.repr(cx.tcx)); + a.repr(), b.repr()); let trace = TypeTrace { origin: origin, @@ -355,7 +355,7 @@ pub fn mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx)); + debug!("mk_subty({} <: {})", a.repr(), b.repr()); cx.sub_types(a_is_expected, origin, a, b) } @@ -363,7 +363,7 @@ pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("can_mk_subty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx)); + debug!("can_mk_subty({} <: {})", a.repr(), b.repr()); cx.probe(|_| { let trace = TypeTrace { origin: Misc(codemap::DUMMY_SP), @@ -383,7 +383,7 @@ pub fn mk_subr<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, origin: SubregionOrigin<'tcx>, a: ty::Region, b: ty::Region) { - debug!("mk_subr({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx)); + debug!("mk_subr({} <: {})", a.repr(), b.repr()); let snapshot = cx.region_vars.start_snapshot(); cx.region_vars.make_subregion(origin, a, b); cx.region_vars.commit(snapshot); @@ -396,7 +396,7 @@ pub fn mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("mk_eqty({} <: {})", a.repr(cx.tcx), b.repr(cx.tcx)); + debug!("mk_eqty({} <: {})", a.repr(), b.repr()); cx.commit_if_ok(|_| cx.eq_types(a_is_expected, origin, a, b)) } @@ -408,7 +408,7 @@ pub fn mk_sub_poly_trait_refs<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, -> UnitResult<'tcx> { debug!("mk_sub_trait_refs({} <: {})", - a.repr(cx.tcx), b.repr(cx.tcx)); + a.repr(), b.repr()); cx.commit_if_ok(|_| cx.sub_poly_trait_refs(a_is_expected, origin, a.clone(), b.clone())) } @@ -637,7 +637,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("sub_types({} <: {})", a.repr(self.tcx), b.repr(self.tcx)); + debug!("sub_types({} <: {})", a.repr(), b.repr()); self.commit_if_ok(|_| { let trace = TypeTrace::types(origin, a_is_expected, a, b); self.sub(a_is_expected, trace).relate(&a, &b).map(|_| ()) @@ -665,8 +665,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { -> UnitResult<'tcx> { debug!("sub_trait_refs({} <: {})", - a.repr(self.tcx), - b.repr(self.tcx)); + a.repr(), + b.repr()); self.commit_if_ok(|_| { let trace = TypeTrace { origin: origin, @@ -684,8 +684,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { -> UnitResult<'tcx> { debug!("sub_poly_trait_refs({} <: {})", - a.repr(self.tcx), - b.repr(self.tcx)); + a.repr(), + b.repr()); self.commit_if_ok(|_| { let trace = TypeTrace { origin: origin, @@ -708,7 +708,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { value: &ty::Binder, snapshot: &CombinedSnapshot) -> (T, SkolemizationMap) - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { /*! See `higher_ranked::skolemize_late_bound_regions` */ @@ -733,7 +733,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { snapshot: &CombinedSnapshot, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { /*! See `higher_ranked::plug_leaks` */ @@ -861,7 +861,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } pub fn ty_to_string(&self, t: Ty<'tcx>) -> String { - self.resolve_type_vars_if_possible(&t).user_string(self.tcx) + self.resolve_type_vars_if_possible(&t).user_string() } pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String { @@ -871,7 +871,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { pub fn trait_ref_to_string(&self, t: &ty::TraitRef<'tcx>) -> String { let t = self.resolve_type_vars_if_possible(t); - t.user_string(self.tcx) + t.user_string() } pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> { @@ -1033,7 +1033,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { lbrct: LateBoundRegionConversionTime, value: &ty::Binder) -> (T, FnvHashMap) - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { ty_fold::replace_late_bound_regions( self.tcx, @@ -1048,17 +1048,17 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { a: ty::Region, bs: Vec) { debug!("verify_generic_bound({}, {} <: {})", - kind.repr(self.tcx), - a.repr(self.tcx), - bs.repr(self.tcx)); + kind.repr(), + a.repr(), + bs.repr()); self.region_vars.verify_generic_bound(origin, kind, a, bs); } pub fn can_equate<'b,T>(&'b self, a: &T, b: &T) -> UnitResult<'tcx> - where T: Relate<'b,'tcx> + Repr<'tcx> + where T: Relate<'b,'tcx> + Repr { - debug!("can_equate({}, {})", a.repr(self.tcx), b.repr(self.tcx)); + debug!("can_equate({}, {})", a.repr(), b.repr()); self.probe(|_| { // Gin up a dummy trace, since this won't be committed // anyhow. We should make this typetrace stuff more @@ -1099,9 +1099,9 @@ impl<'tcx> TypeTrace<'tcx> { } } -impl<'tcx> Repr<'tcx> for TypeTrace<'tcx> { - fn repr(&self, tcx: &ty::ctxt) -> String { - format!("TypeTrace({})", self.origin.repr(tcx)) +impl<'tcx> Repr for TypeTrace<'tcx> { + fn repr(&self) -> String { + format!("TypeTrace({})", self.origin.repr()) } } @@ -1123,39 +1123,39 @@ impl TypeOrigin { } } -impl<'tcx> Repr<'tcx> for TypeOrigin { - fn repr(&self, tcx: &ty::ctxt) -> String { +impl<'tcx> Repr for TypeOrigin { + fn repr(&self) -> String { match *self { MethodCompatCheck(a) => { - format!("MethodCompatCheck({})", a.repr(tcx)) + format!("MethodCompatCheck({})", a.repr()) } ExprAssignable(a) => { - format!("ExprAssignable({})", a.repr(tcx)) + format!("ExprAssignable({})", a.repr()) } - Misc(a) => format!("Misc({})", a.repr(tcx)), + Misc(a) => format!("Misc({})", a.repr()), RelateTraitRefs(a) => { - format!("RelateTraitRefs({})", a.repr(tcx)) + format!("RelateTraitRefs({})", a.repr()) } RelateSelfType(a) => { - format!("RelateSelfType({})", a.repr(tcx)) + format!("RelateSelfType({})", a.repr()) } RelateOutputImplTypes(a) => { - format!("RelateOutputImplTypes({})", a.repr(tcx)) + format!("RelateOutputImplTypes({})", a.repr()) } MatchExpressionArm(a, b) => { - format!("MatchExpressionArm({}, {})", a.repr(tcx), b.repr(tcx)) + format!("MatchExpressionArm({}, {})", a.repr(), b.repr()) } IfExpression(a) => { - format!("IfExpression({})", a.repr(tcx)) + format!("IfExpression({})", a.repr()) } IfExpressionWithNoElse(a) => { - format!("IfExpressionWithNoElse({})", a.repr(tcx)) + format!("IfExpressionWithNoElse({})", a.repr()) } RangeExpression(a) => { - format!("RangeExpression({})", a.repr(tcx)) + format!("RangeExpression({})", a.repr()) } EquatePredicate(a) => { - format!("EquatePredicate({})", a.repr(tcx)) + format!("EquatePredicate({})", a.repr()) } } } @@ -1190,66 +1190,66 @@ impl<'tcx> SubregionOrigin<'tcx> { } } -impl<'tcx> Repr<'tcx> for SubregionOrigin<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for SubregionOrigin<'tcx> { + fn repr(&self) -> String { match *self { Subtype(ref a) => { - format!("Subtype({})", a.repr(tcx)) + format!("Subtype({})", a.repr()) } InfStackClosure(a) => { - format!("InfStackClosure({})", a.repr(tcx)) + format!("InfStackClosure({})", a.repr()) } InvokeClosure(a) => { - format!("InvokeClosure({})", a.repr(tcx)) + format!("InvokeClosure({})", a.repr()) } DerefPointer(a) => { - format!("DerefPointer({})", a.repr(tcx)) + format!("DerefPointer({})", a.repr()) } FreeVariable(a, b) => { - format!("FreeVariable({}, {})", a.repr(tcx), b) + format!("FreeVariable({}, {})", a.repr(), b) } IndexSlice(a) => { - format!("IndexSlice({})", a.repr(tcx)) + format!("IndexSlice({})", a.repr()) } RelateObjectBound(a) => { - format!("RelateObjectBound({})", a.repr(tcx)) + format!("RelateObjectBound({})", a.repr()) } RelateParamBound(a, b) => { format!("RelateParamBound({},{})", - a.repr(tcx), - b.repr(tcx)) + a.repr(), + b.repr()) } RelateRegionParamBound(a) => { format!("RelateRegionParamBound({})", - a.repr(tcx)) + a.repr()) } RelateDefaultParamBound(a, b) => { format!("RelateDefaultParamBound({},{})", - a.repr(tcx), - b.repr(tcx)) + a.repr(), + b.repr()) } - Reborrow(a) => format!("Reborrow({})", a.repr(tcx)), + Reborrow(a) => format!("Reborrow({})", a.repr()), ReborrowUpvar(a, b) => { - format!("ReborrowUpvar({},{:?})", a.repr(tcx), b) + format!("ReborrowUpvar({},{:?})", a.repr(), b) } ReferenceOutlivesReferent(_, a) => { - format!("ReferenceOutlivesReferent({})", a.repr(tcx)) + format!("ReferenceOutlivesReferent({})", a.repr()) } ExprTypeIsNotInScope(a, b) => { format!("ExprTypeIsNotInScope({}, {})", - a.repr(tcx), - b.repr(tcx)) + a.repr(), + b.repr()) } BindingTypeIsNotValidAtDecl(a) => { - format!("BindingTypeIsNotValidAtDecl({})", a.repr(tcx)) + format!("BindingTypeIsNotValidAtDecl({})", a.repr()) } - CallRcvr(a) => format!("CallRcvr({})", a.repr(tcx)), - CallArg(a) => format!("CallArg({})", a.repr(tcx)), - CallReturn(a) => format!("CallReturn({})", a.repr(tcx)), - Operand(a) => format!("Operand({})", a.repr(tcx)), - AddrOf(a) => format!("AddrOf({})", a.repr(tcx)), - AutoBorrow(a) => format!("AutoBorrow({})", a.repr(tcx)), - SafeDestructor(a) => format!("SafeDestructor({})", a.repr(tcx)), + CallRcvr(a) => format!("CallRcvr({})", a.repr()), + CallArg(a) => format!("CallArg({})", a.repr()), + CallReturn(a) => format!("CallReturn({})", a.repr()), + Operand(a) => format!("Operand({})", a.repr()), + AddrOf(a) => format!("AddrOf({})", a.repr()), + AutoBorrow(a) => format!("AutoBorrow({})", a.repr()), + SafeDestructor(a) => format!("SafeDestructor({})", a.repr()), } } } @@ -1270,31 +1270,31 @@ impl RegionVariableOrigin { } } -impl<'tcx> Repr<'tcx> for RegionVariableOrigin { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for RegionVariableOrigin { + fn repr(&self) -> String { match *self { MiscVariable(a) => { - format!("MiscVariable({})", a.repr(tcx)) + format!("MiscVariable({})", a.repr()) } PatternRegion(a) => { - format!("PatternRegion({})", a.repr(tcx)) + format!("PatternRegion({})", a.repr()) } AddrOfRegion(a) => { - format!("AddrOfRegion({})", a.repr(tcx)) + format!("AddrOfRegion({})", a.repr()) } - Autoref(a) => format!("Autoref({})", a.repr(tcx)), - Coercion(a) => format!("Coercion({})", a.repr(tcx)), + Autoref(a) => format!("Autoref({})", a.repr()), + Coercion(a) => format!("Coercion({})", a.repr()), EarlyBoundRegion(a, b) => { - format!("EarlyBoundRegion({},{})", a.repr(tcx), b.repr(tcx)) + format!("EarlyBoundRegion({},{})", a.repr(), b.repr()) } LateBoundRegion(a, b, c) => { - format!("LateBoundRegion({},{},{:?})", a.repr(tcx), b.repr(tcx), c) + format!("LateBoundRegion({},{},{:?})", a.repr(), b.repr(), c) } BoundRegionInCoherence(a) => { - format!("bound_regionInCoherence({})", a.repr(tcx)) + format!("bound_regionInCoherence({})", a.repr()) } UpvarRegion(a, b) => { - format!("UpvarRegion({}, {})", a.repr(tcx), b.repr(tcx)) + format!("UpvarRegion({}, {})", a.repr(), b.repr()) } } } diff --git a/src/librustc/middle/infer/region_inference/graphviz.rs b/src/librustc/middle/infer/region_inference/graphviz.rs index 5a06a5193bf1c..be606e6fa4afd 100644 --- a/src/librustc/middle/infer/region_inference/graphviz.rs +++ b/src/librustc/middle/infer/region_inference/graphviz.rs @@ -191,13 +191,13 @@ impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> { Node::RegionVid(n_vid) => dot::LabelText::label(format!("{:?}", n_vid)), Node::Region(n_rgn) => - dot::LabelText::label(format!("{}", n_rgn.repr(self.tcx))), + dot::LabelText::label(format!("{}", n_rgn.repr())), } } fn edge_label(&self, e: &Edge) -> dot::LabelText { match *e { Edge::Constraint(ref c) => - dot::LabelText::label(format!("{}", self.map.get(c).unwrap().repr(self.tcx))), + dot::LabelText::label(format!("{}", self.map.get(c).unwrap().repr())), Edge::EnclScope(..) => dot::LabelText::label(format!("(enclosed)")), } diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index a6906e7b2d313..066083d27c73d 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -324,7 +324,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { self.undo_log.borrow_mut().push(AddVar(vid)); } debug!("created new region variable {:?} with origin {}", - vid, origin.repr(self.tcx)); + vid, origin.repr()); return vid; } @@ -392,7 +392,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { assert!(self.values_are_none()); debug!("RegionVarBindings: add_constraint({})", - constraint.repr(self.tcx)); + constraint.repr()); if self.constraints.borrow_mut().insert(constraint, origin).is_none() { if self.in_snapshot() { @@ -407,7 +407,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { assert!(self.values_are_none()); debug!("RegionVarBindings: add_verify({})", - verify.repr(self.tcx)); + verify.repr()); let mut verifys = self.verifys.borrow_mut(); let index = verifys.len(); @@ -426,7 +426,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { let mut givens = self.givens.borrow_mut(); if givens.insert((sub, sup)) { debug!("add_given({} <= {:?})", - sub.repr(self.tcx), + sub.repr(), sup); self.undo_log.borrow_mut().push(AddGiven(sub, sup)); @@ -453,9 +453,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { assert!(self.values_are_none()); debug!("RegionVarBindings: make_subregion({}, {}) due to {}", - sub.repr(self.tcx), - sup.repr(self.tcx), - origin.repr(self.tcx)); + sub.repr(), + sup.repr(), + origin.repr()); match (sub, sup) { (ReEarlyBound(..), ReEarlyBound(..)) => { @@ -472,8 +472,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { self.tcx.sess.span_bug( origin.span(), &format!("cannot relate bound region: {} <= {}", - sub.repr(self.tcx), - sup.repr(self.tcx))); + sub.repr(), + sup.repr())); } (_, ReStatic) => { // all regions are subregions of static, so we can ignore this @@ -511,8 +511,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { assert!(self.values_are_none()); debug!("RegionVarBindings: lub_regions({}, {})", - a.repr(self.tcx), - b.repr(self.tcx)); + a.repr(), + b.repr()); match (a, b) { (ReStatic, _) | (_, ReStatic) => { ReStatic // nothing lives longer than static @@ -536,8 +536,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { assert!(self.values_are_none()); debug!("RegionVarBindings: glb_regions({}, {})", - a.repr(self.tcx), - b.repr(self.tcx)); + a.repr(), + b.repr()); match (a, b) { (ReStatic, r) | (r, ReStatic) => { // static lives longer than everything else @@ -563,7 +563,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } Some(ref values) => { let r = lookup(values, rid); - debug!("resolve_var({:?}) = {}", rid, r.repr(self.tcx)); + debug!("resolve_var({:?}) = {}", rid, r.repr()); r } } @@ -620,7 +620,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { /// made---`r0` itself will be the first entry. This is used when checking whether skolemized /// regions are being improperly related to other regions. pub fn tainted(&self, mark: &RegionSnapshot, r0: Region) -> Vec { - debug!("tainted(mark={:?}, r0={})", mark, r0.repr(self.tcx)); + debug!("tainted(mark={:?}, r0={})", mark, r0.repr()); let _indenter = indenter(); // `result_set` acts as a worklist: we explore all outgoing @@ -732,8 +732,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { (_, ReEarlyBound(..)) => { self.tcx.sess.bug( &format!("cannot relate bound region: LUB({}, {})", - a.repr(self.tcx), - b.repr(self.tcx))); + a.repr(), + b.repr())); } (ReStatic, _) | (_, ReStatic) => { @@ -837,8 +837,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { (_, ReEarlyBound(..)) => { self.tcx.sess.bug( &format!("cannot relate bound region: GLB({}, {})", - a.repr(self.tcx), - b.repr(self.tcx))); + a.repr(), + b.repr())); } (ReStatic, r) | (r, ReStatic) => { @@ -1013,18 +1013,18 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { fn dump_constraints(&self) { debug!("----() Start constraint listing ()----"); for (idx, (constraint, _)) in self.constraints.borrow().iter().enumerate() { - debug!("Constraint {} => {}", idx, constraint.repr(self.tcx)); + debug!("Constraint {} => {}", idx, constraint.repr()); } } fn expansion(&self, free_regions: &FreeRegionMap, var_data: &mut [VarData]) { self.iterate_until_fixed_point("Expansion", |constraint| { debug!("expansion: constraint={} origin={}", - constraint.repr(self.tcx), + constraint.repr(), self.constraints.borrow() .get(constraint) .unwrap() - .repr(self.tcx)); + .repr()); match *constraint { ConstrainRegSubVar(a_region, b_vid) => { let b_data = &mut var_data[b_vid.index as usize]; @@ -1055,9 +1055,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { -> bool { debug!("expand_node({}, {:?} == {})", - a_region.repr(self.tcx), + a_region.repr(), b_vid, - b_data.value.repr(self.tcx)); + b_data.value.repr()); // Check if this relationship is implied by a given. match a_region { @@ -1074,7 +1074,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { match b_data.value { NoValue => { debug!("Setting initial value of {:?} to {}", - b_vid, a_region.repr(self.tcx)); + b_vid, a_region.repr()); b_data.value = Value(a_region); return true; @@ -1088,8 +1088,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { debug!("Expanding value of {:?} from {} to {}", b_vid, - cur_region.repr(self.tcx), - lub.repr(self.tcx)); + cur_region.repr(), + lub.repr()); b_data.value = Value(lub); return true; @@ -1106,11 +1106,11 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { var_data: &mut [VarData]) { self.iterate_until_fixed_point("Contraction", |constraint| { debug!("contraction: constraint={} origin={}", - constraint.repr(self.tcx), + constraint.repr(), self.constraints.borrow() .get(constraint) .unwrap() - .repr(self.tcx)); + .repr()); match *constraint { ConstrainRegSubVar(..) => { // This is an expansion constraint. Ignore. @@ -1140,8 +1140,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { b_region: Region) -> bool { debug!("contract_node({:?} == {}/{:?}, {})", - a_vid, a_data.value.repr(self.tcx), - a_data.classification, b_region.repr(self.tcx)); + a_vid, a_data.value.repr(), + a_data.classification, b_region.repr()); return match a_data.value { NoValue => { @@ -1173,8 +1173,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { if !free_regions.is_subregion_of(this.tcx, a_region, b_region) { debug!("Setting {:?} to ErrorValue: {} not subregion of {}", a_vid, - a_region.repr(this.tcx), - b_region.repr(this.tcx)); + a_region.repr(), + b_region.repr()); a_data.value = ErrorValue; } false @@ -1194,8 +1194,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } else { debug!("Contracting value of {:?} from {} to {}", a_vid, - a_region.repr(this.tcx), - glb.repr(this.tcx)); + a_region.repr(), + glb.repr()); a_data.value = Value(glb); true } @@ -1203,8 +1203,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { Err(_) => { debug!("Setting {:?} to ErrorValue: no glb of {}, {}", a_vid, - a_region.repr(this.tcx), - b_region.repr(this.tcx)); + a_region.repr(), + b_region.repr()); a_data.value = ErrorValue; false } @@ -1230,8 +1230,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } debug!("ConcreteFailure: !(sub <= sup): sub={}, sup={}", - sub.repr(self.tcx), - sup.repr(self.tcx)); + sub.repr(), + sup.repr()); errors.push(ConcreteFailure((*origin).clone(), sub, sup)); } @@ -1433,8 +1433,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { &format!("collect_error_for_expanding_node() could not find error \ for var {:?}, lower_bounds={}, upper_bounds={}", node_idx, - lower_bounds.repr(self.tcx), - upper_bounds.repr(self.tcx))); + lower_bounds.repr(), + upper_bounds.repr())); } fn collect_error_for_contracting_node( @@ -1480,7 +1480,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { &format!("collect_error_for_contracting_node() could not find error \ for var {:?}, upper_bounds={}", node_idx, - upper_bounds.repr(self.tcx))); + upper_bounds.repr())); } fn collect_concrete_regions(&self, @@ -1579,7 +1579,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { let edge_changed = body(constraint); if edge_changed { debug!("Updated due to constraint {}", - constraint.repr(self.tcx)); + constraint.repr()); changed = true; } } @@ -1589,31 +1589,31 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } -impl<'tcx> Repr<'tcx> for Constraint { - fn repr(&self, tcx: &ty::ctxt) -> String { +impl Repr for Constraint { + fn repr(&self) -> String { match *self { ConstrainVarSubVar(a, b) => { - format!("ConstrainVarSubVar({}, {})", a.repr(tcx), b.repr(tcx)) + format!("ConstrainVarSubVar({}, {})", a.repr(), b.repr()) } ConstrainRegSubVar(a, b) => { - format!("ConstrainRegSubVar({}, {})", a.repr(tcx), b.repr(tcx)) + format!("ConstrainRegSubVar({}, {})", a.repr(), b.repr()) } ConstrainVarSubReg(a, b) => { - format!("ConstrainVarSubReg({}, {})", a.repr(tcx), b.repr(tcx)) + format!("ConstrainVarSubReg({}, {})", a.repr(), b.repr()) } } } } -impl<'tcx> Repr<'tcx> for Verify<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for Verify<'tcx> { + fn repr(&self) -> String { match *self { VerifyRegSubReg(_, ref a, ref b) => { - format!("VerifyRegSubReg({}, {})", a.repr(tcx), b.repr(tcx)) + format!("VerifyRegSubReg({}, {})", a.repr(), b.repr()) } VerifyGenericBound(_, ref p, ref a, ref bs) => { format!("VerifyGenericBound({}, {}, {})", - p.repr(tcx), a.repr(tcx), bs.repr(tcx)) + p.repr(), a.repr(), bs.repr()) } } } @@ -1634,38 +1634,38 @@ fn lookup(values: &Vec, rid: ty::RegionVid) -> ty::Region { } } -impl<'tcx> Repr<'tcx> for VarValue { - fn repr(&self, tcx: &ty::ctxt) -> String { +impl Repr for VarValue { + fn repr(&self) -> String { match *self { NoValue => format!("NoValue"), - Value(r) => format!("Value({})", r.repr(tcx)), + Value(r) => format!("Value({})", r.repr()), ErrorValue => format!("ErrorValue"), } } } -impl<'tcx> Repr<'tcx> for RegionAndOrigin<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for RegionAndOrigin<'tcx> { + fn repr(&self) -> String { format!("RegionAndOrigin({},{})", - self.region.repr(tcx), - self.origin.repr(tcx)) + self.region.repr(), + self.origin.repr()) } } -impl<'tcx> Repr<'tcx> for GenericKind<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for GenericKind<'tcx> { + fn repr(&self) -> String { match *self { - GenericKind::Param(ref p) => p.repr(tcx), - GenericKind::Projection(ref p) => p.repr(tcx), + GenericKind::Param(ref p) => p.repr(), + GenericKind::Projection(ref p) => p.repr(), } } } -impl<'tcx> UserString<'tcx> for GenericKind<'tcx> { - fn user_string(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> UserString for GenericKind<'tcx> { + fn user_string(&self) -> String { match *self { - GenericKind::Param(ref p) => p.user_string(tcx), - GenericKind::Projection(ref p) => p.user_string(tcx), + GenericKind::Param(ref p) => p.user_string(), + GenericKind::Projection(ref p) => p.user_string(), } } } diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/middle/infer/resolve.rs index 62e56d2e2d7d3..c22aa6a4f996e 100644 --- a/src/librustc/middle/infer/resolve.rs +++ b/src/librustc/middle/infer/resolve.rs @@ -96,7 +96,7 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { ty::TyInfer(_) => { self.infcx.tcx.sess.bug( &format!("Unexpected type in full type resolver: {}", - t.repr(self.infcx.tcx))); + t.repr())); } _ => { ty_fold::super_fold_ty(self, t) diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/middle/infer/sub.rs index 9d6854eba4369..24eae6307fafd 100644 --- a/src/librustc/middle/infer/sub.rs +++ b/src/librustc/middle/infer/sub.rs @@ -49,7 +49,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> { } fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - debug!("{}.tys({}, {})", self.tag(), a.repr(self.tcx()), b.repr(self.tcx())); + debug!("{}.tys({}, {})", self.tag(), a.repr(), b.repr()); if a == b { return Ok(a); } @@ -87,8 +87,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> { fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { debug!("{}.regions({}, {})", self.tag(), - a.repr(self.tcx()), - b.repr(self.tcx())); + a.repr(), + b.repr()); let origin = Subtype(self.fields.trace.clone()); self.fields.infcx.region_vars.make_subregion(origin, a, b); Ok(a) diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index f76cfebf7b997..a3ea726f0f2f9 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -203,14 +203,14 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> { match types_in_scope.next() { None => { debug!("with_each_combination(substs={})", - substs.repr(self.tcx)); + substs.repr()); callback(substs); } Some((space, index, ¶m_ty)) => { debug!("with_each_combination: space={:?}, index={}, param_ty={}", - space, index, param_ty.repr(self.tcx)); + space, index, param_ty.repr()); if !ty::type_is_sized(Some(param_env), self.tcx, span, param_ty) { debug!("with_each_combination: param_ty is not known to be sized"); @@ -228,7 +228,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> { } fn push_transmute_restriction(&self, restriction: TransmuteRestriction<'tcx>) { - debug!("Pushing transmute restriction: {}", restriction.repr(self.tcx)); + debug!("Pushing transmute restriction: {}", restriction.repr()); self.tcx.transmute_restrictions.borrow_mut().push(restriction); } } @@ -277,13 +277,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> { } } -impl<'tcx> Repr<'tcx> for TransmuteRestriction<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for TransmuteRestriction<'tcx> { + fn repr(&self) -> String { format!("TransmuteRestriction(id={}, original=({},{}), substituted=({},{}))", self.id, - self.original_from.repr(tcx), - self.original_to.repr(tcx), - self.substituted_from.repr(tcx), - self.substituted_to.repr(tcx)) + self.original_from.repr(), + self.original_to.repr(), + self.substituted_from.repr(), + self.substituted_to.repr()) } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 9d0a1821debc1..a3e12db6644ab 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -437,7 +437,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { _ => base_ty, }; debug!("pat_ty(pat={}) base_ty={} ret_ty={}", - pat.repr(tcx), base_ty.repr(tcx), ret_ty.repr(tcx)); + pat.repr(), base_ty.repr(), ret_ty.repr()); Ok(ret_ty) } @@ -461,8 +461,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty::AdjustUnsafeFnPointer | ty::AdjustDerefRef(_) => { debug!("cat_expr({}): {}", - adjustment.repr(self.tcx()), - expr.repr(self.tcx())); + adjustment.repr(), + expr.repr()); // Result is an rvalue. let expr_ty = try!(self.expr_ty_adjusted(expr)); Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty)) @@ -479,7 +479,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let mut cmt = try!(self.cat_expr_unadjusted(expr)); debug!("cat_expr_autoderefd: autoderefs={}, cmt={}", autoderefs, - cmt.repr(self.tcx())); + cmt.repr()); for deref in 1..autoderefs + 1 { cmt = try!(self.cat_deref(expr, cmt, deref, None)); } @@ -487,7 +487,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult> { - debug!("cat_expr: id={} expr={}", expr.id, expr.repr(self.tcx())); + debug!("cat_expr: id={} expr={}", expr.id, expr.repr()); let expr_ty = try!(self.expr_ty(expr)); match expr.node { @@ -500,8 +500,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let base_cmt = try!(self.cat_expr(&**base)); debug!("cat_expr(cat_field): id={} expr={} base={}", expr.id, - expr.repr(self.tcx()), - base_cmt.repr(self.tcx())); + expr.repr(), + base_cmt.repr()); Ok(self.cat_field(expr, base_cmt, f_name.node.name, expr_ty)) } @@ -525,7 +525,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty::TyRef(_, mt) => mt.ty, _ => { debug!("cat_expr_unadjusted: return type of overloaded index is {}?", - ret_ty.repr(self.tcx())); + ret_ty.repr()); return Err(()); } }; @@ -584,7 +584,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { def: def::Def) -> McResult> { debug!("cat_def: id={} expr={} def={:?}", - id, expr_ty.repr(self.tcx()), def); + id, expr_ty.repr(), def); match def { def::DefStruct(..) | def::DefVariant(..) | def::DefConst(..) | @@ -637,7 +637,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { span, &format!("Upvar of non-closure {} - {}", fn_node_id, - ty.repr(self.tcx()))); + ty.repr())); } } } @@ -746,7 +746,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { }; let ret = Rc::new(cmt_result); - debug!("cat_upvar ret={}", ret.repr(self.tcx())); + debug!("cat_upvar ret={}", ret.repr()); Ok(ret) } @@ -817,7 +817,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { note: NoteClosureEnv(upvar_id) }; - debug!("env_deref ret {}", ret.repr(self.tcx())); + debug!("env_deref ret {}", ret.repr()); ret } @@ -855,7 +855,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty::ReStatic }; let ret = self.cat_rvalue(id, span, re, expr_ty); - debug!("cat_rvalue_node ret {}", ret.repr(self.tcx())); + debug!("cat_rvalue_node ret {}", ret.repr()); ret } @@ -872,7 +872,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty:expr_ty, note: NoteNone }); - debug!("cat_rvalue ret {}", ret.repr(self.tcx())); + debug!("cat_rvalue ret {}", ret.repr()); ret } @@ -890,7 +890,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: f_ty, note: NoteNone }); - debug!("cat_field ret {}", ret.repr(self.tcx())); + debug!("cat_field ret {}", ret.repr()); ret } @@ -908,7 +908,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: f_ty, note: NoteNone }); - debug!("cat_tup_field ret {}", ret.repr(self.tcx())); + debug!("cat_tup_field ret {}", ret.repr()); ret } @@ -925,7 +925,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let method_ty = self.typer.node_method_ty(method_call); debug!("cat_deref: method_call={:?} method_ty={:?}", - method_call, method_ty.map(|ty| ty.repr(self.tcx()))); + method_call, method_ty.map(|ty| ty.repr())); let base_cmt = match method_ty { Some(method_ty) => { @@ -943,12 +943,12 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { mt.ty, deref_context, /* implicit: */ false); - debug!("cat_deref ret {}", ret.repr(self.tcx())); + debug!("cat_deref ret {}", ret.repr()); ret } None => { debug!("Explicit deref of non-derefable type: {}", - base_cmt_ty.repr(self.tcx())); + base_cmt_ty.repr()); return Err(()); } } @@ -991,7 +991,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: deref_ty, note: NoteNone }); - debug!("cat_deref_common ret {}", ret.repr(self.tcx())); + debug!("cat_deref_common ret {}", ret.repr()); Ok(ret) } @@ -1042,7 +1042,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let m = base_cmt.mutbl.inherit(); let ret = interior(elt, base_cmt.clone(), base_cmt.ty, m, context, element_ty); - debug!("cat_index ret {}", ret.repr(self.tcx())); + debug!("cat_index ret {}", ret.repr()); return Ok(ret); fn interior<'tcx, N: ast_node>(elt: &N, @@ -1096,7 +1096,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { base_cmt } }; - debug!("deref_vec ret {}", ret.repr(self.tcx())); + debug!("deref_vec ret {}", ret.repr()); Ok(ret) } @@ -1155,7 +1155,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: interior_ty, note: NoteNone }); - debug!("cat_imm_interior ret={}", ret.repr(self.tcx())); + debug!("cat_imm_interior ret={}", ret.repr()); ret } @@ -1173,7 +1173,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: downcast_ty, note: NoteNone }); - debug!("cat_downcast ret={}", ret.repr(self.tcx())); + debug!("cat_downcast ret={}", ret.repr()); ret } @@ -1235,7 +1235,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { debug!("cat_pattern: id={} pat={} cmt={}", pat.id, pprust::pat_to_string(pat), - cmt.repr(self.tcx())); + cmt.repr()); (*op)(self, cmt.clone(), pat); @@ -1521,7 +1521,7 @@ impl<'tcx> cmt_<'tcx> { let upvar = self.upvar(); match upvar.as_ref().map(|i| &i.cat) { Some(&cat_upvar(ref var)) => { - var.user_string(tcx) + var.user_string() } Some(_) => unreachable!(), None => { @@ -1561,7 +1561,7 @@ impl<'tcx> cmt_<'tcx> { "pattern-bound indexed content".to_string() } cat_upvar(ref var) => { - var.user_string(tcx) + var.user_string() } cat_downcast(ref cmt, _) => { cmt.descriptive_string(tcx) @@ -1570,18 +1570,18 @@ impl<'tcx> cmt_<'tcx> { } } -impl<'tcx> Repr<'tcx> for cmt_<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for cmt_<'tcx> { + fn repr(&self) -> String { format!("{{{} id:{} m:{:?} ty:{}}}", - self.cat.repr(tcx), + self.cat.repr(), self.id, self.mutbl, - self.ty.repr(tcx)) + self.ty.repr()) } } -impl<'tcx> Repr<'tcx> for categorization<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for categorization<'tcx> { + fn repr(&self) -> String { match *self { cat_static_item | cat_rvalue(..) | @@ -1590,13 +1590,13 @@ impl<'tcx> Repr<'tcx> for categorization<'tcx> { format!("{:?}", *self) } cat_deref(ref cmt, derefs, ptr) => { - format!("{}-{}{}->", cmt.cat.repr(tcx), ptr.repr(tcx), derefs) + format!("{}-{}{}->", cmt.cat.repr(), ptr.repr(), derefs) } cat_interior(ref cmt, interior) => { - format!("{}.{}", cmt.cat.repr(tcx), interior.repr(tcx)) + format!("{}.{}", cmt.cat.repr(), interior.repr()) } cat_downcast(ref cmt, _) => { - format!("{}->(enum)", cmt.cat.repr(tcx)) + format!("{}->(enum)", cmt.cat.repr()) } } } @@ -1615,23 +1615,23 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str { } } -impl<'tcx> Repr<'tcx> for PointerKind { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl Repr for PointerKind { + fn repr(&self) -> String { match *self { Unique => { format!("Box") } BorrowedPtr(ty::ImmBorrow, ref r) | Implicit(ty::ImmBorrow, ref r) => { - format!("&{}", r.repr(tcx)) + format!("&{}", r.repr()) } BorrowedPtr(ty::MutBorrow, ref r) | Implicit(ty::MutBorrow, ref r) => { - format!("&{} mut", r.repr(tcx)) + format!("&{} mut", r.repr()) } BorrowedPtr(ty::UniqueImmBorrow, ref r) | Implicit(ty::UniqueImmBorrow, ref r) => { - format!("&{} uniq", r.repr(tcx)) + format!("&{} uniq", r.repr()) } UnsafePtr(_) => { format!("*") @@ -1640,8 +1640,8 @@ impl<'tcx> Repr<'tcx> for PointerKind { } } -impl<'tcx> Repr<'tcx> for InteriorKind { - fn repr(&self, _tcx: &ty::ctxt) -> String { +impl Repr for InteriorKind { + fn repr(&self) -> String { match *self { InteriorField(NamedField(fld)) => { token::get_name(fld).to_string() @@ -1664,20 +1664,20 @@ fn element_kind(t: Ty) -> ElementKind { } } -impl<'tcx> Repr<'tcx> for ty::ClosureKind { - fn repr(&self, _: &ty::ctxt) -> String { +impl Repr for ty::ClosureKind { + fn repr(&self) -> String { format!("Upvar({:?})", self) } } -impl<'tcx> Repr<'tcx> for Upvar { - fn repr(&self, tcx: &ty::ctxt) -> String { - format!("Upvar({})", self.kind.repr(tcx)) +impl Repr for Upvar { + fn repr(&self) -> String { + format!("Upvar({})", self.kind.repr()) } } -impl<'tcx> UserString<'tcx> for Upvar { - fn user_string(&self, _: &ty::ctxt) -> String { +impl UserString for Upvar { + fn user_string(&self) -> String { let kind = match self.kind { ty::FnClosureKind => "Fn", ty::FnMutClosureKind => "FnMut", diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 861fa97d50bf2..3fec62cd8b481 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -450,7 +450,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr, tcx.sess.span_bug(e.span, &format!("stability::check_expr: struct construction \ of non-struct, type {:?}", - type_.repr(tcx))); + type_.repr())); } } } @@ -551,7 +551,7 @@ pub fn lookup<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> } fn lookup_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> { - debug!("lookup(id={})", id.repr(tcx)); + debug!("lookup(id={})", id.repr()); // is this definition the implementation of a trait method? match ty::trait_item_of_item(tcx, id) { diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 75af3366397dd..8f6e85a17b128 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -623,7 +623,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { when substituting in region {} (root type={}) \ (space={:?}, index={})", data.name.as_str(), - self.root_ty.repr(self.tcx()), + self.root_ty.repr(), data.space, data.index)); } @@ -677,12 +677,12 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> { span, &format!("Type parameter `{}` ({}/{:?}/{}) out of range \ when substituting (root type={}) substs={}", - p.repr(self.tcx()), - source_ty.repr(self.tcx()), + p.repr(), + source_ty.repr(), p.space, p.idx, - self.root_ty.repr(self.tcx()), - self.substs.repr(self.tcx()))); + self.root_ty.repr(), + self.substs.repr())); } }; @@ -733,14 +733,14 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> { /// is that only in the second case have we passed through a fn binder. fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx> { debug!("shift_regions(ty={:?}, region_binders_passed={:?}, type_has_escaping_regions={:?})", - ty.repr(self.tcx()), self.region_binders_passed, ty::type_has_escaping_regions(ty)); + ty.repr(), self.region_binders_passed, ty::type_has_escaping_regions(ty)); if self.region_binders_passed == 0 || !ty::type_has_escaping_regions(ty) { return ty; } let result = ty_fold::shift_regions(self.tcx(), self.region_binders_passed, &ty); - debug!("shift_regions: shifted result = {:?}", result.repr(self.tcx())); + debug!("shift_regions: shifted result = {:?}", result.repr()); result } diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index dcf37e7d56a1b..b7568b565cec9 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -36,8 +36,8 @@ pub fn overlapping_impls(infcx: &InferCtxt, debug!("impl_can_satisfy(\ impl1_def_id={}, \ impl2_def_id={})", - impl1_def_id.repr(infcx.tcx), - impl2_def_id.repr(infcx.tcx)); + impl1_def_id.repr(), + impl2_def_id.repr()); let param_env = &ty::empty_parameter_environment(infcx.tcx); let selcx = &mut SelectionContext::intercrate(infcx, param_env); @@ -54,8 +54,8 @@ fn overlap(selcx: &mut SelectionContext, -> bool { debug!("overlap(a_def_id={}, b_def_id={})", - a_def_id.repr(selcx.tcx()), - b_def_id.repr(selcx.tcx())); + a_def_id.repr(), + b_def_id.repr()); let (a_trait_ref, a_obligations) = impl_trait_ref_and_oblig(selcx, a_def_id, @@ -65,9 +65,9 @@ fn overlap(selcx: &mut SelectionContext, b_def_id, util::fresh_type_vars_for_impl); - debug!("overlap: a_trait_ref={}", a_trait_ref.repr(selcx.tcx())); + debug!("overlap: a_trait_ref={}", a_trait_ref.repr()); - debug!("overlap: b_trait_ref={}", b_trait_ref.repr(selcx.tcx())); + debug!("overlap: b_trait_ref={}", b_trait_ref.repr()); // Does `a <: b` hold? If not, no overlap. if let Err(_) = infer::mk_sub_poly_trait_refs(selcx.infcx(), @@ -90,7 +90,7 @@ fn overlap(selcx: &mut SelectionContext, .find(|o| !selcx.evaluate_obligation(o)); if let Some(failing_obligation) = opt_failing_obligation { - debug!("overlap: obligation unsatisfiable {}", failing_obligation.repr(tcx)); + debug!("overlap: obligation unsatisfiable {}", failing_obligation.repr()); return false } @@ -99,7 +99,7 @@ fn overlap(selcx: &mut SelectionContext, pub fn trait_ref_is_knowable<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> bool { - debug!("trait_ref_is_knowable(trait_ref={})", trait_ref.repr(tcx)); + debug!("trait_ref_is_knowable(trait_ref={})", trait_ref.repr()); // if the orphan rules pass, that means that no ancestor crate can // impl this, so it's up to us. @@ -181,17 +181,17 @@ pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>, impl_def_id: ast::DefId) -> Result<(), OrphanCheckErr<'tcx>> { - debug!("orphan_check({})", impl_def_id.repr(tcx)); + debug!("orphan_check({})", impl_def_id.repr()); // We only except this routine to be invoked on implementations // of a trait, not inherent implementations. let trait_ref = ty::impl_trait_ref(tcx, impl_def_id).unwrap(); - debug!("orphan_check: trait_ref={}", trait_ref.repr(tcx)); + debug!("orphan_check: trait_ref={}", trait_ref.repr()); // If the *trait* is local to the crate, ok. if trait_ref.def_id.krate == ast::LOCAL_CRATE { debug!("trait {} is local to current crate", - trait_ref.def_id.repr(tcx)); + trait_ref.def_id.repr()); return Ok(()); } @@ -204,7 +204,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, -> Result<(), OrphanCheckErr<'tcx>> { debug!("orphan_check_trait_ref(trait_ref={}, infer_is_local={})", - trait_ref.repr(tcx), infer_is_local.0); + trait_ref.repr(), infer_is_local.0); // First, create an ordered iterator over all the type parameters to the trait, with the self // type appearing first. @@ -215,14 +215,14 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, // some local type. for input_ty in input_tys { if ty_is_local(tcx, input_ty, infer_is_local) { - debug!("orphan_check_trait_ref: ty_is_local `{}`", input_ty.repr(tcx)); + debug!("orphan_check_trait_ref: ty_is_local `{}`", input_ty.repr()); // First local input type. Check that there are no // uncovered type parameters. let uncovered_tys = uncovered_tys(tcx, input_ty, infer_is_local); for uncovered_ty in uncovered_tys { if let Some(param) = uncovered_ty.walk().find(|t| is_type_parameter(t)) { - debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr(tcx)); + debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr()); return Err(OrphanCheckErr::UncoveredTy(param)); } } @@ -235,7 +235,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, // parameters reachable. if !infer_is_local.0 { if let Some(param) = input_ty.walk().find(|t| is_type_parameter(t)) { - debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr(tcx)); + debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr()); return Err(OrphanCheckErr::UncoveredTy(param)); } } @@ -295,7 +295,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, infer_is_local: InferIsLocal) -> bool { - debug!("ty_is_local_constructor({})", ty.repr(tcx)); + debug!("ty_is_local_constructor({})", ty.repr()); match ty.sty { ty::TyBool | @@ -337,7 +337,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, ty::TyError => { tcx.sess.bug( &format!("ty_is_local invoked on unexpected type: {}", - ty.repr(tcx))) + ty.repr())) } } } diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index 2d65c5dd626c9..72f162638929f 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -68,7 +68,7 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, if !infcx.tcx.sess.has_errors() || !predicate.references_error() { span_err!(infcx.tcx.sess, obligation.cause.span, E0271, "type mismatch resolving `{}`: {}", - predicate.user_string(infcx.tcx), + predicate.user_string(), ty::type_err_to_str(infcx.tcx, &error.err)); note_obligation_cause(infcx, obligation); } @@ -87,16 +87,16 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, item.meta().span }; let def = ty::lookup_trait_def(infcx.tcx, def_id); - let trait_str = def.trait_ref.user_string(infcx.tcx); + let trait_str = def.trait_ref.user_string(); if let Some(ref istring) = item.value_str() { let mut generic_map = def.generics.types.iter_enumerated() .map(|(param, i, gen)| { (gen.name.as_str().to_string(), trait_ref.substs.types.get(param, i) - .user_string(infcx.tcx)) + .user_string()) }).collect::>(); generic_map.insert("Self".to_string(), - trait_ref.self_ty().user_string(infcx.tcx)); + trait_ref.self_ty().user_string()); let parser = Parser::new(&istring); let mut errored = false; let err: String = parser.filter_map(|p| { @@ -157,13 +157,13 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, pub fn report_overflow_error<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, obligation: &Obligation<'tcx, T>) -> ! - where T: UserString<'tcx> + TypeFoldable<'tcx> + where T: UserString + TypeFoldable<'tcx> { let predicate = infcx.resolve_type_vars_if_possible(&obligation.predicate); span_err!(infcx.tcx.sess, obligation.cause.span, E0275, "overflow evaluating the requirement `{}`", - predicate.user_string(infcx.tcx)); + predicate.user_string()); suggest_new_overflow_limit(infcx.tcx, obligation.cause.span); @@ -184,7 +184,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0276, "the requirement `{}` appears on the impl \ method but not on the corresponding trait method", - obligation.predicate.user_string(infcx.tcx));; + obligation.predicate.user_string());; } _ => { match obligation.predicate { @@ -197,8 +197,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let trait_ref = trait_predicate.to_poly_trait_ref(); span_err!(infcx.tcx.sess, obligation.cause.span, E0277, "the trait `{}` is not implemented for the type `{}`", - trait_ref.user_string(infcx.tcx), - trait_ref.self_ty().user_string(infcx.tcx)); + trait_ref.user_string(), + trait_ref.self_ty().user_string()); // Check if it has a custom "#[rustc_on_unimplemented]" // error message, report with that message if it does let custom_note = report_on_unimplemented(infcx, &trait_ref.0, @@ -216,7 +216,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, &predicate).err().unwrap(); span_err!(infcx.tcx.sess, obligation.cause.span, E0278, "the requirement `{}` is not satisfied (`{}`)", - predicate.user_string(infcx.tcx), + predicate.user_string(), ty::type_err_to_str(infcx.tcx, &err)); } @@ -226,7 +226,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, &predicate).err().unwrap(); span_err!(infcx.tcx.sess, obligation.cause.span, E0279, "the requirement `{}` is not satisfied (`{}`)", - predicate.user_string(infcx.tcx), + predicate.user_string(), ty::type_err_to_str(infcx.tcx, &err)); } @@ -235,7 +235,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.resolve_type_vars_if_possible(&obligation.predicate); span_err!(infcx.tcx.sess, obligation.cause.span, E0280, "the requirement `{}` is not satisfied", - predicate.user_string(infcx.tcx)); + predicate.user_string()); } } } @@ -249,9 +249,9 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0281, "type mismatch: the type `{}` implements the trait `{}`, \ but the trait `{}` is required ({})", - expected_trait_ref.self_ty().user_string(infcx.tcx), - expected_trait_ref.user_string(infcx.tcx), - actual_trait_ref.user_string(infcx.tcx), + expected_trait_ref.self_ty().user_string(), + expected_trait_ref.user_string(), + actual_trait_ref.user_string(), ty::type_err_to_str(infcx.tcx, e)); note_obligation_cause(infcx, obligation); } @@ -282,7 +282,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.tcx.sess.span_note( obligation.cause.span, &format!("method `{}` has no receiver", - method.name.user_string(infcx.tcx))); + method.name.user_string())); } ObjectSafetyViolation::Method(method, @@ -291,7 +291,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, obligation.cause.span, &format!("method `{}` references the `Self` type \ in its arguments or return type", - method.name.user_string(infcx.tcx))); + method.name.user_string())); } ObjectSafetyViolation::Method(method, @@ -299,7 +299,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.tcx.sess.span_note( obligation.cause.span, &format!("method `{}` has generic type parameters", - method.name.user_string(infcx.tcx))); + method.name.user_string())); } } } @@ -317,8 +317,8 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let predicate = infcx.resolve_type_vars_if_possible(&obligation.predicate); debug!("maybe_report_ambiguity(predicate={}, obligation={})", - predicate.repr(infcx.tcx), - obligation.repr(infcx.tcx)); + predicate.repr(), + obligation.repr()); match predicate { ty::Predicate::Trait(ref data) => { @@ -349,11 +349,11 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0282, "unable to infer enough type information about `{}`; \ type annotations or generic parameter binding required", - self_ty.user_string(infcx.tcx)); + self_ty.user_string()); } else { span_err!(infcx.tcx.sess, obligation.cause.span, E0283, "type annotations required: cannot resolve `{}`", - predicate.user_string(infcx.tcx));; + predicate.user_string());; note_obligation_cause(infcx, obligation); } } @@ -365,8 +365,8 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, "coherence failed to report ambiguity: \ cannot locate the impl of the trait `{}` for \ the type `{}`", - trait_ref.user_string(infcx.tcx), - self_ty.user_string(infcx.tcx))); + trait_ref.user_string(), + self_ty.user_string())); } } @@ -374,7 +374,7 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, if !infcx.tcx.sess.has_errors() { span_err!(infcx.tcx.sess, obligation.cause.span, E0284, "type annotations required: cannot resolve `{}`", - predicate.user_string(infcx.tcx));; + predicate.user_string());; note_obligation_cause(infcx, obligation); } } @@ -383,7 +383,7 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, fn note_obligation_cause<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, obligation: &Obligation<'tcx, T>) - where T: UserString<'tcx> + where T: UserString { note_obligation_cause_code(infcx, &obligation.predicate, @@ -395,7 +395,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, predicate: &T, cause_span: Span, cause_code: &ObligationCauseCode<'tcx>) - where T: UserString<'tcx> + where T: UserString { let tcx = infcx.tcx; match *cause_code { @@ -463,7 +463,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, let parent_trait_ref = infcx.resolve_type_vars_if_possible(&data.parent_trait_ref); span_note!(tcx.sess, cause_span, "required because it appears within the type `{}`", - parent_trait_ref.0.self_ty().user_string(infcx.tcx)); + parent_trait_ref.0.self_ty().user_string()); let parent_predicate = parent_trait_ref.as_predicate(); note_obligation_cause_code(infcx, &parent_predicate, cause_span, &*data.parent_code); } @@ -471,8 +471,8 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, let parent_trait_ref = infcx.resolve_type_vars_if_possible(&data.parent_trait_ref); span_note!(tcx.sess, cause_span, "required because of the requirements on the impl of `{}` for `{}`", - parent_trait_ref.user_string(infcx.tcx), - parent_trait_ref.0.self_ty().user_string(infcx.tcx)); + parent_trait_ref.user_string(), + parent_trait_ref.0.self_ty().user_string()); let parent_predicate = parent_trait_ref.as_predicate(); note_obligation_cause_code(infcx, &parent_predicate, cause_span, &*data.parent_code); } @@ -480,7 +480,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, span_note!(tcx.sess, cause_span, "the requirement `{}` appears on the impl method \ but not on the corresponding trait method", - predicate.user_string(infcx.tcx)); + predicate.user_string()); } } } diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index b9117745db2e2..8615a7822bea9 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -138,7 +138,7 @@ impl<'tcx> FulfillmentContext<'tcx> { -> Ty<'tcx> { debug!("normalize_associated_type(projection_ty={})", - projection_ty.repr(infcx.tcx)); + projection_ty.repr()); assert!(!projection_ty.has_escaping_regions()); @@ -151,7 +151,7 @@ impl<'tcx> FulfillmentContext<'tcx> { self.register_predicate_obligation(infcx, obligation); } - debug!("normalize_associated_type: result={}", normalized.value.repr(infcx.tcx)); + debug!("normalize_associated_type: result={}", normalized.value.repr()); normalized.value } @@ -190,11 +190,11 @@ impl<'tcx> FulfillmentContext<'tcx> { assert!(!obligation.has_escaping_regions()); if self.is_duplicate_or_add(infcx.tcx, &obligation.predicate) { - debug!("register_predicate({}) -- already seen, skip", obligation.repr(infcx.tcx)); + debug!("register_predicate({}) -- already seen, skip", obligation.repr()); return; } - debug!("register_predicate({})", obligation.repr(infcx.tcx)); + debug!("register_predicate({})", obligation.repr()); self.predicates.push(obligation); } @@ -380,8 +380,8 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, } Err(selection_err) => { debug!("predicate: {} error: {}", - obligation.repr(tcx), - selection_err.repr(tcx)); + obligation.repr(), + selection_err.repr()); errors.push( FulfillmentError::new( obligation.clone(), @@ -441,8 +441,8 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, let project_obligation = obligation.with(data.clone()); let result = project::poly_project_and_unify_type(selcx, &project_obligation); debug!("process_predicate: poly_project_and_unify_type({}) returned {}", - project_obligation.repr(tcx), - result.repr(tcx)); + project_obligation.repr(), + result.repr()); match result { Ok(Some(obligations)) => { new_obligations.extend(obligations); @@ -463,11 +463,11 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, } } -impl<'tcx> Repr<'tcx> for RegionObligation<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for RegionObligation<'tcx> { + fn repr(&self) -> String { format!("RegionObligation(sub_region={}, sup_type={})", - self.sub_region.repr(tcx), - self.sup_type.repr(tcx)) + self.sub_region.repr(), + self.sup_type.repr()) } } @@ -482,7 +482,7 @@ fn register_region_obligation<'tcx>(tcx: &ty::ctxt<'tcx>, cause: cause }; debug!("register_region_obligation({})", - region_obligation.repr(tcx)); + region_obligation.repr()); region_obligations.entry(region_obligation.cause.body_id).or_insert(vec![]) .push(region_obligation); diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index b4b53c003ea2f..036aaedb446de 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -321,7 +321,7 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, -> bool { debug!("type_known_to_meet_builtin_bound(ty={}, bound={:?})", - ty.repr(infcx.tcx), + ty.repr(), bound); let mut fulfill_cx = FulfillmentContext::new(false); @@ -339,15 +339,15 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, match fulfill_cx.select_all_or_error(infcx, typer) { Ok(()) => { debug!("type_known_to_meet_builtin_bound: ty={} bound={:?} success", - ty.repr(infcx.tcx), + ty.repr(), bound); true } Err(e) => { debug!("type_known_to_meet_builtin_bound: ty={} bound={:?} errors={}", - ty.repr(infcx.tcx), + ty.repr(), bound, - e.repr(infcx.tcx)); + e.repr()); false } } @@ -378,7 +378,7 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi let body_id = cause.body_id; debug!("normalize_param_env_or_error(unnormalized_env={})", - unnormalized_env.repr(tcx)); + unnormalized_env.repr()); let predicates: Vec<_> = util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.clone()) @@ -394,7 +394,7 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi // -nmatsakis debug!("normalize_param_env_or_error: elaborated-predicates={}", - predicates.repr(tcx)); + predicates.repr()); let elaborated_env = unnormalized_env.with_caller_bounds(predicates); @@ -434,25 +434,25 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, cause: ObligationCause<'tcx>, value: &T) -> Result>> - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx> + where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr { let tcx = closure_typer.tcx(); - debug!("normalize_param_env(value={})", value.repr(tcx)); + debug!("normalize_param_env(value={})", value.repr()); let mut selcx = &mut SelectionContext::new(infcx, closure_typer); let mut fulfill_cx = FulfillmentContext::new(false); let Normalized { value: normalized_value, obligations } = project::normalize(selcx, cause, value); debug!("normalize_param_env: normalized_value={} obligations={}", - normalized_value.repr(tcx), - obligations.repr(tcx)); + normalized_value.repr(), + obligations.repr()); for obligation in obligations { fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation); } try!(fulfill_cx.select_all_or_error(infcx, closure_typer)); let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value); - debug!("normalize_param_env: resolved_value={}", resolved_value.repr(tcx)); + debug!("normalize_param_env: resolved_value={}", resolved_value.repr()); Ok(resolved_value) } diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/middle/traits/object_safety.rs index cf8e391bf5456..9be973c701893 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/middle/traits/object_safety.rs @@ -70,7 +70,7 @@ pub fn is_object_safe<'tcx>(tcx: &ty::ctxt<'tcx>, result }); - debug!("is_object_safe({}) = {}", trait_def_id.repr(tcx), result); + debug!("is_object_safe({}) = {}", trait_def_id.repr(), result); result } @@ -112,8 +112,8 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>, } debug!("object_safety_violations_for_trait(trait_def_id={}) = {}", - trait_def_id.repr(tcx), - violations.repr(tcx)); + trait_def_id.repr(), + violations.repr()); violations } @@ -352,15 +352,15 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>, error } -impl<'tcx> Repr<'tcx> for ObjectSafetyViolation<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for ObjectSafetyViolation<'tcx> { + fn repr(&self) -> String { match *self { ObjectSafetyViolation::SizedSelf => format!("SizedSelf"), ObjectSafetyViolation::SupertraitSelf => format!("SupertraitSelf"), ObjectSafetyViolation::Method(ref m, code) => - format!("Method({},{:?})", m.repr(tcx), code), + format!("Method({},{:?})", m.repr(), code), } } } diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index 71946aa79ce3a..ef89dc384bbd9 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -77,7 +77,7 @@ pub fn poly_project_and_unify_type<'cx,'tcx>( -> Result>>, MismatchedProjectionTypes<'tcx>> { debug!("poly_project_and_unify_type(obligation={})", - obligation.repr(selcx.tcx())); + obligation.repr()); let infcx = selcx.infcx(); infcx.commit_if_ok(|snapshot| { @@ -110,7 +110,7 @@ fn project_and_unify_type<'cx,'tcx>( -> Result>>, MismatchedProjectionTypes<'tcx>> { debug!("project_and_unify_type(obligation={})", - obligation.repr(selcx.tcx())); + obligation.repr()); let Normalized { value: normalized_ty, obligations } = match opt_normalize_projection_type(selcx, @@ -125,8 +125,8 @@ fn project_and_unify_type<'cx,'tcx>( }; debug!("project_and_unify_type: normalized_ty={} obligations={}", - normalized_ty.repr(selcx.tcx()), - obligations.repr(selcx.tcx())); + normalized_ty.repr(), + obligations.repr()); let infcx = selcx.infcx(); let origin = infer::RelateOutputImplTypes(obligation.cause.span); @@ -139,7 +139,7 @@ fn project_and_unify_type<'cx,'tcx>( fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext<'cx,'tcx>, obligation: &ProjectionObligation<'tcx>) { debug!("consider_unification_despite_ambiguity(obligation={})", - obligation.repr(selcx.tcx())); + obligation.repr()); let def_id = obligation.predicate.projection_ty.trait_ref.def_id; match selcx.tcx().lang_items.fn_trait_kind(def_id) { @@ -173,7 +173,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext &ty::Binder(ret_type)); debug!("consider_unification_despite_ambiguity: ret_type={:?}", - ret_type.repr(selcx.tcx())); + ret_type.repr()); let origin = infer::RelateOutputImplTypes(obligation.cause.span); let obligation_ty = obligation.predicate.ty; match infer::mk_eqty(infcx, true, origin, obligation_ty, ret_type) { @@ -193,7 +193,7 @@ pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>, cause: ObligationCause<'tcx>, value: &T) -> Normalized<'tcx, T> - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx> + where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr { normalize_with_depth(selcx, cause, 0, value) } @@ -204,7 +204,7 @@ pub fn normalize_with_depth<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tc depth: usize, value: &T) -> Normalized<'tcx, T> - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx> + where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr { let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth); let result = normalizer.fold(value); @@ -356,7 +356,7 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( debug!("normalize_projection_type(\ projection_ty={}, \ depth={})", - projection_ty.repr(selcx.tcx()), + projection_ty.repr(), depth); let obligation = Obligation::with_depth(cause.clone(), depth, projection_ty.clone()); @@ -368,9 +368,9 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( // re-normalize it debug!("normalize_projection_type: projected_ty={} depth={} obligations={}", - projected_ty.repr(selcx.tcx()), + projected_ty.repr(), depth, - obligations.repr(selcx.tcx())); + obligations.repr()); if ty::type_has_projection(projected_ty) { let tcx = selcx.tcx(); @@ -378,7 +378,7 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( let normalized_ty = normalizer.fold(&projected_ty); debug!("normalize_projection_type: normalized_ty={} depth={}", - normalized_ty.repr(tcx), + normalized_ty.repr(), depth); obligations.extend(normalizer.obligations); @@ -395,7 +395,7 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( } Ok(ProjectedTy::NoProgress(projected_ty)) => { debug!("normalize_projection_type: projected_ty={} no progress", - projected_ty.repr(selcx.tcx())); + projected_ty.repr()); Some(Normalized { value: projected_ty, obligations: vec!() @@ -450,7 +450,7 @@ fn project_type<'cx,'tcx>( -> Result, ProjectionTyError<'tcx>> { debug!("project(obligation={})", - obligation.repr(selcx.tcx())); + obligation.repr()); let recursion_limit = selcx.tcx().sess.recursion_limit.get(); if obligation.recursion_depth >= recursion_limit { @@ -461,7 +461,7 @@ fn project_type<'cx,'tcx>( let obligation_trait_ref = selcx.infcx().resolve_type_vars_if_possible(&obligation.predicate.trait_ref); - debug!("project: obligation_trait_ref={}", obligation_trait_ref.repr(selcx.tcx())); + debug!("project: obligation_trait_ref={}", obligation_trait_ref.repr()); if obligation_trait_ref.references_error() { return Ok(ProjectedTy::Progress(selcx.tcx().types.err, vec!())); @@ -590,11 +590,11 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>( where I: Iterator> { debug!("assemble_candidates_from_predicates(obligation={})", - obligation.repr(selcx.tcx())); + obligation.repr()); let infcx = selcx.infcx(); for predicate in env_predicates { debug!("assemble_candidates_from_predicates: predicate={}", - predicate.repr(selcx.tcx())); + predicate.repr()); match predicate { ty::Predicate::Projection(ref data) => { let same_name = data.item_name() == obligation.predicate.item_name; @@ -612,7 +612,7 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>( }); debug!("assemble_candidates_from_predicates: candidate {} is_match {} same_name {}", - data.repr(selcx.tcx()), + data.repr(), is_match, same_name); @@ -635,14 +635,14 @@ fn assemble_candidates_from_object_type<'cx,'tcx>( { let infcx = selcx.infcx(); debug!("assemble_candidates_from_object_type(object_ty={})", - object_ty.repr(infcx.tcx)); + object_ty.repr()); let data = match object_ty.sty { ty::TyTrait(ref data) => data, _ => { selcx.tcx().sess.span_bug( obligation.cause.span, &format!("assemble_candidates_from_object_type called with non-object: {}", - object_ty.repr(selcx.tcx()))); + object_ty.repr())); } }; let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty); @@ -673,7 +673,7 @@ fn assemble_candidates_from_impls<'cx,'tcx>( } Err(e) => { debug!("assemble_candidates_from_impls: selection error {}", - e.repr(selcx.tcx())); + e.repr()); return Err(e); } }; @@ -681,7 +681,7 @@ fn assemble_candidates_from_impls<'cx,'tcx>( match vtable { super::VtableImpl(data) => { debug!("assemble_candidates_from_impls: impl candidate {}", - data.repr(selcx.tcx())); + data.repr()); candidate_set.vec.push( ProjectionTyCandidate::Impl(data)); @@ -732,7 +732,7 @@ fn assemble_candidates_from_impls<'cx,'tcx>( selcx.tcx().sess.span_bug( obligation.cause.span, &format!("Cannot project an associated type from `{}`", - vtable.repr(selcx.tcx()))); + vtable.repr())); } } @@ -748,8 +748,8 @@ fn confirm_candidate<'cx,'tcx>( let infcx = selcx.infcx(); debug!("confirm_candidate(candidate={}, obligation={})", - candidate.repr(infcx.tcx), - obligation.repr(infcx.tcx)); + candidate.repr(), + obligation.repr()); match candidate { ProjectionTyCandidate::ParamEnv(poly_projection) => { @@ -814,8 +814,8 @@ fn confirm_callable_candidate<'cx,'tcx>( let tcx = selcx.tcx(); debug!("confirm_callable_candidate({},{})", - obligation.repr(tcx), - fn_sig.repr(tcx)); + obligation.repr(), + fn_sig.repr()); // the `Output` associated type is declared on `FnOnce` let fn_once_def_id = tcx.lang_items.fn_once_trait().unwrap(); @@ -866,8 +866,8 @@ fn confirm_param_env_candidate<'cx,'tcx>( selcx.tcx().sess.span_bug( obligation.cause.span, &format!("Failed to unify `{}` and `{}` in projection: {}", - obligation.repr(selcx.tcx()), - projection.repr(selcx.tcx()), + obligation.repr(), + projection.repr(), ty::type_err_to_str(selcx.tcx(), &e))); } } @@ -916,31 +916,31 @@ fn confirm_impl_candidate<'cx,'tcx>( selcx.tcx().sess.span_bug(obligation.cause.span, &format!("No associated type for {}", - trait_ref.repr(selcx.tcx()))); + trait_ref.repr())); } -impl<'tcx> Repr<'tcx> for ProjectionTyError<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for ProjectionTyError<'tcx> { + fn repr(&self) -> String { match *self { ProjectionTyError::TooManyCandidates => format!("NoCandidate"), ProjectionTyError::TraitSelectionError(ref e) => - format!("TraitSelectionError({})", e.repr(tcx)), + format!("TraitSelectionError({})", e.repr()), } } } -impl<'tcx> Repr<'tcx> for ProjectionTyCandidate<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for ProjectionTyCandidate<'tcx> { + fn repr(&self) -> String { match *self { ProjectionTyCandidate::ParamEnv(ref data) => - format!("ParamEnv({})", data.repr(tcx)), + format!("ParamEnv({})", data.repr()), ProjectionTyCandidate::Impl(ref data) => - format!("Impl({})", data.repr(tcx)), + format!("Impl({})", data.repr()), ProjectionTyCandidate::Closure(ref data) => - format!("Closure({})", data.repr(tcx)), + format!("Closure({})", data.repr()), ProjectionTyCandidate::FnPointer(a) => - format!("FnPointer(({}))", a.repr(tcx)), + format!("FnPointer(({}))", a.repr()), } } } @@ -954,10 +954,10 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> { } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Normalized<'tcx, T> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx, T:Repr> Repr for Normalized<'tcx, T> { + fn repr(&self) -> String { format!("Normalized({},{})", - self.value.repr(tcx), - self.obligations.repr(tcx)) + self.value.repr(), + self.obligations.repr()) } } diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 8e2a90aa80884..ea5d789683f41 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -298,7 +298,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { /// type environment by performing unification. pub fn select(&mut self, obligation: &TraitObligation<'tcx>) -> SelectionResult<'tcx, Selection<'tcx>> { - debug!("select({})", obligation.repr(self.tcx())); + debug!("select({})", obligation.repr()); assert!(!obligation.predicate.has_escaping_regions()); let stack = self.push_stack(TraitObligationStackList::empty(), obligation); @@ -388,7 +388,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> bool { debug!("evaluate_obligation({})", - obligation.repr(self.tcx())); + obligation.repr()); self.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation) .may_apply() @@ -441,7 +441,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> EvaluationResult<'tcx> { debug!("evaluate_predicate_recursively({})", - obligation.repr(self.tcx())); + obligation.repr()); // Check the cache from the tcx of predicates that we know // have been proven elsewhere. This cache only contains @@ -500,7 +500,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> EvaluationResult<'tcx> { debug!("evaluate_obligation_recursively({})", - obligation.repr(self.tcx())); + obligation.repr()); let stack = self.push_stack(previous_stack, obligation); @@ -548,7 +548,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { &prev.fresh_trait_ref))) { debug!("evaluate_stack({}) --> unbound argument, recursion --> ambiguous", - stack.fresh_trait_ref.repr(self.tcx())); + stack.fresh_trait_ref.repr()); return EvaluatedToAmbig; } @@ -577,7 +577,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { .any(|prev| stack.fresh_trait_ref == prev.fresh_trait_ref) { debug!("evaluate_stack({}) --> recursive", - stack.fresh_trait_ref.repr(self.tcx())); + stack.fresh_trait_ref.repr()); return EvaluatedToOk; } @@ -596,8 +596,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> bool { debug!("evaluate_impl(impl_def_id={}, obligation={})", - impl_def_id.repr(self.tcx()), - obligation.repr(self.tcx())); + impl_def_id.repr(), + obligation.repr()); self.infcx.probe(|snapshot| { match self.match_impl(impl_def_id, obligation, snapshot) { @@ -644,15 +644,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let cache_fresh_trait_pred = self.infcx.freshen(stack.obligation.predicate.clone()); debug!("candidate_from_obligation(cache_fresh_trait_pred={}, obligation={})", - cache_fresh_trait_pred.repr(self.tcx()), - stack.repr(self.tcx())); + cache_fresh_trait_pred.repr(), + stack.repr()); assert!(!stack.obligation.predicate.has_escaping_regions()); match self.check_candidate_cache(&cache_fresh_trait_pred) { Some(c) => { debug!("CACHE HIT: cache_fresh_trait_pred={}, candidate={}", - cache_fresh_trait_pred.repr(self.tcx()), - c.repr(self.tcx())); + cache_fresh_trait_pred.repr(), + c.repr()); return c; } None => { } @@ -663,7 +663,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { if self.should_update_candidate_cache(&cache_fresh_trait_pred, &candidate) { debug!("CACHE MISS: cache_fresh_trait_pred={}, candidate={}", - cache_fresh_trait_pred.repr(self.tcx()), candidate.repr(self.tcx())); + cache_fresh_trait_pred.repr(), candidate.repr()); self.insert_candidate_cache(cache_fresh_trait_pred, candidate.clone()); } @@ -694,8 +694,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug!("assembled {} candidates for {}: {}", candidates.len(), - stack.repr(self.tcx()), - candidates.repr(self.tcx())); + stack.repr(), + candidates.repr()); // At this point, we know that each of the entries in the // candidate set is *individually* applicable. Now we have to @@ -736,11 +736,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { &candidates[j])); if is_dup { debug!("Dropping candidate #{}/{}: {}", - i, candidates.len(), candidates[i].repr(self.tcx())); + i, candidates.len(), candidates[i].repr()); candidates.swap_remove(i); } else { debug!("Retaining candidate #{}/{}: {}", - i, candidates.len(), candidates[i].repr(self.tcx())); + i, candidates.len(), candidates[i].repr()); i += 1; } } @@ -907,7 +907,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { match self.tcx().lang_items.to_builtin_kind(obligation.predicate.def_id()) { Some(ty::BoundCopy) => { debug!("obligation self ty is {}", - obligation.predicate.0.self_ty().repr(self.tcx())); + obligation.predicate.0.self_ty().repr()); // User-defined copy impls are permitted, but only for // structs and enums. @@ -958,8 +958,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx().resolve_type_vars_if_possible(&obligation.predicate); debug!("assemble_candidates_for_projected_tys({},{})", - obligation.repr(self.tcx()), - poly_trait_predicate.repr(self.tcx())); + obligation.repr(), + poly_trait_predicate.repr()); // FIXME(#20297) -- just examining the self-type is very simplistic @@ -982,7 +982,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }; debug!("assemble_candidates_for_projected_tys: trait_def_id={}", - trait_def_id.repr(self.tcx())); + trait_def_id.repr()); let result = self.infcx.probe(|snapshot| { self.match_projection_obligation_against_bounds_from_trait(obligation, @@ -1006,8 +1006,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx().skolemize_late_bound_regions(&poly_trait_predicate, snapshot); debug!("match_projection_obligation_against_bounds_from_trait: \ skol_trait_predicate={} skol_map={}", - skol_trait_predicate.repr(self.tcx()), - skol_map.repr(self.tcx())); + skol_trait_predicate.repr(), + skol_map.repr()); let projection_trait_ref = match skol_trait_predicate.trait_ref.self_ty().sty { ty::TyProjection(ref data) => &data.trait_ref, @@ -1016,18 +1016,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation.cause.span, &format!("match_projection_obligation_against_bounds_from_trait() called \ but self-ty not a projection: {}", - skol_trait_predicate.trait_ref.self_ty().repr(self.tcx()))); + skol_trait_predicate.trait_ref.self_ty().repr())); } }; debug!("match_projection_obligation_against_bounds_from_trait: \ projection_trait_ref={}", - projection_trait_ref.repr(self.tcx())); + projection_trait_ref.repr()); let trait_predicates = ty::lookup_predicates(self.tcx(), projection_trait_ref.def_id); let bounds = trait_predicates.instantiate(self.tcx(), projection_trait_ref.substs); debug!("match_projection_obligation_against_bounds_from_trait: \ bounds={}", - bounds.repr(self.tcx())); + bounds.repr()); let matching_bound = util::elaborate_predicates(self.tcx(), bounds.predicates.into_vec()) @@ -1042,7 +1042,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug!("match_projection_obligation_against_bounds_from_trait: \ matching_bound={}", - matching_bound.repr(self.tcx())); + matching_bound.repr()); match matching_bound { None => false, Some(bound) => { @@ -1089,7 +1089,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Result<(),SelectionError<'tcx>> { debug!("assemble_candidates_from_caller_bounds({})", - stack.obligation.repr(self.tcx())); + stack.obligation.repr()); let all_bounds = self.param_env().caller_bounds @@ -1156,9 +1156,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }; debug!("assemble_unboxed_candidates: self_ty={} kind={:?} obligation={}", - self_ty.repr(self.tcx()), + self_ty.repr(), kind, - obligation.repr(self.tcx())); + obligation.repr()); match self.closure_typer.closure_kind(closure_def_id) { Some(closure_kind) => { @@ -1221,7 +1221,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidates: &mut SelectionCandidateSet<'tcx>) -> Result<(), SelectionError<'tcx>> { - debug!("assemble_candidates_from_impls(obligation={})", obligation.repr(self.tcx())); + debug!("assemble_candidates_from_impls(obligation={})", obligation.repr()); let def = ty::lookup_trait_def(self.tcx(), obligation.predicate.def_id()); @@ -1247,7 +1247,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { { // OK to skip binder here because the tests we do below do not involve bound regions let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()); - debug!("assemble_candidates_from_default_impls(self_ty={})", self_ty.repr(self.tcx())); + debug!("assemble_candidates_from_default_impls(self_ty={})", self_ty.repr()); let def_id = obligation.predicate.def_id(); @@ -1317,7 +1317,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidates: &mut SelectionCandidateSet<'tcx>) { debug!("assemble_candidates_from_object_ty(self_ty={})", - self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()).repr(self.tcx())); + self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()).repr()); // Object-safety candidates are only applicable to object-safe // traits. Including this check is useful because it helps @@ -1363,7 +1363,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }; debug!("assemble_candidates_from_object_ty: poly_trait_ref={}", - poly_trait_ref.repr(self.tcx())); + poly_trait_ref.repr()); // see whether the object trait can be upcast to the trait we are looking for let upcast_trait_refs = self.upcast(poly_trait_ref, obligation); @@ -1407,7 +1407,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]); debug!("assemble_candidates_for_unsizing(source={}, target={})", - source.repr(self.tcx()), target.repr(self.tcx())); + source.repr(), target.repr()); let may_apply = match (&source.sty, &target.sty) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). @@ -1473,7 +1473,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidate: &SelectionCandidate<'tcx>) -> EvaluationResult<'tcx> { - debug!("winnow_candidate: candidate={}", candidate.repr(self.tcx())); + debug!("winnow_candidate: candidate={}", candidate.repr()); let result = self.infcx.probe(|_| { let candidate = (*candidate).clone(); match self.confirm_candidate(stack.obligation, candidate) { @@ -1566,7 +1566,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { match self.builtin_bound(bound, stack.obligation) { Ok(If(..)) => { debug!("builtin_bound: bound={}", - bound.repr(self.tcx())); + bound.repr()); candidates.vec.push(BuiltinCandidate(bound)); Ok(()) } @@ -1775,7 +1775,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.tcx().sess.bug( &format!( "asked to assemble builtin bounds of unexpected type: {}", - self_ty.repr(self.tcx()))); + self_ty.repr())); } }; @@ -1838,7 +1838,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.tcx().sess.bug( &format!( "asked to assemble constituent types of unexpected type: {}", - t.repr(self.tcx()))); + t.repr())); } ty::TyBox(referent_ty) => { // Box @@ -1973,8 +1973,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Result,SelectionError<'tcx>> { debug!("confirm_candidate({}, {})", - obligation.repr(self.tcx()), - candidate.repr(self.tcx())); + obligation.repr(), + candidate.repr()); match candidate { BuiltinCandidate(builtin_bound) => { @@ -2065,8 +2065,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Vec> { debug!("confirm_param_candidate({},{})", - obligation.repr(self.tcx()), - param.repr(self.tcx())); + obligation.repr(), + param.repr()); // During evaluation, we already checked that this // where-clause trait-ref could be unified with the obligation @@ -2077,8 +2077,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Err(()) => { self.tcx().sess.bug( &format!("Where clause `{}` was applicable to `{}` but now is not", - param.repr(self.tcx()), - obligation.repr(self.tcx()))); + param.repr(), + obligation.repr())); } } } @@ -2090,7 +2090,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { SelectionError<'tcx>> { debug!("confirm_builtin_candidate({})", - obligation.repr(self.tcx())); + obligation.repr()); match try!(self.builtin_bound(bound, obligation)) { If(nested) => Ok(self.vtable_builtin_data(obligation, bound, nested)), @@ -2098,7 +2098,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.tcx().sess.span_bug( obligation.cause.span, &format!("builtin bound for {} was ambig", - obligation.repr(self.tcx()))); + obligation.repr())); } } } @@ -2119,7 +2119,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let obligations = self.collect_predicates_for_types(obligation, trait_def, nested); debug!("vtable_builtin_data: obligations={}", - obligations.repr(self.tcx())); + obligations.repr()); VtableBuiltinData { nested: obligations } } @@ -2135,8 +2135,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> VtableDefaultImplData> { debug!("confirm_default_impl_candidate({}, {})", - obligation.repr(self.tcx()), - trait_def_id.repr(self.tcx())); + obligation.repr(), + trait_def_id.repr()); // binder is moved below let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty()); @@ -2146,7 +2146,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.tcx().sess.bug( &format!( "asked to confirm default implementation for ambiguous type: {}", - self_ty.repr(self.tcx()))); + self_ty.repr())); } } } @@ -2157,8 +2157,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> VtableDefaultImplData> { debug!("confirm_default_impl_object_candidate({}, {})", - obligation.repr(self.tcx()), - trait_def_id.repr(self.tcx())); + obligation.repr(), + trait_def_id.repr()); assert!(ty::has_attr(self.tcx(), trait_def_id, "rustc_reflect_like")); @@ -2185,7 +2185,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.tcx().sess.bug( &format!( "asked to confirm default object implementation for non-object type: {}", - self_ty.repr(self.tcx()))); + self_ty.repr())); } } } @@ -2197,7 +2197,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { nested: ty::Binder>>) -> VtableDefaultImplData> { - debug!("vtable_default_impl_data: nested={}", nested.repr(self.tcx())); + debug!("vtable_default_impl_data: nested={}", nested.repr()); let mut obligations = self.collect_predicates_for_types(obligation, trait_def_id, @@ -2218,7 +2218,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // no Errors in that code above obligations.append(&mut trait_obligations.unwrap()); - debug!("vtable_default_impl_data: obligations={}", obligations.repr(self.tcx())); + debug!("vtable_default_impl_data: obligations={}", obligations.repr()); VtableDefaultImplData { trait_def_id: trait_def_id, @@ -2233,8 +2233,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { SelectionError<'tcx>> { debug!("confirm_impl_candidate({},{})", - obligation.repr(self.tcx()), - impl_def_id.repr(self.tcx())); + obligation.repr(), + impl_def_id.repr()); // First, create the substitutions by matching the impl again, // this time not in a probe. @@ -2242,7 +2242,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let (substs, skol_map) = self.rematch_impl(impl_def_id, obligation, snapshot); - debug!("confirm_impl_candidate substs={}", substs.repr(self.tcx())); + debug!("confirm_impl_candidate substs={}", substs.repr()); Ok(self.vtable_impl(impl_def_id, substs, obligation.cause.clone(), obligation.recursion_depth + 1, skol_map, snapshot)) }) @@ -2258,10 +2258,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> VtableImplData<'tcx, PredicateObligation<'tcx>> { debug!("vtable_impl(impl_def_id={}, substs={}, recursion_depth={}, skol_map={})", - impl_def_id.repr(self.tcx()), - substs.repr(self.tcx()), + impl_def_id.repr(), + substs.repr(), recursion_depth, - skol_map.repr(self.tcx())); + skol_map.repr()); let mut impl_obligations = self.impl_or_trait_obligations(cause, @@ -2272,8 +2272,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { snapshot); debug!("vtable_impl: impl_def_id={} impl_obligations={}", - impl_def_id.repr(self.tcx()), - impl_obligations.repr(self.tcx())); + impl_def_id.repr(), + impl_obligations.repr()); impl_obligations.append(&mut substs.obligations); @@ -2287,7 +2287,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> VtableObjectData<'tcx> { debug!("confirm_object_candidate({})", - obligation.repr(self.tcx())); + obligation.repr()); // FIXME skipping binder here seems wrong -- we should // probably flatten the binder from the obligation and the @@ -2329,7 +2329,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Result,SelectionError<'tcx>> { debug!("confirm_fn_pointer_candidate({})", - obligation.repr(self.tcx())); + obligation.repr()); // ok to skip binder; it is reintroduced below let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()); @@ -2356,9 +2356,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { SelectionError<'tcx>> { debug!("confirm_closure_candidate({},{},{})", - obligation.repr(self.tcx()), - closure_def_id.repr(self.tcx()), - substs.repr(self.tcx())); + obligation.repr(), + closure_def_id.repr(), + substs.repr()); let Normalized { value: trait_ref, @@ -2366,9 +2366,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } = self.closure_trait_ref(obligation, closure_def_id, substs); debug!("confirm_closure_candidate(closure_def_id={}, trait_ref={}, obligations={})", - closure_def_id.repr(self.tcx()), - trait_ref.repr(self.tcx()), - obligations.repr(self.tcx())); + closure_def_id.repr(), + trait_ref.repr(), + obligations.repr()); try!(self.confirm_poly_trait_refs(obligation.cause.clone(), obligation.predicate.to_poly_trait_ref(), @@ -2437,7 +2437,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]); debug!("confirm_builtin_unsize_candidate(source={}, target={})", - source.repr(tcx), target.repr(tcx)); + source.repr(), target.repr()); let mut nested = vec![]; match (&source.sty, &target.sty) { @@ -2614,8 +2614,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Err(()) => { self.tcx().sess.bug( &format!("Impl {} was matchable against {} but now is not", - impl_def_id.repr(self.tcx()), - obligation.repr(self.tcx()))); + impl_def_id.repr(), + obligation.repr())); } } } @@ -2656,10 +2656,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { debug!("match_impl(impl_def_id={}, obligation={}, \ impl_trait_ref={}, skol_obligation_trait_ref={})", - impl_def_id.repr(self.tcx()), - obligation.repr(self.tcx()), - impl_trait_ref.repr(self.tcx()), - skol_obligation_trait_ref.repr(self.tcx())); + impl_def_id.repr(), + obligation.repr(), + impl_trait_ref.repr(), + skol_obligation_trait_ref.repr()); let origin = infer::RelateOutputImplTypes(obligation.cause.span); if let Err(e) = self.infcx.sub_trait_refs(false, @@ -2677,7 +2677,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { return Err(()); } - debug!("match_impl: success impl_substs={}", impl_substs.repr(self.tcx())); + debug!("match_impl: success impl_substs={}", impl_substs.repr()); Ok((Normalized { value: impl_substs, obligations: impl_trait_ref.obligations @@ -2729,8 +2729,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Result<(),()> { debug!("match_poly_trait_ref: obligation={} poly_trait_ref={}", - obligation.repr(self.tcx()), - poly_trait_ref.repr(self.tcx())); + obligation.repr(), + poly_trait_ref.repr()); let origin = infer::RelateOutputImplTypes(obligation.cause.span); match self.infcx.sub_poly_trait_refs(false, @@ -2770,14 +2770,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let impl_self_ty = impl_self_ty.subst(self.tcx(), &impl_substs); debug!("match_impl_self_types(obligation_self_ty={}, impl_self_ty={})", - obligation_self_ty.repr(self.tcx()), - impl_self_ty.repr(self.tcx())); + obligation_self_ty.repr(), + impl_self_ty.repr()); match self.match_self_types(obligation_cause, impl_self_ty, obligation_self_ty) { Ok(()) => { - debug!("Matched impl_substs={}", impl_substs.repr(self.tcx())); + debug!("Matched impl_substs={}", impl_substs.repr()); Ok(impl_substs) } Err(()) => { @@ -2889,7 +2889,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { snapshot: &infer::CombinedSnapshot) -> Vec> { - debug!("impl_or_trait_obligations(def_id={})", def_id.repr(self.tcx())); + debug!("impl_or_trait_obligations(def_id={})", def_id.repr()); let predicates = ty::lookup_predicates(self.tcx(), def_id); let predicates = predicates.instantiate(self.tcx(), substs); @@ -2941,8 +2941,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Vec> { debug!("upcast(obj_trait_ref={}, obligation={})", - obj_trait_ref.repr(self.tcx()), - obligation.repr(self.tcx())); + obj_trait_ref.repr(), + obligation.repr()); let obligation_def_id = obligation.predicate.def_id(); let mut upcast_trait_refs = util::upcast(self.tcx(), obj_trait_ref, obligation_def_id); @@ -2958,28 +2958,28 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx.probe(|_| self.match_poly_trait_ref(obligation, upcast_trait_ref)).is_ok() }); - debug!("upcast: upcast_trait_refs={}", upcast_trait_refs.repr(self.tcx())); + debug!("upcast: upcast_trait_refs={}", upcast_trait_refs.repr()); upcast_trait_refs } } -impl<'tcx> Repr<'tcx> for SelectionCandidate<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for SelectionCandidate<'tcx> { + fn repr(&self) -> String { match *self { PhantomFnCandidate => format!("PhantomFnCandidate"), ErrorCandidate => format!("ErrorCandidate"), BuiltinCandidate(b) => format!("BuiltinCandidate({:?})", b), BuiltinObjectCandidate => format!("BuiltinObjectCandidate"), BuiltinUnsizeCandidate => format!("BuiltinUnsizeCandidate"), - ParamCandidate(ref a) => format!("ParamCandidate({})", a.repr(tcx)), - ImplCandidate(a) => format!("ImplCandidate({})", a.repr(tcx)), + ParamCandidate(ref a) => format!("ParamCandidate({})", a.repr()), + ImplCandidate(a) => format!("ImplCandidate({})", a.repr()), DefaultImplCandidate(t) => format!("DefaultImplCandidate({:?})", t), DefaultImplObjectCandidate(t) => format!("DefaultImplObjectCandidate({:?})", t), ProjectionCandidate => format!("ProjectionCandidate"), FnPointerCandidate => format!("FnPointerCandidate"), ObjectCandidate => format!("ObjectCandidate"), ClosureCandidate(c, ref s) => { - format!("ClosureCandidate({:?},{})", c, s.repr(tcx)) + format!("ClosureCandidate({:?},{})", c, s.repr()) } } } @@ -3032,10 +3032,10 @@ impl<'o,'tcx> Iterator for TraitObligationStackList<'o,'tcx>{ } } -impl<'o,'tcx> Repr<'tcx> for TraitObligationStack<'o,'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'o,'tcx> Repr for TraitObligationStack<'o,'tcx> { + fn repr(&self) -> String { format!("TraitObligationStack({})", - self.obligation.repr(tcx)) + self.obligation.repr()) } } diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index c1205d4a46d81..a3ce5a90c2b04 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -126,7 +126,7 @@ impl<'cx, 'tcx> Elaborator<'cx, 'tcx> { .collect(); debug!("super_predicates: data={} predicates={}", - data.repr(self.tcx), predicates.repr(self.tcx)); + data.repr(), predicates.repr()); // Only keep those bounds that we haven't already // seen. This is necessary to prevent infinite @@ -328,7 +328,7 @@ pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>, -> Vec> { debug!("predicates_for_generics(generic_bounds={})", - generic_bounds.repr(tcx)); + generic_bounds.repr()); generic_bounds.predicates.iter().map(|predicate| { Obligation { cause: cause.clone(), @@ -486,116 +486,116 @@ pub fn closure_trait_ref_and_return_type<'tcx>( ty::Binder((trait_ref, sig.0.output.unwrap_or(ty::mk_nil(tcx)))) } -impl<'tcx,O:Repr<'tcx>> Repr<'tcx> for super::Obligation<'tcx, O> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx,O:Repr> Repr for super::Obligation<'tcx, O> { + fn repr(&self) -> String { format!("Obligation(predicate={},depth={})", - self.predicate.repr(tcx), + self.predicate.repr(), self.recursion_depth) } } -impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::Vtable<'tcx, N> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx, N:Repr> Repr for super::Vtable<'tcx, N> { + fn repr(&self) -> String { match *self { super::VtableImpl(ref v) => - v.repr(tcx), + v.repr(), super::VtableDefaultImpl(ref t) => - t.repr(tcx), + t.repr(), super::VtableClosure(ref d) => - d.repr(tcx), + d.repr(), super::VtableFnPointer(ref d) => format!("VtableFnPointer({})", - d.repr(tcx)), + d.repr()), super::VtableObject(ref d) => format!("VtableObject({})", - d.repr(tcx)), + d.repr()), super::VtableParam(ref n) => format!("VtableParam({})", - n.repr(tcx)), + n.repr()), super::VtableBuiltin(ref d) => - d.repr(tcx) + d.repr() } } } -impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableImplData<'tcx, N> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx, N:Repr> Repr for super::VtableImplData<'tcx, N> { + fn repr(&self) -> String { format!("VtableImpl(impl_def_id={}, substs={}, nested={})", - self.impl_def_id.repr(tcx), - self.substs.repr(tcx), - self.nested.repr(tcx)) + self.impl_def_id.repr(), + self.substs.repr(), + self.nested.repr()) } } -impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableClosureData<'tcx, N> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx, N:Repr> Repr for super::VtableClosureData<'tcx, N> { + fn repr(&self) -> String { format!("VtableClosure(closure_def_id={}, substs={}, nested={})", - self.closure_def_id.repr(tcx), - self.substs.repr(tcx), - self.nested.repr(tcx)) + self.closure_def_id.repr(), + self.substs.repr(), + self.nested.repr()) } } -impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableBuiltinData { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx, N:Repr> Repr for super::VtableBuiltinData { + fn repr(&self) -> String { format!("VtableBuiltin(nested={})", - self.nested.repr(tcx)) + self.nested.repr()) } } -impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::VtableDefaultImplData { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx, N:Repr> Repr for super::VtableDefaultImplData { + fn repr(&self) -> String { format!("VtableDefaultImplData(trait_def_id={}, nested={})", - self.trait_def_id.repr(tcx), - self.nested.repr(tcx)) + self.trait_def_id.repr(), + self.nested.repr()) } } -impl<'tcx> Repr<'tcx> for super::VtableObjectData<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for super::VtableObjectData<'tcx> { + fn repr(&self) -> String { format!("VtableObject(object_ty={})", - self.object_ty.repr(tcx)) + self.object_ty.repr()) } } -impl<'tcx> Repr<'tcx> for super::SelectionError<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for super::SelectionError<'tcx> { + fn repr(&self) -> String { match *self { super::Unimplemented => format!("Unimplemented"), super::OutputTypeParameterMismatch(ref a, ref b, ref c) => format!("OutputTypeParameterMismatch({},{},{})", - a.repr(tcx), - b.repr(tcx), - c.repr(tcx)), + a.repr(), + b.repr(), + c.repr()), super::TraitNotObjectSafe(ref tr) => format!("TraitNotObjectSafe({})", - tr.repr(tcx)) + tr.repr()) } } } -impl<'tcx> Repr<'tcx> for super::FulfillmentError<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for super::FulfillmentError<'tcx> { + fn repr(&self) -> String { format!("FulfillmentError({},{})", - self.obligation.repr(tcx), - self.code.repr(tcx)) + self.obligation.repr(), + self.code.repr()) } } -impl<'tcx> Repr<'tcx> for super::FulfillmentErrorCode<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for super::FulfillmentErrorCode<'tcx> { + fn repr(&self) -> String { match *self { - super::CodeSelectionError(ref o) => o.repr(tcx), - super::CodeProjectionError(ref o) => o.repr(tcx), + super::CodeSelectionError(ref o) => o.repr(), + super::CodeProjectionError(ref o) => o.repr(), super::CodeAmbiguity => format!("Ambiguity") } } @@ -611,9 +611,9 @@ impl<'tcx> fmt::Debug for super::FulfillmentErrorCode<'tcx> { } } -impl<'tcx> Repr<'tcx> for super::MismatchedProjectionTypes<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { - self.err.repr(tcx) +impl<'tcx> Repr for super::MismatchedProjectionTypes<'tcx> { + fn repr(&self) -> String { + self.err.repr() } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2a0c224ad807a..e9f1fbeef9000 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2786,7 +2786,7 @@ impl<'tcx> TraitDef<'tcx> { impl_def_id: DefId, impl_trait_ref: TraitRef<'tcx>) { debug!("TraitDef::record_impl for {}, from {}", - self.repr(tcx), impl_trait_ref.repr(tcx)); + self.repr(), impl_trait_ref.repr()); // We don't want to borrow_mut after we already populated all impls, // so check if an impl is present with an immutable borrow first. @@ -3710,7 +3710,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { TyArray(ty, _) | TySlice(ty) => ty, TyStr => mk_mach_uint(cx, ast::TyU8), _ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}", - ty.user_string(cx))), + ty.user_string())), } } @@ -4180,7 +4180,7 @@ fn type_impls_bound<'a,'tcx>(param_env: Option<&ParameterEnvironment<'a,'tcx>>, let is_impld = traits::type_known_to_meet_builtin_bound(&infcx, param_env, ty, bound, span); debug!("type_impls_bound({}, {:?}) = {:?}", - ty.repr(tcx), + ty.repr(), bound, is_impld); @@ -4282,19 +4282,19 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec, r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool { debug!("type_requires({}, {})?", - r_ty.repr(cx), ty.repr(cx)); + r_ty.repr(), ty.repr()); let r = r_ty == ty || subtypes_require(cx, seen, r_ty, ty); debug!("type_requires({}, {})? {:?}", - r_ty.repr(cx), ty.repr(cx), r); + r_ty.repr(), ty.repr(), r); return r; } fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec, r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool { debug!("subtypes_require({}, {})?", - r_ty.repr(cx), ty.repr(cx)); + r_ty.repr(), ty.repr()); let r = match ty.sty { // fixed length vectors need special treatment compared to @@ -4373,7 +4373,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { }; debug!("subtypes_require({}, {})? {:?}", - r_ty.repr(cx), ty.repr(cx), r); + r_ty.repr(), ty.repr(), r); return r; } @@ -4479,7 +4479,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span, seen: &mut Vec>, ty: Ty<'tcx>) -> Representability { - debug!("is_type_structurally_recursive: {}", ty.repr(cx)); + debug!("is_type_structurally_recursive: {}", ty.repr()); match ty.sty { TyStruct(did, _) | TyEnum(did, _) => { @@ -4499,8 +4499,8 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) Some(&seen_type) => { if same_struct_or_enum_def_id(seen_type, did) { debug!("SelfRecursive: {} contains {}", - seen_type.repr(cx), - ty.repr(cx)); + seen_type.repr(), + ty.repr()); return SelfRecursive; } } @@ -4519,8 +4519,8 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) for &seen_type in iter { if same_type(ty, seen_type) { debug!("ContainsRecursive: {} contains {}", - seen_type.repr(cx), - ty.repr(cx)); + seen_type.repr(), + ty.repr()); return ContainsRecursive; } } @@ -4540,14 +4540,14 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) } } - debug!("is_type_representable: {}", ty.repr(cx)); + debug!("is_type_representable: {}", ty.repr()); // To avoid a stack overflow when checking an enum variant or struct that // contains a different, structurally recursive type, maintain a stack // of seen types and check recursion for each of them (issues #3008, #3779). let mut seen: Vec = Vec::new(); let r = is_type_structurally_recursive(cx, sp, &mut seen, ty); - debug!("is_type_representable: {} is {:?}", ty.repr(cx), r); + debug!("is_type_representable: {} is {:?}", ty.repr(), r); r } @@ -4949,7 +4949,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>, _ => { cx.sess.bug( &format!("AdjustReifyFnPointer adjustment on non-fn-item: \ - {}", unadjusted_ty.repr(cx))); + {}", unadjusted_ty.repr())); } } } @@ -4990,7 +4990,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>, span, &format!("the {}th autoderef failed: {}", i, - adjusted_ty.user_string(cx)) + adjusted_ty.user_string()) ); } } @@ -5232,11 +5232,11 @@ pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem]) trait_items.iter().position(|m| m.name() == id) } -pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String { +pub fn ty_sort_string(cx: &ctxt, ty: Ty) -> String { match ty.sty { TyBool | TyChar | TyInt(_) | - TyUint(_) | TyFloat(_) | TyStr => ty.user_string(cx), - TyTuple(ref tys) if tys.is_empty() => ty.user_string(cx), + TyUint(_) | TyFloat(_) | TyStr => ty.user_string(), + TyTuple(ref tys) if tys.is_empty() => ty.user_string(), TyEnum(id, _) => format!("enum `{}`", item_path_str(cx, id)), TyBox(_) => "box".to_string(), @@ -5272,9 +5272,9 @@ pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String { } } -impl<'tcx> Repr<'tcx> for ty::type_err<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { - ty::type_err_to_str(tcx, self) +impl<'tcx> Repr for ty::type_err<'tcx> { + fn repr(&self) -> String { + tls::with(|tcx| ty::type_err_to_str(tcx, self)) } } @@ -5282,7 +5282,7 @@ impl<'tcx> Repr<'tcx> for ty::type_err<'tcx> { /// in parentheses after some larger message. You should also invoke `note_and_explain_type_err()` /// afterwards to present additional details, particularly when it comes to lifetime-related /// errors. -pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String { +pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String { match *err { terr_cyclic_ty => "cyclic type of infinite size".to_string(), terr_mismatch => "types differ".to_string(), @@ -5336,12 +5336,12 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String { terr_regions_insufficiently_polymorphic(br, _) => { format!("expected bound lifetime parameter {}, \ found concrete lifetime", - br.user_string(cx)) + br.user_string()) } terr_regions_overly_polymorphic(br, _) => { format!("expected concrete lifetime, \ found bound lifetime parameter {}", - br.user_string(cx)) + br.user_string()) } terr_sorts(values) => { // A naive approach to making sure that we're not reporting silly errors such as: @@ -5362,14 +5362,14 @@ pub fn type_err_to_str<'tcx>(cx: &ctxt<'tcx>, err: &type_err<'tcx>) -> String { terr_builtin_bounds(values) => { if values.expected.is_empty() { format!("expected no bounds, found `{}`", - values.found.user_string(cx)) + values.found.user_string()) } else if values.found.is_empty() { format!("expected bounds `{}`, found no bounds", - values.expected.user_string(cx)) + values.expected.user_string()) } else { format!("expected bounds `{}`, found bounds `{}`", - values.expected.user_string(cx), - values.found.user_string(cx)) + values.expected.user_string(), + values.found.user_string()) } } terr_integer_as_char => { @@ -6010,7 +6010,7 @@ fn report_discrim_overflow(cx: &ctxt, let computed_value = repr_type.disr_wrap_incr(Some(prev_val)); let computed_value = repr_type.disr_string(computed_value); let prev_val = repr_type.disr_string(prev_val); - let repr_type = repr_type.to_ty(cx).user_string(cx); + let repr_type = repr_type.to_ty(cx).user_string(); span_err!(cx.sess, variant_span, E0370, "enum discriminant overflowed on value after {}: {}; \ set explicitly via {} = {} if that is desired outcome", @@ -6503,8 +6503,8 @@ pub fn required_region_bounds<'tcx>(tcx: &ctxt<'tcx>, -> Vec { debug!("required_region_bounds(erased_self_ty={:?}, predicates={:?})", - erased_self_ty.repr(tcx), - predicates.repr(tcx)); + erased_self_ty.repr(), + predicates.repr()); assert!(!erased_self_ty.has_escaping_regions()); @@ -6622,7 +6622,7 @@ pub fn populate_implementations_for_trait_if_necessary(tcx: &ctxt, trait_id: ast return; } - debug!("populate_implementations_for_trait_if_necessary: searching for {}", def.repr(tcx)); + debug!("populate_implementations_for_trait_if_necessary: searching for {}", def.repr()); if csearch::is_defaulted_trait(&tcx.sess.cstore, trait_id) { record_trait_has_default_impl(tcx, trait_id); @@ -6931,7 +6931,7 @@ pub fn construct_free_substs<'a,'tcx>( defs: &[TypeParameterDef<'tcx>]) { for def in defs { debug!("construct_parameter_environment(): push_types_from_defs: def={:?}", - def.repr(tcx)); + def.repr()); let ty = ty::mk_param_from_def(tcx, def); types.push(def.space, ty); } @@ -6964,8 +6964,8 @@ pub fn construct_parameter_environment<'a,'tcx>( debug!("construct_parameter_environment: free_id={:?} free_subst={:?} predicates={:?}", free_id, - free_substs.repr(tcx), - predicates.repr(tcx)); + free_substs.repr(), + predicates.repr()); // // Finally, we have to normalize the bounds in the environment, in @@ -7221,7 +7221,7 @@ pub fn liberate_late_bound_regions<'tcx, T>( all_outlive_scope: region::DestructionScopeData, value: &Binder) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { ty_fold::replace_late_bound_regions( tcx, value, @@ -7232,7 +7232,7 @@ pub fn count_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> usize - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { let (_, skol_map) = ty_fold::replace_late_bound_regions(tcx, value, |_| ty::ReStatic); skol_map.len() @@ -7242,7 +7242,7 @@ pub fn binds_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> bool - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { count_late_bound_regions(tcx, value) > 0 } @@ -7253,7 +7253,7 @@ pub fn flatten_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, bound2_value: &Binder>) -> Binder - where T: TypeFoldable<'tcx> + Repr<'tcx> + where T: TypeFoldable<'tcx> + Repr { let bound0_value = bound2_value.skip_binder().skip_binder(); let value = ty_fold::fold_regions(tcx, bound0_value, |region, current_depth| { @@ -7275,7 +7275,7 @@ pub fn no_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> Option - where T : TypeFoldable<'tcx> + Repr<'tcx> + Clone + where T : TypeFoldable<'tcx> + Repr + Clone { if binds_late_bound_regions(tcx, value) { None @@ -7290,7 +7290,7 @@ pub fn erase_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { ty_fold::replace_late_bound_regions(tcx, value, |_| ty::ReStatic).0 } @@ -7307,7 +7307,7 @@ pub fn anonymize_late_bound_regions<'tcx, T>( tcx: &ctxt<'tcx>, sig: &Binder) -> Binder - where T : TypeFoldable<'tcx> + Repr<'tcx>, + where T : TypeFoldable<'tcx> + Repr, { let mut counter = 0; ty::Binder(ty_fold::replace_late_bound_regions(tcx, sig, |_| { @@ -7327,8 +7327,8 @@ impl DebruijnIndex { } } -impl<'tcx> Repr<'tcx> for AutoAdjustment<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for AutoAdjustment<'tcx> { + fn repr(&self) -> String { match *self { AdjustReifyFnPointer => { format!("AdjustReifyFnPointer") @@ -7337,24 +7337,24 @@ impl<'tcx> Repr<'tcx> for AutoAdjustment<'tcx> { format!("AdjustUnsafeFnPointer") } AdjustDerefRef(ref data) => { - data.repr(tcx) + data.repr() } } } } -impl<'tcx> Repr<'tcx> for AutoDerefRef<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for AutoDerefRef<'tcx> { + fn repr(&self) -> String { format!("AutoDerefRef({}, unsize={}, {})", - self.autoderefs, self.unsize.repr(tcx), self.autoref.repr(tcx)) + self.autoderefs, self.unsize.repr(), self.autoref.repr()) } } -impl<'tcx> Repr<'tcx> for AutoRef<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for AutoRef<'tcx> { + fn repr(&self) -> String { match *self { AutoPtr(a, b) => { - format!("AutoPtr({},{:?})", a.repr(tcx), b) + format!("AutoPtr({},{:?})", a.repr(), b) } AutoUnsafe(ref a) => { format!("AutoUnsafe({:?})", a) @@ -7363,22 +7363,22 @@ impl<'tcx> Repr<'tcx> for AutoRef<'tcx> { } } -impl<'tcx> Repr<'tcx> for TraitTy<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for TraitTy<'tcx> { + fn repr(&self) -> String { format!("TraitTy({},{})", - self.principal.repr(tcx), - self.bounds.repr(tcx)) + self.principal.repr(), + self.bounds.repr()) } } -impl<'tcx> Repr<'tcx> for ty::Predicate<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::Predicate<'tcx> { + fn repr(&self) -> String { match *self { - Predicate::Trait(ref a) => a.repr(tcx), - Predicate::Equate(ref pair) => pair.repr(tcx), - Predicate::RegionOutlives(ref pair) => pair.repr(tcx), - Predicate::TypeOutlives(ref pair) => pair.repr(tcx), - Predicate::Projection(ref pair) => pair.repr(tcx), + Predicate::Trait(ref a) => a.repr(), + Predicate::Equate(ref pair) => pair.repr(), + Predicate::RegionOutlives(ref pair) => pair.repr(), + Predicate::TypeOutlives(ref pair) => pair.repr(), + Predicate::Projection(ref pair) => pair.repr(), } } } @@ -7584,11 +7584,11 @@ impl<'tcx> RegionEscape for ProjectionTy<'tcx> { } } -impl<'tcx> Repr<'tcx> for ty::ProjectionPredicate<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::ProjectionPredicate<'tcx> { + fn repr(&self) -> String { format!("ProjectionPredicate({}, {})", - self.projection_ty.repr(tcx), - self.ty.repr(tcx)) + self.projection_ty.repr(), + self.ty.repr()) } } @@ -7826,48 +7826,48 @@ impl ReferencesError for Region } } -impl<'tcx> Repr<'tcx> for ClosureTy<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ClosureTy<'tcx> { + fn repr(&self) -> String { format!("ClosureTy({},{},{})", self.unsafety, - self.sig.repr(tcx), + self.sig.repr(), self.abi) } } -impl<'tcx> Repr<'tcx> for ClosureUpvar<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ClosureUpvar<'tcx> { + fn repr(&self) -> String { format!("ClosureUpvar({},{})", - self.def.repr(tcx), - self.ty.repr(tcx)) + self.def.repr(), + self.ty.repr()) } } -impl<'tcx> Repr<'tcx> for field<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for field<'tcx> { + fn repr(&self) -> String { format!("field({},{})", - self.name.repr(tcx), - self.mt.repr(tcx)) + self.name.repr(), + self.mt.repr()) } } -impl<'a, 'tcx> Repr<'tcx> for ParameterEnvironment<'a, 'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'a, 'tcx> Repr for ParameterEnvironment<'a, 'tcx> { + fn repr(&self) -> String { format!("ParameterEnvironment(\ free_substs={}, \ implicit_region_bound={}, \ caller_bounds={})", - self.free_substs.repr(tcx), - self.implicit_region_bound.repr(tcx), - self.caller_bounds.repr(tcx)) + self.free_substs.repr(), + self.implicit_region_bound.repr(), + self.caller_bounds.repr()) } } -impl<'tcx> Repr<'tcx> for ObjectLifetimeDefault { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ObjectLifetimeDefault { + fn repr(&self) -> String { match *self { ObjectLifetimeDefault::Ambiguous => format!("Ambiguous"), - ObjectLifetimeDefault::Specific(ref r) => r.repr(tcx), + ObjectLifetimeDefault::Specific(ref r) => r.repr(), } } } diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index cc91ccbfbd41e..00905eda1498e 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -50,7 +50,7 @@ use util::ppaux::Repr; /// The TypeFoldable trait is implemented for every type that can be folded. /// Basically, every type that has a corresponding method in TypeFolder. -pub trait TypeFoldable<'tcx>: Repr<'tcx> + Clone { +pub trait TypeFoldable<'tcx>: Repr + Clone { fn fold_with>(&self, folder: &mut F) -> Self; } @@ -74,7 +74,7 @@ pub trait TypeFolder<'tcx> : Sized { fn exit_region_binder(&mut self) { } fn fold_binder(&mut self, t: &ty::Binder) -> ty::Binder - where T : TypeFoldable<'tcx> + Repr<'tcx> + Clone + where T : TypeFoldable<'tcx> + Repr + Clone { // FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`. super_fold_binder(self, t) @@ -197,7 +197,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec { } } -impl<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>+Clone> TypeFoldable<'tcx> for ty::Binder { +impl<'tcx, T:TypeFoldable<'tcx>+Repr+Clone> TypeFoldable<'tcx> for ty::Binder { fn fold_with>(&self, folder: &mut F) -> ty::Binder { folder.fold_binder(self) } @@ -843,12 +843,12 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> match r { ty::ReLateBound(debruijn, _) if debruijn.depth < self.current_depth => { debug!("RegionFolder.fold_region({}) skipped bound region (current depth={})", - r.repr(self.tcx()), self.current_depth); + r.repr(), self.current_depth); r } _ => { debug!("RegionFolder.fold_region({}) folding free region (current_depth={})", - r.repr(self.tcx()), self.current_depth); + r.repr(), self.current_depth); (self.fld_r)(r, self.current_depth) } } @@ -885,9 +885,9 @@ pub fn replace_late_bound_regions<'tcx,T,F>(tcx: &ty::ctxt<'tcx>, mut f: F) -> (T, FnvHashMap) where F : FnMut(ty::BoundRegion) -> ty::Region, - T : TypeFoldable<'tcx> + Repr<'tcx>, + T : TypeFoldable<'tcx> + Repr, { - debug!("replace_late_bound_regions({})", value.repr(tcx)); + debug!("replace_late_bound_regions({})", value.repr()); let mut replacer = RegionReplacer::new(tcx, &mut f); let result = value.skip_binder().fold_with(&mut replacer); (result, replacer.map) @@ -917,7 +917,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> match r { ty::ReLateBound(debruijn, br) if debruijn.depth == self.current_depth => { debug!("RegionReplacer.fold_region({}) folding region (current_depth={})", - r.repr(self.tcx()), self.current_depth); + r.repr(), self.current_depth); let fld_r = &mut self.fld_r; let region = *self.map.entry(br).or_insert_with(|| fld_r(br)); if let ty::ReLateBound(debruijn1, br) = region { @@ -994,10 +994,10 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region { } } -pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr<'tcx>>(tcx: &ty::ctxt<'tcx>, +pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr>(tcx: &ty::ctxt<'tcx>, amount: u32, value: &T) -> T { debug!("shift_regions(value={}, amount={})", - value.repr(tcx), amount); + value.repr(), amount); value.fold_with(&mut RegionFolder::new(tcx, &mut |region, _current_depth| { shift_region(region, amount) diff --git a/src/librustc/middle/ty_match.rs b/src/librustc/middle/ty_match.rs index 241a27aa0cd79..3c9777935706f 100644 --- a/src/librustc/middle/ty_match.rs +++ b/src/librustc/middle/ty_match.rs @@ -55,14 +55,14 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> { fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { debug!("{}.regions({}, {})", self.tag(), - a.repr(self.tcx()), - b.repr(self.tcx())); + a.repr(), + b.repr()); Ok(a) } fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { debug!("{}.tys({}, {})", self.tag(), - a.repr(self.tcx()), b.repr(self.tcx())); + a.repr(), b.repr()); if a == b { return Ok(a); } match (&a.sty, &b.sty) { diff --git a/src/librustc/middle/ty_relate/mod.rs b/src/librustc/middle/ty_relate/mod.rs index 91169af4adbe3..a97f9d0b9f8a1 100644 --- a/src/librustc/middle/ty_relate/mod.rs +++ b/src/librustc/middle/ty_relate/mod.rs @@ -81,8 +81,8 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::mt<'tcx> { { debug!("{}.mts({}, {})", relation.tag(), - a.repr(relation.tcx()), - b.repr(relation.tcx())); + a.repr(), + b.repr()); if a.mutbl != b.mutbl { Err(ty::terr_mutability) } else { @@ -108,9 +108,9 @@ fn relate_item_substs<'a,'tcx:'a,R>(relation: &mut R, where R: TypeRelation<'a,'tcx> { debug!("substs: item_def_id={} a_subst={} b_subst={}", - item_def_id.repr(relation.tcx()), - a_subst.repr(relation.tcx()), - b_subst.repr(relation.tcx())); + item_def_id.repr(), + a_subst.repr(), + b_subst.repr()); let variances; let opt_variances = if relation.tcx().variance_computed.get() { @@ -196,9 +196,9 @@ fn relate_region_params<'a,'tcx:'a,R>(relation: &mut R, debug!("relate_region_params(a_rs={}, \ b_rs={}, variances={})", - a_rs.repr(tcx), - b_rs.repr(tcx), - variances.repr(tcx)); + a_rs.repr(), + b_rs.repr(), + variances.repr()); assert_eq!(num_region_params, variances.map_or(num_region_params, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index c4f69a7f5fe93..079741b0f2815 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -40,25 +40,28 @@ use syntax::{ast, ast_util}; use syntax::owned_slice::OwnedSlice; /// Produces a string suitable for debugging output. -pub trait Repr<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String; +pub trait Repr { + fn repr(&self) -> String; } /// Produces a string suitable for showing to the user. -pub trait UserString<'tcx> : Repr<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String; +pub trait UserString: Repr { + fn user_string(&self) -> String; } -fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, - substs: &subst::Substs<'tcx>, - did: ast::DefId, - projections: &[ty::ProjectionPredicate<'tcx>], - get_generics: GG) - -> String - where GG : FnOnce() -> ty::Generics<'tcx> +pub fn verbose() -> bool { + ty::tls::with(|tcx| tcx.sess.verbose()) +} + +fn parameterized(substs: &subst::Substs, + did: ast::DefId, + projections: &[ty::ProjectionPredicate], + get_generics: GG) + -> String + where GG: for<'tcx> FnOnce(&ty::ctxt<'tcx>) -> ty::Generics<'tcx> { - let base = ty::item_path_str(cx, did); - if cx.sess.verbose() { + let base = ty::tls::with(|tcx| ty::item_path_str(tcx, did)); + if verbose() { let mut strings = vec![]; match substs.regions { subst::ErasedRegions => { @@ -66,17 +69,17 @@ fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, } subst::NonerasedRegions(ref regions) => { for region in regions { - strings.push(region.repr(cx)); + strings.push(region.repr()); } } } for ty in &substs.types { - strings.push(ty.repr(cx)); + strings.push(ty.repr()); } for projection in projections { strings.push(format!("{}={}", - projection.projection_ty.item_name.user_string(cx), - projection.ty.user_string(cx))); + projection.projection_ty.item_name.user_string(), + projection.ty.user_string())); } return if strings.is_empty() { format!("{}", base) @@ -91,7 +94,7 @@ fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, subst::ErasedRegions => { } subst::NonerasedRegions(ref regions) => { for &r in regions { - let s = r.user_string(cx); + let s = r.user_string(); if s.is_empty() { // This happens when the value of the region // parameter is not easily serialized. This may be @@ -111,52 +114,57 @@ fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, // ICEs trying to fetch the generics early in the pipeline. This // is kind of a hacky workaround in that -Z verbose is required to // avoid those ICEs. - let generics = get_generics(); - - let has_self = substs.self_ty().is_some(); - let tps = substs.types.get_slice(subst::TypeSpace); - let ty_params = generics.types.get_slice(subst::TypeSpace); - let has_defaults = ty_params.last().map_or(false, |def| def.default.is_some()); - let num_defaults = if has_defaults { - ty_params.iter().zip(tps).rev().take_while(|&(def, &actual)| { - match def.default { - Some(default) => { - if !has_self && ty::type_has_self(default) { - // In an object type, there is no `Self`, and - // thus if the default value references Self, - // the user will be required to give an - // explicit value. We can't even do the - // substitution below to check without causing - // an ICE. (#18956). - false - } else { - default.subst(cx, substs) == actual + ty::tls::with(|tcx| { + let generics = get_generics(tcx); + + let has_self = substs.self_ty().is_some(); + let tps = substs.types.get_slice(subst::TypeSpace); + let ty_params = generics.types.get_slice(subst::TypeSpace); + let has_defaults = ty_params.last().map_or(false, |def| def.default.is_some()); + let num_defaults = if has_defaults { + let substs = tcx.lift(&substs); + ty_params.iter().zip(tps).rev().take_while(|&(def, &actual)| { + match def.default { + Some(default) => { + if !has_self && ty::type_has_self(default) { + // In an object type, there is no `Self`, and + // thus if the default value references Self, + // the user will be required to give an + // explicit value. We can't even do the + // substitution below to check without causing + // an ICE. (#18956). + false + } else { + let default = tcx.lift(&default); + substs.and_then(|substs| default.subst(tcx, substs)) == Some(actual) + } } + None => false } - None => false - } - }).count() - } else { - 0 - }; + }).count() + } else { + 0 + }; - for t in &tps[..tps.len() - num_defaults] { - strs.push(t.user_string(cx)) - } + for t in &tps[..tps.len() - num_defaults] { + strs.push(t.user_string()) + } + }); for projection in projections { strs.push(format!("{}={}", - projection.projection_ty.item_name.user_string(cx), - projection.ty.user_string(cx))); + projection.projection_ty.item_name.user_string(), + projection.ty.user_string())); } - if cx.lang_items.fn_trait_kind(did).is_some() && projections.len() == 1 { + let fn_trait_kind = ty::tls::with(|tcx| tcx.lang_items.fn_trait_kind(did)); + if fn_trait_kind.is_some() && projections.len() == 1 { let projection_ty = projections[0].ty; let tail = if ty::type_is_nil(projection_ty) { format!("") } else { - format!(" -> {}", projection_ty.user_string(cx)) + format!(" -> {}", projection_ty.user_string()) }; format!("{}({}){}", base, @@ -175,90 +183,129 @@ fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>, } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Option { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +fn in_binder<'tcx, T, U>(tcx: &ty::ctxt<'tcx>, + original: &ty::Binder, + lifted: Option>) -> String + where T: UserString, U: UserString + TypeFoldable<'tcx> +{ + // Replace any anonymous late-bound regions with named + // variants, using gensym'd identifiers, so that we can + // clearly differentiate between named and unnamed regions in + // the output. We'll probably want to tweak this over time to + // decide just how much information to give. + let value = if let Some(v) = lifted { + v + } else { + return original.0.user_string(); + }; + let mut names = Vec::new(); + let value_str = ty_fold::replace_late_bound_regions(tcx, &value, |br| { + ty::ReLateBound(ty::DebruijnIndex::new(1), match br { + ty::BrNamed(_, name) => { + names.push(token::get_name(name).to_string()); + br + } + ty::BrAnon(_) | + ty::BrFresh(_) | + ty::BrEnv => { + let name = token::gensym("'r"); + names.push(token::get_name(name).to_string()); + ty::BrNamed(ast_util::local_def(ast::DUMMY_NODE_ID), name) + } + }) + }).0.user_string(); + + if names.is_empty() { + value_str + } else { + format!("for<{}> {}", names.connect(","), value_str) + } +} + +impl Repr for Option { + fn repr(&self) -> String { match self { &None => "None".to_string(), - &Some(ref t) => t.repr(tcx), + &Some(ref t) => t.repr(), } } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for P { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - (**self).repr(tcx) +impl Repr for P { + fn repr(&self) -> String { + (**self).repr() } } -impl<'tcx,T:Repr<'tcx>,U:Repr<'tcx>> Repr<'tcx> for Result { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl Repr for Result { + fn repr(&self) -> String { match self { - &Ok(ref t) => t.repr(tcx), - &Err(ref u) => format!("Err({})", u.repr(tcx)) + &Ok(ref t) => t.repr(), + &Err(ref u) => format!("Err({})", u.repr()) } } } -impl<'tcx> Repr<'tcx> for () { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for () { + fn repr(&self) -> String { "()".to_string() } } -impl<'a, 'tcx, T: ?Sized +Repr<'tcx>> Repr<'tcx> for &'a T { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - Repr::repr(*self, tcx) +impl<'a, T: ?Sized +Repr> Repr for &'a T { + fn repr(&self) -> String { + (**self).repr() } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Rc { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - (&**self).repr(tcx) +impl Repr for Rc { + fn repr(&self) -> String { + (&**self).repr() } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Box { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - (&**self).repr(tcx) +impl Repr for Box { + fn repr(&self) -> String { + (&**self).repr() } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for [T] { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - format!("[{}]", self.iter().map(|t| t.repr(tcx)).collect::>().connect(", ")) +impl Repr for [T] { + fn repr(&self) -> String { + format!("[{}]", self.iter().map(|t| t.repr()).collect::>().connect(", ")) } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - self[..].repr(tcx) +impl Repr for OwnedSlice { + fn repr(&self) -> String { + self[..].repr() } } // This is necessary to handle types like Option>, for which // autoderef cannot convert the &[T] handler -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - self[..].repr(tcx) +impl Repr for Vec { + fn repr(&self) -> String { + self[..].repr() } } -impl<'a, 'tcx, T: ?Sized +UserString<'tcx>> UserString<'tcx> for &'a T { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { - UserString::user_string(*self, tcx) +impl<'a, T: ?Sized +UserString> UserString for &'a T { + fn user_string(&self) -> String { + (**self).user_string() } } -impl<'tcx, T:UserString<'tcx>> UserString<'tcx> for Vec { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl UserString for Vec { + fn user_string(&self) -> String { let strs: Vec = - self.iter().map(|t| t.user_string(tcx)).collect(); + self.iter().map(|t| t.user_string()).collect(); strs.connect(", ") } } -impl<'tcx> Repr<'tcx> for def::Def { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for def::Def { + fn repr(&self) -> String { format!("{:?}", *self) } } @@ -277,19 +324,18 @@ impl<'tcx> Repr<'tcx> for def::Def { type TraitAndProjections<'tcx> = (ty::TraitRef<'tcx>, Vec>); -impl<'tcx> UserString<'tcx> for TraitAndProjections<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for TraitAndProjections<'tcx> { + fn user_string(&self) -> String { let &(ref trait_ref, ref projection_bounds) = self; - parameterized(tcx, - trait_ref.substs, + parameterized(trait_ref.substs, trait_ref.def_id, &projection_bounds[..], - || ty::lookup_trait_def(tcx, trait_ref.def_id).generics.clone()) + |tcx| ty::lookup_trait_def(tcx, trait_ref.def_id).generics.clone()) } } -impl<'tcx> UserString<'tcx> for ty::TraitTy<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for ty::TraitTy<'tcx> { + fn user_string(&self) -> String { let &ty::TraitTy { ref principal, ref bounds } = self; let mut components = vec![]; @@ -299,17 +345,17 @@ impl<'tcx> UserString<'tcx> for ty::TraitTy<'tcx> { bounds.projection_bounds.iter().map(|x| x.0.clone()).collect())); // Generate the main trait ref, including associated types. - components.push(tap.user_string(tcx)); + components.push(tap.user_string()); // Builtin bounds. for bound in &bounds.builtin_bounds { - components.push(bound.user_string(tcx)); + components.push(bound.user_string()); } // Region, if not obviously implied by builtin bounds. if bounds.region_bound != ty::ReStatic { // Region bound is implied by builtin bounds: - components.push(bounds.region_bound.user_string(tcx)); + components.push(bounds.region_bound.user_string()); } components.retain(|s| !s.is_empty()); @@ -318,8 +364,8 @@ impl<'tcx> UserString<'tcx> for ty::TraitTy<'tcx> { } } -impl<'tcx> Repr<'tcx> for ty::TypeParameterDef<'tcx> { - fn repr(&self, _tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::TypeParameterDef<'tcx> { + fn repr(&self) -> String { format!("TypeParameterDef({:?}, {:?}/{})", self.def_id, self.space, @@ -327,63 +373,63 @@ impl<'tcx> Repr<'tcx> for ty::TypeParameterDef<'tcx> { } } -impl<'tcx> Repr<'tcx> for ty::RegionParameterDef { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::RegionParameterDef { + fn repr(&self) -> String { format!("RegionParameterDef(name={}, def_id={}, bounds={})", token::get_name(self.name), - self.def_id.repr(tcx), - self.bounds.repr(tcx)) + self.def_id.repr(), + self.bounds.repr()) } } -impl<'tcx> Repr<'tcx> for ty::TyS<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - self.user_string(tcx) +impl<'tcx> Repr for ty::TyS<'tcx> { + fn repr(&self) -> String { + self.user_string() } } -impl<'tcx> Repr<'tcx> for ty::mt<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::mt<'tcx> { + fn repr(&self) -> String { format!("{}{}", if self.mutbl == ast::MutMutable { "mut " } else { "" }, - self.ty.user_string(tcx)) + self.ty.user_string()) } } -impl<'tcx> Repr<'tcx> for subst::Substs<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for subst::Substs<'tcx> { + fn repr(&self) -> String { format!("Substs[types={}, regions={}]", - self.types.repr(tcx), - self.regions.repr(tcx)) + self.types.repr(), + self.regions.repr()) } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for subst::VecPerParamSpace { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl Repr for subst::VecPerParamSpace { + fn repr(&self) -> String { format!("[{};{};{}]", - self.get_slice(subst::TypeSpace).repr(tcx), - self.get_slice(subst::SelfSpace).repr(tcx), - self.get_slice(subst::FnSpace).repr(tcx)) + self.get_slice(subst::TypeSpace).repr(), + self.get_slice(subst::SelfSpace).repr(), + self.get_slice(subst::FnSpace).repr()) } } -impl<'tcx> Repr<'tcx> for ty::ItemSubsts<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - format!("ItemSubsts({})", self.substs.repr(tcx)) +impl<'tcx> Repr for ty::ItemSubsts<'tcx> { + fn repr(&self) -> String { + format!("ItemSubsts({})", self.substs.repr()) } } -impl<'tcx> Repr<'tcx> for subst::RegionSubsts { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for subst::RegionSubsts { + fn repr(&self) -> String { match *self { subst::ErasedRegions => "erased".to_string(), - subst::NonerasedRegions(ref regions) => regions.repr(tcx) + subst::NonerasedRegions(ref regions) => regions.repr() } } } -impl<'tcx> Repr<'tcx> for ty::BuiltinBounds { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::BuiltinBounds { + fn repr(&self) -> String { let mut res = Vec::new(); for b in self { res.push(match b { @@ -397,40 +443,40 @@ impl<'tcx> Repr<'tcx> for ty::BuiltinBounds { } } -impl<'tcx> Repr<'tcx> for ty::ParamBounds<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::ParamBounds<'tcx> { + fn repr(&self) -> String { let mut res = Vec::new(); - res.push(self.builtin_bounds.repr(tcx)); + res.push(self.builtin_bounds.repr()); for t in &self.trait_bounds { - res.push(t.repr(tcx)); + res.push(t.repr()); } res.connect("+") } } -impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::TraitRef<'tcx> { + fn repr(&self) -> String { // when printing out the debug representation, we don't need // to enumerate the `for<...>` etc because the debruijn index // tells you everything you need to know. - let result = self.user_string(tcx); + let result = self.user_string(); match self.substs.self_ty() { None => result, - Some(sty) => format!("<{} as {}>", sty.repr(tcx), result) + Some(sty) => format!("<{} as {}>", sty.repr(), result) } } } -impl<'tcx> Repr<'tcx> for ty::TraitDef<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::TraitDef<'tcx> { + fn repr(&self) -> String { format!("TraitDef(generics={}, trait_ref={})", - self.generics.repr(tcx), - self.trait_ref.repr(tcx)) + self.generics.repr(), + self.trait_ref.repr()) } } -impl<'tcx> Repr<'tcx> for ast::TraitItem { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::TraitItem { + fn repr(&self) -> String { let kind = match self.node { ast::ConstTraitItem(..) => "ConstTraitItem", ast::MethodTraitItem(..) => "MethodTraitItem", @@ -440,62 +486,62 @@ impl<'tcx> Repr<'tcx> for ast::TraitItem { } } -impl<'tcx> Repr<'tcx> for ast::Expr { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Expr { + fn repr(&self) -> String { format!("expr({}: {})", self.id, pprust::expr_to_string(self)) } } -impl<'tcx> Repr<'tcx> for ast::Path { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Path { + fn repr(&self) -> String { format!("path({})", pprust::path_to_string(self)) } } -impl<'tcx> UserString<'tcx> for ast::Path { - fn user_string(&self, _tcx: &ctxt) -> String { +impl UserString for ast::Path { + fn user_string(&self) -> String { pprust::path_to_string(self) } } -impl<'tcx> Repr<'tcx> for ast::Ty { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Ty { + fn repr(&self) -> String { format!("type({})", pprust::ty_to_string(self)) } } -impl<'tcx> Repr<'tcx> for ast::Item { - fn repr(&self, tcx: &ctxt) -> String { - format!("item({})", tcx.map.node_to_string(self.id)) +impl Repr for ast::Item { + fn repr(&self) -> String { + format!("item({})", ty::tls::with(|tcx| tcx.map.node_to_string(self.id))) } } -impl<'tcx> Repr<'tcx> for ast::Lifetime { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Lifetime { + fn repr(&self) -> String { format!("lifetime({}: {})", self.id, pprust::lifetime_to_string(self)) } } -impl<'tcx> Repr<'tcx> for ast::Stmt { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Stmt { + fn repr(&self) -> String { format!("stmt({}: {})", ast_util::stmt_id(self), pprust::stmt_to_string(self)) } } -impl<'tcx> Repr<'tcx> for ast::Pat { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Pat { + fn repr(&self) -> String { format!("pat({}: {})", self.id, pprust::pat_to_string(self)) } } -impl<'tcx> Repr<'tcx> for ty::BoundRegion { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::BoundRegion { + fn repr(&self) -> String { match *self { ty::BrAnon(id) => format!("BrAnon({})", id), ty::BrNamed(id, name) => { - format!("BrNamed({}, {})", id.repr(tcx), token::get_name(name)) + format!("BrNamed({}, {})", id.repr(), token::get_name(name)) } ty::BrFresh(id) => format!("BrFresh({})", id), ty::BrEnv => "BrEnv".to_string() @@ -503,10 +549,10 @@ impl<'tcx> Repr<'tcx> for ty::BoundRegion { } } -impl<'tcx> UserString<'tcx> for ty::BoundRegion { - fn user_string(&self, tcx: &ctxt) -> String { - if tcx.sess.verbose() { - return self.repr(tcx); +impl UserString for ty::BoundRegion { + fn user_string(&self) -> String { + if verbose() { + return self.repr(); } match *self { @@ -516,8 +562,8 @@ impl<'tcx> UserString<'tcx> for ty::BoundRegion { } } -impl<'tcx> Repr<'tcx> for ty::Region { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::Region { + fn repr(&self) -> String { match *self { ty::ReEarlyBound(ref data) => { format!("ReEarlyBound({}, {:?}, {}, {})", @@ -530,10 +576,10 @@ impl<'tcx> Repr<'tcx> for ty::Region { ty::ReLateBound(binder_id, ref bound_region) => { format!("ReLateBound({:?}, {})", binder_id, - bound_region.repr(tcx)) + bound_region.repr()) } - ty::ReFree(ref fr) => fr.repr(tcx), + ty::ReFree(ref fr) => fr.repr(), ty::ReScope(id) => { format!("ReScope({:?})", id) @@ -548,7 +594,7 @@ impl<'tcx> Repr<'tcx> for ty::Region { } ty::ReInfer(ReSkolemized(id, ref bound_region)) => { - format!("re_skolemized({}, {})", id, bound_region.repr(tcx)) + format!("re_skolemized({}, {})", id, bound_region.repr()) } ty::ReEmpty => { @@ -558,10 +604,10 @@ impl<'tcx> Repr<'tcx> for ty::Region { } } -impl<'tcx> UserString<'tcx> for ty::Region { - fn user_string(&self, tcx: &ctxt) -> String { - if tcx.sess.verbose() { - return self.repr(tcx); +impl UserString for ty::Region { + fn user_string(&self) -> String { + if verbose() { + return self.repr(); } // These printouts are concise. They do not contain all the information @@ -575,7 +621,7 @@ impl<'tcx> UserString<'tcx> for ty::Region { ty::ReLateBound(_, br) | ty::ReFree(ty::FreeRegion { bound_region: br, .. }) | ty::ReInfer(ReSkolemized(_, br)) => { - br.user_string(tcx) + br.user_string() } ty::ReScope(_) | ty::ReInfer(ReVar(_)) => String::new(), @@ -585,16 +631,16 @@ impl<'tcx> UserString<'tcx> for ty::Region { } } -impl<'tcx> Repr<'tcx> for ty::FreeRegion { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::FreeRegion { + fn repr(&self) -> String { format!("ReFree({}, {})", - self.scope.repr(tcx), - self.bound_region.repr(tcx)) + self.scope.repr(), + self.bound_region.repr()) } } -impl<'tcx> Repr<'tcx> for region::CodeExtent { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for region::CodeExtent { + fn repr(&self) -> String { match *self { region::CodeExtent::ParameterScope { fn_id, body_id } => format!("ParameterScope({}, {})", fn_id, body_id), @@ -608,8 +654,8 @@ impl<'tcx> Repr<'tcx> for region::CodeExtent { } } -impl<'tcx> Repr<'tcx> for region::DestructionScopeData { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for region::DestructionScopeData { + fn repr(&self) -> String { match *self { region::DestructionScopeData{ node_id } => format!("DestructionScopeData {{ node_id: {} }}", node_id), @@ -617,72 +663,73 @@ impl<'tcx> Repr<'tcx> for region::DestructionScopeData { } } -impl<'tcx> Repr<'tcx> for ast::DefId { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ast::DefId { + fn repr(&self) -> String { // Unfortunately, there seems to be no way to attempt to print // a path for a def-id, so I'll just make a best effort for now // and otherwise fallback to just printing the crate/node pair - if self.krate == ast::LOCAL_CRATE { - match tcx.map.find(self.node) { - Some(ast_map::NodeItem(..)) | - Some(ast_map::NodeForeignItem(..)) | - Some(ast_map::NodeImplItem(..)) | - Some(ast_map::NodeTraitItem(..)) | - Some(ast_map::NodeVariant(..)) | - Some(ast_map::NodeStructCtor(..)) => { - return format!( - "{:?}:{}", - *self, - ty::item_path_str(tcx, *self)) + ty::tls::with(|tcx| { + if self.krate == ast::LOCAL_CRATE { + match tcx.map.find(self.node) { + Some(ast_map::NodeItem(..)) | + Some(ast_map::NodeForeignItem(..)) | + Some(ast_map::NodeImplItem(..)) | + Some(ast_map::NodeTraitItem(..)) | + Some(ast_map::NodeVariant(..)) | + Some(ast_map::NodeStructCtor(..)) => { + return format!("{:?}:{}", + *self, + ty::item_path_str(tcx, *self)); + } + _ => {} } - _ => {} } - } - return format!("{:?}", *self) + format!("{:?}", *self) + }) } } -impl<'tcx> Repr<'tcx> for ty::TypeScheme<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::TypeScheme<'tcx> { + fn repr(&self) -> String { format!("TypeScheme {{generics: {}, ty: {}}}", - self.generics.repr(tcx), - self.ty.repr(tcx)) + self.generics.repr(), + self.ty.repr()) } } -impl<'tcx> Repr<'tcx> for ty::Generics<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::Generics<'tcx> { + fn repr(&self) -> String { format!("Generics(types: {}, regions: {})", - self.types.repr(tcx), - self.regions.repr(tcx)) + self.types.repr(), + self.regions.repr()) } } -impl<'tcx> Repr<'tcx> for ty::GenericPredicates<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::GenericPredicates<'tcx> { + fn repr(&self) -> String { format!("GenericPredicates(predicates: {})", - self.predicates.repr(tcx)) + self.predicates.repr()) } } -impl<'tcx> Repr<'tcx> for ty::InstantiatedPredicates<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::InstantiatedPredicates<'tcx> { + fn repr(&self) -> String { format!("InstantiatedPredicates({})", - self.predicates.repr(tcx)) + self.predicates.repr()) } } -impl<'tcx> Repr<'tcx> for ty::ItemVariances { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::ItemVariances { + fn repr(&self) -> String { format!("ItemVariances(types={}, \ regions={})", - self.types.repr(tcx), - self.regions.repr(tcx)) + self.types.repr(), + self.regions.repr()) } } -impl<'tcx> Repr<'tcx> for ty::Variance { - fn repr(&self, _: &ctxt) -> String { +impl Repr for ty::Variance { + fn repr(&self) -> String { // The first `.to_string()` returns a &'static str (it is not an implementation // of the ToString trait). Because of that, we need to call `.to_string()` again // if we want to have a `String`. @@ -691,160 +738,160 @@ impl<'tcx> Repr<'tcx> for ty::Variance { } } -impl<'tcx> Repr<'tcx> for ty::ImplOrTraitItem<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::ImplOrTraitItem<'tcx> { + fn repr(&self) -> String { format!("ImplOrTraitItem({})", match *self { - ty::ImplOrTraitItem::MethodTraitItem(ref i) => i.repr(tcx), - ty::ImplOrTraitItem::ConstTraitItem(ref i) => i.repr(tcx), - ty::ImplOrTraitItem::TypeTraitItem(ref i) => i.repr(tcx), + ty::ImplOrTraitItem::MethodTraitItem(ref i) => i.repr(), + ty::ImplOrTraitItem::ConstTraitItem(ref i) => i.repr(), + ty::ImplOrTraitItem::TypeTraitItem(ref i) => i.repr(), }) } } -impl<'tcx> Repr<'tcx> for ty::AssociatedConst<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::AssociatedConst<'tcx> { + fn repr(&self) -> String { format!("AssociatedConst(name: {}, ty: {}, vis: {}, def_id: {})", - self.name.repr(tcx), - self.ty.repr(tcx), - self.vis.repr(tcx), - self.def_id.repr(tcx)) + self.name.repr(), + self.ty.repr(), + self.vis.repr(), + self.def_id.repr()) } } -impl<'tcx> Repr<'tcx> for ty::AssociatedType<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::AssociatedType<'tcx> { + fn repr(&self) -> String { format!("AssociatedType(name: {}, vis: {}, def_id: {})", - self.name.repr(tcx), - self.vis.repr(tcx), - self.def_id.repr(tcx)) + self.name.repr(), + self.vis.repr(), + self.def_id.repr()) } } -impl<'tcx> Repr<'tcx> for ty::Method<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::Method<'tcx> { + fn repr(&self) -> String { format!("Method(name: {}, generics: {}, predicates: {}, fty: {}, \ explicit_self: {}, vis: {}, def_id: {})", - self.name.repr(tcx), - self.generics.repr(tcx), - self.predicates.repr(tcx), - self.fty.repr(tcx), - self.explicit_self.repr(tcx), - self.vis.repr(tcx), - self.def_id.repr(tcx)) + self.name.repr(), + self.generics.repr(), + self.predicates.repr(), + self.fty.repr(), + self.explicit_self.repr(), + self.vis.repr(), + self.def_id.repr()) } } -impl<'tcx> Repr<'tcx> for ast::Name { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Name { + fn repr(&self) -> String { token::get_name(*self).to_string() } } -impl<'tcx> UserString<'tcx> for ast::Name { - fn user_string(&self, _tcx: &ctxt) -> String { +impl UserString for ast::Name { + fn user_string(&self) -> String { token::get_name(*self).to_string() } } -impl<'tcx> Repr<'tcx> for ast::Ident { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Ident { + fn repr(&self) -> String { token::get_ident(*self).to_string() } } -impl<'tcx> Repr<'tcx> for ast::ExplicitSelf_ { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::ExplicitSelf_ { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ast::Visibility { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Visibility { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ty::BareFnTy<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::BareFnTy<'tcx> { + fn repr(&self) -> String { format!("BareFnTy {{unsafety: {}, abi: {}, sig: {}}}", self.unsafety, self.abi.to_string(), - self.sig.repr(tcx)) + self.sig.repr()) } } -impl<'tcx> Repr<'tcx> for ty::FnSig<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - format!("fn{} -> {}", self.inputs.repr(tcx), self.output.repr(tcx)) +impl<'tcx> Repr for ty::FnSig<'tcx> { + fn repr(&self) -> String { + format!("fn{} -> {}", self.inputs.repr(), self.output.repr()) } } -impl<'tcx> Repr<'tcx> for ty::FnOutput<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::FnOutput<'tcx> { + fn repr(&self) -> String { match *self { ty::FnConverging(ty) => - format!("FnConverging({0})", ty.repr(tcx)), + format!("FnConverging({0})", ty.repr()), ty::FnDiverging => "FnDiverging".to_string() } } } -impl<'tcx> Repr<'tcx> for ty::MethodCallee<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::MethodCallee<'tcx> { + fn repr(&self) -> String { format!("MethodCallee {{origin: {}, ty: {}, {}}}", - self.origin.repr(tcx), - self.ty.repr(tcx), - self.substs.repr(tcx)) + self.origin.repr(), + self.ty.repr(), + self.substs.repr()) } } -impl<'tcx> Repr<'tcx> for ty::MethodOrigin<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::MethodOrigin<'tcx> { + fn repr(&self) -> String { match self { &ty::MethodStatic(def_id) => { - format!("MethodStatic({})", def_id.repr(tcx)) + format!("MethodStatic({})", def_id.repr()) } &ty::MethodStaticClosure(def_id) => { - format!("MethodStaticClosure({})", def_id.repr(tcx)) + format!("MethodStaticClosure({})", def_id.repr()) } &ty::MethodTypeParam(ref p) => { - p.repr(tcx) + p.repr() } &ty::MethodTraitObject(ref p) => { - p.repr(tcx) + p.repr() } } } } -impl<'tcx> Repr<'tcx> for ty::MethodParam<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::MethodParam<'tcx> { + fn repr(&self) -> String { format!("MethodParam({},{})", - self.trait_ref.repr(tcx), + self.trait_ref.repr(), self.method_num) } } -impl<'tcx> Repr<'tcx> for ty::MethodObject<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::MethodObject<'tcx> { + fn repr(&self) -> String { format!("MethodObject({},{},{})", - self.trait_ref.repr(tcx), + self.trait_ref.repr(), self.method_num, self.vtable_index) } } -impl<'tcx> Repr<'tcx> for ty::BuiltinBound { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::BuiltinBound { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> UserString<'tcx> for ty::BuiltinBound { - fn user_string(&self, _tcx: &ctxt) -> String { +impl UserString for ty::BuiltinBound { + fn user_string(&self) -> String { match *self { ty::BoundSend => "Send".to_string(), ty::BoundSized => "Sized".to_string(), @@ -854,116 +901,132 @@ impl<'tcx> UserString<'tcx> for ty::BuiltinBound { } } -impl<'tcx> Repr<'tcx> for Span { - fn repr(&self, tcx: &ctxt) -> String { - tcx.sess.codemap().span_to_string(*self).to_string() +impl Repr for Span { + fn repr(&self) -> String { + ty::tls::with(|tcx| tcx.sess.codemap().span_to_string(*self).to_string()) } } -impl<'tcx, A:UserString<'tcx>> UserString<'tcx> for Rc { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl UserString for Rc { + fn user_string(&self) -> String { let this: &A = &**self; - this.user_string(tcx) + this.user_string() } } -impl<'tcx> UserString<'tcx> for ty::ParamBounds<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for ty::ParamBounds<'tcx> { + fn user_string(&self) -> String { let mut result = Vec::new(); - let s = self.builtin_bounds.user_string(tcx); + let s = self.builtin_bounds.user_string(); if !s.is_empty() { result.push(s); } for n in &self.trait_bounds { - result.push(n.user_string(tcx)); + result.push(n.user_string()); } result.connect(" + ") } } -impl<'tcx> Repr<'tcx> for ty::ExistentialBounds<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::ExistentialBounds<'tcx> { + fn repr(&self) -> String { let mut res = Vec::new(); - let region_str = self.region_bound.repr(tcx); + let region_str = self.region_bound.repr(); if !region_str.is_empty() { res.push(region_str); } for bound in &self.builtin_bounds { - res.push(bound.repr(tcx)); + res.push(bound.repr()); } for projection_bound in &self.projection_bounds { - res.push(projection_bound.repr(tcx)); + res.push(projection_bound.repr()); } res.connect("+") } } -impl<'tcx> UserString<'tcx> for ty::BuiltinBounds { - fn user_string(&self, tcx: &ctxt) -> String { +impl UserString for ty::BuiltinBounds { + fn user_string(&self) -> String { self.iter() - .map(|bb| bb.user_string(tcx)) + .map(|bb| bb.user_string()) .collect::>() .connect("+") .to_string() } } -impl<'tcx, T> UserString<'tcx> for ty::Binder - where T : UserString<'tcx> + TypeFoldable<'tcx> +// The generic impl doesn't work yet because projections are not +// normalized under HRTB. +/*impl UserString for ty::Binder + where T: UserString + for<'a> ty::Lift<'a>, + for<'a> >::Lifted: UserString + TypeFoldable<'a> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { - // Replace any anonymous late-bound regions with named - // variants, using gensym'd identifiers, so that we can - // clearly differentiate between named and unnamed regions in - // the output. We'll probably want to tweak this over time to - // decide just how much information to give. - let mut names = Vec::new(); - let (unbound_value, _) = ty_fold::replace_late_bound_regions(tcx, self, |br| { - ty::ReLateBound(ty::DebruijnIndex::new(1), match br { - ty::BrNamed(_, name) => { - names.push(token::get_name(name)); - br - } - ty::BrAnon(_) | - ty::BrFresh(_) | - ty::BrEnv => { - let name = token::gensym("'r"); - names.push(token::get_name(name)); - ty::BrNamed(ast_util::local_def(ast::DUMMY_NODE_ID), name) - } - }) - }); - let names: Vec<_> = names.iter().map(|s| &s[..]).collect(); + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) + } +}*/ - let value_str = unbound_value.user_string(tcx); - if names.is_empty() { - value_str - } else { - format!("for<{}> {}", names.connect(","), value_str) - } +impl<'tcx> UserString for ty::Binder> { + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) + } +} + +impl<'tcx> UserString for ty::Binder> { + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) } } -impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { - parameterized(tcx, self.substs, self.def_id, &[], - || ty::lookup_trait_def(tcx, self.def_id).generics.clone()) +impl<'tcx> UserString for ty::Binder> { + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) } } -impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { - fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>, - opt_def_id: Option, - unsafety: ast::Unsafety, - abi: abi::Abi, - ident: Option, - sig: &ty::PolyFnSig<'tcx>) - -> String { +impl<'tcx> UserString for ty::Binder> { + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) + } +} + +impl<'tcx> UserString for ty::Binder> { + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) + } +} + +impl<'tcx> UserString for ty::Binder, ty::Region>> { + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) + } +} + +impl UserString for ty::Binder> { + fn user_string(&self) -> String { + ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) + } +} + +impl<'tcx> UserString for ty::TraitRef<'tcx> { + fn user_string(&self) -> String { + parameterized(self.substs, self.def_id, &[], + |tcx| ty::lookup_trait_def(tcx, self.def_id).generics.clone()) + } +} + +impl<'tcx> UserString for ty::TyS<'tcx> { + fn user_string(&self) -> String { + fn bare_fn_to_string(opt_def_id: Option, + unsafety: ast::Unsafety, + abi: abi::Abi, + ident: Option, + sig: &ty::PolyFnSig) + -> String { let mut s = String::new(); match unsafety { @@ -988,12 +1051,12 @@ impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { _ => { } } - push_sig_to_string(cx, &mut s, '(', ')', sig); + push_sig_to_string(&mut s, '(', ')', sig); match opt_def_id { Some(def_id) => { s.push_str(" {"); - let path_str = ty::item_path_str(cx, def_id); + let path_str = ty::tls::with(|tcx| ty::item_path_str(tcx, def_id)); s.push_str(&path_str[..]); s.push_str("}"); } @@ -1003,30 +1066,14 @@ impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { s } - fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, - cty: &ty::ClosureTy<'tcx>, - did: &ast::DefId) - -> String { - let mut s = String::new(); - s.push_str("[closure"); - push_sig_to_string(cx, &mut s, '(', ')', &cty.sig); - if cx.sess.verbose() { - s.push_str(&format!(" id={:?}]", did)); - } else { - s.push(']'); - } - s - } - - fn push_sig_to_string<'tcx>(cx: &ctxt<'tcx>, - s: &mut String, - bra: char, - ket: char, - sig: &ty::PolyFnSig<'tcx>) { + fn push_sig_to_string(s: &mut String, + bra: char, + ket: char, + sig: &ty::PolyFnSig) { s.push(bra); let strs = sig.0.inputs .iter() - .map(|a| a.user_string(cx)) + .map(|a| a.user_string()) .collect::>(); s.push_str(&strs.connect(", ")); if sig.0.variadic { @@ -1038,7 +1085,7 @@ impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { ty::FnConverging(t) => { if !ty::type_is_nil(t) { s.push_str(" -> "); - s.push_str(& t.user_string(cx)); + s.push_str(&t.user_string()); } } ty::FnDiverging => { @@ -1047,19 +1094,6 @@ impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { } } - fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String { - let print_var_ids = cx.sess.verbose(); - match ty { - ty::TyVar(ref vid) if print_var_ids => vid.repr(cx), - ty::IntVar(ref vid) if print_var_ids => vid.repr(cx), - ty::FloatVar(ref vid) if print_var_ids => vid.repr(cx), - ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => format!("_"), - ty::FreshTy(v) => format!("FreshTy({})", v), - ty::FreshIntTy(v) => format!("FreshIntTy({})", v), - ty::FreshFloatTy(v) => format!("FreshFloatTy({})", v) - } - } - // pretty print the structural type representation: match self.sty { TyBool => "bool".to_string(), @@ -1067,26 +1101,26 @@ impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { TyInt(t) => ast_util::int_ty_to_string(t, None).to_string(), TyUint(t) => ast_util::uint_ty_to_string(t, None).to_string(), TyFloat(t) => ast_util::float_ty_to_string(t).to_string(), - TyBox(typ) => format!("Box<{}>", typ.user_string(tcx)), + TyBox(typ) => format!("Box<{}>", typ.user_string()), TyRawPtr(ref tm) => { format!("*{} {}", match tm.mutbl { ast::MutMutable => "mut", ast::MutImmutable => "const", - }, tm.ty.user_string(tcx)) + }, tm.ty.user_string()) } TyRef(r, ref tm) => { let mut buf = "&".to_owned(); - buf.push_str(&r.user_string(tcx)); - if !buf.is_empty() { + buf.push_str(&r.user_string()); + if buf.len() > 1 { buf.push_str(" "); } - buf.push_str(&tm.repr(tcx)); + buf.push_str(&tm.repr()); buf } TyTuple(ref elems) => { let strs = elems .iter() - .map(|elem| elem.user_string(tcx)) + .map(|elem| elem.user_string()) .collect::>(); match &strs[..] { [ref string] => format!("({},)", string), @@ -1094,161 +1128,185 @@ impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> { } } TyBareFn(opt_def_id, ref f) => { - bare_fn_to_string(tcx, opt_def_id, f.unsafety, f.abi, None, &f.sig) + bare_fn_to_string(opt_def_id, f.unsafety, f.abi, None, &f.sig) } - TyInfer(infer_ty) => infer_ty_to_string(tcx, infer_ty), + TyInfer(infer_ty) => infer_ty.repr(), TyError => "[type error]".to_string(), - TyParam(ref param_ty) => param_ty.user_string(tcx), + TyParam(ref param_ty) => param_ty.user_string(), TyEnum(did, substs) | TyStruct(did, substs) => { - parameterized(tcx, substs, did, &[], - || ty::lookup_item_type(tcx, did).generics) + parameterized(substs, did, &[], + |tcx| ty::lookup_item_type(tcx, did).generics) } TyTrait(ref data) => { - data.user_string(tcx) + data.user_string() } ty::TyProjection(ref data) => { format!("<{} as {}>::{}", - data.trait_ref.self_ty().user_string(tcx), - data.trait_ref.user_string(tcx), - data.item_name.user_string(tcx)) + data.trait_ref.self_ty().user_string(), + data.trait_ref.user_string(), + data.item_name.user_string()) } TyStr => "str".to_string(), - TyClosure(ref did, substs) => { + TyClosure(ref did, substs) => ty::tls::with(|tcx| { let closure_tys = tcx.closure_tys.borrow(); - closure_tys.get(did).map(|closure_type| { - closure_to_string(tcx, &closure_type.subst(tcx, substs), did) + closure_tys.get(did).map(|cty| &cty.sig).and_then(|sig| { + tcx.lift(&substs).map(|substs| sig.subst(tcx, substs)) + }).map(|sig| { + let mut s = String::new(); + s.push_str("[closure"); + push_sig_to_string(&mut s, '(', ')', &sig); + if verbose() { + s.push_str(&format!(" id={:?}]", did)); + } else { + s.push(']'); + } + s }).unwrap_or_else(|| { - let id_str = if tcx.sess.verbose() { + let id_str = if verbose() { format!(" id={:?}", did) } else { "".to_owned() }; - if did.krate == ast::LOCAL_CRATE { - let span = tcx.map.span(did.node); - format!("[closure {}{}]", span.repr(tcx), id_str) + let span = ty::tls::with(|tcx| tcx.map.span(did.node)); + format!("[closure {}{}]", span.repr(), id_str) } else { format!("[closure{}]", id_str) } }) - } + }), TyArray(t, sz) => { - format!("[{}; {}]", t.user_string(tcx), sz) + format!("[{}; {}]", t.user_string(), sz) } TySlice(t) => { - format!("[{}]", t.user_string(tcx)) + format!("[{}]", t.user_string()) } } } } -impl<'tcx> UserString<'tcx> for ast::Ident { - fn user_string(&self, _tcx: &ctxt) -> String { +impl UserString for ast::Ident { + fn user_string(&self) -> String { token::get_name(self.name).to_string() } } -impl<'tcx> Repr<'tcx> for abi::Abi { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for abi::Abi { + fn repr(&self) -> String { self.to_string() } } -impl<'tcx> UserString<'tcx> for abi::Abi { - fn user_string(&self, _tcx: &ctxt) -> String { +impl UserString for abi::Abi { + fn user_string(&self) -> String { self.to_string() } } -impl<'tcx> Repr<'tcx> for ty::UpvarId { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::UpvarId { + fn repr(&self) -> String { format!("UpvarId({};`{}`;{})", self.var_id, - ty::local_var_name_str(tcx, self.var_id), + ty::tls::with(|tcx| ty::local_var_name_str(tcx, self.var_id)), self.closure_expr_id) } } -impl<'tcx> Repr<'tcx> for ast::Mutability { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::Mutability { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ty::BorrowKind { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::BorrowKind { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ty::UpvarBorrow { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::UpvarBorrow { + fn repr(&self) -> String { format!("UpvarBorrow({}, {})", - self.kind.repr(tcx), - self.region.repr(tcx)) + self.kind.repr(), + self.region.repr()) } } -impl<'tcx> Repr<'tcx> for ty::UpvarCapture { - fn repr(&self, tcx: &ctxt) -> String { +impl Repr for ty::UpvarCapture { + fn repr(&self) -> String { match *self { ty::UpvarCapture::ByValue => format!("ByValue"), - ty::UpvarCapture::ByRef(ref data) => format!("ByRef({})", data.repr(tcx)), + ty::UpvarCapture::ByRef(ref data) => format!("ByRef({})", data.repr()), } } } -impl<'tcx> Repr<'tcx> for ty::IntVid { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::IntVid { + fn repr(&self) -> String { format!("{:?}", self) } } -impl<'tcx> Repr<'tcx> for ty::FloatVid { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::FloatVid { + fn repr(&self) -> String { format!("{:?}", self) } } -impl<'tcx> Repr<'tcx> for ty::RegionVid { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::RegionVid { + fn repr(&self) -> String { format!("{:?}", self) } } -impl<'tcx> Repr<'tcx> for ty::TyVid { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::TyVid { + fn repr(&self) -> String { format!("{:?}", self) } } -impl<'tcx> Repr<'tcx> for ty::IntVarValue { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::IntVarValue { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ast::IntTy { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ty::InferTy { + fn repr(&self) -> String { + let print_var_ids = verbose(); + match *self { + ty::TyVar(ref vid) if print_var_ids => vid.repr(), + ty::IntVar(ref vid) if print_var_ids => vid.repr(), + ty::FloatVar(ref vid) if print_var_ids => vid.repr(), + ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => format!("_"), + ty::FreshTy(v) => format!("FreshTy({})", v), + ty::FreshIntTy(v) => format!("FreshIntTy({})", v), + ty::FreshFloatTy(v) => format!("FreshFloatTy({})", v) + } + } +} + +impl Repr for ast::IntTy { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ast::UintTy { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::UintTy { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ast::FloatTy { - fn repr(&self, _tcx: &ctxt) -> String { +impl Repr for ast::FloatTy { + fn repr(&self) -> String { format!("{:?}", *self) } } -impl<'tcx> Repr<'tcx> for ty::ExplicitSelfCategory { - fn repr(&self, _: &ctxt) -> String { +impl Repr for ty::ExplicitSelfCategory { + fn repr(&self) -> String { match *self { ty::StaticExplicitSelfCategory => "static", ty::ByValueExplicitSelfCategory => "self", @@ -1261,138 +1319,138 @@ impl<'tcx> Repr<'tcx> for ty::ExplicitSelfCategory { } } -impl<'tcx> UserString<'tcx> for ParamTy { - fn user_string(&self, _tcx: &ctxt) -> String { +impl UserString for ParamTy { + fn user_string(&self) -> String { format!("{}", token::get_name(self.name)) } } -impl<'tcx> Repr<'tcx> for ParamTy { - fn repr(&self, tcx: &ctxt) -> String { - let ident = self.user_string(tcx); +impl Repr for ParamTy { + fn repr(&self) -> String { + let ident = self.user_string(); format!("{}/{:?}.{}", ident, self.space, self.idx) } } -impl<'tcx, A:Repr<'tcx>, B:Repr<'tcx>> Repr<'tcx> for (A,B) { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl Repr for (A,B) { + fn repr(&self) -> String { let &(ref a, ref b) = self; - format!("({},{})", a.repr(tcx), b.repr(tcx)) + format!("({},{})", a.repr(), b.repr()) } } -impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for ty::Binder { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { - format!("Binder({})", self.0.repr(tcx)) +impl Repr for ty::Binder { + fn repr(&self) -> String { + format!("Binder({})", self.0.repr()) } } -impl<'tcx, S, K, V> Repr<'tcx> for HashMap - where K: Hash + Eq + Repr<'tcx>, - V: Repr<'tcx>, +impl Repr for HashMap + where K: Hash + Eq + Repr, + V: Repr, S: HashState, { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { + fn repr(&self) -> String { format!("HashMap({})", self.iter() - .map(|(k,v)| format!("{} => {}", k.repr(tcx), v.repr(tcx))) + .map(|(k,v)| format!("{} => {}", k.repr(), v.repr())) .collect::>() .connect(", ")) } } -impl<'tcx, T, U> Repr<'tcx> for ty::OutlivesPredicate - where T : Repr<'tcx> + TypeFoldable<'tcx>, - U : Repr<'tcx> + TypeFoldable<'tcx>, +impl<'tcx, T, U> Repr for ty::OutlivesPredicate + where T : Repr + TypeFoldable<'tcx>, + U : Repr + TypeFoldable<'tcx>, { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { + fn repr(&self) -> String { format!("OutlivesPredicate({}, {})", - self.0.repr(tcx), - self.1.repr(tcx)) + self.0.repr(), + self.1.repr()) } } -impl<'tcx, T, U> UserString<'tcx> for ty::OutlivesPredicate - where T : UserString<'tcx> + TypeFoldable<'tcx>, - U : UserString<'tcx> + TypeFoldable<'tcx>, +impl<'tcx, T, U> UserString for ty::OutlivesPredicate + where T : UserString + TypeFoldable<'tcx>, + U : UserString + TypeFoldable<'tcx>, { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { + fn user_string(&self) -> String { format!("{} : {}", - self.0.user_string(tcx), - self.1.user_string(tcx)) + self.0.user_string(), + self.1.user_string()) } } -impl<'tcx> Repr<'tcx> for ty::EquatePredicate<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::EquatePredicate<'tcx> { + fn repr(&self) -> String { format!("EquatePredicate({}, {})", - self.0.repr(tcx), - self.1.repr(tcx)) + self.0.repr(), + self.1.repr()) } } -impl<'tcx> UserString<'tcx> for ty::EquatePredicate<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for ty::EquatePredicate<'tcx> { + fn user_string(&self) -> String { format!("{} == {}", - self.0.user_string(tcx), - self.1.user_string(tcx)) + self.0.user_string(), + self.1.user_string()) } } -impl<'tcx> Repr<'tcx> for ty::TraitPredicate<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::TraitPredicate<'tcx> { + fn repr(&self) -> String { format!("TraitPredicate({})", - self.trait_ref.repr(tcx)) + self.trait_ref.repr()) } } -impl<'tcx> UserString<'tcx> for ty::TraitPredicate<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for ty::TraitPredicate<'tcx> { + fn user_string(&self) -> String { format!("{} : {}", - self.trait_ref.self_ty().user_string(tcx), - self.trait_ref.user_string(tcx)) + self.trait_ref.self_ty().user_string(), + self.trait_ref.user_string()) } } -impl<'tcx> UserString<'tcx> for ty::ProjectionPredicate<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for ty::ProjectionPredicate<'tcx> { + fn user_string(&self) -> String { format!("{} == {}", - self.projection_ty.user_string(tcx), - self.ty.user_string(tcx)) + self.projection_ty.user_string(), + self.ty.user_string()) } } -impl<'tcx> Repr<'tcx> for ty::ProjectionTy<'tcx> { - fn repr(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> Repr for ty::ProjectionTy<'tcx> { + fn repr(&self) -> String { format!("{}::{}", - self.trait_ref.repr(tcx), - self.item_name.repr(tcx)) + self.trait_ref.repr(), + self.item_name.repr()) } } -impl<'tcx> UserString<'tcx> for ty::ProjectionTy<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for ty::ProjectionTy<'tcx> { + fn user_string(&self) -> String { format!("<{} as {}>::{}", - self.trait_ref.self_ty().user_string(tcx), - self.trait_ref.user_string(tcx), - self.item_name.user_string(tcx)) + self.trait_ref.self_ty().user_string(), + self.trait_ref.user_string(), + self.item_name.user_string()) } } -impl<'tcx> UserString<'tcx> for ty::Predicate<'tcx> { - fn user_string(&self, tcx: &ctxt<'tcx>) -> String { +impl<'tcx> UserString for ty::Predicate<'tcx> { + fn user_string(&self) -> String { match *self { - ty::Predicate::Trait(ref data) => data.user_string(tcx), - ty::Predicate::Equate(ref predicate) => predicate.user_string(tcx), - ty::Predicate::RegionOutlives(ref predicate) => predicate.user_string(tcx), - ty::Predicate::TypeOutlives(ref predicate) => predicate.user_string(tcx), - ty::Predicate::Projection(ref predicate) => predicate.user_string(tcx), + ty::Predicate::Trait(ref data) => data.user_string(), + ty::Predicate::Equate(ref predicate) => predicate.user_string(), + ty::Predicate::RegionOutlives(ref predicate) => predicate.user_string(), + ty::Predicate::TypeOutlives(ref predicate) => predicate.user_string(), + ty::Predicate::Projection(ref predicate) => predicate.user_string(), } } } -impl<'tcx> Repr<'tcx> for ast::Unsafety { - fn repr(&self, _: &ctxt<'tcx>) -> String { +impl Repr for ast::Unsafety { + fn repr(&self) -> String { format!("{:?}", *self) } } diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 90bc918c4b197..b15586cc2b455 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -98,7 +98,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { debug!("consume(consume_id={}, cmt={}, mode={:?})", - consume_id, cmt.repr(self.tcx()), mode); + consume_id, cmt.repr(), mode); self.consume_common(consume_id, consume_span, cmt, mode); } @@ -113,8 +113,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { debug!("consume_pat(consume_pat={}, cmt={}, mode={:?})", - consume_pat.repr(self.tcx()), - cmt.repr(self.tcx()), + consume_pat.repr(), + cmt.repr(), mode); self.consume_common(consume_pat.id, consume_pat.span, cmt, mode); @@ -130,7 +130,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { { debug!("borrow(borrow_id={}, cmt={}, loan_region={:?}, \ bk={:?}, loan_cause={:?})", - borrow_id, cmt.repr(self.tcx()), loan_region, + borrow_id, cmt.repr(), loan_region, bk, loan_cause); match opt_loan_path(&cmt) { @@ -154,7 +154,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { mode: euv::MutateMode) { debug!("mutate(assignment_id={}, assignee_cmt={})", - assignment_id, assignee_cmt.repr(self.tcx())); + assignment_id, assignee_cmt.repr()); match opt_loan_path(&assignee_cmt) { Some(lp) => { @@ -385,8 +385,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! simultaneously. debug!("report_error_if_loans_conflict(old_loan={}, new_loan={})", - old_loan.repr(self.tcx()), - new_loan.repr(self.tcx())); + old_loan.repr(), + new_loan.repr()); // Should only be called for loans that are in scope at the same time. assert!(self.tcx().region_maps.scopes_intersect(old_loan.kill_scope, @@ -409,8 +409,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { debug!("report_error_if_loan_conflicts_with_restriction(\ loan1={}, loan2={})", - loan1.repr(self.tcx()), - loan2.repr(self.tcx())); + loan1.repr(), + loan2.repr()); if compatible_borrow_kinds(loan1.kind, loan2.kind) { return true; @@ -674,7 +674,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { -> UseError<'tcx> { debug!("analyze_restrictions_on_use(expr_id={}, use_path={})", self.tcx().map.node_to_string(expr_id), - use_path.repr(self.tcx())); + use_path.repr()); let mut ret = UseOk; @@ -699,7 +699,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { use_kind: MovedValueUseKind, lp: &Rc>) { debug!("check_if_path_is_moved(id={}, use_kind={:?}, lp={})", - id, use_kind, lp.repr(self.bccx.tcx)); + id, use_kind, lp.repr()); // FIXME (22079): if you find yourself tempted to cut and paste // the body below and then specializing the error reporting, @@ -792,7 +792,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { assignment_span: Span, assignee_cmt: mc::cmt<'tcx>, mode: euv::MutateMode) { - debug!("check_assignment(assignee_cmt={})", assignee_cmt.repr(self.tcx())); + debug!("check_assignment(assignee_cmt={})", assignee_cmt.repr()); // Mutable values can be assigned, as long as they obey loans // and aliasing restrictions: @@ -884,7 +884,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! `used_mut_nodes` table here. loop { - debug!("mark_variable_as_used_mut(cmt={})", cmt.repr(this.tcx())); + debug!("mark_variable_as_used_mut(cmt={})", cmt.repr()); match cmt.cat.clone() { mc::cat_upvar(mc::Upvar { id: ty::UpvarId { var_id: id, .. }, .. }) | mc::cat_local(id) => { @@ -930,7 +930,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { let guarantor = cmt.guarantor(); debug!("check_for_aliasable_mutable_writes(cmt={}, guarantor={})", - cmt.repr(this.tcx()), guarantor.repr(this.tcx())); + cmt.repr(), guarantor.repr()); if let mc::cat_deref(ref b, _, mc::BorrowedPtr(ty::MutBorrow, _)) = guarantor.cat { // Statically prohibit writes to `&mut` when aliasable check_for_aliasability_violation(this, span, b.clone()); diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index a70b1dfe187e4..75e9c09fb3da4 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -43,7 +43,7 @@ enum Fragment { impl Fragment { fn loan_path_repr<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String { - let repr = |mpi| move_data.path_loan_path(mpi).repr(tcx); + let repr = |mpi| move_data.path_loan_path(mpi).repr(); match *self { Just(mpi) => repr(mpi), AllButOneFrom(mpi) => format!("$(allbutone {})", repr(mpi)), @@ -53,7 +53,7 @@ impl Fragment { fn loan_path_user_string<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String { - let user_string = |mpi| move_data.path_loan_path(mpi).user_string(tcx); + let user_string = |mpi| move_data.path_loan_path(mpi).user_string(); match *self { Just(mpi) => user_string(mpi), AllButOneFrom(mpi) => format!("$(allbutone {})", user_string(mpi)), @@ -126,7 +126,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>, let instrument_all_paths = |kind, vec_rc: &Vec| { for (i, mpi) in vec_rc.iter().enumerate() { - let render = || this.path_loan_path(*mpi).user_string(tcx); + let render = || this.path_loan_path(*mpi).user_string(); if span_err { tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())); } @@ -172,7 +172,7 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) { let mut assigned = mem::replace(&mut fragments.assigned_leaf_paths, vec![]); let path_lps = |mpis: &[MovePathIndex]| -> Vec { - mpis.iter().map(|mpi| this.path_loan_path(*mpi).repr(tcx)).collect() + mpis.iter().map(|mpi| this.path_loan_path(*mpi).repr()).collect() }; let frag_lps = |fs: &[Fragment]| -> Vec { @@ -344,7 +344,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>, mc::PositionalField(tuple_idx) => tuple_idx, mc::NamedField(_) => panic!("tuple type {} should not have named fields.", - parent_ty.repr(tcx)), + parent_ty.repr()), }; let tuple_len = v.len(); for i in 0..tuple_len { @@ -419,7 +419,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>, ref sty_and_variant_info => { let msg = format!("type {} ({:?}) is not fragmentable", - parent_ty.repr(tcx), sty_and_variant_info); + parent_ty.repr(), sty_and_variant_info); let opt_span = origin_id.and_then(|id|tcx.map.opt_span(id)); tcx.sess.opt_span_bug(opt_span, &msg[..]) } @@ -451,7 +451,7 @@ fn add_fragment_sibling_core<'tcx>(this: &MoveData<'tcx>, let new_lp_variant = LpExtend(parent, mc, loan_path_elem); let new_lp = LoanPath::new(new_lp_variant, new_lp_type.unwrap()); debug!("add_fragment_sibling_core(new_lp={}, origin_lp={})", - new_lp.repr(tcx), origin_lp.repr(tcx)); + new_lp.repr(), origin_lp.repr()); let mp = this.move_path(tcx, Rc::new(new_lp)); // Do not worry about checking for duplicates here; we will sort diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 43877d592ae15..e1410daf279fe 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -67,7 +67,7 @@ pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, mode: euv::MatchMode) { let tcx = bccx.tcx; debug!("gather_match_variant(move_pat={}, cmt={}, mode={:?})", - move_pat.id, cmt.repr(tcx), mode); + move_pat.id, cmt.repr(), mode); let opt_lp = opt_loan_path(&cmt); match opt_lp { @@ -116,13 +116,13 @@ fn gather_move<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_error_collector: &MoveErrorCollector<'tcx>, move_info: GatherMoveInfo<'tcx>) { debug!("gather_move(move_id={}, cmt={})", - move_info.id, move_info.cmt.repr(bccx.tcx)); + move_info.id, move_info.cmt.repr()); let potentially_illegal_move = check_and_get_illegal_move_origin(bccx, &move_info.cmt); match potentially_illegal_move { Some(illegal_move_origin) => { - debug!("illegal_move_origin={}", illegal_move_origin.repr(bccx.tcx)); + debug!("illegal_move_origin={}", illegal_move_origin.repr()); let error = MoveError::with_move_info(illegal_move_origin, move_info.span_path_opt); move_error_collector.add_error(error); diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 9f7b4cf26e1c4..e4911543e6b54 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -34,7 +34,7 @@ pub fn guarantee_lifetime<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, //! where S is `item_scope` if `cmt` is an upvar, //! and is scope of `cmt` otherwise. debug!("guarantee_lifetime(cmt={}, loan_region={})", - cmt.repr(bccx.tcx), loan_region.repr(bccx.tcx)); + cmt.repr(), loan_region.repr()); let ctxt = GuaranteeLifetimeContext {bccx: bccx, item_scope: item_scope, span: span, @@ -66,8 +66,8 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { //! "guarantor". Reports an error if `self.loan_region` is //! larger than scope of `cmt`. debug!("guarantee_lifetime.check(cmt={}, loan_region={})", - cmt.repr(self.bccx.tcx), - self.loan_region.repr(self.bccx.tcx)); + cmt.repr(), + self.loan_region.repr()); match cmt.cat { mc::cat_rvalue(..) | diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 012e01507de72..a33104bff7053 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -77,7 +77,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { debug!("consume(consume_id={}, cmt={}, mode={:?})", - consume_id, cmt.repr(self.tcx()), mode); + consume_id, cmt.repr(), mode); match mode { euv::Move(move_reason) => { @@ -94,8 +94,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { cmt: mc::cmt<'tcx>, mode: euv::MatchMode) { debug!("matched_pat(matched_pat={}, cmt={}, mode={:?})", - matched_pat.repr(self.tcx()), - cmt.repr(self.tcx()), + matched_pat.repr(), + cmt.repr(), mode); if let mc::cat_downcast(..) = cmt.cat { @@ -110,8 +110,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { debug!("consume_pat(consume_pat={}, cmt={}, mode={:?})", - consume_pat.repr(self.tcx()), - cmt.repr(self.tcx()), + consume_pat.repr(), + cmt.repr(), mode); match mode { @@ -134,7 +134,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { { debug!("borrow(borrow_id={}, cmt={}, loan_region={:?}, \ bk={:?}, loan_cause={:?})", - borrow_id, cmt.repr(self.tcx()), loan_region, + borrow_id, cmt.repr(), loan_region, bk, loan_cause); self.guarantee_valid(borrow_id, @@ -153,7 +153,7 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { { let opt_lp = opt_loan_path(&assignee_cmt); debug!("mutate(assignment_id={}, assignee_cmt={}) opt_lp={:?}", - assignment_id, assignee_cmt.repr(self.tcx()), opt_lp); + assignment_id, assignee_cmt.repr(), opt_lp); match opt_lp { Some(lp) => { @@ -237,7 +237,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { debug!("guarantee_valid(borrow_id={}, cmt={}, \ req_mutbl={:?}, loan_region={:?})", borrow_id, - cmt.repr(self.tcx()), + cmt.repr(), req_kind, loan_region); @@ -337,7 +337,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { }; debug!("guarantee_valid(borrow_id={}), loan={}", - borrow_id, loan.repr(self.tcx())); + borrow_id, loan.repr()); // let loan_path = loan.loan_path; // let loan_gen_scope = loan.gen_scope; @@ -377,7 +377,7 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { -> Result<(),()> { //! Implements the M-* rules in README.md. debug!("check_mutability(cause={:?} cmt={} req_kind={:?}", - cause, cmt.repr(bccx.tcx), req_kind); + cause, cmt.repr(), req_kind); match req_kind { ty::UniqueImmBorrow | ty::ImmBorrow => { match cmt.mutbl { @@ -507,7 +507,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> { pub fn gather_loans_in_static_initializer(bccx: &mut BorrowckCtxt, expr: &ast::Expr) { - debug!("gather_loans_in_static_initializer(expr={})", expr.repr(bccx.tcx)); + debug!("gather_loans_in_static_initializer(expr={})", expr.repr()); let mut sicx = StaticInitializerCtxt { bccx: bccx diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index d16e0fdc19fea..bc52fc7622cf1 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -130,7 +130,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, bccx.span_err(move_from.span, &format!("cannot move out of type `{}`, \ a non-copy fixed-size array", - b.ty.user_string(bccx.tcx))); + b.ty.user_string())); } } @@ -143,7 +143,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_from.span, &format!("cannot move out of type `{}`, \ which defines the `Drop` trait", - b.ty.user_string(bccx.tcx))); + b.ty.user_string())); }, _ => { bccx.span_bug(move_from.span, "this path should not cause illegal move") diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index 56f49a3047bf5..274a08dfe1108 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -58,7 +58,7 @@ struct RestrictionsContext<'a, 'tcx: 'a> { impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { fn restrict(&self, cmt: mc::cmt<'tcx>) -> RestrictionResult<'tcx> { - debug!("restrict(cmt={})", cmt.repr(self.bccx.tcx)); + debug!("restrict(cmt={})", cmt.repr()); let new_lp = |v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty)); diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 5833386dd1f02..93b16795fe8d0 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -682,7 +682,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { which is {}", ol, moved_lp_msg, - expr_ty.user_string(self.tcx), + expr_ty.user_string(), suggestion)); } else { self.tcx.sess.span_note( @@ -690,7 +690,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { &format!("`{}` moved here{} because it has type `{}`, which is {}", ol, moved_lp_msg, - expr_ty.user_string(self.tcx), + expr_ty.user_string(), suggestion)); } } @@ -703,7 +703,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { which is moved by default", ol, moved_lp_msg, - pat_ty.user_string(self.tcx))); + pat_ty.user_string())); self.tcx.sess.fileline_help(span, "use `ref` to override"); } @@ -734,7 +734,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { has type `{}`, which is {}", ol, moved_lp_msg, - expr_ty.user_string(self.tcx), + expr_ty.user_string(), suggestion)); self.tcx.sess.fileline_help(expr_span, help); } @@ -1148,8 +1148,8 @@ impl DataFlowOperator for LoanDataFlowOperator { } } -impl<'tcx> Repr<'tcx> for InteriorKind { - fn repr(&self, _tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for InteriorKind { + fn repr(&self) -> String { match *self { InteriorField(mc::NamedField(fld)) => format!("{}", token::get_name(fld)), @@ -1159,77 +1159,77 @@ impl<'tcx> Repr<'tcx> for InteriorKind { } } -impl<'tcx> Repr<'tcx> for Loan<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for Loan<'tcx> { + fn repr(&self) -> String { format!("Loan_{}({}, {:?}, {:?}-{:?}, {})", self.index, - self.loan_path.repr(tcx), + self.loan_path.repr(), self.kind, self.gen_scope, self.kill_scope, - self.restricted_paths.repr(tcx)) + self.restricted_paths.repr()) } } -impl<'tcx> Repr<'tcx> for LoanPath<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for LoanPath<'tcx> { + fn repr(&self) -> String { match self.kind { LpVar(id) => { - format!("$({})", tcx.map.node_to_string(id)) + format!("$({})", ty::tls::with(|tcx| tcx.map.node_to_string(id))) } LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => { - let s = tcx.map.node_to_string(var_id); + let s = ty::tls::with(|tcx| tcx.map.node_to_string(var_id)); format!("$({} captured by id={})", s, closure_expr_id) } LpDowncast(ref lp, variant_def_id) => { let variant_str = if variant_def_id.krate == ast::LOCAL_CRATE { - ty::item_path_str(tcx, variant_def_id) + ty::tls::with(|tcx| ty::item_path_str(tcx, variant_def_id)) } else { - variant_def_id.repr(tcx) + variant_def_id.repr() }; - format!("({}{}{})", lp.repr(tcx), DOWNCAST_PRINTED_OPERATOR, variant_str) + format!("({}{}{})", lp.repr(), DOWNCAST_PRINTED_OPERATOR, variant_str) } LpExtend(ref lp, _, LpDeref(_)) => { - format!("{}.*", lp.repr(tcx)) + format!("{}.*", lp.repr()) } LpExtend(ref lp, _, LpInterior(ref interior)) => { - format!("{}.{}", lp.repr(tcx), interior.repr(tcx)) + format!("{}.{}", lp.repr(), interior.repr()) } } } } -impl<'tcx> UserString<'tcx> for LoanPath<'tcx> { - fn user_string(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> UserString for LoanPath<'tcx> { + fn user_string(&self) -> String { match self.kind { LpVar(id) => { - format!("$({})", tcx.map.node_to_user_string(id)) + format!("$({})", ty::tls::with(|tcx| tcx.map.node_to_user_string(id))) } LpUpvar(ty::UpvarId{ var_id, closure_expr_id: _ }) => { - let s = tcx.map.node_to_user_string(var_id); + let s = ty::tls::with(|tcx| tcx.map.node_to_user_string(var_id)); format!("$({} captured by closure)", s) } LpDowncast(ref lp, variant_def_id) => { let variant_str = if variant_def_id.krate == ast::LOCAL_CRATE { - ty::item_path_str(tcx, variant_def_id) + ty::tls::with(|tcx| ty::item_path_str(tcx, variant_def_id)) } else { - variant_def_id.repr(tcx) + variant_def_id.repr() }; - format!("({}{}{})", lp.user_string(tcx), DOWNCAST_PRINTED_OPERATOR, variant_str) + format!("({}{}{})", lp.user_string(), DOWNCAST_PRINTED_OPERATOR, variant_str) } LpExtend(ref lp, _, LpDeref(_)) => { - format!("{}.*", lp.user_string(tcx)) + format!("{}.*", lp.user_string()) } LpExtend(ref lp, _, LpInterior(ref interior)) => { - format!("{}.{}", lp.user_string(tcx), interior.repr(tcx)) + format!("{}.{}", lp.user_string(), interior.repr()) } } } diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 0f56aa9fb1f65..1b9b15a673aea 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -314,7 +314,7 @@ impl<'tcx> MoveData<'tcx> { }; debug!("move_path(lp={}, index={:?})", - lp.repr(tcx), + lp.repr(), index); assert_eq!(index.get(), self.paths.borrow().len() - 1); @@ -365,7 +365,7 @@ impl<'tcx> MoveData<'tcx> { id: ast::NodeId, kind: MoveKind) { debug!("add_move(lp={}, id={}, kind={:?})", - lp.repr(tcx), + lp.repr(), id, kind); @@ -395,7 +395,7 @@ impl<'tcx> MoveData<'tcx> { assignee_id: ast::NodeId, mode: euv::MutateMode) { debug!("add_assignment(lp={}, assign_id={}, assignee_id={}", - lp.repr(tcx), assign_id, assignee_id); + lp.repr(), assign_id, assignee_id); let path_index = self.move_path(tcx, lp.clone()); @@ -416,12 +416,12 @@ impl<'tcx> MoveData<'tcx> { if self.is_var_path(path_index) { debug!("add_assignment[var](lp={}, assignment={}, path_index={:?})", - lp.repr(tcx), self.var_assignments.borrow().len(), path_index); + lp.repr(), self.var_assignments.borrow().len(), path_index); self.var_assignments.borrow_mut().push(assignment); } else { debug!("add_assignment[path](lp={}, path_index={:?})", - lp.repr(tcx), path_index); + lp.repr(), path_index); self.path_assignments.borrow_mut().push(assignment); } @@ -438,7 +438,7 @@ impl<'tcx> MoveData<'tcx> { base_lp: Rc>, mode: euv::MatchMode) { debug!("add_variant_match(lp={}, pattern_id={})", - lp.repr(tcx), pattern_id); + lp.repr(), pattern_id); let path_index = self.move_path(tcx, lp.clone()); let base_path_index = self.move_path(tcx, base_lp.clone()); diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 597682c89eee8..7f07966991105 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -318,7 +318,7 @@ impl<'a, 'tcx> pprust::PpAnn for TypedAnnotation<'a, 'tcx> { try!(pp::word(&mut s.s, "as")); try!(pp::space(&mut s.s)); try!(pp::word(&mut s.s, - &ty::expr_ty(self.tcx, expr).user_string(self.tcx))); + &ty::expr_ty(self.tcx, expr).user_string())); s.pclose() } _ => Ok(()) diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index c3f5dc084fd83..16f35a8c10a8b 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -188,7 +188,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { -> Option { assert!(idx < names.len()); for item in &m.items { - if item.ident.user_string(this.infcx.tcx) == names[idx] { + if item.ident.user_string() == names[idx] { return search(this, &**item, idx+1, names); } } @@ -253,7 +253,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { } pub fn ty_to_string(&self, a: Ty<'tcx>) -> String { - a.user_string(self.infcx.tcx) + a.user_string() } pub fn t_fn(&self, @@ -388,8 +388,8 @@ impl<'a, 'tcx> Env<'a, 'tcx> { Ok(_) => { } Err(ref e) => { panic!("unexpected error computing sub({},{}): {}", - t1.repr(self.infcx.tcx), - t2.repr(self.infcx.tcx), + t1.repr(), + t2.repr(), ty::type_err_to_str(self.infcx.tcx, e)); } } @@ -402,8 +402,8 @@ impl<'a, 'tcx> Env<'a, 'tcx> { Err(_) => { } Ok(_) => { panic!("unexpected success computing sub({},{})", - t1.repr(self.infcx.tcx), - t2.repr(self.infcx.tcx)); + t1.repr(), + t2.repr()); } } } @@ -659,7 +659,7 @@ fn glb_bound_free_infer() { let t_resolve1 = env.infcx.shallow_resolve(t_infer1); match t_resolve1.sty { ty::TyRef(..) => { } - _ => { panic!("t_resolve1={}", t_resolve1.repr(env.infcx.tcx)); } + _ => { panic!("t_resolve1={}", t_resolve1.repr()); } } }) } @@ -702,10 +702,10 @@ fn subst_ty_renumber_bound() { }; debug!("subst_bound: t_source={} substs={} t_substituted={} t_expected={}", - t_source.repr(env.infcx.tcx), - substs.repr(env.infcx.tcx), - t_substituted.repr(env.infcx.tcx), - t_expected.repr(env.infcx.tcx)); + t_source.repr(), + substs.repr(), + t_substituted.repr(), + t_expected.repr()); assert_eq!(t_substituted, t_expected); }) @@ -739,10 +739,10 @@ fn subst_ty_renumber_some_bounds() { }; debug!("subst_bound: t_source={} substs={} t_substituted={} t_expected={}", - t_source.repr(env.infcx.tcx), - substs.repr(env.infcx.tcx), - t_substituted.repr(env.infcx.tcx), - t_expected.repr(env.infcx.tcx)); + t_source.repr(), + substs.repr(), + t_substituted.repr(), + t_expected.repr()); assert_eq!(t_substituted, t_expected); }) @@ -800,10 +800,10 @@ fn subst_region_renumber_region() { }; debug!("subst_bound: t_source={} substs={} t_substituted={} t_expected={}", - t_source.repr(env.infcx.tcx), - substs.repr(env.infcx.tcx), - t_substituted.repr(env.infcx.tcx), - t_expected.repr(env.infcx.tcx)); + t_source.repr(), + substs.repr(), + t_substituted.repr(), + t_expected.repr()); assert_eq!(t_substituted, t_expected); }) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 755d7af9d4f63..ed8f7372b660c 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -495,7 +495,7 @@ impl BoxPointers { }); if n_uniq > 0 { - let s = ty.user_string(cx.tcx); + let s = ty.user_string(); let m = format!("type uses owned (Box type) pointers: {}", s); cx.span_lint(BOX_POINTERS, span, &m[..]); } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index a5bca132e02d0..eeebe03c21ba1 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -347,7 +347,7 @@ pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathEl pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, name: &str) -> String { - let path = [PathName(token::intern(&t.user_string(ccx.tcx()))), + let path = [PathName(token::intern(&t.user_string())), gensym_name(name)]; let hash = get_symbol_hash(ccx, t); mangle(path.iter().cloned(), Some(&hash[..])) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index 6ec58337e723e..fb174d8ff276e 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -287,7 +287,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { collector.visit_pat(&arg.pat); let span_utils = self.span.clone(); for &(id, ref p, _, _) in &collector.collected_paths { - let typ = self.tcx.node_types().get(&id).unwrap().user_string(self.tcx); + let typ = self.tcx.node_types().get(&id).unwrap().user_string(); // get the span only for the name of the variable (I hope the path is only ever a // variable name, but who knows?) self.fmt.formal_str(p.span, @@ -1392,7 +1392,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { "".to_string() }; let types = self.tcx.node_types(); - let typ = types.get(&id).unwrap().user_string(self.tcx); + let typ = types.get(&id).unwrap().user_string(); // Get the span only for the name of the variable (I hope the path // is only ever a variable name, but who knows?). let sub_span = self.span.span_for_last_ident(p.span); diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 4116e6637aea6..efdc1195a9528 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -293,7 +293,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { self.tcx.map.path_to_string(parent), name); let typ = self.tcx.node_types().get(&field.node.id).unwrap() - .user_string(self.tcx); + .user_string(); let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); Some(Data::VariableData(VariableData { id: field.node.id, diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 898b9b9662db4..065aad96f7943 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -217,7 +217,7 @@ use middle::ty::{self, Ty}; use session::config::{NoDebugInfo, FullDebugInfo}; use util::common::indenter; use util::nodemap::FnvHashMap; -use util::ppaux::Repr; +use util::ppaux::{self, Repr}; use std; use std::cmp::Ordering; @@ -371,11 +371,11 @@ struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> { pat_renaming_map: Option<&'a FnvHashMap<(NodeId, Span), NodeId>> } -impl<'a, 'p, 'blk, 'tcx> Repr<'tcx> for Match<'a, 'p, 'blk, 'tcx> { - fn repr(&self, tcx: &ty::ctxt) -> String { - if tcx.sess.verbose() { +impl<'a, 'p, 'blk, 'tcx> Repr for Match<'a, 'p, 'blk, 'tcx> { + fn repr(&self) -> String { + if ppaux::verbose() { // for many programs, this just take too long to serialize - self.pats.repr(tcx) + self.pats.repr() } else { format!("{} pats", self.pats.len()) } @@ -399,7 +399,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, -> Vec> { debug!("expand_nested_bindings(bcx={}, m={}, col={}, val={})", bcx.to_str(), - m.repr(bcx.tcx()), + m.repr(), col, bcx.val_to_string(val)); let _indenter = indenter(); @@ -439,7 +439,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, { debug!("enter_match(bcx={}, m={}, col={}, val={})", bcx.to_str(), - m.repr(bcx.tcx()), + m.repr(), col, bcx.val_to_string(val)); let _indenter = indenter(); @@ -482,7 +482,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, -> Vec> { debug!("enter_default(bcx={}, m={}, col={}, val={})", bcx.to_str(), - m.repr(bcx.tcx()), + m.repr(), col, bcx.val_to_string(val)); let _indenter = indenter(); @@ -539,7 +539,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>( -> Vec> { debug!("enter_opt(bcx={}, m={}, opt={:?}, col={}, val={})", bcx.to_str(), - m.repr(bcx.tcx()), + m.repr(), *opt, col, bcx.val_to_string(val)); @@ -940,7 +940,7 @@ fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, debug!("compile_guard(bcx={}, guard_expr={}, m={}, vals=[{}])", bcx.to_str(), bcx.expr_to_string(guard_expr), - m.repr(bcx.tcx()), + m.repr(), vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); let _indenter = indenter(); @@ -985,7 +985,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, has_genuine_default: bool) { debug!("compile_submatch(bcx={}, m={}, vals=[{}])", bcx.to_str(), - m.repr(bcx.tcx()), + m.repr(), vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); let _indenter = indenter(); let _icx = push_ctxt("match::compile_submatch"); @@ -1698,11 +1698,11 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, -> Block<'blk, 'tcx> { debug!("bind_irrefutable_pat(bcx={}, pat={})", bcx.to_str(), - pat.repr(bcx.tcx())); + pat.repr()); if bcx.sess().asm_comments() { add_comment(bcx, &format!("bind_irrefutable_pat(pat={})", - pat.repr(bcx.tcx()))); + pat.repr())); } let _indenter = indenter(); diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index 5b8986878c7ab..dc5d3ea2f6248 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -143,7 +143,7 @@ pub fn represent_node<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Rc> { - debug!("Representing: {}", t.repr(cx.tcx())); + debug!("Representing: {}", t.repr()); match cx.adt_reprs().borrow().get(&t) { Some(repr) => return repr.clone(), None => {} @@ -382,7 +382,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, General(ity, fields, dtor_to_init_u8(dtor)) } _ => cx.sess().bug(&format!("adt::represent_type called on non-ADT type: {}", - t.repr(cx.tcx()))) + t.repr())) } } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index f66188dcfb0c8..291541aa98ff8 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -531,7 +531,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, } _ => { cx.sess().unimpl(&format!("type in iter_structural_ty: {}", - t.repr(cx.tcx()))) + t.repr())) } } return cx; @@ -641,7 +641,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>( } _ => { cx.sess().bug(&format!("fail-if-zero on unexpected type: {}", - rhs_t.repr(cx.tcx()))); + rhs_t.repr())); } }; let bcx = with_cond(cx, is_zero, |bcx| { @@ -1193,7 +1193,7 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>, } else { ccx.tcx().map.path_to_string(id).to_string() }, - id, param_substs.repr(ccx.tcx())); + id, param_substs.repr()); let uses_outptr = match output_type { ty::FnConverging(output_type) => { @@ -1511,7 +1511,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>, attributes::emit_uwtable(llfndecl, true); debug!("trans_closure(..., param_substs={})", - param_substs.repr(ccx.tcx())); + param_substs.repr()); let has_env = match closure_env { closure::ClosureEnv::Closure(_) => true, @@ -1554,7 +1554,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }; for monomorphized_arg_type in &monomorphized_arg_types { debug!("trans_closure: monomorphized_arg_type: {}", - monomorphized_arg_type.repr(ccx.tcx())); + monomorphized_arg_type.repr()); } debug!("trans_closure: function lltype: {}", bcx.fcx.ccx.tn().val_to_string(bcx.fcx.llfn)); @@ -1636,7 +1636,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, id: ast::NodeId, attrs: &[ast::Attribute]) { let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string()); - debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx())); + debug!("trans_fn(param_substs={})", param_substs.repr()); let _icx = push_ctxt("trans_fn"); let fn_ty = ty::node_id_to_type(ccx.tcx(), id); let output_type = ty::erase_late_bound_regions(ccx.tcx(), &ty::ty_fn_ret(fn_ty)); @@ -1680,7 +1680,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, _ => ccx.sess().bug( &format!("trans_enum_variant_constructor: \ unexpected ctor return type {}", - ctor_ty.repr(tcx))) + ctor_ty.repr())) }; // Get location to store the result. If the user does not care about @@ -1758,7 +1758,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx _ => ccx.sess().bug( &format!("trans_enum_variant_or_tuple_like_struct: \ unexpected ctor return type {}", - ctor_ty.repr(ccx.tcx()))) + ctor_ty.repr())) }; let (arena, fcx): (TypedArena<_>, FunctionContext); diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 610ac6a113bd6..a06598a7cbe33 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -89,7 +89,7 @@ pub struct Callee<'blk, 'tcx: 'blk> { fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) -> Callee<'blk, 'tcx> { let _icx = push_ctxt("trans_callee"); - debug!("callee::trans(expr={})", expr.repr(bcx.tcx())); + debug!("callee::trans(expr={})", expr.repr()); // pick out special kinds of expressions that can be called: match expr.node { @@ -134,7 +134,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) def: def::Def, ref_expr: &ast::Expr) -> Callee<'blk, 'tcx> { - debug!("trans_def(def={}, ref_expr={})", def.repr(bcx.tcx()), ref_expr.repr(bcx.tcx())); + debug!("trans_def(def={}, ref_expr={})", def.repr(), ref_expr.repr()); let expr_ty = common::node_id_type(bcx, ref_expr.id); match def { def::DefFn(did, _) if { @@ -229,9 +229,9 @@ pub fn trans_fn_ref<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let substs = common::node_id_substs(ccx, node, param_substs); debug!("trans_fn_ref(def_id={}, node={:?}, substs={})", - def_id.repr(ccx.tcx()), + def_id.repr(), node, - substs.repr(ccx.tcx())); + substs.repr()); trans_fn_ref_with_substs(ccx, def_id, node, param_substs, substs) } @@ -292,7 +292,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( } debug!("trans_fn_pointer_shim(bare_fn_ty={})", - bare_fn_ty.repr(tcx)); + bare_fn_ty.repr()); // Construct the "tuply" version of `bare_fn_ty`. It takes two arguments: `self`, // which is the fn pointer, and `args`, which is the arguments tuple. @@ -307,7 +307,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( _ => { tcx.sess.bug(&format!("trans_fn_pointer_shim invoked on invalid type: {}", - bare_fn_ty.repr(tcx))); + bare_fn_ty.repr())); } }; let sig = ty::erase_late_bound_regions(tcx, sig); @@ -323,7 +323,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( output: sig.output, variadic: false })})); - debug!("tuple_fn_ty: {}", tuple_fn_ty.repr(tcx)); + debug!("tuple_fn_ty: {}", tuple_fn_ty.repr()); // let function_name = link::mangle_internal_name_by_type_and_seq(ccx, bare_fn_ty, @@ -403,10 +403,10 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>( debug!("trans_fn_ref_with_substs(def_id={}, node={:?}, \ param_substs={}, substs={})", - def_id.repr(tcx), + def_id.repr(), node, - param_substs.repr(tcx), - substs.repr(tcx)); + param_substs.repr(), + substs.repr()); assert!(substs.types.all(|t| !ty::type_needs_infer(*t))); assert!(substs.types.all(|t| !ty::type_has_escaping_regions(*t))); @@ -459,8 +459,8 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>( debug!("trans_fn_with_vtables - default method: \ substs = {}, trait_subst = {}, \ first_subst = {}, new_subst = {}", - substs.repr(tcx), trait_ref.substs.repr(tcx), - first_subst.repr(tcx), new_substs.repr(tcx)); + substs.repr(), trait_ref.substs.repr(), + first_subst.repr(), new_substs.repr()); (true, source_id, new_substs) } @@ -505,7 +505,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>( }; debug!("trans_fn_ref_with_substs({}) must_monomorphise: {}", - def_id.repr(tcx), must_monomorphise); + def_id.repr(), must_monomorphise); // Create a monomorphic version of generic functions if must_monomorphise { @@ -615,7 +615,7 @@ pub fn trans_method_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, dest: expr::Dest) -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_method_call"); - debug!("trans_method_call(call_expr={})", call_expr.repr(bcx.tcx())); + debug!("trans_method_call(call_expr={})", call_expr.repr()); let method_call = MethodCall::expr(call_expr.id); let method_ty = match bcx.tcx().method_map.borrow().get(&method_call) { Some(method) => match method.origin { @@ -1126,7 +1126,7 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let ccx = bcx.ccx(); debug!("trans_arg_datum({})", - formal_arg_ty.repr(bcx.tcx())); + formal_arg_ty.repr()); let arg_datum_ty = arg_datum.ty; @@ -1165,8 +1165,8 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty); debug!("casting actual type ({}) to match formal ({})", bcx.val_to_string(val), bcx.llty_str(llformal_arg_ty)); - debug!("Rust types: {}; {}", arg_datum_ty.repr(bcx.tcx()), - formal_arg_ty.repr(bcx.tcx())); + debug!("Rust types: {}; {}", arg_datum_ty.repr(), + formal_arg_ty.repr()); val = PointerCast(bcx, val, llformal_arg_ty); } diff --git a/src/librustc_trans/trans/cleanup.rs b/src/librustc_trans/trans/cleanup.rs index 9133004dfeff1..97fe4dfb2a7a6 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/trans/cleanup.rs @@ -400,7 +400,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { debug!("schedule_drop_mem({:?}, val={}, ty={}) fill_on_drop={} skip_dtor={}", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(self.ccx.tcx()), + ty.repr(), drop.fill_on_drop, drop.skip_dtor); @@ -426,7 +426,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { debug!("schedule_drop_and_fill_mem({:?}, val={}, ty={}, fill_on_drop={}, skip_dtor={})", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(self.ccx.tcx()), + ty.repr(), drop.fill_on_drop, drop.skip_dtor); @@ -458,7 +458,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { debug!("schedule_drop_adt_contents({:?}, val={}, ty={}) fill_on_drop={} skip_dtor={}", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(self.ccx.tcx()), + ty.repr(), drop.fill_on_drop, drop.skip_dtor); @@ -484,7 +484,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { debug!("schedule_drop_immediate({:?}, val={}, ty={:?}) fill_on_drop={} skip_dtor={}", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(self.ccx.tcx()), + ty.repr(), drop.fill_on_drop, drop.skip_dtor); diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index 27080966fcb45..ef8839c6d5d14 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -354,8 +354,8 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( -> ValueRef { debug!("trans_fn_once_adapter_shim(closure_def_id={}, substs={}, llreffn={})", - closure_def_id.repr(ccx.tcx()), - substs.repr(ccx.tcx()), + closure_def_id.repr(), + substs.repr(), ccx.tn().val_to_string(llreffn)); let tcx = ccx.tcx(); @@ -375,7 +375,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( sig: sig.clone() }); let llref_fn_ty = ty::mk_bare_fn(tcx, None, llref_bare_fn_ty); debug!("trans_fn_once_adapter_shim: llref_fn_ty={}", - llref_fn_ty.repr(tcx)); + llref_fn_ty.repr()); // Make a version of the closure type with the same arguments, but // with argument #0 being by value. @@ -424,7 +424,7 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( ty::TyTuple(ref tys) => &**tys, _ => bcx.sess().bug(&format!("trans_fn_once_adapter_shim: not rust-call! \ closure_def_id={}", - closure_def_id.repr(tcx))) + closure_def_id.repr())) }; let llargs: Vec<_> = input_tys.iter() diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 1cabeb268562d..1f8e7e07568eb 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -64,11 +64,11 @@ pub use trans::context::CrateContext; /// subtyping, but they are anonymized and normalized as well). This /// is a stronger, caching version of `ty_fold::erase_regions`. pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { let value1 = value.fold_with(&mut RegionEraser(cx)); debug!("erase_regions({}) = {}", - value.repr(cx), value1.repr(cx)); + value.repr(), value1.repr()); return value1; struct RegionEraser<'a, 'tcx: 'a>(&'a ty::ctxt<'tcx>); @@ -88,7 +88,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T } fn fold_binder(&mut self, t: &ty::Binder) -> ty::Binder - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { let u = ty::anonymize_late_bound_regions(self.tcx(), t); ty_fold::super_fold_binder(self, &u) @@ -212,7 +212,7 @@ fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>, // destructor (e.g. zero its memory on move). let contents = ty::type_contents(cx, ty); - debug!("type_needs_drop ty={} contents={:?}", ty.repr(cx), contents); + debug!("type_needs_drop ty={} contents={:?}", ty.repr(), contents); contents.needs_drop(cx) } @@ -518,7 +518,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { } pub fn monomorphize(&self, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone { monomorphize::apply_param_substs(self.ccx.tcx(), self.param_substs, @@ -594,7 +594,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { } pub fn expr_to_string(&self, e: &ast::Expr) -> String { - e.repr(self.tcx()) + e.repr() } pub fn def(&self, nid: ast::NodeId) -> def::Def { @@ -616,7 +616,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { } pub fn ty_to_string(&self, t: Ty<'tcx>) -> String { - t.repr(self.tcx()) + t.repr() } pub fn to_str(&self) -> String { @@ -624,7 +624,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { } pub fn monomorphize(&self, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone { monomorphize::apply_param_substs(self.tcx(), self.fcx.param_substs, @@ -994,14 +994,14 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // First check the cache. match ccx.trait_cache().borrow().get(&trait_ref) { Some(vtable) => { - info!("Cache hit: {}", trait_ref.repr(ccx.tcx())); + info!("Cache hit: {}", trait_ref.repr()); return (*vtable).clone(); } None => { } } debug!("trans fulfill_obligation: trait_ref={} def_id={:?}", - trait_ref.repr(ccx.tcx()), trait_ref.def_id()); + trait_ref.repr(), trait_ref.def_id()); ty::populate_implementations_for_trait_if_necessary(tcx, trait_ref.def_id()); let infcx = infer::new_infer_ctxt(tcx); @@ -1024,7 +1024,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // where ambiguity can result. debug!("Encountered ambiguity selecting `{}` during trans, \ presuming due to overflow", - trait_ref.repr(tcx)); + trait_ref.repr()); ccx.sess().span_fatal( span, "reached the recursion limit during monomorphization"); @@ -1033,8 +1033,8 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, tcx.sess.span_bug( span, &format!("Encountered error `{}` selecting `{}` during trans", - e.repr(tcx), - trait_ref.repr(tcx))) + e.repr(), + trait_ref.repr())) } }; @@ -1047,7 +1047,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }); let vtable = drain_fulfillment_cx_or_panic(span, &infcx, &mut fulfill_cx, &vtable); - info!("Cache miss: {}", trait_ref.repr(ccx.tcx())); + info!("Cache miss: {}", trait_ref.repr()); ccx.trait_cache().borrow_mut().insert(trait_ref, vtable.clone()); @@ -1063,7 +1063,7 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, -> bool { debug!("normalize_and_test_predicates(predicates={})", - predicates.repr(ccx.tcx())); + predicates.repr()); let tcx = ccx.tcx(); let infcx = infer::new_infer_ctxt(tcx); @@ -1135,7 +1135,7 @@ pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span, fulfill_cx: &mut traits::FulfillmentContext<'tcx>, result: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { match drain_fulfillment_cx(infcx, fulfill_cx, result) { Ok(v) => v, @@ -1143,7 +1143,7 @@ pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span, infcx.tcx.sess.span_bug( span, &format!("Encountered errors `{}` fulfilling during trans", - errors.repr(infcx.tcx))); + errors.repr())); } } } @@ -1159,10 +1159,10 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &infer::InferCtxt<'a,'tcx>, fulfill_cx: &mut traits::FulfillmentContext<'tcx>, result: &T) -> StdResult>> - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { debug!("drain_fulfillment_cx(result={})", - result.repr(infcx.tcx)); + result.repr()); // In principle, we only need to do this so long as `result` // contains unbound type parameters. It could be a slight @@ -1210,7 +1210,7 @@ pub fn node_id_substs<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, if substs.types.any(|t| ty::type_needs_infer(*t)) { tcx.sess.bug(&format!("type parameters for node {:?} include inference types: {:?}", - node, substs.repr(tcx))); + node, substs.repr())); } monomorphize::apply_param_substs(tcx, diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 54f7e381f5e5c..09f5509c5ac90 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -68,7 +68,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit) _ => cx.sess().span_bug(lit.span, &format!("integer literal has type {} (expected int \ or usize)", - lit_int_ty.repr(cx.tcx()))) + lit_int_ty.repr())) } } ast::LitFloat(ref fs, t) => { @@ -161,7 +161,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } None => { cx.sess().bug(&format!("unexpected dereferenceable type {}", - ty.repr(cx.tcx()))) + ty.repr())) } } } @@ -369,7 +369,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, llvm::LLVMDumpValue(C_undef(llty)); } cx.sess().bug(&format!("const {} of type {} has size {} instead of {}", - e.repr(cx.tcx()), ety_adjusted.repr(cx.tcx()), + e.repr(), ety_adjusted.repr(), csize, tsize)); } (llconst, ety_adjusted) @@ -477,9 +477,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, -> ValueRef { debug!("const_expr_unadjusted(e={}, ety={}, param_substs={})", - e.repr(cx.tcx()), - ety.repr(cx.tcx()), - param_substs.repr(cx.tcx())); + e.repr(), + ety.repr(), + param_substs.repr()); let map_list = |exprs: &[P]| -> Vec { exprs.iter() @@ -498,7 +498,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let (te1, ty) = const_expr(cx, &**e1, param_substs, fn_args); debug!("const_expr_unadjusted: te1={}, ty={}", cx.tn().val_to_string(te1), - ty.repr(cx.tcx())); + ty.repr()); let is_simd = ty::type_is_simd(cx.tcx(), ty); let intype = if is_simd { ty::simd_type(cx.tcx(), ty) @@ -621,12 +621,12 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, _ => cx.sess().span_bug(base.span, &format!("index-expr base must be a vector \ or string type, found {}", - bt.repr(cx.tcx()))) + bt.repr())) }, _ => cx.sess().span_bug(base.span, &format!("index-expr base must be a vector \ or string type, found {}", - bt.repr(cx.tcx()))) + bt.repr())) }; let len = llvm::LLVMConstIntGetZExtValue(len) as u64; @@ -654,7 +654,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let t_cast = ety; let llty = type_of::type_of(cx, t_cast); let (v, t_expr) = const_expr(cx, &**base, param_substs, fn_args); - debug!("trans_const_cast({} as {})", t_expr.repr(cx.tcx()), t_cast.repr(cx.tcx())); + debug!("trans_const_cast({} as {})", t_expr.repr(), t_cast.repr()); if expr::cast_is_noop(cx.tcx(), base, t_expr, t_cast) { return v; } diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 6bb6916176deb..ab76942ceee4b 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -767,7 +767,7 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { pub fn report_overbig_object(&self, obj: Ty<'tcx>) -> ! { self.sess().fatal( &format!("the type `{}` is too big for the current architecture", - obj.repr(self.tcx()))) + obj.repr())) } pub fn check_overflow(&self) -> bool { diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/trans/controlflow.rs index d203aeca0a757..b2cd99fc3ca89 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -36,14 +36,14 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>, -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_stmt"); let fcx = cx.fcx; - debug!("trans_stmt({})", s.repr(cx.tcx())); + debug!("trans_stmt({})", s.repr()); if cx.unreachable.get() { return cx; } if cx.sess().asm_comments() { - add_span_comment(cx, s.span, &s.repr(cx.tcx())); + add_span_comment(cx, s.span, &s.repr()); } let mut bcx = cx; diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index d73bc28ba1967..e6b47fdee7eec 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -616,7 +616,7 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> { pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { format!("Datum({}, {}, {:?})", ccx.tn().val_to_string(self.val), - self.ty.repr(ccx.tcx()), + self.ty.repr(), self.kind) } diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 842631ed94031..5ced8452b5f70 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -105,7 +105,7 @@ impl<'tcx> TypeMap<'tcx> { metadata: DIType) { if self.type_to_metadata.insert(type_, metadata).is_some() { cx.sess().bug(&format!("Type metadata for Ty '{}' is already in the TypeMap!", - type_.repr(cx.tcx()))); + type_.repr())); } } @@ -298,7 +298,7 @@ impl<'tcx> TypeMap<'tcx> { }, _ => { cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}", - type_.repr(cx.tcx()), type_.sty)) + type_.repr(), type_.sty)) } }; @@ -489,7 +489,7 @@ impl<'tcx> RecursiveTypeDescription<'tcx> { type_map.find_metadata_for_type(unfinished_type).is_none() { cx.sess().bug(&format!("Forward declaration of potentially recursive type \ '{}' was not found in TypeMap!", - unfinished_type.repr(cx.tcx())) + unfinished_type.repr()) ); } } @@ -677,7 +677,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, _ => { cx.sess().bug(&format!("debuginfo: Unexpected trait-object type in \ trait_pointer_metadata(): {}", - trait_type.repr(cx.tcx()))); + trait_type.repr())); } }; @@ -839,7 +839,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, the debuginfo::TypeMap but it \ was not. (Ty = {})", &unique_type_id_str[..], - t.user_string(cx.tcx())); + t.user_string()); cx.sess().span_bug(usage_site_span, &error_message[..]); } }; @@ -854,7 +854,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, debuginfo::TypeMap. \ UniqueTypeId={}, Ty={}", &unique_type_id_str[..], - t.user_string(cx.tcx())); + t.user_string()); cx.sess().span_bug(usage_site_span, &error_message[..]); } } diff --git a/src/librustc_trans/trans/debuginfo/type_names.rs b/src/librustc_trans/trans/debuginfo/type_names.rs index c5dd2c17822d3..e33f059a94554 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/trans/debuginfo/type_names.rs @@ -163,7 +163,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::TyProjection(..) | ty::TyParam(_) => { cx.sess().bug(&format!("debuginfo: Trying to create type name for \ - unexpected type: {}", t.repr(cx.tcx()))); + unexpected type: {}", t.repr())); } } diff --git a/src/librustc_trans/trans/declare.rs b/src/librustc_trans/trans/declare.rs index 935925e5a8fc6..56daf7d570f21 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/trans/declare.rs @@ -107,10 +107,10 @@ pub fn declare_cfn(ccx: &CrateContext, name: &str, fn_type: Type, pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, fn_type: ty::Ty<'tcx>) -> ValueRef { debug!("declare_rust_fn(name={:?}, fn_type={})", name, - fn_type.repr(ccx.tcx())); + fn_type.repr()); let fn_type = monomorphize::normalize_associated_type(ccx.tcx(), &fn_type); debug!("declare_rust_fn (after normalised associated types) fn_type={}", - fn_type.repr(ccx.tcx())); + fn_type.repr()); let function_type; // placeholder so that the memory ownership works out ok let (sig, abi, env) = match fn_type.sty { @@ -123,14 +123,14 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, let self_type = base::self_type_for_closure(ccx, closure_did, fn_type); let llenvironment_type = type_of::type_of_explicit_arg(ccx, self_type); debug!("declare_rust_fn function_type={} self_type={}", - function_type.repr(ccx.tcx()), self_type.repr(ccx.tcx())); + function_type.repr(), self_type.repr()); (&function_type.sig, abi::RustCall, Some(llenvironment_type)) } _ => ccx.sess().bug("expected closure or fn") }; let sig = ty::Binder(ty::erase_late_bound_regions(ccx.tcx(), sig)); - debug!("declare_rust_fn (after region erasure) sig={}", sig.repr(ccx.tcx())); + debug!("declare_rust_fn (after region erasure) sig={}", sig.repr()); let llfty = type_of::type_of_rust_fn(ccx, env, &sig, abi); debug!("declare_rust_fn llfty={}", ccx.tn().type_to_string(llfty)); diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 07a8cbc38d575..5a75a595b5c21 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -181,7 +181,7 @@ pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } - debug!("trans_into() expr={}", expr.repr(bcx.tcx())); + debug!("trans_into() expr={}", expr.repr()); let cleanup_debug_loc = debuginfo::get_cleanup_debug_loc_for_ast_node(bcx.ccx(), expr.id, @@ -330,8 +330,8 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>, Type::vtable_ptr(ccx)) } _ => ccx.sess().bug(&format!("unsized_info: invalid unsizing {} -> {}", - source.repr(ccx.tcx()), - target.repr(ccx.tcx()))) + source.repr(), + target.repr())) } } @@ -351,7 +351,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, Some(adj) => { adj } }; debug!("unadjusted datum for expr {}: {} adjustment={:?}", - expr.repr(bcx.tcx()), + expr.repr(), datum.to_string(bcx.ccx()), adjustment); match adjustment { @@ -502,7 +502,7 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } vtable => { bcx.sess().span_bug(span, &format!("invalid CoerceUnsized vtable: {}", - vtable.repr(bcx.tcx()))); + vtable.repr())); } }; @@ -546,8 +546,8 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } _ => bcx.sess().bug(&format!("coerce_unsized: invalid coercion {} -> {}", - source.ty.repr(bcx.tcx()), - target.ty.repr(bcx.tcx()))) + source.ty.repr(), + target.ty.repr())) } bcx } @@ -1283,7 +1283,7 @@ pub fn trans_def_fn_unadjusted<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ccx.tcx().sess.span_bug(ref_expr.span, &format!( "trans_def_fn_unadjusted invoked on: {:?} for {}", def, - ref_expr.repr(ccx.tcx()))); + ref_expr.repr())); } } } @@ -1356,7 +1356,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>, tcx.sess.bug(&format!( "cannot get field types from the enum type {} \ without a node ID", - ty.repr(tcx))); + ty.repr())); } Some(node_id) => { let def = tcx.def_map.borrow().get(&node_id).unwrap().full_def(); @@ -1379,7 +1379,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>, _ => { tcx.sess.bug(&format!( "cannot get field types from the type {}", - ty.repr(tcx))); + ty.repr())); } } } @@ -2060,7 +2060,7 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let t_in = expr_ty_adjusted(bcx, expr); let t_out = node_id_type(bcx, id); - debug!("trans_cast({} as {})", t_in.repr(bcx.tcx()), t_out.repr(bcx.tcx())); + debug!("trans_cast({} as {})", t_in.repr(), t_out.repr()); let mut ll_t_in = type_of::arg_type_of(ccx, t_in); let ll_t_out = type_of::arg_type_of(ccx, t_out); // Convert the value to be cast into a ValueRef, either by-ref or @@ -2124,8 +2124,8 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, _ => ccx.sess().span_bug(expr.span, &format!("translating unsupported cast: \ {} -> {}", - t_in.repr(bcx.tcx()), - t_out.repr(bcx.tcx())) + t_in.repr(), + t_out.repr()) ) }; return immediate_rvalue_bcx(bcx, newval, t_out).to_expr_datumblock(); @@ -2211,7 +2211,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let ccx = bcx.ccx(); debug!("deref_once(expr={}, datum={}, method_call={:?})", - expr.repr(bcx.tcx()), + expr.repr(), datum.to_string(ccx), method_call); @@ -2296,7 +2296,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, bcx.tcx().sess.span_bug( expr.span, &format!("deref invoked on expr of illegal type {}", - datum.ty.repr(bcx.tcx()))); + datum.ty.repr())); } }; diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index 9ad6df5a6aba1..bfbcbd92734e5 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -186,8 +186,8 @@ pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, debug!("register_foreign_item_fn(abi={}, \ ty={}, \ name={})", - abi.repr(ccx.tcx()), - fty.repr(ccx.tcx()), + abi.repr(), + fty.repr(), name); let cc = llvm_calling_convention(ccx, abi); @@ -238,7 +238,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, debug!("trans_native_call(callee_ty={}, \ llfn={}, \ llretptr={})", - callee_ty.repr(tcx), + callee_ty.repr(), ccx.tn().val_to_string(llfn), ccx.tn().val_to_string(llretptr)); @@ -613,13 +613,13 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ccx.sess().bug(&format!("build_rust_fn: extern fn {} has ty {}, \ expected a bare fn ty", ccx.tcx().map.path_to_string(id), - t.repr(tcx))); + t.repr())); } }; debug!("build_rust_fn: path={} id={} t={}", ccx.tcx().map.path_to_string(id), - id, t.repr(tcx)); + id, t.repr()); let llfn = declare::define_internal_rust_fn(ccx, &ps[..], t).unwrap_or_else(||{ ccx.sess().bug(&format!("symbol `{}` already defined", ps)); @@ -641,7 +641,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, debug!("build_wrap_fn(llrustfn={}, llwrapfn={}, t={})", ccx.tn().val_to_string(llrustfn), ccx.tn().val_to_string(llwrapfn), - t.repr(ccx.tcx())); + t.repr()); // Avoid all the Rust generation stuff and just generate raw // LLVM here. @@ -726,7 +726,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, return_ty={}", ccx.tn().val_to_string(slot), ccx.tn().type_to_string(llrust_ret_ty), - tys.fn_sig.output.repr(tcx)); + tys.fn_sig.output.repr()); llrust_args.push(slot); return_alloca = Some(slot); } @@ -818,7 +818,7 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // Perform the call itself debug!("calling llrustfn = {}, t = {}", - ccx.tn().val_to_string(llrustfn), t.repr(ccx.tcx())); + ccx.tn().val_to_string(llrustfn), t.repr()); let attributes = attributes::from_fn_type(ccx, t); let llrust_ret_val = builder.call(llrustfn, &llrust_args, Some(attributes)); @@ -940,7 +940,7 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, llsig={} -> {}, \ fn_ty={} -> {}, \ ret_def={}", - ty.repr(ccx.tcx()), + ty.repr(), ccx.tn().types_to_str(&llsig.llarg_tys), ccx.tn().type_to_string(llsig.llret_ty), ccx.tn().types_to_str(&fn_ty.arg_tys.iter().map(|t| t.ty).collect::>()), diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index a8e4783fbdd29..05cc16c9b8887 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -140,7 +140,7 @@ pub fn drop_ty_core<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, debug_loc: DebugLoc, skip_dtor: bool) -> Block<'blk, 'tcx> { // NB: v is an *alias* of type t here, not a direct value. - debug!("drop_ty_core(t={}, skip_dtor={})", t.repr(bcx.tcx()), skip_dtor); + debug!("drop_ty_core(t={}, skip_dtor={})", t.repr(), skip_dtor); let _icx = push_ctxt("drop_ty"); if bcx.fcx.type_needs_drop(t) { let ccx = bcx.ccx(); @@ -207,10 +207,10 @@ impl<'tcx> DropGlueKind<'tcx> { fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { match *self { DropGlueKind::Ty(ty) => { - format!("DropGlueKind::Ty({})", ty.repr(ccx.tcx())) + format!("DropGlueKind::Ty({})", ty.repr()) } DropGlueKind::TyContents(ty) => { - format!("DropGlueKind::TyContents({})", ty.repr(ccx.tcx())) + format!("DropGlueKind::TyContents({})", ty.repr()) } } } @@ -249,7 +249,7 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }); ccx.available_drop_glues().borrow_mut().insert(g, fn_nm); - let _s = StatRecorder::new(ccx, format!("drop {}", t.repr(ccx.tcx()))); + let _s = StatRecorder::new(ccx, format!("drop {}", t.repr())); let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty()); let (arena, fcx): (TypedArena<_>, FunctionContext); diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 41780e08b909a..c2b0d78ce1f88 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -102,7 +102,7 @@ pub fn check_intrinsics(ccx: &CrateContext) { continue; } - debug!("transmute_restriction: {}", transmute_restriction.repr(ccx.tcx())); + debug!("transmute_restriction: {}", transmute_restriction.repr()); assert!(!ty::type_has_params(transmute_restriction.substituted_from)); assert!(!ty::type_has_params(transmute_restriction.substituted_to)); @@ -121,10 +121,10 @@ pub fn check_intrinsics(ccx: &CrateContext) { transmute_restriction.span, &format!("transmute called on types with potentially different sizes: \ {} (could be {} bit{}) to {} (could be {} bit{})", - transmute_restriction.original_from.user_string(ccx.tcx()), + transmute_restriction.original_from.user_string(), from_type_size as usize, if from_type_size == 1 {""} else {"s"}, - transmute_restriction.original_to.user_string(ccx.tcx()), + transmute_restriction.original_to.user_string(), to_type_size as usize, if to_type_size == 1 {""} else {"s"})); } else { @@ -132,10 +132,10 @@ pub fn check_intrinsics(ccx: &CrateContext) { transmute_restriction.span, &format!("transmute called on types with different sizes: \ {} ({} bit{}) to {} ({} bit{})", - transmute_restriction.original_from.user_string(ccx.tcx()), + transmute_restriction.original_from.user_string(), from_type_size as usize, if from_type_size == 1 {""} else {"s"}, - transmute_restriction.original_to.user_string(ccx.tcx()), + transmute_restriction.original_to.user_string(), to_type_size as usize, if to_type_size == 1 {""} else {"s"})); } @@ -405,7 +405,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } (_, "type_name") => { let tp_ty = *substs.types.get(FnSpace, 0); - let ty_name = token::intern_and_get_ident(&tp_ty.user_string(ccx.tcx())); + let ty_name = token::intern_and_get_ident(&tp_ty.user_string()); C_str_slice(ccx, ty_name) } (_, "type_id") => { diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index 7827771994f98..7229995048aa2 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -62,7 +62,7 @@ pub fn trans_impl(ccx: &CrateContext, let _icx = push_ctxt("meth::trans_impl"); let tcx = ccx.tcx(); - debug!("trans_impl(name={}, id={})", name.repr(tcx), id); + debug!("trans_impl(name={}, id={})", name.repr(), id); let mut v = TransItemVisitor { ccx: ccx }; @@ -138,13 +138,13 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let span = bcx.tcx().map.span(method_call.expr_id); debug!("method_call={:?} trait_ref={} trait_ref id={:?} substs={:?}", method_call, - trait_ref.repr(bcx.tcx()), + trait_ref.repr(), trait_ref.0.def_id, trait_ref.0.substs); let origin = fulfill_obligation(bcx.ccx(), span, trait_ref.clone()); - debug!("origin = {}", origin.repr(bcx.tcx())); + debug!("origin = {}", origin.repr()); trans_monomorphized_callee(bcx, method_call, trait_ref.def_id(), @@ -234,7 +234,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, rcvr_self, Vec::new())); let trait_substs = tcx.mk_substs(trait_substs); - debug!("trait_substs={}", trait_substs.repr(tcx)); + debug!("trait_substs={}", trait_substs.repr()); let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id, substs: trait_substs }); let vtbl = fulfill_obligation(ccx, @@ -297,7 +297,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } _ => { tcx.sess.bug(&format!("static call to invalid vtable: {}", - vtbl.repr(tcx))); + vtbl.repr())); } } } @@ -391,7 +391,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, traits::VtableParam(..) => { bcx.sess().bug( &format!("resolved vtable bad vtable {} in trans", - vtable.repr(bcx.tcx()))); + vtable.repr())); } } } @@ -415,8 +415,8 @@ fn combine_impl_and_methods_tps<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let node_substs = node_id_substs(ccx, node, bcx.fcx.param_substs); - debug!("rcvr_substs={}", rcvr_substs.repr(ccx.tcx())); - debug!("node_substs={}", node_substs.repr(ccx.tcx())); + debug!("rcvr_substs={}", rcvr_substs.repr()); + debug!("node_substs={}", node_substs.repr()); // Break apart the type parameters from the node and type // parameters from the receiver. @@ -484,7 +484,7 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Load the data pointer from the object. debug!("trans_trait_callee_from_llval(callee_ty={}, vtable_index={}, llpair={})", - callee_ty.repr(ccx.tcx()), + callee_ty.repr(), vtable_index, bcx.val_to_string(llpair)); let llboxptr = GEPi(bcx, llpair, &[0, abi::FAT_PTR_ADDR]); @@ -557,8 +557,8 @@ pub fn trans_object_shim<'a, 'tcx>( let trait_id = upcast_trait_ref.def_id(); debug!("trans_object_shim(object_ty={}, upcast_trait_ref={}, method_offset_in_trait={})", - object_ty.repr(tcx), - upcast_trait_ref.repr(tcx), + object_ty.repr(), + upcast_trait_ref.repr(), method_offset_in_trait); let object_trait_ref = @@ -568,14 +568,14 @@ pub fn trans_object_shim<'a, 'tcx>( } _ => { tcx.sess.bug(&format!("trans_object_shim() called on non-object: {}", - object_ty.repr(tcx))); + object_ty.repr())); } }; // Upcast to the trait in question and extract out the substitutions. let upcast_trait_ref = ty::erase_late_bound_regions(tcx, &upcast_trait_ref); let object_substs = upcast_trait_ref.substs.clone().erase_regions(); - debug!("trans_object_shim: object_substs={}", object_substs.repr(tcx)); + debug!("trans_object_shim: object_substs={}", object_substs.repr()); // Lookup the type of this method as declared in the trait and apply substitutions. let method_ty = match ty::trait_item(tcx, trait_id, method_offset_in_trait) { @@ -587,7 +587,7 @@ pub fn trans_object_shim<'a, 'tcx>( let fty = monomorphize::apply_param_substs(tcx, &object_substs, &method_ty.fty); let fty = tcx.mk_bare_fn(fty); let method_ty = opaque_method_ty(tcx, fty); - debug!("trans_object_shim: fty={} method_ty={}", fty.repr(tcx), method_ty.repr(tcx)); + debug!("trans_object_shim: fty={} method_ty={}", fty.repr(), method_ty.repr()); // let shim_fn_ty = ty::mk_bare_fn(tcx, None, fty); @@ -628,7 +628,7 @@ pub fn trans_object_shim<'a, 'tcx>( _ => { bcx.sess().bug( &format!("rust-call expects a tuple not {}", - sig.inputs[1].repr(tcx))); + sig.inputs[1].repr())); } } } @@ -692,7 +692,7 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let tcx = ccx.tcx(); let _icx = push_ctxt("meth::get_vtable"); - debug!("get_vtable(trait_ref={})", trait_ref.repr(tcx)); + debug!("get_vtable(trait_ref={})", trait_ref.repr()); // Check the cache. match ccx.vtables().borrow().get(&trait_ref) { @@ -740,13 +740,13 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // cannot cast an unsized type into a trait object tcx.sess.bug( &format!("cannot get vtable for an object type: {}", - data.repr(tcx))); + data.repr())); } traits::VtableParam(..) => { tcx.sess.bug( &format!("resolved vtable for {} to bad vtable {} in trans", - trait_ref.repr(tcx), - vtable.repr(tcx))); + trait_ref.repr(), + vtable.repr())); } } }); @@ -777,9 +777,9 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let tcx = ccx.tcx(); debug!("emit_vtable_methods(impl_id={}, substs={}, param_substs={})", - impl_id.repr(tcx), - substs.repr(tcx), - param_substs.repr(tcx)); + impl_id.repr(), + substs.repr(), + param_substs.repr()); let trt_id = match ty::impl_trait_ref(tcx, impl_id) { Some(t_id) => t_id.def_id, @@ -807,7 +807,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // null. .map(|trait_method_def_id| { debug!("emit_vtable_methods: trait_method_def_id={}", - trait_method_def_id.repr(tcx)); + trait_method_def_id.repr()); let trait_method_type = match ty::impl_or_trait_item(tcx, trait_method_def_id) { ty::MethodTraitItem(m) => m, @@ -822,7 +822,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } debug!("emit_vtable_methods: trait_method_type={}", - trait_method_type.repr(tcx)); + trait_method_type.repr()); // The substitutions we have are on the impl, so we grab // the method type from the impl to substitute into. @@ -833,7 +833,7 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }; debug!("emit_vtable_methods: impl_method_type={}", - impl_method_type.repr(tcx)); + impl_method_type.repr()); // If this is a default method, it's possible that it // relies on where clauses that do not hold for this diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index e28dd77d5e58e..3744716960009 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -44,8 +44,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_id={}, \ real_substs={}, \ ref_id={:?})", - fn_id.repr(ccx.tcx()), - psubsts.repr(ccx.tcx()), + fn_id.repr(), + psubsts.repr(), ref_id); assert!(psubsts.types.all(|t| { @@ -61,7 +61,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let item_ty = ty::lookup_item_type(ccx.tcx(), fn_id).ty; - debug!("monomorphic_fn about to subst into {}", item_ty.repr(ccx.tcx())); + debug!("monomorphic_fn about to subst into {}", item_ty.repr()); let mono_ty = item_ty.subst(ccx.tcx(), psubsts); match ccx.monomorphized().borrow().get(&hash_id) { @@ -77,8 +77,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_id={}, \ psubsts={}, \ hash_id={:?})", - fn_id.repr(ccx.tcx()), - psubsts.repr(ccx.tcx()), + fn_id.repr(), + psubsts.repr(), hash_id); @@ -99,10 +99,10 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } } - debug!("mono_ty = {} (post-substitution)", mono_ty.repr(ccx.tcx())); + debug!("mono_ty = {} (post-substitution)", mono_ty.repr()); let mono_ty = normalize_associated_type(ccx.tcx(), &mono_ty); - debug!("mono_ty = {} (post-normalization)", mono_ty.repr(ccx.tcx())); + debug!("mono_ty = {} (post-normalization)", mono_ty.repr()); ccx.stats().n_monos.set(ccx.stats().n_monos.get() + 1); @@ -303,7 +303,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>, param_substs: &Substs<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone { let substituted = value.subst(tcx, param_substs); normalize_associated_type(tcx, &substituted) @@ -314,9 +314,9 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>, /// and hence we can be sure that all associated types will be /// completely normalized away. pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone { - debug!("normalize_associated_type(t={})", value.repr(tcx)); + debug!("normalize_associated_type(t={})", value.repr()); let value = erase_regions(tcx, value); @@ -334,8 +334,8 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T traits::normalize(&mut selcx, cause, &value); debug!("normalize_associated_type: result={} obligations={}", - result.repr(tcx), - obligations.repr(tcx)); + result.repr(), + obligations.repr()); let mut fulfill_cx = traits::FulfillmentContext::new(true); for obligation in obligations { diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index df3fd72cc4623..f2168d38c9e57 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -42,7 +42,7 @@ struct VecTypes<'tcx> { impl<'tcx> VecTypes<'tcx> { pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { format!("VecTypes {{unit_ty={}, llunit_ty={}}}", - self.unit_ty.user_string(ccx.tcx()), + self.unit_ty.user_string(), ccx.tn().type_to_string(self.llunit_ty)) } } diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index ecbeb714b4a94..4ec6edcea714d 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -100,7 +100,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, -> Type { debug!("type_of_rust_fn(sig={},abi={:?})", - sig.repr(cx.tcx()), + sig.repr(), abi); let sig = ty::erase_late_bound_regions(cx.tcx(), sig); @@ -229,7 +229,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ ty::TyProjection(..) | ty::TyInfer(..) | ty::TyParam(..) | ty::TyError(..) => { cx.sess().bug(&format!("fictitious type {} in sizing_type_of()", - t.repr(cx.tcx()))) + t.repr())) } ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!() }; @@ -298,7 +298,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> None => () } - debug!("type_of {} {:?}", t.repr(cx.tcx()), t.sty); + debug!("type_of {} {:?}", t.repr(), t.sty); assert!(!t.has_escaping_regions()); @@ -312,9 +312,9 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> if t != t_norm { let llty = in_memory_type_of(cx, t_norm); debug!("--> normalized {} {:?} to {} {:?} llty={}", - t.repr(cx.tcx()), + t.repr(), t, - t_norm.repr(cx.tcx()), + t_norm.repr(), t_norm, cx.tn().type_to_string(llty)); cx.lltypes().borrow_mut().insert(t, llty); @@ -364,7 +364,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> ty::TyTrait(_) => Type::vtable_ptr(cx), _ => panic!("Unexpected type returned from \ struct_tail: {} for ty={}", - unsized_part.repr(cx.tcx()), ty.repr(cx.tcx())) + unsized_part.repr(), ty.repr()) }; Type::struct_(cx, &[ptr_ty, info_ty], false) } @@ -419,7 +419,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> }; debug!("--> mapped t={} {:?} to llty={}", - t.repr(cx.tcx()), + t.repr(), t, cx.tn().type_to_string(llty)); @@ -449,7 +449,7 @@ fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, tps: &[Ty<'tcx>]) -> String { let base = ty::item_path_str(cx.tcx(), did); - let strings: Vec = tps.iter().map(|t| t.repr(cx.tcx())).collect(); + let strings: Vec = tps.iter().map(|t| t.repr()).collect(); let tstr = if strings.is_empty() { base } else { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index cec267b8f7658..b7516530e6f18 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -179,9 +179,9 @@ pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime) }; debug!("ast_region_to_region(lifetime={} id={}) yields {}", - lifetime.repr(tcx), + lifetime.repr(), lifetime.id, - r.repr(tcx)); + r.repr()); r } @@ -257,8 +257,8 @@ pub fn opt_ast_region_to_region<'tcx>( }; debug!("opt_ast_region_to_region(opt_lifetime={}) yields {}", - opt_lifetime.repr(this.tcx()), - r.repr(this.tcx())); + opt_lifetime.repr(), + r.repr()); r } @@ -375,8 +375,8 @@ fn create_substs_for_ast_path<'tcx>( debug!("create_substs_for_ast_path(decl_generics={}, self_ty={}, \ types_provided={}, region_substs={}", - decl_generics.repr(tcx), self_ty.repr(tcx), types_provided.repr(tcx), - region_substs.repr(tcx)); + decl_generics.repr(), self_ty.repr(), types_provided.repr(), + region_substs.repr()); assert_eq!(region_substs.regions().len(TypeSpace), decl_generics.regions.len(TypeSpace)); assert!(region_substs.types.is_empty()); @@ -441,8 +441,8 @@ fn create_substs_for_ast_path<'tcx>( "the type parameter `{}` must be explicitly specified \ in an object type because its default value `{}` references \ the type `Self`", - param.name.user_string(tcx), - default.user_string(tcx)); + param.name.user_string(), + default.user_string()); substs.types.push(TypeSpace, tcx.types.err); } else { // This is a default type parameter. @@ -649,7 +649,7 @@ fn trait_def_id<'tcx>(this: &AstConv<'tcx>, trait_ref: &ast::TraitRef) -> ast::D def::DefTrait(trait_def_id) => trait_def_id, _ => { span_fatal!(this.tcx().sess, path.span, E0245, "`{}` is not a trait", - path.user_string(this.tcx())); + path.user_string()); } } } @@ -879,7 +879,7 @@ fn ast_type_binding_to_poly_projection_predicate<'tcx>( let candidate = try!(one_bound_for_assoc_type(tcx, candidates, - &trait_ref.user_string(tcx), + &trait_ref.user_string(), &token::get_name(binding.item_name), binding.span)); @@ -1031,7 +1031,7 @@ fn trait_ref_to_object_type<'tcx>(this: &AstConv<'tcx>, let result = make_object_type(this, span, trait_ref, existential_bounds); debug!("trait_ref_to_object_type: result={}", - result.repr(this.tcx())); + result.repr()); result } @@ -1074,7 +1074,7 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>, for (trait_def_id, name) in associated_types { span_err!(tcx.sess, span, E0191, "the value of the associated type `{}` (from the trait `{}`) must be specified", - name.user_string(tcx), + name.user_string(), ty::item_path_str(tcx, trait_def_id)); } @@ -1160,7 +1160,7 @@ fn one_bound_for_assoc_type<'tcx>(tcx: &ty::ctxt<'tcx>, span_note!(tcx.sess, span, "associated type `{}` could derive from `{}`", ty_param_name, - bound.user_string(tcx)); + bound.user_string()); } } @@ -1183,7 +1183,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>, let tcx = this.tcx(); let assoc_name = item_segment.identifier.name; - debug!("associated_path_def_to_ty: {}::{}", ty.repr(tcx), token::get_name(assoc_name)); + debug!("associated_path_def_to_ty: {}::{}", ty.repr(), token::get_name(assoc_name)); check_path_args(tcx, slice::ref_slice(item_segment), NO_TPS | NO_REGIONS); @@ -1239,7 +1239,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>, _ => { report_ambiguous_associated_type(tcx, span, - &ty.user_string(tcx), + &ty.user_string(), "Trait", &token::get_name(assoc_name)); return (tcx.types.err, ty_path_def); @@ -1296,7 +1296,7 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>, return tcx.types.err; }; - debug!("qpath_to_ty: self_type={}", self_ty.repr(tcx)); + debug!("qpath_to_ty: self_type={}", self_ty.repr()); let trait_ref = ast_path_to_mono_trait_ref(this, rscope, @@ -1306,7 +1306,7 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>, Some(self_ty), trait_segment); - debug!("qpath_to_ty: trait_ref={}", trait_ref.repr(tcx)); + debug!("qpath_to_ty: trait_ref={}", trait_ref.repr()); this.projected_ty(span, trait_ref, item_segment.identifier.name) } @@ -1496,7 +1496,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, -> Ty<'tcx> { debug!("ast_ty_to_ty(ast_ty={})", - ast_ty.repr(this.tcx())); + ast_ty.repr()); let tcx = this.tcx(); @@ -1531,7 +1531,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, } ast::TyRptr(ref region, ref mt) => { let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region); - debug!("TyRef r={}", r.repr(this.tcx())); + debug!("TyRef r={}", r.repr()); let rscope1 = &ObjectLifetimeDefaultRscope::new( rscope, @@ -1569,7 +1569,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, } } else { tcx.sess.span_bug(ast_ty.span, - &format!("unbound path {}", ast_ty.repr(tcx))) + &format!("unbound path {}", ast_ty.repr())) }; let def = path_res.base_def; let base_ty_end = path.segments.len() - path_res.depth; @@ -1846,8 +1846,8 @@ fn determine_explicit_self_category<'a, 'tcx>(this: &AstConv<'tcx>, debug!("determine_explicit_self_category(self_info.untransformed_self_ty={} \ explicit_type={} \ modifiers=({},{})", - self_info.untransformed_self_ty.repr(this.tcx()), - explicit_type.repr(this.tcx()), + self_info.untransformed_self_ty.repr(), + explicit_type.repr(), impl_modifiers, method_modifiers); @@ -1881,7 +1881,7 @@ pub fn ty_of_closure<'tcx>( -> ty::ClosureTy<'tcx> { debug!("ty_of_closure(expected_sig={})", - expected_sig.repr(this.tcx())); + expected_sig.repr()); // new region names that appear inside of the fn decl are bound to // that function type @@ -1919,8 +1919,8 @@ pub fn ty_of_closure<'tcx>( ast::NoReturn(..) => ty::FnDiverging }; - debug!("ty_of_closure: input_tys={}", input_tys.repr(this.tcx())); - debug!("ty_of_closure: output_ty={}", output_ty.repr(this.tcx())); + debug!("ty_of_closure: input_tys={}", input_tys.repr()); + debug!("ty_of_closure: output_ty={}", output_ty.repr()); ty::ClosureTy { unsafety: unsafety, @@ -2039,8 +2039,8 @@ fn compute_object_lifetime_bound<'tcx>( debug!("compute_opt_region_bound(explicit_region_bounds={:?}, \ principal_trait_ref={}, builtin_bounds={})", explicit_region_bounds, - principal_trait_ref.repr(tcx), - builtin_bounds.repr(tcx)); + principal_trait_ref.repr(), + builtin_bounds.repr()); if explicit_region_bounds.len() > 1 { span_err!(tcx.sess, explicit_region_bounds[1].span, E0226, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 2f1447e071468..0f1498e2be7e2 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -41,8 +41,8 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, let tcx = pcx.fcx.ccx.tcx; debug!("check_pat(pat={},expected={})", - pat.repr(tcx), - expected.repr(tcx)); + pat.repr(), + expected.repr()); match pat.node { ast::PatWild(_) => { @@ -222,7 +222,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, } } else { tcx.sess.span_bug(pat.span, - &format!("unbound path {}", pat.repr(tcx))) + &format!("unbound path {}", pat.repr())) }; if let Some((opt_ty, segments, def)) = resolve_ty_and_def_ufcs(fcx, path_res, Some(self_ty), diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs index 377af080526b7..334fe2f54c03c 100644 --- a/src/librustc_typeck/check/assoc.rs +++ b/src/librustc_typeck/check/assoc.rs @@ -24,15 +24,15 @@ pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, body_id: ast::NodeId, value: &T) -> T - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr<'tcx> + where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr { - debug!("normalize_associated_types_in(value={})", value.repr(infcx.tcx)); + debug!("normalize_associated_types_in(value={})", value.repr()); let mut selcx = SelectionContext::new(infcx, typer); let cause = ObligationCause::new(span, body_id, MiscObligation); let Normalized { value: result, obligations } = traits::normalize(&mut selcx, cause, value); debug!("normalize_associated_types_in: result={} predicates={}", - result.repr(infcx.tcx), - obligations.repr(infcx.tcx)); + result.repr(), + obligations.repr()); for obligation in obligations { fulfillment_cx.register_predicate_obligation(infcx, obligation); } diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index aa2433a362a70..a5422e1e58e57 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -121,8 +121,8 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, -> Option> { debug!("try_overloaded_call_step(call_expr={}, adjusted_ty={}, autoderefs={})", - call_expr.repr(fcx.tcx()), - adjusted_ty.repr(fcx.tcx()), + call_expr.repr(), + adjusted_ty.repr(), autoderefs); // If the callee is a bare function or a closure, then we're all set. @@ -337,23 +337,23 @@ struct CallResolution<'tcx> { closure_def_id: ast::DefId, } -impl<'tcx> Repr<'tcx> for CallResolution<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for CallResolution<'tcx> { + fn repr(&self) -> String { format!("CallResolution(call_expr={}, callee_expr={}, adjusted_ty={}, \ autoderefs={}, fn_sig={}, closure_def_id={})", - self.call_expr.repr(tcx), - self.callee_expr.repr(tcx), - self.adjusted_ty.repr(tcx), + self.call_expr.repr(), + self.callee_expr.repr(), + self.adjusted_ty.repr(), self.autoderefs, - self.fn_sig.repr(tcx), - self.closure_def_id.repr(tcx)) + self.fn_sig.repr(), + self.closure_def_id.repr()) } } impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> { fn resolve<'a>(&mut self, fcx: &FnCtxt<'a,'tcx>) { debug!("DeferredCallResolution::resolve() {}", - self.repr(fcx.tcx())); + self.repr()); // we should not be invoked until the closure kind has been // determined by upvar inference @@ -376,7 +376,7 @@ impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> { ty::ty_fn_sig(method_callee.ty)).unwrap(); debug!("attempt_resolution: method_callee={}", - method_callee.repr(fcx.tcx())); + method_callee.repr()); for (&method_arg_ty, &self_arg_ty) in method_sig.inputs[1..].iter().zip(&self.fn_sig.inputs) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 9fefd7ac03690..14976bf95593f 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -192,8 +192,8 @@ impl<'tcx> CastCheck<'tcx> { self.expr_ty = structurally_resolved_type(fcx, self.span, self.expr_ty); self.cast_ty = structurally_resolved_type(fcx, self.span, self.cast_ty); - debug!("check_cast({}, {} as {})", self.expr.id, self.expr_ty.repr(fcx.tcx()), - self.cast_ty.repr(fcx.tcx())); + debug!("check_cast({}, {} as {})", self.expr.id, self.expr_ty.repr(), + self.cast_ty.repr()); if ty::type_is_error(self.expr_ty) || ty::type_is_error(self.cast_ty) { // No sense in giving duplicate error messages @@ -274,7 +274,7 @@ impl<'tcx> CastCheck<'tcx> { -> Result { debug!("check_ptr_ptr_cast m_expr={} m_cast={}", - m_expr.repr(fcx.tcx()), m_cast.repr(fcx.tcx())); + m_expr.repr(), m_cast.repr()); // ptr-ptr cast. vtables must match. // Cast to sized is OK diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index cac0a86124ee3..16d4c0f997ae1 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -29,8 +29,8 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, body: &'tcx ast::Block, expected: Expectation<'tcx>) { debug!("check_expr_closure(expr={},expected={})", - expr.repr(fcx.tcx()), - expected.repr(fcx.tcx())); + expr.repr(), + expected.repr()); // It's always helpful for inference if we know the kind of // closure sooner rather than later, so first examine the expected @@ -52,7 +52,7 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, debug!("check_closure opt_kind={:?} expected_sig={}", opt_kind, - expected_sig.repr(fcx.tcx())); + expected_sig.repr()); let mut fn_ty = astconv::ty_of_closure( fcx, @@ -87,8 +87,8 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, fn_ty.sig.0.inputs = vec![ty::mk_tup(fcx.tcx(), fn_ty.sig.0.inputs)]; debug!("closure for {} --> sig={} opt_kind={:?}", - expr_def_id.repr(fcx.tcx()), - fn_ty.sig.repr(fcx.tcx()), + expr_def_id.repr(), + fn_ty.sig.repr(), opt_kind); fcx.inh.closure_tys.borrow_mut().insert(expr_def_id, fn_ty); @@ -104,7 +104,7 @@ fn deduce_expectations_from_expected_type<'a,'tcx>( -> (Option>,Option) { debug!("deduce_expectations_from_expected_type(expected_ty={})", - expected_ty.repr(fcx.tcx())); + expected_ty.repr()); match expected_ty.sty { ty::TyTrait(ref object_type) => { @@ -139,7 +139,7 @@ fn deduce_expectations_from_obligations<'a,'tcx>( .iter() .filter_map(|obligation| { debug!("deduce_expectations_from_obligations: obligation.predicate={}", - obligation.predicate.repr(fcx.tcx())); + obligation.predicate.repr()); match obligation.predicate { // Given a Projection predicate, we can potentially infer @@ -201,7 +201,7 @@ fn deduce_sig_from_projection<'a,'tcx>( let tcx = fcx.tcx(); debug!("deduce_sig_from_projection({})", - projection.repr(tcx)); + projection.repr()); let trait_ref = projection.to_poly_trait_ref(); @@ -211,24 +211,24 @@ fn deduce_sig_from_projection<'a,'tcx>( let arg_param_ty = *trait_ref.substs().types.get(subst::TypeSpace, 0); let arg_param_ty = fcx.infcx().resolve_type_vars_if_possible(&arg_param_ty); - debug!("deduce_sig_from_projection: arg_param_ty {}", arg_param_ty.repr(tcx)); + debug!("deduce_sig_from_projection: arg_param_ty {}", arg_param_ty.repr()); let input_tys = match arg_param_ty.sty { ty::TyTuple(ref tys) => { (*tys).clone() } _ => { return None; } }; - debug!("deduce_sig_from_projection: input_tys {}", input_tys.repr(tcx)); + debug!("deduce_sig_from_projection: input_tys {}", input_tys.repr()); let ret_param_ty = projection.0.ty; let ret_param_ty = fcx.infcx().resolve_type_vars_if_possible(&ret_param_ty); - debug!("deduce_sig_from_projection: ret_param_ty {}", ret_param_ty.repr(tcx)); + debug!("deduce_sig_from_projection: ret_param_ty {}", ret_param_ty.repr()); let fn_sig = ty::FnSig { inputs: input_tys, output: ty::FnConverging(ret_param_ty), variadic: false }; - debug!("deduce_sig_from_projection: fn_sig {}", fn_sig.repr(tcx)); + debug!("deduce_sig_from_projection: fn_sig {}", fn_sig.repr()); Some(fn_sig) } @@ -241,8 +241,8 @@ fn self_type_matches_expected_vid<'a,'tcx>( { let self_ty = fcx.infcx().shallow_resolve(trait_ref.self_ty()); debug!("self_type_matches_expected_vid(trait_ref={}, self_ty={})", - trait_ref.repr(fcx.tcx()), - self_ty.repr(fcx.tcx())); + trait_ref.repr(), + self_ty.repr()); match self_ty.sty { ty::TyInfer(ty::TyVar(v)) if expected_vid == v => Some(trait_ref), _ => None, diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 2c332b65a48d4..d10a605adb427 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -105,8 +105,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: Ty<'tcx>) -> CoerceResult<'tcx> { debug!("Coerce.tys({} => {})", - a.repr(self.tcx()), - b.repr(self.tcx())); + a.repr(), + b.repr()); // Consider coercing the subtype to a DST let unsize = self.unpack_actual_value(a, |a| { @@ -167,8 +167,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { mutbl_b: ast::Mutability) -> CoerceResult<'tcx> { debug!("coerce_borrowed_pointer(a={}, b={})", - a.repr(self.tcx()), - b.repr(self.tcx())); + a.repr(), + b.repr()); // If we have a parameter of type `&M T_a` and the value // provided is `expr`, we will be adding an implicit borrow, @@ -239,8 +239,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { target: Ty<'tcx>) -> CoerceResult<'tcx> { debug!("coerce_unsized(source={}, target={})", - source.repr(self.tcx()), - target.repr(self.tcx())); + source.repr(), + target.repr()); let traits = (self.tcx().lang_items.unsize_trait(), self.tcx().lang_items.coerce_unsized_trait()); @@ -294,7 +294,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // inference might unify those two inner type variables later. let traits = [coerce_unsized_did, unsize_did]; while let Some(obligation) = queue.pop_front() { - debug!("coerce_unsized resolve step: {}", obligation.repr(self.tcx())); + debug!("coerce_unsized resolve step: {}", obligation.repr()); let trait_ref = match obligation.predicate { ty::Predicate::Trait(ref tr) if traits.contains(&tr.def_id()) => { tr.clone() @@ -336,7 +336,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { autoref: reborrow, unsize: Some(target) }; - debug!("Success, coerced with {}", adjustment.repr(self.tcx())); + debug!("Success, coerced with {}", adjustment.repr()); Ok(Some(AdjustDerefRef(adjustment))) } @@ -353,7 +353,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { self.unpack_actual_value(b, |b| { debug!("coerce_from_fn_pointer(a={}, b={})", - a.repr(self.tcx()), b.repr(self.tcx())); + a.repr(), b.repr()); if let ty::TyBareFn(None, fn_ty_b) = b.sty { match (fn_ty_a.unsafety, fn_ty_b.unsafety) { @@ -381,7 +381,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { self.unpack_actual_value(b, |b| { debug!("coerce_from_fn_item(a={}, b={})", - a.repr(self.tcx()), b.repr(self.tcx())); + a.repr(), b.repr()); match b.sty { ty::TyBareFn(None, _) => { @@ -400,8 +400,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { mutbl_b: ast::Mutability) -> CoerceResult<'tcx> { debug!("coerce_unsafe_ptr(a={}, b={})", - a.repr(self.tcx()), - b.repr(self.tcx())); + a.repr(), + b.repr()); let (is_ref, mt_a) = match a.sty { ty::TyRef(_, mt) => (true, mt), @@ -436,7 +436,7 @@ pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()> { - debug!("mk_assignty({} -> {})", a.repr(fcx.tcx()), b.repr(fcx.tcx())); + debug!("mk_assignty({} -> {})", a.repr(), b.repr()); let mut unsizing_obligations = vec![]; let adjustment = try!(indent(|| { fcx.infcx().commit_if_ok(|_| { @@ -460,7 +460,7 @@ pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } if let Some(adjustment) = adjustment { - debug!("Success, coerced with {}", adjustment.repr(fcx.tcx())); + debug!("Success, coerced with {}", adjustment.repr()); fcx.write_adjustment(expr.id, adjustment); } Ok(()) diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 11069fdfd698d..eb50b231155bb 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -39,10 +39,10 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, trait_m: &ty::Method<'tcx>, impl_trait_ref: &ty::TraitRef<'tcx>) { debug!("compare_impl_method(impl_trait_ref={})", - impl_trait_ref.repr(tcx)); + impl_trait_ref.repr()); debug!("compare_impl_method: impl_trait_ref (liberated) = {}", - impl_trait_ref.repr(tcx)); + impl_trait_ref.repr()); let infcx = infer::new_infer_ctxt(tcx); let mut fulfillment_cx = traits::FulfillmentContext::new(true); @@ -64,7 +64,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, "method `{}` has a `{}` declaration in the impl, \ but not in the trait", token::get_name(trait_m.name), - impl_m.explicit_self.repr(tcx)); + impl_m.explicit_self.repr()); return; } (_, &ty::StaticExplicitSelfCategory) => { @@ -72,7 +72,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, "method `{}` has a `{}` declaration in the trait, \ but not in the impl", token::get_name(trait_m.name), - trait_m.explicit_self.repr(tcx)); + trait_m.explicit_self.repr()); return; } _ => { @@ -184,7 +184,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, .with_method(impl_to_skol_substs.types.get_slice(subst::FnSpace).to_vec(), impl_to_skol_substs.regions().get_slice(subst::FnSpace).to_vec()); debug!("compare_impl_method: trait_to_skol_substs={}", - trait_to_skol_substs.repr(tcx)); + trait_to_skol_substs.repr()); // Check region bounds. FIXME(@jroesch) refactor this away when removing // ParamBounds. @@ -212,7 +212,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, infer::HigherRankedType, &ty::Binder(impl_bounds)); debug!("compare_impl_method: impl_bounds={}", - impl_bounds.repr(tcx)); + impl_bounds.repr()); // Normalize the associated types in the trait_bounds. let trait_bounds = trait_m.predicates.instantiate(tcx, &trait_to_skol_substs); @@ -243,7 +243,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, normalize_cause.clone()); debug!("compare_impl_method: trait_bounds={}", - trait_param_env.caller_bounds.repr(tcx)); + trait_param_env.caller_bounds.repr()); let mut selcx = traits::SelectionContext::new(&infcx, &trait_param_env); @@ -304,7 +304,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, abi: impl_m.fty.abi, sig: ty::Binder(impl_sig) })); debug!("compare_impl_method: impl_fty={}", - impl_fty.repr(tcx)); + impl_fty.repr()); let (trait_sig, skol_map) = infcx.skolemize_late_bound_regions(&trait_m.fty.sig, snapshot); @@ -325,7 +325,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, sig: ty::Binder(trait_sig) })); debug!("compare_impl_method: trait_fty={}", - trait_fty.repr(tcx)); + trait_fty.repr()); try!(infer::mk_subty(&infcx, false, origin, impl_fty, trait_fty)); @@ -336,8 +336,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, Ok(()) => { } Err(terr) => { debug!("checking trait method for compatibility: impl ty {}, trait ty {}", - impl_fty.repr(tcx), - trait_fty.repr(tcx)); + impl_fty.repr(), + trait_fty.repr()); span_err!(tcx.sess, impl_m_span, E0053, "method `{}` has an incompatible type for trait: {}", token::get_name(trait_m.name), @@ -385,10 +385,10 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, impl_generics={} \ trait_to_skol_substs={} \ impl_to_skol_substs={}", - trait_generics.repr(tcx), - impl_generics.repr(tcx), - trait_to_skol_substs.repr(tcx), - impl_to_skol_substs.repr(tcx)); + trait_generics.repr(), + impl_generics.repr(), + trait_to_skol_substs.repr(), + impl_to_skol_substs.repr()); // Must have same number of early-bound lifetime parameters. // Unfortunately, if the user screws up the bounds, then this @@ -417,7 +417,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, trait_c: &ty::AssociatedConst<'tcx>, impl_trait_ref: &ty::TraitRef<'tcx>) { debug!("compare_const_impl(impl_trait_ref={})", - impl_trait_ref.repr(tcx)); + impl_trait_ref.repr()); let infcx = infer::new_infer_ctxt(tcx); let mut fulfillment_cx = traits::FulfillmentContext::new(true); @@ -444,7 +444,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, .with_method(impl_to_skol_substs.types.get_slice(subst::FnSpace).to_vec(), impl_to_skol_substs.regions().get_slice(subst::FnSpace).to_vec()); debug!("compare_const_impl: trait_to_skol_substs={}", - trait_to_skol_substs.repr(tcx)); + trait_to_skol_substs.repr()); // Compute skolemized form of impl and trait const tys. let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs); @@ -462,7 +462,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, 0, &impl_ty); debug!("compare_const_impl: impl_ty={}", - impl_ty.repr(tcx)); + impl_ty.repr()); let trait_ty = assoc::normalize_associated_types_in(&infcx, @@ -472,7 +472,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, 0, &trait_ty); debug!("compare_const_impl: trait_ty={}", - trait_ty.repr(tcx)); + trait_ty.repr()); infer::mk_subty(&infcx, false, origin, impl_ty, trait_ty) }); @@ -481,8 +481,8 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, Ok(()) => { } Err(terr) => { debug!("checking associated const for compatibility: impl ty {}, trait ty {}", - impl_ty.repr(tcx), - trait_ty.repr(tcx)); + impl_ty.repr(), + trait_ty.repr()); span_err!(tcx.sess, impl_c_span, E0326, "implemented const `{}` has an incompatible type for \ trait: {}", diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index cd6a1226e00c9..3fc833034d221 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -60,8 +60,8 @@ pub fn coerce<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, expr: &ast::Expr) { let expr_ty = fcx.expr_ty(expr); debug!("demand::coerce(expected = {}, expr_ty = {})", - expected.repr(fcx.ccx.tcx), - expr_ty.repr(fcx.ccx.tcx)); + expected.repr(), + expr_ty.repr()); let expr_ty = fcx.resolve_type_vars_if_possible(expr_ty); let expected = fcx.resolve_type_vars_if_possible(expected); match coercion::mk_assignty(fcx, expr, expr_ty, expected) { diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 6e6231dec324b..14238179f87c2 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -62,7 +62,7 @@ pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: ast::DefId) -> Result<(), let span = tcx.map.def_id_span(drop_impl_did, codemap::DUMMY_SP); tcx.sess.span_bug( span, &format!("should have been rejected by coherence check: {}", - dtor_self_type.repr(tcx))); + dtor_self_type.repr())); } } } @@ -212,7 +212,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( if !assumptions_in_impl_context.contains(&predicate) { let item_span = tcx.map.span(self_type_did.node); - let req = predicate.user_string(tcx); + let req = predicate.user_string(); span_err!(tcx.sess, drop_impl_span, E0367, "The requirement `{}` is added only by the Drop impl.", req); tcx.sess.span_note(item_span, @@ -258,7 +258,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> span: Span, scope: region::CodeExtent) { debug!("check_safety_of_destructor_if_necessary typ: {} scope: {:?}", - typ.repr(rcx.tcx()), scope); + typ.repr(), scope); // types that have been traversed so far by `traverse_type_if_unseen` let mut breadcrumbs: Vec> = Vec::new(); @@ -278,7 +278,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> let tcx = rcx.tcx(); span_err!(tcx.sess, span, E0320, "overflow while adding drop-check rules for {}", - typ.user_string(rcx.tcx())); + typ.user_string()); match *ctxt { TypeContext::Root => { // no need for an additional note if the overflow @@ -294,7 +294,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> ty::item_path_str(tcx, def_id), variant, arg_index, - detected_on_typ.user_string(rcx.tcx())); + detected_on_typ.user_string()); } TypeContext::Struct { def_id, field } => { span_note!( @@ -303,7 +303,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> "overflowed on struct {} field {} type: {}", ty::item_path_str(tcx, def_id), field, - detected_on_typ.user_string(rcx.tcx())); + detected_on_typ.user_string()); } } } @@ -373,7 +373,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( .opt_get(subst::TypeSpace, 0).unwrap(); let new_typ = substs.type_for_def(tp_def); debug!("replacing phantom {} with {}", - typ.repr(rcx.tcx()), new_typ.repr(rcx.tcx())); + typ.repr(), new_typ.repr()); (new_typ, xref_depth_orig + 1) } else { (typ, xref_depth_orig) @@ -385,7 +385,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( // puts us into the previous case. ty::TyBox(new_typ) => { debug!("replacing TyBox {} with {}", - typ.repr(rcx.tcx()), new_typ.repr(rcx.tcx())); + typ.repr(), new_typ.repr()); (new_typ, xref_depth_orig + 1) } @@ -411,7 +411,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( debug!("iterate_over_potentially_unsafe_regions_in_type \ {}typ: {} scope: {:?} xref: {}", (0..depth).map(|_| ' ').collect::(), - typ.repr(rcx.tcx()), scope, xref_depth); + typ.repr(), scope, xref_depth); // If `typ` has a destructor, then we must ensure that all // borrowed data reachable via `typ` must outlive the parent @@ -468,7 +468,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( match typ.sty { ty::TyStruct(struct_did, substs) => { debug!("typ: {} is struct; traverse structure and not type-expression", - typ.repr(rcx.tcx())); + typ.repr()); // Don't recurse; we extract type's substructure, // so do not process subparts of type expression. walker.skip_current_subtree(); @@ -498,7 +498,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( ty::TyEnum(enum_did, substs) => { debug!("typ: {} is enum; traverse structure and not type-expression", - typ.repr(rcx.tcx())); + typ.repr()); // Don't recurse; we extract type's substructure, // so do not process subparts of type expression. walker.skip_current_subtree(); @@ -572,23 +572,23 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>, DtorKind::PureRecur => { has_dtor_of_interest = false; debug!("typ: {} has no dtor, and thus is uninteresting", - typ.repr(tcx)); + typ.repr()); } DtorKind::Unknown(bounds) => { match bounds.region_bound { ty::ReStatic => { debug!("trait: {} has 'static bound, and thus is uninteresting", - typ.repr(tcx)); + typ.repr()); has_dtor_of_interest = false; } ty::ReEmpty => { debug!("trait: {} has empty region bound, and thus is uninteresting", - typ.repr(tcx)); + typ.repr()); has_dtor_of_interest = false; } r => { debug!("trait: {} has non-static bound: {}; assumed interesting", - typ.repr(tcx), r.repr(tcx)); + typ.repr(), r.repr()); has_dtor_of_interest = true; } } @@ -646,7 +646,7 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>, if result { has_pred_of_interest = true; debug!("typ: {} has interesting dtor due to generic preds, e.g. {}", - typ.repr(tcx), pred.repr(tcx)); + typ.repr(), pred.repr()); break 'items; } } @@ -672,12 +672,12 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>, if has_dtor_of_interest { debug!("typ: {} has interesting dtor, due to \ region params: {} or pred: {}", - typ.repr(tcx), + typ.repr(), has_region_param_of_interest, has_pred_of_interest); } else { debug!("typ: {} has dtor, but it is uninteresting", - typ.repr(tcx)); + typ.repr()); } } } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index bd482a4c787f1..2b8394f2e1659 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -57,9 +57,9 @@ pub fn confirm<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, -> MethodCallee<'tcx> { debug!("confirm(unadjusted_self_ty={}, pick={}, supplied_method_types={})", - unadjusted_self_ty.repr(fcx.tcx()), - pick.repr(fcx.tcx()), - supplied_method_types.repr(fcx.tcx())); + unadjusted_self_ty.repr(), + pick.repr(), + supplied_method_types.repr()); let mut confirm_cx = ConfirmContext::new(fcx, span, self_expr, call_expr); confirm_cx.confirm(unadjusted_self_ty, pick, supplied_method_types) @@ -93,7 +93,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { let (method_types, method_regions) = self.instantiate_method_substs(&pick, supplied_method_types); let all_substs = rcvr_substs.with_method(method_types, method_regions); - debug!("all_substs={}", all_substs.repr(self.tcx())); + debug!("all_substs={}", all_substs.repr()); // Create the final signature for the method, replacing late-bound regions. let InstantiatedMethodSig { @@ -226,9 +226,9 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { let upcast_trait_ref = this.replace_late_bound_regions_with_fresh_var(&upcast_poly_trait_ref); debug!("original_poly_trait_ref={} upcast_trait_ref={} target_trait={}", - original_poly_trait_ref.repr(this.tcx()), - upcast_trait_ref.repr(this.tcx()), - trait_def_id.repr(this.tcx())); + original_poly_trait_ref.repr(), + upcast_trait_ref.repr(), + trait_def_id.repr()); let substs = upcast_trait_ref.substs.clone(); let origin = MethodTraitObject(MethodObject { trait_ref: upcast_trait_ref, @@ -322,7 +322,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { self.tcx().sess.span_bug( self.span, &format!("self-type `{}` for ObjectPick never dereferenced to an object", - self_ty.repr(self.tcx()))) + self_ty.repr())) } } } @@ -378,8 +378,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { self.span, &format!( "{} was a subtype of {} but now is not?", - self_ty.repr(self.tcx()), - method_self_ty.repr(self.tcx()))); + self_ty.repr(), + method_self_ty.repr())); } } } @@ -393,8 +393,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { -> InstantiatedMethodSig<'tcx> { debug!("instantiate_method_sig(pick={}, all_substs={})", - pick.repr(self.tcx()), - all_substs.repr(self.tcx())); + pick.repr(), + all_substs.repr()); // Instantiate the bounds on the method with the // type/early-bound-regions substitutions performed. There can @@ -405,7 +405,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { &method_predicates); debug!("method_predicates after subst = {}", - method_predicates.repr(self.tcx())); + method_predicates.repr()); // Instantiate late-bound regions and substitute the trait // parameters into the method type to get the actual method type. @@ -416,11 +416,11 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { let method_sig = self.replace_late_bound_regions_with_fresh_var( &pick.item.as_opt_method().unwrap().fty.sig); debug!("late-bound lifetimes from method instantiated, method_sig={}", - method_sig.repr(self.tcx())); + method_sig.repr()); let method_sig = self.fcx.instantiate_type_scheme(self.span, &all_substs, &method_sig); debug!("type scheme substituted, method_sig={}", - method_sig.repr(self.tcx())); + method_sig.repr()); InstantiatedMethodSig { method_sig: method_sig, @@ -434,9 +434,9 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { all_substs: &subst::Substs<'tcx>, method_predicates: &ty::InstantiatedPredicates<'tcx>) { debug!("add_obligations: pick={} all_substs={} method_predicates={}", - pick.repr(self.tcx()), - all_substs.repr(self.tcx()), - method_predicates.repr(self.tcx())); + pick.repr(), + all_substs.repr(), + method_predicates.repr()); self.fcx.add_obligations_for_parameters( traits::ObligationCause::misc(self.span, self.fcx.body_id), @@ -484,7 +484,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { } debug!("fixup_derefs_on_method_receiver_if_necessary: exprs={}", - exprs.repr(self.tcx())); + exprs.repr()); // Fix up autoderefs and derefs. for (i, &expr) in exprs.iter().rev().enumerate() { @@ -499,7 +499,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { }; debug!("fixup_derefs_on_method_receiver_if_necessary: i={} expr={} autoderef_count={}", - i, expr.repr(self.tcx()), autoderef_count); + i, expr.repr(), autoderef_count); if autoderef_count > 0 { check::autoderef(self.fcx, @@ -546,7 +546,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { self.tcx().sess.span_bug( base_expr.span, &format!("unexpected adjustment autoref {}", - adr.repr(self.tcx()))); + adr.repr())); } }, None => (0, None), @@ -648,16 +648,16 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { self.tcx().sess.span_bug( self.span, &format!("cannot uniquely upcast `{}` to `{}`: `{}`", - source_trait_ref.repr(self.tcx()), - target_trait_def_id.repr(self.tcx()), - upcast_trait_refs.repr(self.tcx()))); + source_trait_ref.repr(), + target_trait_def_id.repr(), + upcast_trait_refs.repr())); } upcast_trait_refs.into_iter().next().unwrap() } fn replace_late_bound_regions_with_fresh_var(&self, value: &ty::Binder) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { self.infcx().replace_late_bound_regions_with_fresh_var( self.span, infer::FnCall, value).0 diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index bb620c6ecd895..fd7695b1f0934 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -97,10 +97,10 @@ pub fn lookup<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, -> Result, MethodError> { debug!("lookup(method_name={}, self_ty={}, call_expr={}, self_expr={})", - method_name.repr(fcx.tcx()), - self_ty.repr(fcx.tcx()), - call_expr.repr(fcx.tcx()), - self_expr.repr(fcx.tcx())); + method_name.repr(), + self_ty.repr(), + call_expr.repr(), + self_expr.repr()); let mode = probe::Mode::MethodCall; let self_ty = fcx.infcx().resolve_type_vars_if_possible(&self_ty); @@ -142,10 +142,10 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, -> Option> { debug!("lookup_in_trait_adjusted(self_ty={}, self_expr={}, m_name={}, trait_def_id={})", - self_ty.repr(fcx.tcx()), - self_expr.repr(fcx.tcx()), - m_name.repr(fcx.tcx()), - trait_def_id.repr(fcx.tcx())); + self_ty.repr(), + self_expr.repr(), + m_name.repr(), + trait_def_id.repr()); let trait_def = ty::lookup_trait_def(fcx.tcx(), trait_def_id); @@ -191,7 +191,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, assert_eq!(method_ty.generics.regions.len(subst::FnSpace), 0); debug!("lookup_in_trait_adjusted: method_num={} method_ty={}", - method_num, method_ty.repr(fcx.tcx())); + method_num, method_ty.repr()); // Instantiate late-bound regions and substitute the trait // parameters into the method type to get the actual method type. @@ -211,8 +211,8 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, })); debug!("lookup_in_trait_adjusted: matched method fty={} obligation={}", - fty.repr(fcx.tcx()), - obligation.repr(fcx.tcx())); + fty.repr(), + obligation.repr()); // Register obligations for the parameters. This will include the // `Self` parameter, which in turn has a bound of the main trait, @@ -272,7 +272,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, span, &format!( "trait method is &self but first arg is: {}", - transformed_self_ty.repr(fcx.tcx()))); + transformed_self_ty.repr())); } } } @@ -296,7 +296,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, substs: trait_ref.substs.clone() }; - debug!("callee = {}", callee.repr(fcx.tcx())); + debug!("callee = {}", callee.repr()); Some(callee) } diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 915aadd722b2c..daa2b95e07e80 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -124,7 +124,7 @@ pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, -> PickResult<'tcx> { debug!("probe(self_ty={}, item_name={}, scope_expr_id={})", - self_ty.repr(fcx.tcx()), + self_ty.repr(), item_name, scope_expr_id); @@ -164,8 +164,8 @@ pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, }; debug!("ProbeContext: steps for self_ty={} are {}", - self_ty.repr(fcx.tcx()), - steps.repr(fcx.tcx())); + self_ty.repr(), + steps.repr()); // this creates one big transaction so that all type variables etc // that we create during the probe process are removed later @@ -269,7 +269,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { fn assemble_probe(&mut self, self_ty: Ty<'tcx>) { debug!("assemble_probe: self_ty={}", - self_ty.repr(self.tcx())); + self_ty.repr()); match self_ty.sty { ty::TyTrait(box ref data) => { @@ -412,7 +412,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let traits::Normalized { value: xform_self_ty, obligations } = traits::normalize(selcx, cause, &xform_self_ty); debug!("assemble_inherent_impl_probe: xform_self_ty = {:?}", - xform_self_ty.repr(self.tcx())); + xform_self_ty.repr()); self.inherent_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -425,7 +425,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { self_ty: Ty<'tcx>, data: &ty::TraitTy<'tcx>) { debug!("assemble_inherent_candidates_from_object(self_ty={})", - self_ty.repr(self.tcx())); + self_ty.repr()); let tcx = self.tcx(); @@ -497,9 +497,9 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { if let Some(ref m) = item.as_opt_method() { debug!("found match: trait_ref={} substs={} m={}", - trait_ref.repr(this.tcx()), - trait_ref.substs.repr(this.tcx()), - m.repr(this.tcx())); + trait_ref.repr(), + trait_ref.substs.repr(), + m.repr()); assert_eq!(m.generics.types.get_slice(subst::TypeSpace).len(), trait_ref.substs.types.get_slice(subst::TypeSpace).len()); assert_eq!(m.generics.regions.get_slice(subst::TypeSpace).len(), @@ -539,7 +539,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { usize, ), { - debug!("elaborate_bounds(bounds={})", bounds.repr(self.tcx())); + debug!("elaborate_bounds(bounds={})", bounds.repr()); let tcx = self.tcx(); for bound_trait_ref in traits::transitive_bounds(tcx, bounds) { @@ -589,7 +589,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { -> Result<(),MethodError> { debug!("assemble_extension_candidates_for_trait(trait_def_id={})", - trait_def_id.repr(self.tcx())); + trait_def_id.repr()); // Check whether `trait_def_id` defines a method with suitable name: let trait_items = @@ -639,8 +639,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { // FIXME(arielb1): can we use for_each_relevant_impl here? trait_def.for_each_impl(self.tcx(), |impl_def_id| { debug!("assemble_extension_candidates_for_trait_impl: trait_def_id={} impl_def_id={}", - trait_def_id.repr(self.tcx()), - impl_def_id.repr(self.tcx())); + trait_def_id.repr(), + impl_def_id.repr()); if !self.impl_can_possibly_match(impl_def_id) { return; @@ -648,14 +648,14 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let (_, impl_substs) = self.impl_ty_and_substs(impl_def_id); - debug!("impl_substs={}", impl_substs.repr(self.tcx())); + debug!("impl_substs={}", impl_substs.repr()); let impl_trait_ref = ty::impl_trait_ref(self.tcx(), impl_def_id) .unwrap() // we know this is a trait impl .subst(self.tcx(), &impl_substs); - debug!("impl_trait_ref={}", impl_trait_ref.repr(self.tcx())); + debug!("impl_trait_ref={}", impl_trait_ref.repr()); // Determine the receiver type that the method itself expects. let xform_self_ty = @@ -671,7 +671,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let traits::Normalized { value: xform_self_ty, obligations } = traits::normalize(selcx, cause, &xform_self_ty); - debug!("xform_self_ty={}", xform_self_ty.repr(self.tcx())); + debug!("xform_self_ty={}", xform_self_ty.repr()); self.extension_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -772,13 +772,13 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { trait_def_id={}, \ item={}, \ item_index={})", - trait_def_id.repr(self.tcx()), - item.repr(self.tcx()), + trait_def_id.repr(), + item.repr(), item_index); for step in self.steps.iter() { debug!("assemble_projection_candidates: step={}", - step.repr(self.tcx())); + step.repr()); let projection_trait_ref = match step.self_ty.sty { ty::TyProjection(ref data) => &data.trait_ref, @@ -786,14 +786,14 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { }; debug!("assemble_projection_candidates: projection_trait_ref={}", - projection_trait_ref.repr(self.tcx())); + projection_trait_ref.repr()); let trait_predicates = ty::lookup_predicates(self.tcx(), projection_trait_ref.def_id); let bounds = trait_predicates.instantiate(self.tcx(), projection_trait_ref.substs); let predicates = bounds.predicates.into_vec(); debug!("assemble_projection_candidates: predicates={}", - predicates.repr(self.tcx())); + predicates.repr()); for poly_bound in traits::elaborate_predicates(self.tcx(), predicates) .filter_map(|p| p.to_opt_poly_trait_ref()) @@ -802,8 +802,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let bound = self.erase_late_bound_regions(&poly_bound); debug!("assemble_projection_candidates: projection_trait_ref={} bound={}", - projection_trait_ref.repr(self.tcx()), - bound.repr(self.tcx())); + projection_trait_ref.repr(), + bound.repr()); if self.infcx().can_equate(&step.self_ty, &bound.self_ty()).is_ok() { let xform_self_ty = self.xform_self_ty(&item, @@ -811,8 +811,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { bound.substs); debug!("assemble_projection_candidates: bound={} xform_self_ty={}", - bound.repr(self.tcx()), - xform_self_ty.repr(self.tcx())); + bound.repr(), + xform_self_ty.repr()); self.extension_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -830,7 +830,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { item_index: usize) { debug!("assemble_where_clause_candidates(trait_def_id={})", - trait_def_id.repr(self.tcx())); + trait_def_id.repr()); let caller_predicates = self.fcx.inh.param_env.caller_bounds.clone(); for poly_bound in traits::elaborate_predicates(self.tcx(), caller_predicates) @@ -843,8 +843,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { bound.substs); debug!("assemble_where_clause_candidates: bound={} xform_self_ty={}", - bound.repr(self.tcx()), - xform_self_ty.repr(self.tcx())); + bound.repr(), + xform_self_ty.repr()); self.extension_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -910,7 +910,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { } fn pick_step(&mut self, step: &CandidateStep<'tcx>) -> Option> { - debug!("pick_step: step={}", step.repr(self.tcx())); + debug!("pick_step: step={}", step.repr()); if ty::type_is_error(step.self_ty) { return None; @@ -1008,7 +1008,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { .filter(|&probe| self.consider_probe(self_ty, probe)) .collect(); - debug!("applicable_candidates: {}", applicable_candidates.repr(self.tcx())); + debug!("applicable_candidates: {}", applicable_candidates.repr()); if applicable_candidates.len() > 1 { match self.collapse_candidates_to_trait_pick(&applicable_candidates[..]) { @@ -1030,8 +1030,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { fn consider_probe(&self, self_ty: Ty<'tcx>, probe: &Candidate<'tcx>) -> bool { debug!("consider_probe: self_ty={} probe={}", - self_ty.repr(self.tcx()), - probe.repr(self.tcx())); + self_ty.repr(), + probe.repr()); self.infcx().probe(|_| { // First check that the self type can be related. @@ -1065,7 +1065,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { traits::predicates_for_generics(self.tcx(), cause.clone(), &impl_bounds); - debug!("impl_obligations={}", obligations.repr(self.tcx())); + debug!("impl_obligations={}", obligations.repr()); // Evaluate those obligations to see if they might possibly hold. obligations.iter() @@ -1178,9 +1178,9 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { -> Ty<'tcx> { debug!("xform_self_ty(impl_ty={}, self_ty={}, substs={})", - impl_ty.repr(self.tcx()), - method.fty.sig.0.inputs.get(0).repr(self.tcx()), - substs.repr(self.tcx())); + impl_ty.repr(), + method.fty.sig.0.inputs.get(0).repr(), + substs.repr()); assert!(!substs.has_escaping_regions()); @@ -1265,7 +1265,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { /// and/or tracking the substitution and /// so forth. fn erase_late_bound_regions(&self, value: &ty::Binder) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { ty::erase_late_bound_regions(self.tcx(), value) } @@ -1372,58 +1372,58 @@ impl<'tcx> Candidate<'tcx> { } } -impl<'tcx> Repr<'tcx> for Candidate<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for Candidate<'tcx> { + fn repr(&self) -> String { format!("Candidate(xform_self_ty={}, kind={})", - self.xform_self_ty.repr(tcx), - self.kind.repr(tcx)) + self.xform_self_ty.repr(), + self.kind.repr()) } } -impl<'tcx> Repr<'tcx> for CandidateKind<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for CandidateKind<'tcx> { + fn repr(&self) -> String { match *self { InherentImplCandidate(ref a, ref b, ref c) => - format!("InherentImplCandidate({},{},{})", a.repr(tcx), b.repr(tcx), - c.repr(tcx)), + format!("InherentImplCandidate({},{},{})", a.repr(), b.repr(), + c.repr()), ObjectCandidate(a, b, c) => - format!("ObjectCandidate({},{},{})", a.repr(tcx), b, c), + format!("ObjectCandidate({},{},{})", a.repr(), b, c), ExtensionImplCandidate(ref a, ref b, ref c, ref d, ref e) => - format!("ExtensionImplCandidate({},{},{},{},{})", a.repr(tcx), b.repr(tcx), - c.repr(tcx), d, e.repr(tcx)), + format!("ExtensionImplCandidate({},{},{},{},{})", a.repr(), b.repr(), + c.repr(), d, e.repr()), ClosureCandidate(ref a, ref b) => - format!("ClosureCandidate({},{})", a.repr(tcx), b), + format!("ClosureCandidate({},{})", a.repr(), b), WhereClauseCandidate(ref a, ref b) => - format!("WhereClauseCandidate({},{})", a.repr(tcx), b), + format!("WhereClauseCandidate({},{})", a.repr(), b), ProjectionCandidate(ref a, ref b) => - format!("ProjectionCandidate({},{})", a.repr(tcx), b), + format!("ProjectionCandidate({},{})", a.repr(), b), } } } -impl<'tcx> Repr<'tcx> for CandidateStep<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for CandidateStep<'tcx> { + fn repr(&self) -> String { format!("CandidateStep({}, autoderefs={}, unsize={})", - self.self_ty.repr(tcx), + self.self_ty.repr(), self.autoderefs, self.unsize) } } -impl<'tcx> Repr<'tcx> for PickKind<'tcx> { - fn repr(&self, _tcx: &ty::ctxt) -> String { +impl<'tcx> Repr for PickKind<'tcx> { + fn repr(&self) -> String { format!("{:?}", self) } } -impl<'tcx> Repr<'tcx> for Pick<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for Pick<'tcx> { + fn repr(&self) -> String { format!("Pick(item={}, autoderefs={}, autoref={}, unsize={}, kind={:?})", - self.item.repr(tcx), + self.item.repr(), self.autoderefs, - self.autoref.repr(tcx), - self.unsize.repr(tcx), + self.autoref.repr(), + self.unsize.repr(), self.kind) } } diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 8a48ef543ccc1..52fdf52c35da7 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -45,7 +45,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, match error { MethodError::NoMatch(static_sources, out_of_scope_traits, mode) => { let cx = fcx.tcx(); - let item_ustring = item_name.user_string(cx); + let item_ustring = item_name.user_string(); fcx.type_error_message( span, @@ -93,7 +93,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let msg = format!("the `{}` method from the `{}` trait cannot be explicitly \ invoked on this closure as we have not yet inferred what \ kind of closure it is", - item_name.user_string(fcx.tcx()), + item_name.user_string(), ty::item_path_str(fcx.tcx(), trait_def_id)); let msg = if let Some(callee) = rcvr_expr { format!("{}; use overloaded call notation instead (e.g., `{}()`)", @@ -134,7 +134,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, "candidate #{} is defined in an impl{} for the type `{}`", idx + 1, insertion, - impl_ty.user_string(fcx.tcx())); + impl_ty.user_string()); } CandidateSource::TraitSource(trait_did) => { let (_, item) = trait_item(fcx.tcx(), trait_did, item_name).unwrap(); @@ -160,7 +160,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, valid_out_of_scope_traits: Vec) { let tcx = fcx.tcx(); - let item_ustring = item_name.user_string(tcx); + let item_ustring = item_name.user_string(); if !valid_out_of_scope_traits.is_empty() { let mut candidates = valid_out_of_scope_traits; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 41dcb12395259..34403b53fc6f0 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -398,7 +398,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> { body_id: ast::NodeId, value: &T) -> T - where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr<'tcx> + where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr { let mut fulfillment_cx = self.fulfillment_cx.borrow_mut(); assoc::normalize_associated_types_in(&self.infcx, @@ -587,7 +587,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { token::get_ident(path1.node), self.fcx.infcx().ty_to_string( self.fcx.inh.locals.borrow().get(&p.id).unwrap().clone()), - var_ty.repr(self.fcx.tcx())); + var_ty.repr()); } } visit::walk_pat(self, p); @@ -642,8 +642,8 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, let ret_ty = fn_sig.output; debug!("check_fn(arg_tys={}, ret_ty={}, fn_id={})", - arg_tys.repr(tcx), - ret_ty.repr(tcx), + arg_tys.repr(), + ret_ty.repr(), fn_id); // Create the function context. This is either derived from scratch or, @@ -671,7 +671,7 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, debug!("fn-sig-map: fn_id={} fn_sig_tys={}", fn_id, - fn_sig_tys.repr(tcx)); + fn_sig_tys.repr()); inherited.fn_sig_map.borrow_mut().insert(fn_id, fn_sig_tys); @@ -919,11 +919,11 @@ fn check_method_body<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, body: &'tcx ast::Block, id: ast::NodeId, span: Span) { debug!("check_method_body(item_generics={}, id={})", - item_generics.repr(ccx.tcx), id); + item_generics.repr(), id); let param_env = ParameterEnvironment::for_item(ccx.tcx, id); let fty = ty::node_id_to_type(ccx.tcx, id); - debug!("check_method_body: fty={}", fty.repr(ccx.tcx)); + debug!("check_method_body: fty={}", fty.repr()); check_bare_fn(ccx, &sig.decl, body, id, span, fty, param_env); } @@ -965,7 +965,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, "item `{}` is an associated const, \ which doesn't match its trait `{}`", token::get_name(impl_const_ty.name()), - impl_trait_ref.repr(tcx)) + impl_trait_ref.repr()) } } } @@ -978,7 +978,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, "associated const `{}` is not a member of \ trait `{}`", token::get_name(impl_const_ty.name()), - impl_trait_ref.repr(tcx))); + impl_trait_ref.repr())); } } } @@ -1011,7 +1011,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, "item `{}` is an associated method, \ which doesn't match its trait `{}`", token::get_name(impl_item_ty.name()), - impl_trait_ref.repr(tcx)) + impl_trait_ref.repr()) } } } @@ -1022,7 +1022,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_item.span, &format!("method `{}` is not a member of trait `{}`", token::get_name(impl_item_ty.name()), - impl_trait_ref.repr(tcx))); + impl_trait_ref.repr())); } } } @@ -1045,7 +1045,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, "item `{}` is an associated type, \ which doesn't match its trait `{}`", token::get_name(typedef_ty.name()), - impl_trait_ref.repr(tcx)) + impl_trait_ref.repr()) } } } @@ -1058,7 +1058,7 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, "associated type `{}` is not a member of \ trait `{}`", token::get_name(typedef_ty.name()), - impl_trait_ref.repr(tcx))); + impl_trait_ref.repr())); } } } @@ -1295,18 +1295,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// version, this version will also select obligations if it seems /// useful, in an effort to get more type information. fn resolve_type_vars_if_possible(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> { - debug!("resolve_type_vars_if_possible(ty={})", ty.repr(self.tcx())); + debug!("resolve_type_vars_if_possible(ty={})", ty.repr()); // No ty::infer()? Nothing needs doing. if !ty::type_has_ty_infer(ty) { - debug!("resolve_type_vars_if_possible: ty={}", ty.repr(self.tcx())); + debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); return ty; } // If `ty` is a type variable, see whether we already know what it is. ty = self.infcx().resolve_type_vars_if_possible(&ty); if !ty::type_has_ty_infer(ty) { - debug!("resolve_type_vars_if_possible: ty={}", ty.repr(self.tcx())); + debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); return ty; } @@ -1314,7 +1314,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.select_new_obligations(); ty = self.infcx().resolve_type_vars_if_possible(&ty); if !ty::type_has_ty_infer(ty) { - debug!("resolve_type_vars_if_possible: ty={}", ty.repr(self.tcx())); + debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); return ty; } @@ -1325,7 +1325,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.select_obligations_where_possible(); ty = self.infcx().resolve_type_vars_if_possible(&ty); - debug!("resolve_type_vars_if_possible: ty={}", ty.repr(self.tcx())); + debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); ty } @@ -1396,7 +1396,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[inline] pub fn write_ty(&self, node_id: ast::NodeId, ty: Ty<'tcx>) { debug!("write_ty({}, {}) in fcx {}", - node_id, ty.repr(self.tcx()), self.tag()); + node_id, ty.repr(), self.tag()); self.inh.node_types.borrow_mut().insert(node_id, ty); } @@ -1404,7 +1404,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if !substs.substs.is_noop() { debug!("write_substs({}, {}) in fcx {}", node_id, - substs.repr(self.tcx()), + substs.repr(), self.tag()); self.inh.item_substs.borrow_mut().insert(node_id, substs); @@ -1427,7 +1427,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn write_adjustment(&self, node_id: ast::NodeId, adj: ty::AutoAdjustment<'tcx>) { - debug!("write_adjustment(node_id={}, adj={})", node_id, adj.repr(self.tcx())); + debug!("write_adjustment(node_id={}, adj={})", node_id, adj.repr()); if adj.is_identity() { return; @@ -1444,14 +1444,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { substs: &Substs<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr<'tcx> + where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr { let value = value.subst(self.tcx(), substs); let result = self.normalize_associated_types_in(span, &value); debug!("instantiate_type_scheme(value={}, substs={}) = {}", - value.repr(self.tcx()), - substs.repr(self.tcx()), - result.repr(self.tcx())); + value.repr(), + substs.repr(), + result.repr()); result } @@ -1470,7 +1470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn normalize_associated_types_in(&self, span: Span, value: &T) -> T - where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr<'tcx> + where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr { self.inh.normalize_associated_types_in(self, span, self.body_id, value) } @@ -1616,7 +1616,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { obligation: traits::PredicateObligation<'tcx>) { debug!("register_predicate({})", - obligation.repr(self.tcx())); + obligation.repr()); self.inh.fulfillment_cx .borrow_mut() .register_predicate_obligation(self.infcx(), obligation); @@ -1634,7 +1634,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } pub fn pat_to_string(&self, pat: &ast::Pat) -> String { - pat.repr(self.tcx()) + pat.repr() } pub fn expr_ty(&self, ex: &ast::Expr) -> Ty<'tcx> { @@ -1785,7 +1785,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { assert!(!predicates.has_escaping_regions()); debug!("add_obligations_for_parameters(predicates={})", - predicates.repr(self.tcx())); + predicates.repr()); for obligation in traits::predicates_for_generics(self.tcx(), cause, @@ -1943,8 +1943,8 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>, where F: FnMut(Ty<'tcx>, usize) -> Option, { debug!("autoderef(base_ty={}, opt_expr={}, lvalue_pref={:?})", - base_ty.repr(fcx.tcx()), - opt_expr.repr(fcx.tcx()), + base_ty.repr(), + opt_expr.repr(), lvalue_pref); let mut t = base_ty; @@ -2005,7 +2005,7 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>, // We've reached the recursion limit, error gracefully. span_err!(fcx.tcx().sess, sp, E0055, "reached the recursion limit while auto-dereferencing {}", - base_ty.repr(fcx.tcx())); + base_ty.repr()); (fcx.tcx().types.err, 0, None) } @@ -2122,12 +2122,12 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let tcx = fcx.tcx(); debug!("try_index_step(expr={}, base_expr.id={}, adjusted_ty={}, \ autoderefs={}, unsize={}, index_ty={})", - expr.repr(tcx), - base_expr.repr(tcx), - adjusted_ty.repr(tcx), + expr.repr(), + base_expr.repr(), + adjusted_ty.repr(), autoderefs, unsize, - index_ty.repr(tcx)); + index_ty.repr()); let input_ty = fcx.infcx().next_ty_var(); @@ -2607,8 +2607,8 @@ fn expected_types_for_fn_args<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } }).unwrap_or(vec![]); debug!("expected_types_for_fn_args(formal={} -> {}, expected={} -> {})", - formal_args.repr(fcx.tcx()), formal_ret.repr(fcx.tcx()), - expected_args.repr(fcx.tcx()), expected_ret.repr(fcx.tcx())); + formal_args.repr(), formal_ret.repr(), + expected_args.repr(), expected_ret.repr()); expected_args } @@ -2630,7 +2630,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, F: FnOnce(), { debug!(">> typechecking: expr={} expected={}", - expr.repr(fcx.tcx()), expected.repr(fcx.tcx())); + expr.repr(), expected.repr()); // Checks a method call. fn check_method_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, @@ -2746,7 +2746,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, |base_t, _| { match base_t.sty { ty::TyStruct(base_id, substs) => { - debug!("struct named {}", base_t.repr(tcx)); + debug!("struct named {}", base_t.repr()); let fields = ty::lookup_struct_fields(tcx, base_id); fcx.lookup_field_ty(expr.span, base_id, &fields[..], field.node.name, &(*substs)) @@ -2850,7 +2850,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, ty::TyStruct(base_id, substs) => { tuple_like = ty::is_tuple_struct(tcx, base_id); if tuple_like { - debug!("tuple struct named {}", base_t.repr(tcx)); + debug!("tuple struct named {}", base_t.repr()); let fields = ty::lookup_struct_fields(tcx, base_id); fcx.lookup_tup_field_ty(expr.span, base_id, &fields[..], idx.node, &(*substs)) @@ -3276,7 +3276,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } } else { tcx.sess.span_bug(expr.span, - &format!("unbound path {}", expr.repr(tcx))) + &format!("unbound path {}", expr.repr())) }; if let Some((opt_ty, segments, def)) = @@ -3749,8 +3749,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, debug!("type of expr({}) {} is...", expr.id, syntax::print::pprust::expr_to_string(expr)); debug!("... {}, expected is {}", - fcx.expr_ty(expr).repr(tcx), - expected.repr(tcx)); + fcx.expr_ty(expr).repr(), + expected.repr()); unifier(); } @@ -3909,16 +3909,16 @@ impl<'tcx> Expectation<'tcx> { } } -impl<'tcx> Repr<'tcx> for Expectation<'tcx> { - fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String { +impl<'tcx> Repr for Expectation<'tcx> { + fn repr(&self) -> String { match *self { NoExpectation => format!("NoExpectation"), ExpectHasType(t) => format!("ExpectHasType({})", - t.repr(tcx)), + t.repr()), ExpectCastableToType(t) => format!("ExpectCastableToType({})", - t.repr(tcx)), + t.repr()), ExpectRvalueLikeUnsized(t) => format!("ExpectRvalueLikeUnsized({})", - t.repr(tcx)), + t.repr()), } } } @@ -4198,7 +4198,7 @@ pub fn check_instantiable(tcx: &ty::ctxt, "this type cannot be instantiated without an \ instance of itself"); fileline_help!(tcx.sess, sp, "consider using `Option<{}>`", - item_ty.repr(tcx)); + item_ty.repr()); false } else { true @@ -4391,9 +4391,9 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, node_id: ast::NodeId) { debug!("instantiate_path(path={:?}, def={}, node_id={}, type_scheme={})", segments, - def.repr(fcx.tcx()), + def.repr(), node_id, - type_scheme.repr(fcx.tcx())); + type_scheme.repr()); // We need to extract the type parameters supplied by the user in // the path `path`. Due to the current setup, this is a bit of a @@ -4634,8 +4634,8 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, fcx.tcx().sess.span_bug(span, &format!( "instantiate_path: (UFCS) {} was a subtype of {} but now is not?", - self_ty.repr(fcx.tcx()), - impl_ty.repr(fcx.tcx()))); + self_ty.repr(), + impl_ty.repr())); } } @@ -4840,7 +4840,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } assert_eq!(substs.types.len(space), desired.len()); - debug!("Final substs: {}", substs.repr(fcx.tcx())); + debug!("Final substs: {}", substs.repr()); } fn adjust_region_parameters( @@ -4950,7 +4950,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, tps: &OwnedSlice, ty: Ty<'tcx>) { debug!("check_bounds_are_used(n_tps={}, ty={})", - tps.len(), ty.repr(ccx.tcx)); + tps.len(), ty.repr()); // make a vector of booleans initially false, set to true when used if tps.is_empty() { return; } @@ -5273,7 +5273,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) { fty, || { format!("intrinsic has wrong type: expected `{}`", - fty.user_string(ccx.tcx)) + fty.user_string()) }); } } diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index b4000788d1998..fbff7afb3e59c 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -51,8 +51,8 @@ pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, span_err!(tcx.sess, lhs_expr.span, E0368, "binary assignment operation `{}=` cannot be applied to types `{}` and `{}`", ast_util::binop_to_string(op.node), - lhs_ty.user_string(fcx.tcx()), - rhs_ty.user_string(fcx.tcx())); + lhs_ty.user_string(), + rhs_ty.user_string()); fcx.write_error(expr.id); } @@ -75,10 +75,10 @@ pub fn check_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, debug!("check_binop(expr.id={}, expr={}, op={:?}, lhs_expr={}, rhs_expr={})", expr.id, - expr.repr(tcx), + expr.repr(), op, - lhs_expr.repr(tcx), - rhs_expr.repr(tcx)); + lhs_expr.repr(), + rhs_expr.repr()); check_expr(fcx, lhs_expr); let lhs_ty = fcx.resolve_type_vars_if_possible(fcx.expr_ty(lhs_expr)); @@ -181,15 +181,15 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, if ty::type_is_simd(tcx, lhs_ty) { let unit_ty = ty::simd_type(tcx, lhs_ty); debug!("enforce_builtin_binop_types: lhs_ty={} unit_ty={}", - lhs_ty.repr(tcx), - unit_ty.repr(tcx)); + lhs_ty.repr(), + unit_ty.repr()); if !ty::type_is_integral(unit_ty) { tcx.sess.span_err( lhs_expr.span, &format!("binary comparison operation `{}` not supported \ for floating point SIMD vector `{}`", ast_util::binop_to_string(op.node), - lhs_ty.user_string(tcx))); + lhs_ty.user_string())); tcx.types.err } else { lhs_ty @@ -211,7 +211,7 @@ fn check_overloaded_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, { debug!("check_overloaded_binop(expr.id={}, lhs_ty={})", expr.id, - lhs_ty.repr(fcx.tcx())); + lhs_ty.repr()); let (name, trait_def_id) = name_and_trait_def_id(fcx, op); @@ -233,7 +233,7 @@ fn check_overloaded_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, span_err!(fcx.tcx().sess, lhs_expr.span, E0369, "binary operation `{}` cannot be applied to type `{}`", ast_util::binop_to_string(op.node), - lhs_ty.user_string(fcx.tcx())); + lhs_ty.user_string()); } fcx.tcx().types.err } @@ -305,11 +305,11 @@ fn lookup_op_method<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>, -> Result,()> { debug!("lookup_op_method(expr={}, lhs_ty={}, opname={:?}, trait_did={}, lhs_expr={})", - expr.repr(fcx.tcx()), - lhs_ty.repr(fcx.tcx()), + expr.repr(), + lhs_ty.repr(), opname, - trait_did.repr(fcx.tcx()), - lhs_expr.repr(fcx.tcx())); + trait_did.repr(), + lhs_expr.repr()); let method = match trait_did { Some(trait_did) => { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 04dd7f46b834b..057b4de3f0d96 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -322,7 +322,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { for r_o in ®ion_obligations { debug!("visit_region_obligations: r_o={}", - r_o.repr(self.tcx())); + r_o.repr()); let sup_type = self.resolve_type(r_o.sup_type); let origin = infer::RelateParamBound(r_o.cause.span, sup_type); type_must_outlive(self, origin, sup_type, r_o.sub_region); @@ -352,7 +352,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { for &ty in fn_sig_tys { let ty = self.resolve_type(ty); - debug!("relate_free_regions(t={})", ty.repr(tcx)); + debug!("relate_free_regions(t={})", ty.repr()); let body_scope = CodeExtent::from_node_id(body_id); let body_scope = ty::ReScope(body_scope); let implications = implicator::implications(self.fcx.infcx(), self.fcx, body_id, @@ -365,7 +365,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { // that don't go into the free-region-map but which we use // here. for implication in implications { - debug!("implication: {}", implication.repr(tcx)); + debug!("implication: {}", implication.repr()); match implication { implicator::Implication::RegionSubRegion(_, ty::ReFree(free_a), @@ -374,7 +374,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { } implicator::Implication::RegionSubGeneric(_, r_a, ref generic_b) => { debug!("RegionSubGeneric: {} <= {}", - r_a.repr(tcx), generic_b.repr(tcx)); + r_a.repr(), generic_b.repr()); self.region_bound_pairs.push((r_a, generic_b.clone())); } @@ -465,7 +465,7 @@ fn visit_local(rcx: &mut Rcx, l: &ast::Local) { fn constrain_bindings_in_pat(pat: &ast::Pat, rcx: &mut Rcx) { let tcx = rcx.fcx.tcx(); - debug!("regionck::visit_pat(pat={})", pat.repr(tcx)); + debug!("regionck::visit_pat(pat={})", pat.repr()); pat_util::pat_bindings(&tcx.def_map, pat, |_, id, span, _| { // If we have a variable that contains region'd data, that // data will be accessible from anywhere that the variable is @@ -503,7 +503,7 @@ fn constrain_bindings_in_pat(pat: &ast::Pat, rcx: &mut Rcx) { fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { debug!("regionck::visit_expr(e={}, repeating_scope={})", - expr.repr(rcx.fcx.tcx()), rcx.repeating_scope); + expr.repr(), rcx.repeating_scope); // No matter what, the type of each expression must outlive the // scope of that expression. This also guarantees basic WF. @@ -746,8 +746,8 @@ fn constrain_cast(rcx: &mut Rcx, source_expr: &ast::Expr) { debug!("constrain_cast(cast_expr={}, source_expr={})", - cast_expr.repr(rcx.tcx()), - source_expr.repr(rcx.tcx())); + cast_expr.repr(), + source_expr.repr()); let source_ty = rcx.resolve_node_type(source_expr.id); let target_ty = rcx.resolve_node_type(cast_expr.id); @@ -759,8 +759,8 @@ fn constrain_cast(rcx: &mut Rcx, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { debug!("walk_cast(from_ty={}, to_ty={})", - from_ty.repr(rcx.tcx()), - to_ty.repr(rcx.tcx())); + from_ty.repr(), + to_ty.repr()); match (&from_ty.sty, &to_ty.sty) { /*From:*/ (&ty::TyRef(from_r, ref from_mt), /*To: */ &ty::TyRef(to_r, ref to_mt)) => { @@ -808,7 +808,7 @@ fn constrain_callee(rcx: &mut Rcx, // // tcx.sess.span_bug( // callee_expr.span, - // format!("Calling non-function: {}", callee_ty.repr(tcx))); + // format!("Calling non-function: {}", callee_ty.repr())); } } } @@ -827,8 +827,8 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, debug!("constrain_call(call_expr={}, \ receiver={}, \ implicitly_ref_args={})", - call_expr.repr(tcx), - receiver.repr(tcx), + call_expr.repr(), + receiver.repr(), implicitly_ref_args); // `callee_region` is the scope representing the time in which the @@ -838,10 +838,10 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, let callee_scope = CodeExtent::from_node_id(call_expr.id); let callee_region = ty::ReScope(callee_scope); - debug!("callee_region={}", callee_region.repr(tcx)); + debug!("callee_region={}", callee_region.repr()); for arg_expr in arg_exprs { - debug!("Argument: {}", arg_expr.repr(tcx)); + debug!("Argument: {}", arg_expr.repr()); // ensure that any regions appearing in the argument type are // valid for at least the lifetime of the function: @@ -860,7 +860,7 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, // as loop above, but for receiver if let Some(r) = receiver { - debug!("receiver: {}", r.repr(tcx)); + debug!("receiver: {}", r.repr()); type_of_node_must_outlive( rcx, infer::CallRcvr(r.span), r.id, callee_region); @@ -878,9 +878,9 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, mut derefd_ty: Ty<'tcx>) { debug!("constrain_autoderefs(deref_expr={}, derefs={}, derefd_ty={})", - deref_expr.repr(rcx.tcx()), + deref_expr.repr(), derefs, - derefd_ty.repr(rcx.tcx())); + derefd_ty.repr()); let r_deref_expr = ty::ReScope(CodeExtent::from_node_id(deref_expr.id)); for i in 0..derefs { @@ -890,7 +890,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, derefd_ty = match rcx.fcx.inh.method_map.borrow().get(&method_call) { Some(method) => { debug!("constrain_autoderefs: #{} is overloaded, method={}", - i, method.repr(rcx.tcx())); + i, method.repr()); // Treat overloaded autoderefs as if an AutoRef adjustment // was applied on the base type, as that is always the case. @@ -904,18 +904,18 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, rcx.tcx().sess.span_bug( deref_expr.span, &format!("bad overloaded deref type {}", - method.ty.repr(rcx.tcx()))) + method.ty.repr())) } }; debug!("constrain_autoderefs: receiver r={:?} m={:?}", - r.repr(rcx.tcx()), m); + r.repr(), m); { let mc = mc::MemCategorizationContext::new(rcx.fcx); let self_cmt = ignore_err!(mc.cat_expr_autoderefd(deref_expr, i)); debug!("constrain_autoderefs: self_cmt={:?}", - self_cmt.repr(rcx.tcx())); + self_cmt.repr()); link_region(rcx, deref_expr.span, r, ty::BorrowKind::from_mutbl(m), self_cmt); } @@ -977,7 +977,7 @@ fn check_safety_of_rvalue_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 't .span_bug(span, &format!("unexpected rvalue region in rvalue \ destructor safety checking: `{}`", - region.repr(rcx.tcx()))); + region.repr())); } } } @@ -1025,7 +1025,7 @@ fn type_of_node_must_outlive<'a, 'tcx>( |method_call| rcx.resolve_method_type(method_call)); debug!("constrain_regions_in_type_of_node(\ ty={}, ty0={}, id={}, minimum_lifetime={:?})", - ty.user_string(tcx), ty0.user_string(tcx), + ty.user_string(), ty0.user_string(), id, minimum_lifetime); type_must_outlive(rcx, origin, ty, minimum_lifetime); } @@ -1034,14 +1034,14 @@ fn type_of_node_must_outlive<'a, 'tcx>( /// resulting pointer is linked to the lifetime of its guarantor (if any). fn link_addr_of(rcx: &mut Rcx, expr: &ast::Expr, mutability: ast::Mutability, base: &ast::Expr) { - debug!("link_addr_of(expr={}, base={})", expr.repr(rcx.tcx()), base.repr(rcx.tcx())); + debug!("link_addr_of(expr={}, base={})", expr.repr(), base.repr()); let cmt = { let mc = mc::MemCategorizationContext::new(rcx.fcx); ignore_err!(mc.cat_expr(base)) }; - debug!("link_addr_of: cmt={}", cmt.repr(rcx.tcx())); + debug!("link_addr_of: cmt={}", cmt.repr()); link_region_from_node_type(rcx, expr.span, expr.id, mutability, cmt); } @@ -1067,7 +1067,7 @@ fn link_match(rcx: &Rcx, discr: &ast::Expr, arms: &[ast::Arm]) { debug!("regionck::for_match()"); let mc = mc::MemCategorizationContext::new(rcx.fcx); let discr_cmt = ignore_err!(mc.cat_expr(discr)); - debug!("discr_cmt={}", discr_cmt.repr(rcx.tcx())); + debug!("discr_cmt={}", discr_cmt.repr()); for arm in arms { for root_pat in &arm.pats { link_pattern(rcx, mc, discr_cmt.clone(), &**root_pat); @@ -1086,8 +1086,8 @@ fn link_fn_args(rcx: &Rcx, body_scope: CodeExtent, args: &[ast::Arg]) { let re_scope = ty::ReScope(body_scope); let arg_cmt = mc.cat_rvalue(arg.id, arg.ty.span, re_scope, arg_ty); debug!("arg_ty={} arg_cmt={}", - arg_ty.repr(rcx.tcx()), - arg_cmt.repr(rcx.tcx())); + arg_ty.repr(), + arg_cmt.repr()); link_pattern(rcx, mc, arg_cmt, &*arg.pat); } } @@ -1099,8 +1099,8 @@ fn link_pattern<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, discr_cmt: mc::cmt<'tcx>, root_pat: &ast::Pat) { debug!("link_pattern(discr_cmt={}, root_pat={})", - discr_cmt.repr(rcx.tcx()), - root_pat.repr(rcx.tcx())); + discr_cmt.repr(), + root_pat.repr()); let _ = mc.cat_pattern(discr_cmt, root_pat, |mc, sub_cmt, sub_pat| { match sub_pat.node { // `ref x` pattern @@ -1136,7 +1136,7 @@ fn link_autoref(rcx: &Rcx, debug!("link_autoref(autoref={:?})", autoref); let mc = mc::MemCategorizationContext::new(rcx.fcx); let expr_cmt = ignore_err!(mc.cat_expr_autoderefd(expr, autoderefs)); - debug!("expr_cmt={}", expr_cmt.repr(rcx.tcx())); + debug!("expr_cmt={}", expr_cmt.repr()); match *autoref { ty::AutoPtr(r, m) => { @@ -1158,7 +1158,7 @@ fn link_by_ref(rcx: &Rcx, callee_scope: CodeExtent) { let tcx = rcx.tcx(); debug!("link_by_ref(expr={}, callee_scope={:?})", - expr.repr(tcx), callee_scope); + expr.repr(), callee_scope); let mc = mc::MemCategorizationContext::new(rcx.fcx); let expr_cmt = ignore_err!(mc.cat_expr(expr)); let borrow_region = ty::ReScope(callee_scope); @@ -1173,12 +1173,12 @@ fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, mutbl: ast::Mutability, cmt_borrowed: mc::cmt<'tcx>) { debug!("link_region_from_node_type(id={:?}, mutbl={:?}, cmt_borrowed={})", - id, mutbl, cmt_borrowed.repr(rcx.tcx())); + id, mutbl, cmt_borrowed.repr()); let rptr_ty = rcx.resolve_node_type(id); if !ty::type_is_error(rptr_ty) { let tcx = rcx.fcx.ccx.tcx; - debug!("rptr_ty={}", rptr_ty.user_string(tcx)); + debug!("rptr_ty={}", rptr_ty.user_string()); let r = ty::ty_region(tcx, span, rptr_ty); link_region(rcx, span, &r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); @@ -1198,9 +1198,9 @@ fn link_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, loop { debug!("link_region(borrow_region={}, borrow_kind={}, borrow_cmt={})", - borrow_region.repr(rcx.tcx()), - borrow_kind.repr(rcx.tcx()), - borrow_cmt.repr(rcx.tcx())); + borrow_region.repr(), + borrow_kind.repr(), + borrow_cmt.repr()); match borrow_cmt.cat.clone() { mc::cat_deref(ref_cmt, _, mc::Implicit(ref_kind, ref_region)) | @@ -1311,7 +1311,7 @@ fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, rcx.tcx().sess.span_bug( span, &format!("Illegal upvar id: {}", - upvar_id.repr(rcx.tcx()))); + upvar_id.repr())); } } } @@ -1327,8 +1327,8 @@ fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, }; debug!("link_reborrowed_region: {} <= {}", - borrow_region.repr(rcx.tcx()), - ref_region.repr(rcx.tcx())); + borrow_region.repr(), + ref_region.repr()); rcx.fcx.mk_subr(cause, *borrow_region, ref_region); // If we end up needing to recurse and establish a region link @@ -1402,13 +1402,13 @@ pub fn type_must_outlive<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, region: ty::Region) { debug!("type_must_outlive(ty={}, region={})", - ty.repr(rcx.tcx()), - region.repr(rcx.tcx())); + ty.repr(), + region.repr()); let implications = implicator::implications(rcx.fcx.infcx(), rcx.fcx, rcx.body_id, ty, region, origin.span()); for implication in implications { - debug!("implication: {}", implication.repr(rcx.tcx())); + debug!("implication: {}", implication.repr()); match implication { implicator::Implication::RegionSubRegion(None, r_a, r_b) => { rcx.fcx.mk_subr(origin.clone(), r_a, r_b); @@ -1444,7 +1444,7 @@ fn closure_must_outlive<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, def_id: ast::DefId, substs: &'tcx Substs<'tcx>) { debug!("closure_must_outlive(region={}, def_id={}, substs={})", - region.repr(rcx.tcx()), def_id.repr(rcx.tcx()), substs.repr(rcx.tcx())); + region.repr(), def_id.repr(), substs.repr()); let upvars = rcx.fcx.closure_upvars(def_id, substs).unwrap(); for upvar in upvars { @@ -1462,8 +1462,8 @@ fn generic_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, let param_env = &rcx.fcx.inh.param_env; debug!("param_must_outlive(region={}, generic={})", - region.repr(rcx.tcx()), - generic.repr(rcx.tcx())); + region.repr(), + generic.repr()); // To start, collect bounds from user: let mut param_bounds = @@ -1497,8 +1497,8 @@ fn generic_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, // don't know that this holds from first principles. for &(ref r, ref p) in &rcx.region_bound_pairs { debug!("generic={} p={}", - generic.repr(rcx.tcx()), - p.repr(rcx.tcx())); + generic.repr(), + p.repr()); if generic == p { param_bounds.push(*r); } @@ -1522,7 +1522,7 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, let infcx = fcx.infcx(); debug!("projection_bounds(projection_ty={})", - projection_ty.repr(tcx)); + projection_ty.repr()); let ty = ty::mk_projection(tcx, projection_ty.trait_ref.clone(), projection_ty.item_name); @@ -1547,7 +1547,7 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, }; debug!("projection_bounds: outlives={} (1)", - outlives.repr(tcx)); + outlives.repr()); // apply the substitutions (and normalize any projected types) let outlives = fcx.instantiate_type_scheme(span, @@ -1555,7 +1555,7 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, &outlives); debug!("projection_bounds: outlives={} (2)", - outlives.repr(tcx)); + outlives.repr()); let region_result = infcx.commit_if_ok(|_| { let (outlives, _) = @@ -1565,7 +1565,7 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, &outlives); debug!("projection_bounds: outlives={} (3)", - outlives.repr(tcx)); + outlives.repr()); // check whether this predicate applies to our current projection match infer::mk_eqty(infcx, false, infer::Misc(span), ty, outlives.0) { @@ -1575,7 +1575,7 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, }); debug!("projection_bounds: region_result={}", - region_result.repr(tcx)); + region_result.repr()); region_result.ok() }) diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 10ec2225555e9..f27985d741aee 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -134,7 +134,7 @@ impl<'a,'tcx> SeedBorrowKind<'a,'tcx> { self.closures_with_inferred_kinds.insert(expr.id); self.fcx.inh.closure_kinds.borrow_mut().insert(closure_def_id, ty::FnClosureKind); debug!("check_closure: adding closure_id={} to closures_with_inferred_kinds", - closure_def_id.repr(self.tcx())); + closure_def_id.repr()); } ty::with_freevars(self.tcx(), expr.id, |freevars| { @@ -246,7 +246,7 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { mode: euv::ConsumeMode) { debug!("adjust_upvar_borrow_kind_for_consume(cmt={}, mode={:?})", - cmt.repr(self.tcx()), mode); + cmt.repr(), mode); // we only care about moves match mode { @@ -259,7 +259,7 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { // by value instead let guarantor = cmt.guarantor(); debug!("adjust_upvar_borrow_kind_for_consume: guarantor={}", - guarantor.repr(self.tcx())); + guarantor.repr()); match guarantor.cat { mc::cat_deref(_, _, mc::BorrowedPtr(..)) | mc::cat_deref(_, _, mc::Implicit(..)) => { @@ -297,7 +297,7 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { /// those upvars must be borrowed using an `&mut` borrow. fn adjust_upvar_borrow_kind_for_mut(&mut self, cmt: mc::cmt<'tcx>) { debug!("adjust_upvar_borrow_kind_for_mut(cmt={})", - cmt.repr(self.tcx())); + cmt.repr()); match cmt.cat.clone() { mc::cat_deref(base, _, mc::Unique) | @@ -331,7 +331,7 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { fn adjust_upvar_borrow_kind_for_unique(&self, cmt: mc::cmt<'tcx>) { debug!("adjust_upvar_borrow_kind_for_unique(cmt={})", - cmt.repr(self.tcx())); + cmt.repr()); match cmt.cat.clone() { mc::cat_deref(base, _, mc::Unique) | @@ -498,7 +498,7 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume(cmt={},mode={:?})", cmt.repr(self.tcx()), mode); + debug!("consume(cmt={},mode={:?})", cmt.repr(), mode); self.adjust_upvar_borrow_kind_for_consume(cmt, mode); } @@ -513,7 +513,7 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume_pat(cmt={},mode={:?})", cmt.repr(self.tcx()), mode); + debug!("consume_pat(cmt={},mode={:?})", cmt.repr(), mode); self.adjust_upvar_borrow_kind_for_consume(cmt, mode); } @@ -526,7 +526,7 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { _loan_cause: euv::LoanCause) { debug!("borrow(borrow_id={}, cmt={}, bk={:?})", - borrow_id, cmt.repr(self.tcx()), bk); + borrow_id, cmt.repr(), bk); match bk { ty::ImmBorrow => { } @@ -551,7 +551,7 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { _mode: euv::MutateMode) { debug!("mutate(assignee_cmt={})", - assignee_cmt.repr(self.tcx())); + assignee_cmt.repr()); self.adjust_upvar_borrow_kind_for_mut(assignee_cmt); } diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs index 779f48d1e1b9e..bd7b212d32063 100644 --- a/src/librustc_typeck/check/wf.rs +++ b/src/librustc_typeck/check/wf.rs @@ -350,7 +350,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { param_name: ast::Name) { span_err!(self.tcx().sess, span, E0392, - "parameter `{}` is never used", param_name.user_string(self.tcx())); + "parameter `{}` is never used", param_name.user_string()); let suggested_marker_id = self.tcx().lang_items.phantom_data(); match suggested_marker_id { @@ -358,7 +358,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { self.tcx().sess.fileline_help( span, &format!("consider removing `{}` or using a marker such as `{}`", - param_name.user_string(self.tcx()), + param_name.user_string(), ty::item_path_str(self.tcx(), def_id))); } None => { @@ -395,7 +395,7 @@ fn reject_non_type_param_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, "cannot bound type `{}`, where clause \ bounds may only be attached to types involving \ type parameters", - bounded_ty.repr(tcx)) + bounded_ty.repr()) } fn is_ty_param(ty: ty::Ty) -> bool { @@ -536,7 +536,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> { } fn fold_binder(&mut self, binder: &ty::Binder) -> ty::Binder - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { self.binding_count += 1; let value = liberate_late_bound_regions( @@ -544,7 +544,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> { region::DestructionScopeData::new(self.scope), binder); debug!("BoundsChecker::fold_binder: late-bound regions replaced: {} at scope: {:?}", - value.repr(self.tcx()), self.scope); + value.repr(), self.scope); let value = value.fold_with(self); self.binding_count -= 1; ty::Binder(value) @@ -552,7 +552,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> { fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { debug!("BoundsChecker t={}", - t.repr(self.tcx())); + t.repr()); match self.cache { Some(ref mut cache) => { diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 3ecef67ed9895..1be7e42b7170d 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -172,7 +172,7 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> { debug!("Type for pattern binding {} (id {}) resolved to {}", pat_to_string(p), p.id, - ty::node_id_to_type(self.tcx(), p.id).repr(self.tcx())); + ty::node_id_to_type(self.tcx(), p.id).repr()); visit::walk_pat(self, p); } @@ -216,8 +216,8 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } }; debug!("Upvar capture for {} resolved to {}", - upvar_id.repr(self.tcx()), - new_upvar_capture.repr(self.tcx())); + upvar_id.repr(), + new_upvar_capture.repr()); self.fcx.tcx().upvar_capture_map.borrow_mut().insert(*upvar_id, new_upvar_capture); } } @@ -245,7 +245,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { let n_ty = self.fcx.node_ty(id); let n_ty = self.resolve(&n_ty, reason); write_ty_to_tcx(self.tcx(), id, n_ty); - debug!("Node {} has type {}", id, n_ty.repr(self.tcx())); + debug!("Node {} has type {}", id, n_ty.repr()); // Resolve any substitutions self.fcx.opt_node_ty_substs(id, |item_substs| { @@ -296,7 +296,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { Some(method) => { debug!("writeback::resolve_method_map_entry(call={:?}, entry={})", method_call, - method.repr(self.tcx())); + method.repr()); let new_method = MethodCallee { origin: self.resolve(&method.origin, reason), ty: self.resolve(&method.ty, reason), @@ -428,7 +428,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { Ok(t) => t, Err(e) => { debug!("Resolver::fold_ty: input type `{}` not fully resolvable", - t.repr(self.tcx)); + t.repr()); self.report_error(e); self.tcx().types.err } diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index cd7be46f9e012..59b57a4926491 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -82,7 +82,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>, inference_context.tcx.sess.span_bug( span, &format!("coherence encountered unexpected type searching for base type: {}", - ty.repr(inference_context.tcx))); + ty.repr())); } } } @@ -150,7 +150,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { if let Some(trait_ref) = ty::impl_trait_ref(self.crate_context.tcx, impl_did) { debug!("(checking implementation) adding impl for trait '{}', item '{}'", - trait_ref.repr(self.crate_context.tcx), + trait_ref.repr(), token::get_ident(item.ident)); enforce_trait_manually_implementable(self.crate_context.tcx, @@ -180,7 +180,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { all_impl_items: &mut Vec) { let tcx = self.crate_context.tcx; debug!("instantiate_default_methods(impl_id={:?}, trait_ref={})", - impl_id, trait_ref.repr(tcx)); + impl_id, trait_ref.repr()); let impl_type_scheme = ty::lookup_item_type(tcx, impl_id); @@ -190,7 +190,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let new_id = tcx.sess.next_node_id(); let new_did = local_def(new_id); - debug!("new_did={:?} trait_method={}", new_did, trait_method.repr(tcx)); + debug!("new_did={:?} trait_method={}", new_did, trait_method.repr()); // Create substitutions for the various trait parameters. let new_method_ty = @@ -203,7 +203,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { &**trait_method, Some(trait_method.def_id))); - debug!("new_method_ty={}", new_method_ty.repr(tcx)); + debug!("new_method_ty={}", new_method_ty.repr()); all_impl_items.push(MethodTraitItemId(new_did)); // construct the polytype for the method based on the @@ -214,7 +214,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { ty: ty::mk_bare_fn(tcx, Some(new_did), tcx.mk_bare_fn(new_method_ty.fty.clone())) }; - debug!("new_polytype={}", new_polytype.repr(tcx)); + debug!("new_polytype={}", new_polytype.repr()); tcx.tcache.borrow_mut().insert(new_did, new_polytype); tcx.predicates.borrow_mut().insert(new_did, new_method_ty.predicates.clone()); @@ -361,7 +361,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { copy_trait.for_each_impl(tcx, |impl_did| { debug!("check_implementations_of_copy: impl_did={}", - impl_did.repr(tcx)); + impl_did.repr()); if impl_did.krate != ast::LOCAL_CRATE { debug!("check_implementations_of_copy(): impl not in this \ @@ -371,7 +371,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let self_type = ty::lookup_item_type(tcx, impl_did); debug!("check_implementations_of_copy: self_type={} (bound)", - self_type.repr(tcx)); + self_type.repr()); let span = tcx.map.span(impl_did.node); let param_env = ParameterEnvironment::for_item(tcx, impl_did.node); @@ -379,7 +379,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { assert!(!self_type.has_escaping_regions()); debug!("check_implementations_of_copy: self_type={} (free)", - self_type.repr(tcx)); + self_type.repr()); match ty::can_type_implement_copy(¶m_env, span, self_type) { Ok(()) => {} @@ -430,7 +430,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { trait_def.for_each_impl(tcx, |impl_did| { debug!("check_implementations_of_coerce_unsized: impl_did={}", - impl_did.repr(tcx)); + impl_did.repr()); if impl_did.krate != ast::LOCAL_CRATE { debug!("check_implementations_of_coerce_unsized(): impl not \ @@ -443,7 +443,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { impl_did).unwrap(); let target = *trait_ref.substs.types.get(subst::TypeSpace, 0); debug!("check_implementations_of_coerce_unsized: {} -> {} (bound)", - source.repr(tcx), target.repr(tcx)); + source.repr(), target.repr()); let span = tcx.map.span(impl_did.node); let param_env = ParameterEnvironment::for_item(tcx, impl_did.node); @@ -452,7 +452,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { assert!(!source.has_escaping_regions()); debug!("check_implementations_of_coerce_unsized: {} -> {} (free)", - source.repr(tcx), target.repr(tcx)); + source.repr(), target.repr()); let infcx = new_infer_ctxt(tcx); @@ -520,8 +520,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { } else { token::get_name(name).to_string() }, - a.repr(tcx), - b.repr(tcx)) + a.repr(), + b.repr()) }).collect::>().connect(", ")); return; } @@ -598,7 +598,7 @@ fn subst_receiver_types_in_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, let combined_substs = ty::make_substs_for_receiver_types(tcx, trait_ref, method); debug!("subst_receiver_types_in_method_ty: combined_substs={}", - combined_substs.repr(tcx)); + combined_substs.repr()); let method_predicates = method.predicates.subst(tcx, &combined_substs); let mut method_generics = method.generics.subst(tcx, &combined_substs); @@ -615,12 +615,12 @@ fn subst_receiver_types_in_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, } debug!("subst_receiver_types_in_method_ty: method_generics={}", - method_generics.repr(tcx)); + method_generics.repr()); let method_fty = method.fty.subst(tcx, &combined_substs); debug!("subst_receiver_types_in_method_ty: method_ty={}", - method.fty.repr(tcx)); + method.fty.repr()); ty::Method::new( method.name, diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index d815893524ff3..5c99998b95325 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -66,7 +66,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { ast::ItemImpl(_, _, _, None, _, _) => { // For inherent impls, self type must be a nominal type // defined in this crate. - debug!("coherence2::orphan check: inherent impl {}", item.repr(self.tcx)); + debug!("coherence2::orphan check: inherent impl {}", item.repr()); let self_ty = ty::lookup_item_type(self.tcx, def_id).ty; match self_ty.sty { ty::TyEnum(def_id, _) | @@ -208,7 +208,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { } ast::ItemImpl(_, _, _, Some(_), _, _) => { // "Trait" impl - debug!("coherence2::orphan check: trait impl {}", item.repr(self.tcx)); + debug!("coherence2::orphan check: trait impl {}", item.repr()); let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap(); let trait_def_id = trait_ref.def_id; match traits::orphan_check(self.tcx, def_id) { @@ -227,7 +227,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { "type parameter `{}` must be used as the type parameter for \ some local type (e.g. `MyStruct`); only traits defined in \ the current crate can be implemented for a type parameter", - param_ty.user_string(self.tcx)); + param_ty.user_string()); return; } } @@ -266,8 +266,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { // rules, but it invalidates the reasoning from // `two_foos` above. debug!("trait_ref={} trait_def_id={} trait_has_default_impl={}", - trait_ref.repr(self.tcx), - trait_def_id.repr(self.tcx), + trait_ref.repr(), + trait_def_id.repr(), ty::trait_has_default_impl(self.tcx, trait_def_id)); if ty::trait_has_default_impl(self.tcx, trait_def_id) && @@ -305,7 +305,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { can only be implemented for a struct/enum type, \ not `{}`", ty::item_path_str(self.tcx, trait_def_id), - self_ty.user_string(self.tcx))) + self_ty.user_string())) } }; @@ -329,7 +329,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { } ast::ItemDefaultImpl(..) => { // "Trait" impl - debug!("coherence2::orphan check: default trait impl {}", item.repr(self.tcx)); + debug!("coherence2::orphan check: default trait impl {}", item.repr()); let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap(); if trait_ref.def_id.krate != ast::LOCAL_CRATE { span_err!(self.tcx.sess, item.span, E0318, diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 7564f7862fcd9..74ce9ed540ecb 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -62,7 +62,7 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> { trait_def: &'tcx ty::TraitDef<'tcx>) { debug!("check_for_overlapping_impls_of_trait(trait_def={})", - trait_def.repr(self.tcx)); + trait_def.repr()); // We should already know all impls of this trait, so these // borrows are safe. @@ -132,9 +132,9 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> { impl1_def_id, impl2_def_id) { debug!("check_if_impls_overlap({}, {}, {})", - trait_def_id.repr(self.tcx), - impl1_def_id.repr(self.tcx), - impl2_def_id.repr(self.tcx)); + trait_def_id.repr(), + impl1_def_id.repr(), + impl2_def_id.repr()); let infcx = infer::new_infer_ctxt(self.tcx); if traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id) { @@ -217,7 +217,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> { span_err!(self.tcx.sess, item.span, E0371, "the object type `{}` automatically \ implements the trait `{}`", - trait_ref.self_ty().user_string(self.tcx), + trait_ref.self_ty().user_string(), ty::item_path_str(self.tcx, trait_def_id)); } } diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index e4926b119d5db..fe276b3d1bded 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -55,14 +55,14 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { (ast::Unsafety::Normal, ast::Unsafety::Unsafe, _) => { span_err!(self.tcx.sess, item.span, E0199, "implementing the trait `{}` is not unsafe", - trait_ref.user_string(self.tcx)); + trait_ref.user_string()); } (ast::Unsafety::Unsafe, ast::Unsafety::Normal, ast::ImplPolarity::Positive) => { span_err!(self.tcx.sess, item.span, E0200, "the trait `{}` requires an `unsafe impl` declaration", - trait_ref.user_string(self.tcx)); + trait_ref.user_string()); } (ast::Unsafety::Unsafe, diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 03a0c2f5b62e5..ff7c8e69a6b45 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -255,7 +255,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { tcx.sess.note( &format!("the cycle begins when computing the bounds \ for type parameter `{}`...", - def.name.user_string(tcx))); + def.name.user_string())); } } @@ -277,7 +277,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { tcx.sess.note( &format!("...which then requires computing the bounds \ for type parameter `{}`...", - def.name.user_string(tcx))); + def.name.user_string())); } } } @@ -300,7 +300,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { tcx.sess.note( &format!("...which then again requires computing the bounds \ for type parameter `{}`, completing the cycle.", - def.name.user_string(tcx))); + def.name.user_string())); } } } @@ -317,7 +317,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { let item = match tcx.map.get(trait_id.node) { ast_map::NodeItem(item) => item, - _ => tcx.sess.bug(&format!("get_trait_def({}): not an item", trait_id.repr(tcx))) + _ => tcx.sess.bug(&format!("get_trait_def({}): not an item", trait_id.repr())) }; trait_def_of_item(self, &*item) @@ -372,7 +372,7 @@ impl<'a, 'tcx> AstConv<'tcx> for ItemCtxt<'a, 'tcx> { -> Result<(), ErrorReported> { debug!("ensure_super_predicates(trait_def_id={})", - trait_def_id.repr(self.tcx())); + trait_def_id.repr()); self.ccx.ensure_super_predicates(span, trait_def_id) } @@ -635,7 +635,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let fty = ty::mk_bare_fn(ccx.tcx, Some(def_id), ccx.tcx.mk_bare_fn(ty_method.fty.clone())); debug!("method {} (id {}) has type {}", - ident.repr(ccx.tcx), id, fty.repr(ccx.tcx)); + ident.repr(), id, fty.repr()); ccx.tcx.tcache.borrow_mut().insert(def_id,TypeScheme { generics: ty_method.generics.clone(), ty: fty @@ -645,7 +645,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, write_ty_to_tcx(ccx.tcx, id, fty); debug!("writing method type: def_id={:?} mty={}", - def_id, ty_method.repr(ccx.tcx)); + def_id, ty_method.repr()); ccx.tcx.impl_or_trait_items.borrow_mut().insert(def_id, ty::MethodTraitItem(Rc::new(ty_method))); @@ -743,9 +743,9 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>, where I: Iterator { debug!("convert_methods(untransformed_rcvr_ty={}, rcvr_ty_generics={}, rcvr_ty_predicates={})", - untransformed_rcvr_ty.repr(ccx.tcx), - rcvr_ty_generics.repr(ccx.tcx), - rcvr_ty_predicates.repr(ccx.tcx)); + untransformed_rcvr_ty.repr(), + rcvr_ty_generics.repr(), + rcvr_ty_predicates.repr()); let tcx = ccx.tcx; let mut seen_methods = FnvHashSet(); @@ -1139,7 +1139,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, { let tcx = ccx.tcx; - debug!("ensure_super_predicates_step(trait_def_id={})", trait_def_id.repr(tcx)); + debug!("ensure_super_predicates_step(trait_def_id={})", trait_def_id.repr()); if trait_def_id.krate != ast::LOCAL_CRATE { // If this trait comes from an external crate, then all of the @@ -1192,8 +1192,8 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, predicates: VecPerParamSpace::new(superbounds, vec![], vec![]) }; debug!("superpredicates for trait {} = {}", - local_def(item.id).repr(ccx.tcx), - superpredicates.repr(ccx.tcx)); + local_def(item.id).repr(), + superpredicates.repr()); tcx.super_predicates.borrow_mut().insert(trait_def_id, superpredicates.clone()); @@ -1206,7 +1206,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, .map(|tr| tr.def_id()) .collect(); - debug!("ensure_super_predicates_step: def_ids={}", def_ids.repr(tcx)); + debug!("ensure_super_predicates_step: def_ids={}", def_ids.repr()); def_ids } @@ -1532,9 +1532,9 @@ fn convert_typed_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, scheme.generics.types.iter() .map(|t| match t.object_lifetime_default { Some(ty::ObjectLifetimeDefault::Specific(r)) => - r.user_string(tcx), + r.user_string(), d => - d.repr(ccx.tcx), + d.repr(), }) .collect::>() .connect(","); @@ -1621,7 +1621,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, -> ty::Generics<'tcx> { debug!("ty_generics_for_trait(trait_id={}, substs={})", - local_def(trait_id).repr(ccx.tcx), substs.repr(ccx.tcx)); + local_def(trait_id).repr(), substs.repr()); let mut generics = ty_generics_for_type_or_impl(ccx, ast_generics); @@ -2202,10 +2202,10 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( debug!("required_type={} required_type_free={} \ base_type={} base_type_free={}", - required_type.repr(tcx), - required_type_free.repr(tcx), - base_type.repr(tcx), - base_type_free.repr(tcx)); + required_type.repr(), + required_type_free.repr(), + base_type.repr(), + base_type_free.repr()); let infcx = infer::new_infer_ctxt(tcx); drop(::require_same_types(tcx, @@ -2216,7 +2216,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( required_type_free, || { format!("mismatched self type: expected `{}`", - required_type.user_string(tcx)) + required_type.user_string()) })); // We could conceviably add more free-region relations here, @@ -2235,7 +2235,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( scope: region::DestructionScopeData, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr<'tcx> + where T : TypeFoldable<'tcx> + Repr { /*! * Convert early-bound regions into free regions; normally this is done by @@ -2286,7 +2286,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, idx: index as u32, name: ty_param.ident.name }; if !input_parameters.contains(&ctp::Parameter::Type(param_ty)) { - report_unused_parameter(tcx, ty_param.span, "type", ¶m_ty.user_string(tcx)); + report_unused_parameter(tcx, ty_param.span, "type", ¶m_ty.user_string()); } } @@ -2316,7 +2316,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, !input_parameters.contains(&ctp::Parameter::Region(region)) { report_unused_parameter(tcx, lifetime_def.lifetime.span, - "lifetime", ®ion.name.user_string(tcx)); + "lifetime", ®ion.name.user_string()); } } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 0ea5073bb2490..3f779d6794482 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -148,7 +148,7 @@ pub struct CrateCtxt<'a, 'tcx: 'a> { // Functions that write types into the node type table fn write_ty_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, node_id: ast::NodeId, ty: Ty<'tcx>) { - debug!("write_ty_to_tcx({}, {})", node_id, ty.repr(tcx)); + debug!("write_ty_to_tcx({}, {})", node_id, ty.repr()); assert!(!ty::type_needs_infer(ty)); tcx.node_type_insert(node_id, ty); } @@ -159,7 +159,7 @@ fn write_substs_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, if !item_substs.is_noop() { debug!("write_substs_to_tcx({}, {})", node_id, - item_substs.repr(tcx)); + item_substs.repr()); assert!(item_substs.substs.types.all(|t| !ty::type_needs_infer(*t))); @@ -244,14 +244,14 @@ fn check_main_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, main_span, main_t, se_ty, || { format!("main function expects type: `{}`", - se_ty.user_string(ccx.tcx)) + se_ty.user_string()) }); } _ => { tcx.sess.span_bug(main_span, &format!("main has a non-function type: found \ `{}`", - main_t.repr(tcx))); + main_t.repr())); } } } @@ -294,7 +294,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, start_span, start_t, se_ty, || { format!("start function expects type: `{}`", - se_ty.user_string(ccx.tcx)) + se_ty.user_string()) }); } @@ -302,7 +302,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt, tcx.sess.span_bug(start_span, &format!("start has a non-function type: found \ `{}`", - start_t.repr(tcx))); + start_t.repr())); } } } diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index 37088701adcd6..3085598e4a3ae 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -518,7 +518,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> { fn visit_item(&mut self, item: &ast::Item) { - debug!("add_inferreds for item {}", item.repr(self.tcx)); + debug!("add_inferreds for item {}", item.repr()); match item.node { ast::ItemEnum(_, ref generics) | @@ -601,7 +601,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> { let tcx = self.terms_cx.tcx; debug!("visit_item item={}", - item.repr(tcx)); + item.repr()); match item.node { ast::ItemEnum(ref enum_definition, _) => { @@ -847,7 +847,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { trait_ref: ty::TraitRef<'tcx>, variance: VarianceTermPtr<'a>) { debug!("add_constraints_from_trait_ref: trait_ref={} variance={:?}", - trait_ref.repr(self.tcx()), + trait_ref.repr(), variance); let trait_def = ty::lookup_trait_def(self.tcx(), trait_ref.def_id); @@ -869,7 +869,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { ty: Ty<'tcx>, variance: VarianceTermPtr<'a>) { debug!("add_constraints_from_ty(ty={}, variance={:?})", - ty.repr(self.tcx()), + ty.repr(), variance); match ty.sty { @@ -983,7 +983,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { self.tcx().sess.bug( &format!("unexpected type encountered in \ variance inference: {}", - ty.repr(self.tcx()))); + ty.repr())); } } } @@ -999,8 +999,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { substs: &subst::Substs<'tcx>, variance: VarianceTermPtr<'a>) { debug!("add_constraints_from_substs(def_id={}, substs={}, variance={:?})", - def_id.repr(self.tcx()), - substs.repr(self.tcx()), + def_id.repr(), + substs.repr(), variance); for p in type_param_defs { @@ -1068,7 +1068,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { .sess .bug(&format!("unexpected region encountered in variance \ inference: {}", - region.repr(self.tcx()))); + region.repr())); } } } @@ -1197,14 +1197,14 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { }; debug!("item_id={} item_variances={}", item_id, - item_variances.repr(tcx)); + item_variances.repr()); let item_def_id = ast_util::local_def(item_id); // For unit testing: check for a special "rustc_variance" // attribute and report an error with various results if found. if ty::has_attr(tcx, item_def_id, "rustc_variance") { - let found = item_variances.repr(tcx); + let found = item_variances.repr(); span_err!(tcx.sess, tcx.map.span(item_id), E0208, "{}", &found[..]); } From b510ea1487286123c00f425b368a8328637ac947 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 17 Jun 2015 01:39:20 +0300 Subject: [PATCH 42/48] Clean up unused argument/variable warnings. --- src/librustc/middle/free_region.rs | 1 - src/librustc/middle/infer/combine.rs | 1 - src/librustc/middle/infer/higher_ranked/mod.rs | 2 -- src/librustc/middle/mem_categorization.rs | 1 - src/librustc/middle/traits/coherence.rs | 3 +-- src/librustc/middle/traits/fulfill.rs | 9 +++------ src/librustc/middle/traits/mod.rs | 7 ++----- src/librustc/middle/traits/project.rs | 4 ---- src/librustc/middle/traits/select.rs | 3 +-- src/librustc/middle/traits/util.rs | 3 +-- src/librustc/middle/ty_relate/mod.rs | 1 - src/librustc_borrowck/borrowck/fragments.rs | 10 ++++------ src/librustc_trans/trans/base.rs | 1 - src/librustc_trans/trans/foreign.rs | 2 -- src/librustc_trans/trans/glue.rs | 8 +++++--- src/librustc_typeck/check/assoc.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 3 +-- src/librustc_typeck/check/mod.rs | 6 ++---- src/librustc_typeck/check/regionck.rs | 5 +---- src/librustc_typeck/check/upvar.rs | 4 ---- 20 files changed, 22 insertions(+), 54 deletions(-) diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index a245de3deae38..ed1ce3458a26b 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -29,7 +29,6 @@ impl FreeRegionMap { } pub fn relate_free_regions_from_implications<'tcx>(&mut self, - tcx: &ty::ctxt<'tcx>, implications: &[Implication<'tcx>]) { for implication in implications { diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index decd07b87c07a..30242dac695d9 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -187,7 +187,6 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> { b_vid: ty::TyVid) -> RelateResult<'tcx, ()> { - let tcx = self.infcx.tcx; let mut stack = Vec::new(); stack.push((a_ty, dir, b_vid)); loop { diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index d38de0f5a3f65..d6001270d1c7a 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -46,8 +46,6 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { -> RelateResult<'tcx, Binder> where T: Relate<'a,'tcx> { - let tcx = self.infcx.tcx; - debug!("higher_ranked_sub(a={}, b={})", a.repr(), b.repr()); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index a3e12db6644ab..3dbb3dfae2f00 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -418,7 +418,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } fn pat_ty(&self, pat: &ast::Pat) -> McResult> { - let tcx = self.typer.tcx(); let base_ty = try!(self.typer.node_ty(pat.id)); // FIXME (Issue #18207): This code detects whether we are // looking at a `ref x`, and if so, figures out what the type diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index b7568b565cec9..622ed134a6091 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -81,7 +81,6 @@ fn overlap(selcx: &mut SelectionContext, debug!("overlap: subtraitref check succeeded"); // Are any of the obligations unsatisfiable? If so, no overlap. - let tcx = selcx.tcx(); let infcx = selcx.infcx(); let opt_failing_obligation = a_obligations.iter() @@ -155,7 +154,7 @@ fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, let Normalized { value: predicates, obligations: normalization_obligations2 } = project::normalize(selcx, ObligationCause::dummy(), &predicates); let impl_obligations = - util::predicates_for_generics(selcx.tcx(), ObligationCause::dummy(), 0, &predicates); + util::predicates_for_generics(ObligationCause::dummy(), 0, &predicates); let impl_obligations: Vec<_> = impl_obligations.into_iter() diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 8615a7822bea9..418c4522cd9b3 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -171,12 +171,11 @@ impl<'tcx> FulfillmentContext<'tcx> { } pub fn register_region_obligation<'a>(&mut self, - infcx: &InferCtxt<'a,'tcx>, t_a: Ty<'tcx>, r_b: ty::Region, cause: ObligationCause<'tcx>) { - register_region_obligation(infcx.tcx, t_a, r_b, cause, &mut self.region_obligations); + register_region_obligation(t_a, r_b, cause, &mut self.region_obligations); } pub fn register_predicate_obligation<'a>(&mut self, @@ -366,7 +365,6 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, * type inference. */ - let tcx = selcx.tcx(); match obligation.predicate { ty::Predicate::Trait(ref data) => { let trait_obligation = obligation.with(data.clone()); @@ -430,7 +428,7 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, CodeSelectionError(Unimplemented))); } else { let ty::OutlivesPredicate(t_a, r_b) = binder.0; - register_region_obligation(tcx, t_a, r_b, + register_region_obligation(t_a, r_b, obligation.cause.clone(), region_obligations); } @@ -471,8 +469,7 @@ impl<'tcx> Repr for RegionObligation<'tcx> { } } -fn register_region_obligation<'tcx>(tcx: &ty::ctxt<'tcx>, - t_a: Ty<'tcx>, +fn register_region_obligation<'tcx>(t_a: Ty<'tcx>, r_b: ty::Region, cause: ObligationCause<'tcx>, region_obligations: &mut NodeMap>>) diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index 036aaedb446de..551bafc57161a 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -300,12 +300,11 @@ pub struct VtableObjectData<'tcx> { } /// Creates predicate obligations from the generic bounds. -pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>, - cause: ObligationCause<'tcx>, +pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, generic_bounds: &ty::InstantiatedPredicates<'tcx>) -> PredicateObligations<'tcx> { - util::predicates_for_generics(tcx, cause, 0, generic_bounds) + util::predicates_for_generics(cause, 0, generic_bounds) } /// Determines whether the type `ty` is known to meet `bound` and @@ -436,8 +435,6 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, -> Result>> where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr { - let tcx = closure_typer.tcx(); - debug!("normalize_param_env(value={})", value.repr()); let mut selcx = &mut SelectionContext::new(infcx, closure_typer); diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index ef89dc384bbd9..1b5f79452c0f2 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -373,7 +373,6 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( obligations.repr()); if ty::type_has_projection(projected_ty) { - let tcx = selcx.tcx(); let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth); let normalized_ty = normalizer.fold(&projected_ty); @@ -633,7 +632,6 @@ fn assemble_candidates_from_object_type<'cx,'tcx>( candidate_set: &mut ProjectionTyCandidateSet<'tcx>, object_ty: Ty<'tcx>) { - let infcx = selcx.infcx(); debug!("assemble_candidates_from_object_type(object_ty={})", object_ty.repr()); let data = match object_ty.sty { @@ -745,8 +743,6 @@ fn confirm_candidate<'cx,'tcx>( candidate: ProjectionTyCandidate<'tcx>) -> (Ty<'tcx>, Vec>) { - let infcx = selcx.infcx(); - debug!("confirm_candidate(candidate={}, obligation={})", candidate.repr(), obligation.repr()); diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index ea5d789683f41..5519ad97d2225 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -2896,8 +2896,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let predicates = normalize_with_depth(self, cause.clone(), recursion_depth, &predicates); let mut predicates = self.infcx().plug_leaks(skol_map, snapshot, &predicates); let mut obligations = - util::predicates_for_generics(self.tcx(), - cause, + util::predicates_for_generics(cause, recursion_depth, &predicates.value); obligations.append(&mut predicates.obligations); diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index a3ce5a90c2b04..475e2f69a4c1d 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -321,8 +321,7 @@ impl<'tcx> fmt::Debug for super::VtableObjectData<'tcx> { } /// See `super::obligations_for_generics` -pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>, - cause: ObligationCause<'tcx>, +pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, recursion_depth: usize, generic_bounds: &ty::InstantiatedPredicates<'tcx>) -> Vec> diff --git a/src/librustc/middle/ty_relate/mod.rs b/src/librustc/middle/ty_relate/mod.rs index a97f9d0b9f8a1..e9c84f4c9ce2a 100644 --- a/src/librustc/middle/ty_relate/mod.rs +++ b/src/librustc/middle/ty_relate/mod.rs @@ -191,7 +191,6 @@ fn relate_region_params<'a,'tcx:'a,R>(relation: &mut R, -> RelateResult<'tcx, Vec> where R: TypeRelation<'a,'tcx> { - let tcx = relation.tcx(); let num_region_params = a_rs.len(); debug!("relate_region_params(a_rs={}, \ diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index 75e9c09fb3da4..6f896fffd3db3 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -42,7 +42,7 @@ enum Fragment { } impl Fragment { - fn loan_path_repr<'tcx>(&self, move_data: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) -> String { + fn loan_path_repr(&self, move_data: &MoveData) -> String { let repr = |mpi| move_data.path_loan_path(mpi).repr(); match *self { Just(mpi) => repr(mpi), @@ -50,9 +50,7 @@ impl Fragment { } } - fn loan_path_user_string<'tcx>(&self, - move_data: &MoveData<'tcx>, - tcx: &ty::ctxt<'tcx>) -> String { + fn loan_path_user_string(&self, move_data: &MoveData) -> String { let user_string = |mpi| move_data.path_loan_path(mpi).user_string(); match *self { Just(mpi) => user_string(mpi), @@ -138,7 +136,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>, let instrument_all_fragments = |kind, vec_rc: &Vec| { for (i, f) in vec_rc.iter().enumerate() { - let render = || f.loan_path_user_string(this, tcx); + let render = || f.loan_path_user_string(this); if span_err { tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())); } @@ -176,7 +174,7 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) { }; let frag_lps = |fs: &[Fragment]| -> Vec { - fs.iter().map(|f| f.loan_path_repr(this, tcx)).collect() + fs.iter().map(|f| f.loan_path_repr(this)).collect() }; // First, filter out duplicates diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 291541aa98ff8..81657c9537066 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -1671,7 +1671,6 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, -> Result<'blk, 'tcx> { let ccx = bcx.fcx.ccx; - let tcx = ccx.tcx(); let result_ty = match ctor_ty.sty { ty::TyBareFn(_, ref bft) => { diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index bfbcbd92734e5..66f7a89d7abb2 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -233,7 +233,6 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, -> Block<'blk, 'tcx> { let ccx = bcx.ccx(); - let tcx = bcx.tcx(); debug!("trans_native_call(callee_ty={}, \ llfn={}, \ @@ -636,7 +635,6 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) { let _icx = push_ctxt( "foreign::trans_rust_fn_with_foreign_abi::build_wrap_fn"); - let tcx = ccx.tcx(); debug!("build_wrap_fn(llrustfn={}, llwrapfn={}, t={})", ccx.tn().val_to_string(llrustfn), diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index 05cc16c9b8887..e885f56ef8e42 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -203,8 +203,10 @@ impl<'tcx> DropGlueKind<'tcx> { DropGlueKind::TyContents(t) => DropGlueKind::TyContents(f(t)), } } +} - fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { +impl<'tcx> Repr for DropGlueKind<'tcx> { + fn repr(&self) -> String { match *self { DropGlueKind::Ty(ty) => { format!("DropGlueKind::Ty({})", ty.repr()) @@ -218,9 +220,9 @@ impl<'tcx> DropGlueKind<'tcx> { fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKind<'tcx>) -> ValueRef { - debug!("make drop glue for {}", g.to_string(ccx)); + debug!("make drop glue for {}", g.repr()); let g = g.map_ty(|t| get_drop_glue_type(ccx, t)); - debug!("drop glue type {}", g.to_string(ccx)); + debug!("drop glue type {}", g.repr()); match ccx.drop_glues().borrow().get(&g) { Some(&glue) => return glue, _ => { } diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs index 334fe2f54c03c..5e25404bf738d 100644 --- a/src/librustc_typeck/check/assoc.rs +++ b/src/librustc_typeck/check/assoc.rs @@ -12,7 +12,7 @@ use middle::infer::InferCtxt; use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation, SelectionContext, ObligationCause}; use middle::ty::{self, HasProjectionTypes}; -use middle::ty_fold::{TypeFoldable, TypeFolder}; +use middle::ty_fold::TypeFoldable; use syntax::ast; use syntax::codemap::Span; use util::ppaux::Repr; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index daa2b95e07e80..eeccb576749cb 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1062,8 +1062,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { // Convert the bounds into obligations. let obligations = - traits::predicates_for_generics(self.tcx(), - cause.clone(), + traits::predicates_for_generics(cause.clone(), &impl_bounds); debug!("impl_obligations={}", obligations.repr()); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 34403b53fc6f0..b728c01291939 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1745,7 +1745,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { cause: traits::ObligationCause<'tcx>) { let mut fulfillment_cx = self.inh.fulfillment_cx.borrow_mut(); - fulfillment_cx.register_region_obligation(self.infcx(), ty, region, cause); + fulfillment_cx.register_region_obligation(ty, region, cause); } pub fn add_default_region_param_bounds(&self, @@ -1787,9 +1787,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { debug!("add_obligations_for_parameters(predicates={})", predicates.repr()); - for obligation in traits::predicates_for_generics(self.tcx(), - cause, - predicates) { + for obligation in traits::predicates_for_generics(cause, predicates) { self.register_predicate(obligation); } } diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 057b4de3f0d96..949cf118afca4 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -348,7 +348,6 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { body_id: ast::NodeId, span: Span) { debug!("relate_free_regions >>"); - let tcx = self.tcx(); for &ty in fn_sig_tys { let ty = self.resolve_type(ty); @@ -359,7 +358,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { ty, body_scope, span); // Record any relations between free regions that we observe into the free-region-map. - self.free_region_map.relate_free_regions_from_implications(tcx, &implications); + self.free_region_map.relate_free_regions_from_implications(&implications); // But also record other relationships, such as `T:'x`, // that don't go into the free-region-map but which we use @@ -823,7 +822,6 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, //! in the type of the function. Also constrains the regions that //! appear in the arguments appropriately. - let tcx = rcx.fcx.tcx(); debug!("constrain_call(call_expr={}, \ receiver={}, \ implicitly_ref_args={})", @@ -1156,7 +1154,6 @@ fn link_autoref(rcx: &Rcx, fn link_by_ref(rcx: &Rcx, expr: &ast::Expr, callee_scope: CodeExtent) { - let tcx = rcx.tcx(); debug!("link_by_ref(expr={}, callee_scope={:?})", expr.repr(), callee_scope); let mc = mc::MemCategorizationContext::new(rcx.fcx); diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index f27985d741aee..a5668d8e86053 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -178,10 +178,6 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { AdjustBorrowKind { fcx: fcx, closures_with_inferred_kinds: closures_with_inferred_kinds } } - fn tcx(&self) -> &'a ty::ctxt<'tcx> { - self.fcx.tcx() - } - fn analyze_closure(&mut self, id: ast::NodeId, decl: &ast::FnDecl, body: &ast::Block) { /*! * Analysis starting point. From af7daa0daff91f8a58708f2d98f94d49acc28c6a Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 17 Jun 2015 09:53:07 +0300 Subject: [PATCH 43/48] rustc: remove some unused UserString and Repr impls. --- src/librustc/util/ppaux.rs | 27 +-------------------------- src/librustc_trans/trans/meth.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 079741b0f2815..7b82b49dadb10 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -45,7 +45,7 @@ pub trait Repr { } /// Produces a string suitable for showing to the user. -pub trait UserString: Repr { +pub trait UserString { fn user_string(&self) -> String; } @@ -296,14 +296,6 @@ impl<'a, T: ?Sized +UserString> UserString for &'a T { } } -impl UserString for Vec { - fn user_string(&self) -> String { - let strs: Vec = - self.iter().map(|t| t.user_string()).collect(); - strs.connect(", ") - } -} - impl Repr for def::Def { fn repr(&self) -> String { format!("{:?}", *self) @@ -475,17 +467,6 @@ impl<'tcx> Repr for ty::TraitDef<'tcx> { } } -impl Repr for ast::TraitItem { - fn repr(&self) -> String { - let kind = match self.node { - ast::ConstTraitItem(..) => "ConstTraitItem", - ast::MethodTraitItem(..) => "MethodTraitItem", - ast::TypeTraitItem(..) => "TypeTraitItem", - }; - format!("{}({}, id={})", kind, self.ident, self.id) - } -} - impl Repr for ast::Expr { fn repr(&self) -> String { format!("expr({}: {})", self.id, pprust::expr_to_string(self)) @@ -794,12 +775,6 @@ impl UserString for ast::Name { } } -impl Repr for ast::Ident { - fn repr(&self) -> String { - token::get_ident(*self).to_string() - } -} - impl Repr for ast::ExplicitSelf_ { fn repr(&self) -> String { format!("{:?}", *self) diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index 7229995048aa2..ec95bfe483c26 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -62,7 +62,7 @@ pub fn trans_impl(ccx: &CrateContext, let _icx = push_ctxt("meth::trans_impl"); let tcx = ccx.tcx(); - debug!("trans_impl(name={}, id={})", name.repr(), id); + debug!("trans_impl(name={}, id={})", name, id); let mut v = TransItemVisitor { ccx: ccx }; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ff7c8e69a6b45..4bb9aa4955779 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -635,7 +635,7 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let fty = ty::mk_bare_fn(ccx.tcx, Some(def_id), ccx.tcx.mk_bare_fn(ty_method.fty.clone())); debug!("method {} (id {}) has type {}", - ident.repr(), id, fty.repr()); + ident, id, fty.repr()); ccx.tcx.tcache.borrow_mut().insert(def_id,TypeScheme { generics: ty_method.generics.clone(), ty: fty From 17e333d31b6237c2e3775b254e3808d1137c6b94 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Wed, 17 Jun 2015 09:56:27 +0300 Subject: [PATCH 44/48] Move AST Repr impls to Debug impls in libsyntax. --- src/librustc/middle/check_const.rs | 3 +- src/librustc/middle/ty.rs | 48 +++++++++++++++- src/librustc/util/ppaux.rs | 54 ++++-------------- src/librustc_typeck/coherence/orphan.rs | 9 ++- src/librustc_typeck/variance.rs | 5 +- src/libsyntax/ast.rs | 76 ++++++++++++++++++++++--- src/libsyntax/codemap.rs | 18 +++++- 7 files changed, 150 insertions(+), 63 deletions(-) diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs index 9100f45a5de89..8af6946d3c3b1 100644 --- a/src/librustc/middle/check_const.rs +++ b/src/librustc/middle/check_const.rs @@ -33,7 +33,6 @@ use middle::mem_categorization as mc; use middle::traits; use middle::ty::{self, Ty}; use util::nodemap::NodeMap; -use util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; @@ -300,7 +299,7 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> { fn visit_item(&mut self, i: &ast::Item) { - debug!("visit_item(item={})", i.repr()); + debug!("visit_item(item={})", self.tcx.map.node_to_string(i.id)); match i.node { ast::ItemStatic(_, ast::MutImmutable, ref expr) => { self.check_static_type(&**expr); diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index e9f1fbeef9000..293043af53979 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -927,9 +927,14 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Binder { } pub mod tls { + use ast_map; use middle::ty; use session::Session; + use std::fmt; + use syntax::ast; + use syntax::codemap; + /// Marker type used for the scoped TLS slot. /// The type context cannot be used directly because the scoped TLS /// in libstd doesn't allow types generic over lifetimes. @@ -937,10 +942,49 @@ pub mod tls { scoped_thread_local!(static TLS_TCX: ThreadLocalTyCx); + fn def_id_debug(def_id: ast::DefId, f: &mut fmt::Formatter) -> fmt::Result { + // Unfortunately, there seems to be no way to attempt to print + // a path for a def-id, so I'll just make a best effort for now + // and otherwise fallback to just printing the crate/node pair + with(|tcx| { + if def_id.krate == ast::LOCAL_CRATE { + match tcx.map.find(def_id.node) { + Some(ast_map::NodeItem(..)) | + Some(ast_map::NodeForeignItem(..)) | + Some(ast_map::NodeImplItem(..)) | + Some(ast_map::NodeTraitItem(..)) | + Some(ast_map::NodeVariant(..)) | + Some(ast_map::NodeStructCtor(..)) => { + return write!(f, "{}", ty::item_path_str(tcx, def_id)); + } + _ => {} + } + } + Ok(()) + }) + } + + fn span_debug(span: codemap::Span, f: &mut fmt::Formatter) -> fmt::Result { + with(|tcx| { + write!(f, "{}", tcx.sess.codemap().span_to_string(span)) + }) + } + pub fn enter<'tcx, F: FnOnce(&ty::ctxt<'tcx>) -> R, R>(tcx: ty::ctxt<'tcx>, f: F) -> (Session, R) { - let tls_ptr = &tcx as *const _ as *const ThreadLocalTyCx; - let result = TLS_TCX.set(unsafe { &*tls_ptr }, || f(&tcx)); + let result = ast::DEF_ID_DEBUG.with(|def_id_dbg| { + codemap::SPAN_DEBUG.with(|span_dbg| { + let original_def_id_debug = def_id_dbg.get(); + def_id_dbg.set(def_id_debug); + let original_span_debug = span_dbg.get(); + span_dbg.set(span_debug); + let tls_ptr = &tcx as *const _ as *const ThreadLocalTyCx; + let result = TLS_TCX.set(unsafe { &*tls_ptr }, || f(&tcx)); + def_id_dbg.set(original_def_id_debug); + span_dbg.set(original_span_debug); + result + }) + }); (tcx.sess, result) } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 7b82b49dadb10..3851eb6573ba1 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -9,7 +9,6 @@ // except according to those terms. -use ast_map; use middle::def; use middle::region; use middle::subst::{VecPerParamSpace,Subst}; @@ -34,7 +33,6 @@ use std::rc::Rc; use syntax::abi; use syntax::codemap::Span; use syntax::parse::token; -use syntax::print::pprust; use syntax::ptr::P; use syntax::{ast, ast_util}; use syntax::owned_slice::OwnedSlice; @@ -469,51 +467,43 @@ impl<'tcx> Repr for ty::TraitDef<'tcx> { impl Repr for ast::Expr { fn repr(&self) -> String { - format!("expr({}: {})", self.id, pprust::expr_to_string(self)) + format!("{:?}", *self) } } impl Repr for ast::Path { fn repr(&self) -> String { - format!("path({})", pprust::path_to_string(self)) + format!("{:?}", *self) } } impl UserString for ast::Path { fn user_string(&self) -> String { - pprust::path_to_string(self) + format!("{}", *self) } } impl Repr for ast::Ty { fn repr(&self) -> String { - format!("type({})", pprust::ty_to_string(self)) - } -} - -impl Repr for ast::Item { - fn repr(&self) -> String { - format!("item({})", ty::tls::with(|tcx| tcx.map.node_to_string(self.id))) + format!("{:?}", *self) } } impl Repr for ast::Lifetime { fn repr(&self) -> String { - format!("lifetime({}: {})", self.id, pprust::lifetime_to_string(self)) + format!("{:?}", *self) } } impl Repr for ast::Stmt { fn repr(&self) -> String { - format!("stmt({}: {})", - ast_util::stmt_id(self), - pprust::stmt_to_string(self)) + format!("{:?}", *self) } } impl Repr for ast::Pat { fn repr(&self) -> String { - format!("pat({}: {})", self.id, pprust::pat_to_string(self)) + format!("{:?}", *self) } } @@ -646,27 +636,7 @@ impl Repr for region::DestructionScopeData { impl Repr for ast::DefId { fn repr(&self) -> String { - // Unfortunately, there seems to be no way to attempt to print - // a path for a def-id, so I'll just make a best effort for now - // and otherwise fallback to just printing the crate/node pair - ty::tls::with(|tcx| { - if self.krate == ast::LOCAL_CRATE { - match tcx.map.find(self.node) { - Some(ast_map::NodeItem(..)) | - Some(ast_map::NodeForeignItem(..)) | - Some(ast_map::NodeImplItem(..)) | - Some(ast_map::NodeTraitItem(..)) | - Some(ast_map::NodeVariant(..)) | - Some(ast_map::NodeStructCtor(..)) => { - return format!("{:?}:{}", - *self, - ty::item_path_str(tcx, *self)); - } - _ => {} - } - } - format!("{:?}", *self) - }) + format!("{:?}", *self) } } @@ -765,13 +735,13 @@ impl<'tcx> Repr for ty::Method<'tcx> { impl Repr for ast::Name { fn repr(&self) -> String { - token::get_name(*self).to_string() + format!("{:?}", *self) } } impl UserString for ast::Name { fn user_string(&self) -> String { - token::get_name(*self).to_string() + format!("{}", *self) } } @@ -878,7 +848,7 @@ impl UserString for ty::BuiltinBound { impl Repr for Span { fn repr(&self) -> String { - ty::tls::with(|tcx| tcx.sess.codemap().span_to_string(*self).to_string()) + format!("{:?}", *self) } } @@ -1163,7 +1133,7 @@ impl<'tcx> UserString for ty::TyS<'tcx> { impl UserString for ast::Ident { fn user_string(&self) -> String { - token::get_name(self.name).to_string() + format!("{}", *self) } } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 5c99998b95325..3068bb9923dd0 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -66,7 +66,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { ast::ItemImpl(_, _, _, None, _, _) => { // For inherent impls, self type must be a nominal type // defined in this crate. - debug!("coherence2::orphan check: inherent impl {}", item.repr()); + debug!("coherence2::orphan check: inherent impl {}", + self.tcx.map.node_to_string(item.id)); let self_ty = ty::lookup_item_type(self.tcx, def_id).ty; match self_ty.sty { ty::TyEnum(def_id, _) | @@ -208,7 +209,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { } ast::ItemImpl(_, _, _, Some(_), _, _) => { // "Trait" impl - debug!("coherence2::orphan check: trait impl {}", item.repr()); + debug!("coherence2::orphan check: trait impl {}", + self.tcx.map.node_to_string(item.id)); let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap(); let trait_def_id = trait_ref.def_id; match traits::orphan_check(self.tcx, def_id) { @@ -329,7 +331,8 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { } ast::ItemDefaultImpl(..) => { // "Trait" impl - debug!("coherence2::orphan check: default trait impl {}", item.repr()); + debug!("coherence2::orphan check: default trait impl {}", + self.tcx.map.node_to_string(item.id)); let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap(); if trait_ref.def_id.krate != ast::LOCAL_CRATE { span_err!(self.tcx.sess, item.span, E0318, diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index 3085598e4a3ae..91ec676c09521 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -518,7 +518,7 @@ impl<'a, 'tcx> TermsContext<'a, 'tcx> { impl<'a, 'tcx, 'v> Visitor<'v> for TermsContext<'a, 'tcx> { fn visit_item(&mut self, item: &ast::Item) { - debug!("add_inferreds for item {}", item.repr()); + debug!("add_inferreds for item {}", self.tcx.map.node_to_string(item.id)); match item.node { ast::ItemEnum(_, ref generics) | @@ -600,8 +600,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ConstraintContext<'a, 'tcx> { let did = ast_util::local_def(item.id); let tcx = self.terms_cx.tcx; - debug!("visit_item item={}", - item.repr()); + debug!("visit_item item={}", tcx.map.node_to_string(item.id)); match item.node { ast::ItemEnum(ref enum_definition, _) => { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 5b03b3bf0385c..e844b206cc0a0 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -63,8 +63,10 @@ use owned_slice::OwnedSlice; use parse::token::{InternedString, str_to_ident}; use parse::token; use parse::lexer; +use print::pprust; use ptr::P; +use std::cell::Cell; use std::fmt; use std::rc::Rc; use serialize::{Encodable, Decodable, Encoder, Decoder}; @@ -200,14 +202,19 @@ impl Decodable for Ident { /// Function name (not all functions have names) pub type FnIdent = Option; -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, - Debug, Copy)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] pub struct Lifetime { pub id: NodeId, pub span: Span, pub name: Name } +impl fmt::Debug for Lifetime { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "lifetime({}: {})", self.id, pprust::lifetime_to_string(self)) + } +} + /// A lifetime definition, eg `'a: 'b+'c+'d` #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct LifetimeDef { @@ -218,7 +225,7 @@ pub struct LifetimeDef { /// A "Path" is essentially Rust's notion of a name; for instance: /// std::cmp::PartialEq . It's represented as a sequence of identifiers, /// along with a bunch of supporting information. -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub struct Path { pub span: Span, /// A `::foo` path, is relative to the crate root rather than current @@ -228,6 +235,18 @@ pub struct Path { pub segments: Vec, } +impl fmt::Debug for Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "path({})", pprust::path_to_string(self)) + } +} + +impl fmt::Display for Path { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", pprust::path_to_string(self)) + } +} + /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] @@ -358,12 +377,25 @@ pub type CrateNum = u32; pub type NodeId = u32; #[derive(Clone, Eq, Ord, PartialOrd, PartialEq, RustcEncodable, - RustcDecodable, Hash, Debug, Copy)] + RustcDecodable, Hash, Copy)] pub struct DefId { pub krate: CrateNum, pub node: NodeId, } +fn default_def_id_debug(_: DefId, _: &mut fmt::Formatter) -> fmt::Result { Ok(()) } + +thread_local!(pub static DEF_ID_DEBUG: Cell fmt::Result> = + Cell::new(default_def_id_debug)); + +impl fmt::Debug for DefId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "DefId {{ krate: {}, node: {} }}", + self.krate, self.node)); + DEF_ID_DEBUG.with(|def_id_debug| def_id_debug.get()(*self, f)) + } +} + impl DefId { /// Read the node id, asserting that this def-id is krate-local. pub fn local_id(&self) -> NodeId { @@ -539,13 +571,19 @@ pub struct Block { pub span: Span, } -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub struct Pat { pub id: NodeId, pub node: Pat_, pub span: Span, } +impl fmt::Debug for Pat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "pat({}: {})", self.id, pprust::pat_to_string(self)) + } +} + /// A single field in a struct pattern /// /// Patterns like the fields of Foo `{ x, ref y, ref mut z }` @@ -682,7 +720,16 @@ pub enum UnOp { /// A statement pub type Stmt = Spanned; -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +impl fmt::Debug for Stmt { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "stmt({}: {})", + ast_util::stmt_id(self), + pprust::stmt_to_string(self)) + } +} + + +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub enum Stmt_ { /// Could be an item or a local (let) binding: StmtDecl(P, NodeId), @@ -695,7 +742,6 @@ pub enum Stmt_ { StmtMac(P, MacStmtStyle), } - #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum MacStmtStyle { /// The macro statement had a trailing semicolon, e.g. `foo! { ... };` @@ -772,13 +818,19 @@ pub enum UnsafeSource { } /// An expression -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash,)] pub struct Expr { pub id: NodeId, pub node: Expr_, pub span: Span, } +impl fmt::Debug for Expr { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "expr({}: {})", self.id, pprust::expr_to_string(self)) + } +} + #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub enum Expr_ { /// First expr is the place; second expr is the value. @@ -1357,13 +1409,19 @@ pub struct TypeBinding { // NB PartialEq method appears below. -#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub struct Ty { pub id: NodeId, pub node: Ty_, pub span: Span, } +impl fmt::Debug for Ty { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "type({})", pprust::ty_to_string(self)) + } +} + /// Not represented directly in the AST, referred to by name through a ty_path. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum PrimTy { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index ea27ed6b3605c..5ddcfaef9ea28 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -19,7 +19,7 @@ pub use self::ExpnFormat::*; -use std::cell::RefCell; +use std::cell::{Cell, RefCell}; use std::ops::{Add, Sub}; use std::path::Path; use std::rc::Rc; @@ -115,7 +115,7 @@ impl Sub for CharPos { /// are *absolute* positions from the beginning of the codemap, not positions /// relative to FileMaps. Methods on the CodeMap can be used to relate spans back /// to the original source. -#[derive(Clone, Copy, Debug, Hash)] +#[derive(Clone, Copy, Hash)] pub struct Span { pub lo: BytePos, pub hi: BytePos, @@ -164,6 +164,20 @@ impl Decodable for Span { } } +fn default_span_debug(span: Span, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Span {{ lo: {:?}, hi: {:?}, expn_id: {:?} }}", + span.lo, span.hi, span.expn_id) +} + +thread_local!(pub static SPAN_DEBUG: Cell fmt::Result> = + Cell::new(default_span_debug)); + +impl fmt::Debug for Span { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + SPAN_DEBUG.with(|span_debug| span_debug.get()(*self, f)) + } +} + pub fn spanned(lo: BytePos, hi: BytePos, t: T) -> Spanned { respan(mk_sp(lo, hi), t) } From dfbc9608ce5c9655a36b63f6cc9694f5e4ad9890 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Thu, 18 Jun 2015 08:51:23 +0300 Subject: [PATCH 45/48] rustc: replace Repr/UserString impls with Debug/Display ones. --- src/librustc/metadata/tydecode.rs | 2 +- src/librustc/middle/implicator.rs | 34 +- src/librustc/middle/infer/error_reporting.rs | 2 +- .../middle/infer/higher_ranked/mod.rs | 4 +- src/librustc/middle/infer/mod.rs | 148 +- .../middle/infer/region_inference/mod.rs | 68 +- src/librustc/middle/intrinsicck.rs | 18 +- src/librustc/middle/mem_categorization.rs | 97 +- src/librustc/middle/subst.rs | 16 +- src/librustc/middle/traits/error_reporting.rs | 8 +- src/librustc/middle/traits/fulfill.rs | 13 +- src/librustc/middle/traits/mod.rs | 8 +- src/librustc/middle/traits/object_safety.rs | 14 +- src/librustc/middle/traits/project.rs | 49 +- src/librustc/middle/traits/select.rs | 37 +- src/librustc/middle/traits/util.rs | 138 +- src/librustc/middle/ty.rs | 506 +++--- src/librustc/middle/ty_fold.rs | 14 +- src/librustc/util/ppaux.rs | 1458 ++++++----------- src/librustc_borrowck/borrowck/mod.rs | 64 +- src/librustc_driver/test.rs | 11 +- src/librustc_trans/trans/_match.rs | 9 +- src/librustc_trans/trans/common.rs | 12 +- src/librustc_trans/trans/glue.rs | 13 - src/librustc_trans/trans/monomorphize.rs | 4 +- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/assoc.rs | 2 +- src/librustc_typeck/check/callee.rs | 14 +- src/librustc_typeck/check/compare_method.rs | 4 +- src/librustc_typeck/check/method/confirm.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 62 +- src/librustc_typeck/check/mod.rs | 26 +- src/librustc_typeck/check/wf.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- src/librustc_typeck/lib.rs | 6 +- src/librustdoc/clean/mod.rs | 2 +- .../compile-fail/object-lifetime-default.rs | 2 +- 37 files changed, 977 insertions(+), 1896 deletions(-) diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index ad650fcfb1144..693ccc13f1e46 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -898,7 +898,7 @@ fn parse_builtin_bounds(st: &mut PState, mut _conv: F) -> ty::BuiltinBounds w fn parse_builtin_bounds_(st: &mut PState, _conv: &mut F) -> ty::BuiltinBounds where F: FnMut(DefIdSource, ast::DefId) -> ast::DefId, { - let mut builtin_bounds = ty::empty_builtin_bounds(); + let mut builtin_bounds = ty::BuiltinBounds::empty(); loop { match next(st) { diff --git a/src/librustc/middle/implicator.rs b/src/librustc/middle/implicator.rs index 599ecc6e7a97a..abdaa9f38c0e1 100644 --- a/src/librustc/middle/implicator.rs +++ b/src/librustc/middle/implicator.rs @@ -25,6 +25,7 @@ use util::ppaux::Repr; // Helper functions related to manipulating region types. +#[derive(Debug)] pub enum Implication<'tcx> { RegionSubRegion(Option>, ty::Region, ty::Region), RegionSubGeneric(Option>, ty::Region, GenericKind<'tcx>), @@ -400,7 +401,7 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { } fn fully_normalize(&self, value: &T) -> Result - where T : TypeFoldable<'tcx> + ty::HasProjectionTypes + Clone + Repr + where T : TypeFoldable<'tcx> + ty::HasProjectionTypes { let value = traits::fully_normalize(self.infcx, @@ -454,34 +455,3 @@ pub fn object_region_bounds<'tcx>( let predicates = ty::predicates(tcx, open_ty, ¶m_bounds); ty::required_region_bounds(tcx, open_ty, predicates) } - -impl<'tcx> Repr for Implication<'tcx> { - fn repr(&self) -> String { - match *self { - Implication::RegionSubRegion(_, ref r_a, ref r_b) => { - format!("RegionSubRegion({}, {})", - r_a.repr(), - r_b.repr()) - } - - Implication::RegionSubGeneric(_, ref r, ref p) => { - format!("RegionSubGeneric({}, {})", - r.repr(), - p.repr()) - } - - Implication::RegionSubClosure(_, ref a, ref b, ref c) => { - format!("RegionSubClosure({}, {}, {})", - a.repr(), - b.repr(), - c.repr()) - } - - Implication::Predicate(ref def_id, ref p) => { - format!("Predicate({}, {})", - def_id.repr(), - p.repr()) - } - } - } -} diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index fa324c57bcd06..9f3dd0a4b736b 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -480,7 +480,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { "{}: {} ({})", trace.origin, expected_found_str, - ty::type_err_to_str(self.tcx, terr)); + terr); match trace.origin { infer::MatchExpressionArm(_, arm_span) => diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index d6001270d1c7a..37f3a12b05f61 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -518,7 +518,7 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, binder: &ty::Binder, snapshot: &CombinedSnapshot) -> (T, SkolemizationMap) - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { /*! * Replace all regions bound by `binder` with skolemized regions and @@ -616,7 +616,7 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, snapshot: &CombinedSnapshot, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok()); diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 02a73cfb77052..71febd981e045 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -160,7 +160,7 @@ pub enum ValuePairs<'tcx> { /// encounter an error or subtyping constraint. /// /// See `error_reporting.rs` for more details. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct TypeTrace<'tcx> { origin: TypeOrigin, values: ValuePairs<'tcx>, @@ -708,7 +708,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { value: &ty::Binder, snapshot: &CombinedSnapshot) -> (T, SkolemizationMap) - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { /*! See `higher_ranked::skolemize_late_bound_regions` */ @@ -733,7 +733,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { snapshot: &CombinedSnapshot, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { /*! See `higher_ranked::plug_leaks` */ @@ -979,7 +979,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { Some(t) if ty::type_is_error(t) => (), _ => { let error_str = err.map_or("".to_string(), |t_err| { - format!(" ({})", ty::type_err_to_str(self.tcx, t_err)) + format!(" ({})", t_err) }); self.tcx.sess.span_err(sp, &format!("{}{}", @@ -1033,7 +1033,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { lbrct: LateBoundRegionConversionTime, value: &ty::Binder) -> (T, FnvHashMap) - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { ty_fold::replace_late_bound_regions( self.tcx, @@ -1099,9 +1099,9 @@ impl<'tcx> TypeTrace<'tcx> { } } -impl<'tcx> Repr for TypeTrace<'tcx> { - fn repr(&self) -> String { - format!("TypeTrace({})", self.origin.repr()) +impl<'tcx> fmt::Debug for TypeTrace<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "TypeTrace({:?})", self.origin) } } @@ -1123,44 +1123,6 @@ impl TypeOrigin { } } -impl<'tcx> Repr for TypeOrigin { - fn repr(&self) -> String { - match *self { - MethodCompatCheck(a) => { - format!("MethodCompatCheck({})", a.repr()) - } - ExprAssignable(a) => { - format!("ExprAssignable({})", a.repr()) - } - Misc(a) => format!("Misc({})", a.repr()), - RelateTraitRefs(a) => { - format!("RelateTraitRefs({})", a.repr()) - } - RelateSelfType(a) => { - format!("RelateSelfType({})", a.repr()) - } - RelateOutputImplTypes(a) => { - format!("RelateOutputImplTypes({})", a.repr()) - } - MatchExpressionArm(a, b) => { - format!("MatchExpressionArm({}, {})", a.repr(), b.repr()) - } - IfExpression(a) => { - format!("IfExpression({})", a.repr()) - } - IfExpressionWithNoElse(a) => { - format!("IfExpressionWithNoElse({})", a.repr()) - } - RangeExpression(a) => { - format!("RangeExpression({})", a.repr()) - } - EquatePredicate(a) => { - format!("EquatePredicate({})", a.repr()) - } - } - } -} - impl<'tcx> SubregionOrigin<'tcx> { pub fn span(&self) -> Span { match *self { @@ -1190,70 +1152,6 @@ impl<'tcx> SubregionOrigin<'tcx> { } } -impl<'tcx> Repr for SubregionOrigin<'tcx> { - fn repr(&self) -> String { - match *self { - Subtype(ref a) => { - format!("Subtype({})", a.repr()) - } - InfStackClosure(a) => { - format!("InfStackClosure({})", a.repr()) - } - InvokeClosure(a) => { - format!("InvokeClosure({})", a.repr()) - } - DerefPointer(a) => { - format!("DerefPointer({})", a.repr()) - } - FreeVariable(a, b) => { - format!("FreeVariable({}, {})", a.repr(), b) - } - IndexSlice(a) => { - format!("IndexSlice({})", a.repr()) - } - RelateObjectBound(a) => { - format!("RelateObjectBound({})", a.repr()) - } - RelateParamBound(a, b) => { - format!("RelateParamBound({},{})", - a.repr(), - b.repr()) - } - RelateRegionParamBound(a) => { - format!("RelateRegionParamBound({})", - a.repr()) - } - RelateDefaultParamBound(a, b) => { - format!("RelateDefaultParamBound({},{})", - a.repr(), - b.repr()) - } - Reborrow(a) => format!("Reborrow({})", a.repr()), - ReborrowUpvar(a, b) => { - format!("ReborrowUpvar({},{:?})", a.repr(), b) - } - ReferenceOutlivesReferent(_, a) => { - format!("ReferenceOutlivesReferent({})", a.repr()) - } - ExprTypeIsNotInScope(a, b) => { - format!("ExprTypeIsNotInScope({}, {})", - a.repr(), - b.repr()) - } - BindingTypeIsNotValidAtDecl(a) => { - format!("BindingTypeIsNotValidAtDecl({})", a.repr()) - } - CallRcvr(a) => format!("CallRcvr({})", a.repr()), - CallArg(a) => format!("CallArg({})", a.repr()), - CallReturn(a) => format!("CallReturn({})", a.repr()), - Operand(a) => format!("Operand({})", a.repr()), - AddrOf(a) => format!("AddrOf({})", a.repr()), - AutoBorrow(a) => format!("AutoBorrow({})", a.repr()), - SafeDestructor(a) => format!("SafeDestructor({})", a.repr()), - } - } -} - impl RegionVariableOrigin { pub fn span(&self) -> Span { match *self { @@ -1269,33 +1167,3 @@ impl RegionVariableOrigin { } } } - -impl<'tcx> Repr for RegionVariableOrigin { - fn repr(&self) -> String { - match *self { - MiscVariable(a) => { - format!("MiscVariable({})", a.repr()) - } - PatternRegion(a) => { - format!("PatternRegion({})", a.repr()) - } - AddrOfRegion(a) => { - format!("AddrOfRegion({})", a.repr()) - } - Autoref(a) => format!("Autoref({})", a.repr()), - Coercion(a) => format!("Coercion({})", a.repr()), - EarlyBoundRegion(a, b) => { - format!("EarlyBoundRegion({},{})", a.repr(), b.repr()) - } - LateBoundRegion(a, b, c) => { - format!("LateBoundRegion({},{},{:?})", a.repr(), b.repr(), c) - } - BoundRegionInCoherence(a) => { - format!("bound_regionInCoherence({})", a.repr()) - } - UpvarRegion(a, b) => { - format!("UpvarRegion({}, {})", a.repr(), b.repr()) - } - } - } -} diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 066083d27c73d..024889d08290b 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -30,10 +30,11 @@ use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh}; use middle::ty_relate::RelateResult; use util::common::indenter; use util::nodemap::{FnvHashMap, FnvHashSet}; -use util::ppaux::{Repr, UserString}; +use util::ppaux::Repr; use std::cell::{Cell, RefCell}; use std::cmp::Ordering::{self, Less, Greater, Equal}; +use std::fmt; use std::iter::repeat; use std::u32; use syntax::ast; @@ -68,7 +69,7 @@ pub enum Verify<'tcx> { VerifyGenericBound(GenericKind<'tcx>, SubregionOrigin<'tcx>, Region, Vec), } -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, PartialEq, Eq)] pub enum GenericKind<'tcx> { Param(ty::ParamTy), Projection(ty::ProjectionTy<'tcx>), @@ -959,7 +960,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { #[derive(Copy, Clone, PartialEq, Debug)] enum Classification { Expanding, Contracting } -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub enum VarValue { NoValue, Value(Region), ErrorValue } struct VarData { @@ -1589,31 +1590,14 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } -impl Repr for Constraint { - fn repr(&self) -> String { - match *self { - ConstrainVarSubVar(a, b) => { - format!("ConstrainVarSubVar({}, {})", a.repr(), b.repr()) - } - ConstrainRegSubVar(a, b) => { - format!("ConstrainRegSubVar({}, {})", a.repr(), b.repr()) - } - ConstrainVarSubReg(a, b) => { - format!("ConstrainVarSubReg({}, {})", a.repr(), b.repr()) - } - } - } -} - -impl<'tcx> Repr for Verify<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for Verify<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { VerifyRegSubReg(_, ref a, ref b) => { - format!("VerifyRegSubReg({}, {})", a.repr(), b.repr()) + write!(f, "VerifyRegSubReg({:?}, {:?})", a, b) } VerifyGenericBound(_, ref p, ref a, ref bs) => { - format!("VerifyGenericBound({}, {}, {})", - p.repr(), a.repr(), bs.repr()) + write!(f, "VerifyGenericBound({:?}, {:?}, {:?})", p, a, bs) } } } @@ -1634,38 +1618,28 @@ fn lookup(values: &Vec, rid: ty::RegionVid) -> ty::Region { } } -impl Repr for VarValue { - fn repr(&self) -> String { - match *self { - NoValue => format!("NoValue"), - Value(r) => format!("Value({})", r.repr()), - ErrorValue => format!("ErrorValue"), - } - } -} - -impl<'tcx> Repr for RegionAndOrigin<'tcx> { - fn repr(&self) -> String { - format!("RegionAndOrigin({},{})", - self.region.repr(), - self.origin.repr()) +impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RegionAndOrigin({},{})", + self.region.repr(), + self.origin.repr()) } } -impl<'tcx> Repr for GenericKind<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for GenericKind<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - GenericKind::Param(ref p) => p.repr(), - GenericKind::Projection(ref p) => p.repr(), + GenericKind::Param(ref p) => write!(f, "{:?}", p), + GenericKind::Projection(ref p) => write!(f, "{:?}", p), } } } -impl<'tcx> UserString for GenericKind<'tcx> { - fn user_string(&self) -> String { +impl<'tcx> fmt::Display for GenericKind<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - GenericKind::Param(ref p) => p.user_string(), - GenericKind::Projection(ref p) => p.user_string(), + GenericKind::Param(ref p) => write!(f, "{}", p), + GenericKind::Projection(ref p) => write!(f, "{}", p), } } } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index a3ea726f0f2f9..6ff774b4bb01f 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -16,6 +16,8 @@ use middle::ty::{TransmuteRestriction, ctxt, TyBareFn}; use middle::ty::{self, Ty}; use util::ppaux::Repr; +use std::fmt; + use syntax::abi::RustIntrinsic; use syntax::ast::DefId; use syntax::ast; @@ -277,13 +279,13 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> { } } -impl<'tcx> Repr for TransmuteRestriction<'tcx> { - fn repr(&self) -> String { - format!("TransmuteRestriction(id={}, original=({},{}), substituted=({},{}))", - self.id, - self.original_from.repr(), - self.original_to.repr(), - self.substituted_from.repr(), - self.substituted_to.repr()) +impl<'tcx> fmt::Debug for TransmuteRestriction<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "TransmuteRestriction(id={}, original=({:?},{:?}), substituted=({:?},{:?}))", + self.id, + self.original_from, + self.original_to, + self.substituted_from, + self.substituted_to) } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 3dbb3dfae2f00..935c077b6338f 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -84,12 +84,12 @@ use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::codemap::Span; use syntax::print::pprust; -use syntax::parse::token; use std::cell::RefCell; +use std::fmt; use std::rc::Rc; -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq)] pub enum categorization<'tcx> { cat_rvalue(ty::Region), // temporary val, argument is its scope cat_static_item, @@ -103,14 +103,14 @@ pub enum categorization<'tcx> { } // Represents any kind of upvar -#[derive(Clone, Copy, PartialEq, Debug)] +#[derive(Clone, Copy, PartialEq)] pub struct Upvar { pub id: ty::UpvarId, pub kind: ty::ClosureKind } // different kinds of pointers: -#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum PointerKind { /// `Box` Unique, @@ -127,7 +127,7 @@ pub enum PointerKind { // We use the term "interior" to mean "something reachable from the // base without a pointer dereference", e.g. a field -#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum InteriorKind { InteriorField(FieldName), InteriorElement(InteriorOffsetKind, ElementKind), @@ -184,7 +184,7 @@ pub enum Note { // dereference, but its type is the type *before* the dereference // (`@T`). So use `cmt.ty` to find the type of the value in a consistent // fashion. For more details, see the method `cat_pattern` -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq)] pub struct cmt_<'tcx> { pub id: ast::NodeId, // id of expr/pat producing this value pub span: Span, // span of same expr/pat @@ -1569,33 +1569,36 @@ impl<'tcx> cmt_<'tcx> { } } -impl<'tcx> Repr for cmt_<'tcx> { - fn repr(&self) -> String { - format!("{{{} id:{} m:{:?} ty:{}}}", - self.cat.repr(), - self.id, - self.mutbl, - self.ty.repr()) +impl<'tcx> fmt::Debug for cmt_<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{{{:?} id:{} m:{:?} ty:{:?}}}", + self.cat, + self.id, + self.mutbl, + self.ty) } } -impl<'tcx> Repr for categorization<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for categorization<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - cat_static_item | - cat_rvalue(..) | - cat_local(..) | - cat_upvar(..) => { - format!("{:?}", *self) + cat_static_item => write!(f, "static"), + cat_rvalue(r) => write!(f, "rvalue({:?})", r), + cat_local(id) => { + let name = ty::tls::with(|tcx| ty::local_var_name_str(tcx, id)); + write!(f, "local({})", name) + } + cat_upvar(upvar) => { + write!(f, "upvar({:?})", upvar) } cat_deref(ref cmt, derefs, ptr) => { - format!("{}-{}{}->", cmt.cat.repr(), ptr.repr(), derefs) + write!(f, "{:?}-{:?}{}->", cmt.cat, ptr, derefs) } cat_interior(ref cmt, interior) => { - format!("{}.{}", cmt.cat.repr(), interior.repr()) + write!(f, "{:?}.{:?}", cmt.cat, interior) } cat_downcast(ref cmt, _) => { - format!("{}->(enum)", cmt.cat.repr()) + write!(f, "{:?}->(enum)", cmt.cat) } } } @@ -1614,39 +1617,33 @@ pub fn ptr_sigil(ptr: PointerKind) -> &'static str { } } -impl Repr for PointerKind { - fn repr(&self) -> String { +impl fmt::Debug for PointerKind { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Unique => { - format!("Box") - } + Unique => write!(f, "Box"), BorrowedPtr(ty::ImmBorrow, ref r) | Implicit(ty::ImmBorrow, ref r) => { - format!("&{}", r.repr()) + write!(f, "&{:?}", r) } BorrowedPtr(ty::MutBorrow, ref r) | Implicit(ty::MutBorrow, ref r) => { - format!("&{} mut", r.repr()) + write!(f, "&{:?} mut", r) } BorrowedPtr(ty::UniqueImmBorrow, ref r) | Implicit(ty::UniqueImmBorrow, ref r) => { - format!("&{} uniq", r.repr()) - } - UnsafePtr(_) => { - format!("*") + write!(f, "&{:?} uniq", r) } + UnsafePtr(_) => write!(f, "*") } } } -impl Repr for InteriorKind { - fn repr(&self) -> String { +impl fmt::Debug for InteriorKind { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - InteriorField(NamedField(fld)) => { - token::get_name(fld).to_string() - } - InteriorField(PositionalField(i)) => format!("#{}", i), - InteriorElement(..) => "[]".to_string(), + InteriorField(NamedField(fld)) => write!(f, "{}", fld), + InteriorField(PositionalField(i)) => write!(f, "#{}", i), + InteriorElement(..) => write!(f, "[]"), } } } @@ -1663,25 +1660,19 @@ fn element_kind(t: Ty) -> ElementKind { } } -impl Repr for ty::ClosureKind { - fn repr(&self) -> String { - format!("Upvar({:?})", self) - } -} - -impl Repr for Upvar { - fn repr(&self) -> String { - format!("Upvar({})", self.kind.repr()) +impl fmt::Debug for Upvar { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}/{:?}", self.id, self.kind) } } -impl UserString for Upvar { - fn user_string(&self) -> String { +impl fmt::Display for Upvar { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let kind = match self.kind { ty::FnClosureKind => "Fn", ty::FnMutClosureKind => "FnMut", ty::FnOnceClosureKind => "FnOnce", }; - format!("captured outer variable in an `{}` closure", kind) + write!(f, "captured outer variable in an `{}` closure", kind) } } diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 8f6e85a17b128..957bd76bb9426 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -29,7 +29,7 @@ use syntax::codemap::{Span, DUMMY_SP}; /// identify each in-scope parameter by an *index* and a *parameter /// space* (which indices where the parameter is defined; see /// `ParamSpace`). -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] pub struct Substs<'tcx> { pub types: VecPerParamSpace>, pub regions: RegionSubsts, @@ -38,7 +38,7 @@ pub struct Substs<'tcx> { /// Represents the values to use when substituting lifetime parameters. /// If the value is `ErasedRegions`, then this subst is occurring during /// trans, and all region parameters will be replaced with `ty::ReStatic`. -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] pub enum RegionSubsts { ErasedRegions, NonerasedRegions(VecPerParamSpace) @@ -240,13 +240,11 @@ pub struct SeparateVecsPerParamSpace { } impl fmt::Debug for VecPerParamSpace { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - try!(write!(fmt, "VecPerParamSpace {{")); - for space in &ParamSpace::all() { - try!(write!(fmt, "{:?}: {:?}, ", *space, self.get_slice(*space))); - } - try!(write!(fmt, "}}")); - Ok(()) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "[{:?};{:?};{:?}]", + self.get_slice(TypeSpace), + self.get_slice(SelfSpace), + self.get_slice(FnSpace)) } } diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index 72f162638929f..7d4bbb5d7f03f 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -69,7 +69,7 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0271, "type mismatch resolving `{}`: {}", predicate.user_string(), - ty::type_err_to_str(infcx.tcx, &error.err)); + error.err); note_obligation_cause(infcx, obligation); } } @@ -217,7 +217,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0278, "the requirement `{}` is not satisfied (`{}`)", predicate.user_string(), - ty::type_err_to_str(infcx.tcx, &err)); + err); } ty::Predicate::RegionOutlives(ref predicate) => { @@ -227,7 +227,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0279, "the requirement `{}` is not satisfied (`{}`)", predicate.user_string(), - ty::type_err_to_str(infcx.tcx, &err)); + err); } ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => { @@ -252,7 +252,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, expected_trait_ref.self_ty().user_string(), expected_trait_ref.user_string(), actual_trait_ref.user_string(), - ty::type_err_to_str(infcx.tcx, e)); + e); note_obligation_cause(infcx, obligation); } } diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 418c4522cd9b3..0828a67c6c678 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -10,8 +10,9 @@ use middle::infer::InferCtxt; use middle::ty::{self, RegionEscape, Ty}; + use std::collections::HashSet; -use std::default::Default; +use std::fmt; use syntax::ast; use util::common::ErrorReported; use util::ppaux::Repr; @@ -461,11 +462,11 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, } } -impl<'tcx> Repr for RegionObligation<'tcx> { - fn repr(&self) -> String { - format!("RegionObligation(sub_region={}, sup_type={})", - self.sub_region.repr(), - self.sup_type.repr()) +impl<'tcx> fmt::Debug for RegionObligation<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "RegionObligation(sub_region={:?}, sup_type={:?})", + self.sub_region, + self.sup_type) } } diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index 551bafc57161a..35855767e6098 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -219,7 +219,7 @@ pub type SelectionResult<'tcx, T> = Result, SelectionError<'tcx>>; /// ### The type parameter `N` /// /// See explanation on `VtableImplData`. -#[derive(Debug,Clone)] +#[derive(Clone)] pub enum Vtable<'tcx, N> { /// Vtable identifying a particular impl. VtableImpl(VtableImplData<'tcx, N>), @@ -277,13 +277,13 @@ pub struct VtableClosureData<'tcx, N> { pub nested: Vec } -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct VtableDefaultImplData { pub trait_def_id: ast::DefId, pub nested: Vec } -#[derive(Debug,Clone)] +#[derive(Clone)] pub struct VtableBuiltinData { pub nested: Vec } @@ -433,7 +433,7 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, cause: ObligationCause<'tcx>, value: &T) -> Result>> - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr + where T : TypeFoldable<'tcx> + HasProjectionTypes { debug!("normalize_param_env(value={})", value.repr()); diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/middle/traits/object_safety.rs index 9be973c701893..daa03c5160c01 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/middle/traits/object_safety.rs @@ -27,6 +27,7 @@ use std::rc::Rc; use syntax::ast; use util::ppaux::Repr; +#[derive(Debug)] pub enum ObjectSafetyViolation<'tcx> { /// Self : Sized declared on the trait SizedSelf, @@ -352,19 +353,6 @@ fn contains_illegal_self_type_reference<'tcx>(tcx: &ty::ctxt<'tcx>, error } -impl<'tcx> Repr for ObjectSafetyViolation<'tcx> { - fn repr(&self) -> String { - match *self { - ObjectSafetyViolation::SizedSelf => - format!("SizedSelf"), - ObjectSafetyViolation::SupertraitSelf => - format!("SupertraitSelf"), - ObjectSafetyViolation::Method(ref m, code) => - format!("Method({},{:?})", m.repr(), code), - } - } -} - fn is_self<'tcx>(ty: Ty<'tcx>) -> bool { match ty.sty { ty::TyParam(ref data) => data.space == subst::SelfSpace, diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index 1b5f79452c0f2..967edabc0b9c1 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -30,6 +30,8 @@ use syntax::parse::token; use util::common::FN_OUTPUT_NAME; use util::ppaux::Repr; +use std::fmt; + pub type PolyProjectionObligation<'tcx> = Obligation<'tcx, ty::PolyProjectionPredicate<'tcx>>; @@ -40,6 +42,7 @@ pub type ProjectionTyObligation<'tcx> = Obligation<'tcx, ty::ProjectionTy<'tcx>>; /// When attempting to resolve `::Name` ... +#[derive(Debug)] pub enum ProjectionTyError<'tcx> { /// ...we found multiple sources of information and couldn't resolve the ambiguity. TooManyCandidates, @@ -53,7 +56,7 @@ pub struct MismatchedProjectionTypes<'tcx> { pub err: ty::type_err<'tcx> } -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Debug)] enum ProjectionTyCandidate<'tcx> { ParamEnv(ty::PolyProjectionPredicate<'tcx>), Impl(VtableImplData<'tcx, PredicateObligation<'tcx>>), @@ -193,7 +196,7 @@ pub fn normalize<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tcx>, cause: ObligationCause<'tcx>, value: &T) -> Normalized<'tcx, T> - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr + where T : TypeFoldable<'tcx> + HasProjectionTypes { normalize_with_depth(selcx, cause, 0, value) } @@ -204,7 +207,7 @@ pub fn normalize_with_depth<'a,'b,'tcx,T>(selcx: &'a mut SelectionContext<'b,'tc depth: usize, value: &T) -> Normalized<'tcx, T> - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr + where T : TypeFoldable<'tcx> + HasProjectionTypes { let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth); let result = normalizer.fold(value); @@ -236,7 +239,7 @@ impl<'a,'b,'tcx> AssociatedTypeNormalizer<'a,'b,'tcx> { } } - fn fold + HasProjectionTypes + Clone>(&mut self, value: &T) -> T { + fn fold + HasProjectionTypes>(&mut self, value: &T) -> T { let value = self.selcx.infcx().resolve_type_vars_if_possible(value); if !value.has_projection_types() { @@ -864,7 +867,7 @@ fn confirm_param_env_candidate<'cx,'tcx>( &format!("Failed to unify `{}` and `{}` in projection: {}", obligation.repr(), projection.repr(), - ty::type_err_to_str(selcx.tcx(), &e))); + e)); } } @@ -915,32 +918,6 @@ fn confirm_impl_candidate<'cx,'tcx>( trait_ref.repr())); } -impl<'tcx> Repr for ProjectionTyError<'tcx> { - fn repr(&self) -> String { - match *self { - ProjectionTyError::TooManyCandidates => - format!("NoCandidate"), - ProjectionTyError::TraitSelectionError(ref e) => - format!("TraitSelectionError({})", e.repr()), - } - } -} - -impl<'tcx> Repr for ProjectionTyCandidate<'tcx> { - fn repr(&self) -> String { - match *self { - ProjectionTyCandidate::ParamEnv(ref data) => - format!("ParamEnv({})", data.repr()), - ProjectionTyCandidate::Impl(ref data) => - format!("Impl({})", data.repr()), - ProjectionTyCandidate::Closure(ref data) => - format!("Closure({})", data.repr()), - ProjectionTyCandidate::FnPointer(a) => - format!("FnPointer(({}))", a.repr()), - } - } -} - impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> { fn fold_with>(&self, folder: &mut F) -> Normalized<'tcx, T> { Normalized { @@ -950,10 +927,10 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> { } } -impl<'tcx, T:Repr> Repr for Normalized<'tcx, T> { - fn repr(&self) -> String { - format!("Normalized({},{})", - self.value.repr(), - self.obligations.repr()) +impl<'tcx, T:fmt::Debug> fmt::Debug for Normalized<'tcx, T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Normalized({:?},{:?})", + self.value, + self.obligations) } } diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 5519ad97d2225..96d48faf9e092 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -44,7 +44,9 @@ use middle::infer::{InferCtxt, TypeFreshener}; use middle::ty_fold::TypeFoldable; use middle::ty_match; use middle::ty_relate::TypeRelation; + use std::cell::RefCell; +use std::fmt; use std::rc::Rc; use syntax::{abi, ast}; use util::common::ErrorReported; @@ -2666,14 +2668,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { origin, impl_trait_ref.value.clone(), skol_obligation_trait_ref) { - debug!("match_impl: failed sub_trait_refs due to `{}`", - ty::type_err_to_str(self.tcx(), &e)); + debug!("match_impl: failed sub_trait_refs due to `{}`", e); return Err(()); } if let Err(e) = self.infcx.leak_check(&skol_map, snapshot) { - debug!("match_impl: failed leak check due to `{}`", - ty::type_err_to_str(self.tcx(), &e)); + debug!("match_impl: failed leak check due to `{}`", e); return Err(()); } @@ -2962,28 +2962,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } } -impl<'tcx> Repr for SelectionCandidate<'tcx> { - fn repr(&self) -> String { - match *self { - PhantomFnCandidate => format!("PhantomFnCandidate"), - ErrorCandidate => format!("ErrorCandidate"), - BuiltinCandidate(b) => format!("BuiltinCandidate({:?})", b), - BuiltinObjectCandidate => format!("BuiltinObjectCandidate"), - BuiltinUnsizeCandidate => format!("BuiltinUnsizeCandidate"), - ParamCandidate(ref a) => format!("ParamCandidate({})", a.repr()), - ImplCandidate(a) => format!("ImplCandidate({})", a.repr()), - DefaultImplCandidate(t) => format!("DefaultImplCandidate({:?})", t), - DefaultImplObjectCandidate(t) => format!("DefaultImplObjectCandidate({:?})", t), - ProjectionCandidate => format!("ProjectionCandidate"), - FnPointerCandidate => format!("FnPointerCandidate"), - ObjectCandidate => format!("ObjectCandidate"), - ClosureCandidate(c, ref s) => { - format!("ClosureCandidate({:?},{})", c, s.repr()) - } - } - } -} - impl<'tcx> SelectionCache<'tcx> { pub fn new() -> SelectionCache<'tcx> { SelectionCache { @@ -3031,10 +3009,9 @@ impl<'o,'tcx> Iterator for TraitObligationStackList<'o,'tcx>{ } } -impl<'o,'tcx> Repr for TraitObligationStack<'o,'tcx> { - fn repr(&self) -> String { - format!("TraitObligationStack({})", - self.obligation.repr()) +impl<'o,'tcx> fmt::Debug for TraitObligationStack<'o,'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "TraitObligationStack({:?})", self.obligation) } } diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index 475e2f69a4c1d..2c6feb66fa8ca 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -302,24 +302,12 @@ pub fn fresh_type_vars_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.fresh_substs_for_generics(span, &impl_generics) } -impl<'tcx, N> fmt::Debug for VtableImplData<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "VtableImpl({:?})", self.impl_def_id) - } -} - impl<'tcx, N> fmt::Debug for super::VtableClosureData<'tcx, N> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "VtableClosure({:?})", self.closure_def_id) } } -impl<'tcx> fmt::Debug for super::VtableObjectData<'tcx> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "VtableObject(...)") - } -} - /// See `super::obligations_for_generics` pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, recursion_depth: usize, @@ -485,118 +473,84 @@ pub fn closure_trait_ref_and_return_type<'tcx>( ty::Binder((trait_ref, sig.0.output.unwrap_or(ty::mk_nil(tcx)))) } -impl<'tcx,O:Repr> Repr for super::Obligation<'tcx, O> { - fn repr(&self) -> String { - format!("Obligation(predicate={},depth={})", - self.predicate.repr(), - self.recursion_depth) +impl<'tcx,O:fmt::Debug> fmt::Debug for super::Obligation<'tcx, O> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Obligation(predicate={:?},depth={})", + self.predicate, + self.recursion_depth) } } -impl<'tcx, N:Repr> Repr for super::Vtable<'tcx, N> { - fn repr(&self) -> String { +impl<'tcx, N:fmt::Debug> fmt::Debug for super::Vtable<'tcx, N> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { super::VtableImpl(ref v) => - v.repr(), + write!(f, "{:?}", v), super::VtableDefaultImpl(ref t) => - t.repr(), + write!(f, "{:?}", t), super::VtableClosure(ref d) => - d.repr(), + write!(f, "{:?}", d), super::VtableFnPointer(ref d) => - format!("VtableFnPointer({})", - d.repr()), + write!(f, "VtableFnPointer({:?})", d), super::VtableObject(ref d) => - format!("VtableObject({})", - d.repr()), + write!(f, "VtableObject({:?})", d), super::VtableParam(ref n) => - format!("VtableParam({})", - n.repr()), + write!(f, "VtableParam({:?})", n), super::VtableBuiltin(ref d) => - d.repr() + write!(f, "{:?}", d) } } } -impl<'tcx, N:Repr> Repr for super::VtableImplData<'tcx, N> { - fn repr(&self) -> String { - format!("VtableImpl(impl_def_id={}, substs={}, nested={})", - self.impl_def_id.repr(), - self.substs.repr(), - self.nested.repr()) - } -} - -impl<'tcx, N:Repr> Repr for super::VtableClosureData<'tcx, N> { - fn repr(&self) -> String { - format!("VtableClosure(closure_def_id={}, substs={}, nested={})", - self.closure_def_id.repr(), - self.substs.repr(), - self.nested.repr()) - } -} - -impl<'tcx, N:Repr> Repr for super::VtableBuiltinData { - fn repr(&self) -> String { - format!("VtableBuiltin(nested={})", - self.nested.repr()) +impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableImplData<'tcx, N> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "VtableImpl(impl_def_id={:?}, substs={:?}, nested={:?})", + self.impl_def_id, + self.substs, + self.nested) } } -impl<'tcx, N:Repr> Repr for super::VtableDefaultImplData { - fn repr(&self) -> String { - format!("VtableDefaultImplData(trait_def_id={}, nested={})", - self.trait_def_id.repr(), - self.nested.repr()) +impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableClosureData<'tcx, N> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "VtableClosure(closure_def_id={:?}, substs={:?}, nested={:?})", + self.closure_def_id, + self.substs, + self.nested) } } -impl<'tcx> Repr for super::VtableObjectData<'tcx> { - fn repr(&self) -> String { - format!("VtableObject(object_ty={})", - self.object_ty.repr()) +impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableBuiltinData { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "VtableBuiltin(nested={:?})", self.nested) } } -impl<'tcx> Repr for super::SelectionError<'tcx> { - fn repr(&self) -> String { - match *self { - super::Unimplemented => - format!("Unimplemented"), - - super::OutputTypeParameterMismatch(ref a, ref b, ref c) => - format!("OutputTypeParameterMismatch({},{},{})", - a.repr(), - b.repr(), - c.repr()), - - super::TraitNotObjectSafe(ref tr) => - format!("TraitNotObjectSafe({})", - tr.repr()) - } +impl<'tcx, N:fmt::Debug> fmt::Debug for super::VtableDefaultImplData { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "VtableDefaultImplData(trait_def_id={:?}, nested={:?})", + self.trait_def_id, + self.nested) } } -impl<'tcx> Repr for super::FulfillmentError<'tcx> { - fn repr(&self) -> String { - format!("FulfillmentError({},{})", - self.obligation.repr(), - self.code.repr()) +impl<'tcx> fmt::Debug for super::VtableObjectData<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "VtableObject(object_ty={:?})", self.object_ty) } } -impl<'tcx> Repr for super::FulfillmentErrorCode<'tcx> { - fn repr(&self) -> String { - match *self { - super::CodeSelectionError(ref o) => o.repr(), - super::CodeProjectionError(ref o) => o.repr(), - super::CodeAmbiguity => format!("Ambiguity") - } +impl<'tcx> fmt::Debug for super::FulfillmentError<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "FulfillmentError({:?},{:?})", + self.obligation, + self.code) } } @@ -610,14 +564,8 @@ impl<'tcx> fmt::Debug for super::FulfillmentErrorCode<'tcx> { } } -impl<'tcx> Repr for super::MismatchedProjectionTypes<'tcx> { - fn repr(&self) -> String { - self.err.repr() - } -} - impl<'tcx> fmt::Debug for super::MismatchedProjectionTypes<'tcx> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "MismatchedProjectionTypes(..)") + write!(f, "MismatchedProjectionTypes({:?})", self.err) } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 293043af53979..1274b3498fd33 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -12,7 +12,6 @@ pub use self::terr_vstore_kind::*; pub use self::type_err::*; -pub use self::BuiltinBound::*; pub use self::InferTy::*; pub use self::InferRegion::*; pub use self::ImplOrTraitItemId::*; @@ -35,6 +34,11 @@ pub use self::IntVarValue::*; pub use self::MethodOrigin::*; pub use self::CopyImplementationError::*; +pub use self::BuiltinBound::Send as BoundSend; +pub use self::BuiltinBound::Sized as BoundSized; +pub use self::BuiltinBound::Copy as BoundCopy; +pub use self::BuiltinBound::Sync as BoundSync; + use ast_map::{self, LinkedPath}; use back::svh::Svh; use session::Session; @@ -78,7 +82,7 @@ use std::mem; use std::ops; use std::rc::Rc; use std::vec::IntoIter; -use collections::enum_set::{EnumSet, CLike}; +use collections::enum_set::{self, EnumSet, CLike}; use std::collections::{HashMap, HashSet}; use syntax::abi; use syntax::ast::{CrateNum, DefId, ItemImpl, ItemTrait, LOCAL_CRATE}; @@ -130,7 +134,7 @@ impl ImplOrTraitItemContainer { } } -#[derive(Clone, Debug)] +#[derive(Clone)] pub enum ImplOrTraitItem<'tcx> { ConstTraitItem(Rc>), MethodTraitItem(Rc>), @@ -293,7 +297,7 @@ pub struct ItemVariances { pub regions: VecPerParamSpace, } -#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable, Debug, Copy)] +#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable, Copy)] pub enum Variance { Covariant, // T <: T iff A <: B -- e.g., function return type Invariant, // T <: T iff B == A -- e.g., type of mutable cell @@ -301,7 +305,7 @@ pub enum Variance { Bivariant, // T <: T -- e.g., unused type parameter } -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone)] pub enum AutoAdjustment<'tcx> { AdjustReifyFnPointer, // go from a fn-item type to a fn-pointer type AdjustUnsafeFnPointer, // go from a safe fn pointer to an unsafe fn pointer @@ -370,7 +374,7 @@ pub enum AutoAdjustment<'tcx> { /// unsize: Some(Box<[i32]>), /// } /// ``` -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone)] pub struct AutoDerefRef<'tcx> { /// Step 1. Apply a number of dereferences, producing an lvalue. pub autoderefs: usize, @@ -400,7 +404,7 @@ pub enum CustomCoerceUnsized { Struct(usize) } -#[derive(Clone, Debug)] +#[derive(Clone)] pub enum MethodOrigin<'tcx> { // fully statically resolved method MethodStatic(ast::DefId), @@ -418,7 +422,7 @@ pub enum MethodOrigin<'tcx> { // details for a method invoked with a receiver whose type is a type parameter // with a bounded trait. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct MethodParam<'tcx> { // the precise trait reference that occurs as a bound -- this may // be a supertrait of what the user actually typed. Note that it @@ -439,7 +443,7 @@ pub struct MethodParam<'tcx> { } // details for a method invoked with a receiver whose type is an object -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct MethodObject<'tcx> { // the (super)trait containing the method to be invoked pub trait_ref: TraitRef<'tcx>, @@ -803,7 +807,7 @@ impl<'tcx> ctxt<'tcx> { self.free_region_maps.borrow()[&id].clone() } - pub fn lift>(&self, value: &T) -> Option { + pub fn lift>(&self, value: &T) -> Option { value.lift_to_tcx(self) } } @@ -825,7 +829,7 @@ impl<'tcx, A: Lift<'tcx>, B: Lift<'tcx>> Lift<'tcx> for (A, B) { } } -impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for Vec { +impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for [T] { type Lifted = Vec; fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option { let mut result = Vec::with_capacity(self.len()); @@ -1115,7 +1119,6 @@ impl<'tcx> ctxt<'tcx> { } } -#[derive(Debug)] pub struct TyS<'tcx> { pub sty: TypeVariants<'tcx>, pub flags: Cell, @@ -1238,7 +1241,7 @@ pub struct BareFnTy<'tcx> { pub sig: PolyFnSig<'tcx>, } -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] pub struct ClosureTy<'tcx> { pub unsafety: ast::Unsafety, pub abi: abi::Abi, @@ -1309,7 +1312,7 @@ impl<'tcx> PolyFnSig<'tcx> { } } -#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct ParamTy { pub space: subst::ParamSpace, pub idx: u32, @@ -1363,7 +1366,7 @@ pub struct DebruijnIndex { } /// Representation of regions: -#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Copy)] pub enum Region { // Region bound in a type or fn declaration which will be // substituted 'early' -- that is, at the same time when type @@ -1411,7 +1414,7 @@ pub struct EarlyBoundRegion { /// Upvars do not get their own node-id. Instead, we use the pair of /// the original var id (that is, the root variable that is referenced /// by the upvar) and the id of the closure expression. -#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct UpvarId { pub var_id: ast::NodeId, pub closure_expr_id: ast::NodeId, @@ -1476,7 +1479,7 @@ pub enum UpvarCapture { ByRef(UpvarBorrow), } -#[derive(PartialEq, Clone, RustcEncodable, RustcDecodable, Debug, Copy)] +#[derive(PartialEq, Clone, RustcEncodable, RustcDecodable, Copy)] pub struct UpvarBorrow { /// The kind of borrow: by-ref upvars have access to shared /// immutable borrows, which are not part of the normal language @@ -1516,7 +1519,7 @@ impl Region { } #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, - RustcEncodable, RustcDecodable, Debug, Copy)] + RustcEncodable, RustcDecodable, Copy)] /// A "free" region `fr` can be interpreted as "some region /// at least as big as the scope `fr.scope`". pub struct FreeRegion { @@ -1525,7 +1528,7 @@ pub struct FreeRegion { } #[derive(Clone, PartialEq, PartialOrd, Eq, Ord, Hash, - RustcEncodable, RustcDecodable, Debug, Copy)] + RustcEncodable, RustcDecodable, Copy, Debug)] pub enum BoundRegion { /// An anonymous region parameter for a given fn (&T) BrAnon(u32), @@ -1636,7 +1639,7 @@ pub enum TypeVariants<'tcx> { TyError, } -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] pub struct TraitTy<'tcx> { pub principal: ty::PolyTraitRef<'tcx>, pub bounds: ExistentialBounds<'tcx>, @@ -1707,7 +1710,7 @@ impl<'tcx> TraitTy<'tcx> { /// Note that a `TraitRef` introduces a level of region binding, to /// account for higher-ranked trait bounds like `T : for<'a> Foo<&'a /// U>` or higher-ranked object types. -#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct TraitRef<'tcx> { pub def_id: DefId, pub substs: &'tcx Substs<'tcx>, @@ -1842,7 +1845,7 @@ pub enum type_err<'tcx> { /// Bounds suitable for a named type parameter like `A` in `fn foo` /// as well as the existential type parameter in an object type. -#[derive(PartialEq, Eq, Hash, Clone, Debug)] +#[derive(PartialEq, Eq, Hash, Clone)] pub struct ParamBounds<'tcx> { pub region_bounds: Vec, pub builtin_bounds: BuiltinBounds, @@ -1855,41 +1858,57 @@ pub struct ParamBounds<'tcx> { /// major difference between this case and `ParamBounds` is that /// general purpose trait bounds are omitted and there must be /// *exactly one* region. -#[derive(PartialEq, Eq, Hash, Clone, Debug)] +#[derive(PartialEq, Eq, Hash, Clone)] pub struct ExistentialBounds<'tcx> { pub region_bound: ty::Region, pub builtin_bounds: BuiltinBounds, pub projection_bounds: Vec>, } -pub type BuiltinBounds = EnumSet; +#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +pub struct BuiltinBounds(EnumSet); -#[derive(Clone, RustcEncodable, PartialEq, Eq, RustcDecodable, Hash, - Debug, Copy)] -#[repr(usize)] -pub enum BuiltinBound { - BoundSend, - BoundSized, - BoundCopy, - BoundSync, +impl BuiltinBounds { + pub fn empty() -> BuiltinBounds { + BuiltinBounds(EnumSet::new()) + } + + pub fn iter(&self) -> enum_set::Iter { + self.into_iter() + } } -pub fn empty_builtin_bounds() -> BuiltinBounds { - EnumSet::new() +impl ops::Deref for BuiltinBounds { + type Target = EnumSet; + fn deref(&self) -> &Self::Target { &self.0 } } -pub fn all_builtin_bounds() -> BuiltinBounds { - let mut set = EnumSet::new(); - set.insert(BoundSend); - set.insert(BoundSized); - set.insert(BoundSync); - set +impl ops::DerefMut for BuiltinBounds { + fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } +} + +impl<'a> IntoIterator for &'a BuiltinBounds { + type Item = BuiltinBound; + type IntoIter = enum_set::Iter; + fn into_iter(self) -> Self::IntoIter { + (**self).into_iter() + } +} + +#[derive(Clone, RustcEncodable, PartialEq, Eq, RustcDecodable, Hash, + Debug, Copy)] +#[repr(usize)] +pub enum BuiltinBound { + Send, + Sized, + Copy, + Sync, } /// An existential bound that does not implement any traits. pub fn region_existential_bound<'tcx>(r: ty::Region) -> ExistentialBounds<'tcx> { ty::ExistentialBounds { region_bound: r, - builtin_bounds: empty_builtin_bounds(), + builtin_bounds: BuiltinBounds::empty(), projection_bounds: Vec::new() } } @@ -1968,7 +1987,7 @@ impl cmp::PartialEq for InferRegion { } impl fmt::Debug for TyVid { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result{ + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "_#{}t", self.index) } } @@ -2024,7 +2043,7 @@ impl fmt::Debug for IntVarValue { /// from `T:'a` annotations appearing in the type definition. If /// this is `None`, then the default is inherited from the /// surrounding context. See RFC #599 for details. -#[derive(Copy, Clone, Debug)] +#[derive(Copy, Clone)] pub enum ObjectLifetimeDefault { /// Require an explicit annotation. Occurs when multiple /// `T:'a` constraints are found. @@ -2034,7 +2053,7 @@ pub enum ObjectLifetimeDefault { Specific(Region), } -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct TypeParameterDef<'tcx> { pub name: ast::Name, pub def_id: ast::DefId, @@ -2097,7 +2116,7 @@ impl<'tcx> Generics<'tcx> { } /// Bounds on generics. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct GenericPredicates<'tcx> { pub predicates: VecPerParamSpace>, } @@ -2127,7 +2146,7 @@ impl<'tcx> GenericPredicates<'tcx> { } } -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] pub enum Predicate<'tcx> { /// Corresponds to `where Foo : Bar`. `Foo` here would be /// the `Self` type of the trait reference and `A`, `B`, and `C` @@ -2258,7 +2277,7 @@ impl<'tcx> Predicate<'tcx> { } } -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] pub struct TraitPredicate<'tcx> { pub trait_ref: TraitRef<'tcx> } @@ -2306,7 +2325,7 @@ pub type PolyTypeOutlivesPredicate<'tcx> = PolyOutlivesPredicate, ty::R /// equality between arbitrary types. Processing an instance of Form /// #2 eventually yields one of these `ProjectionPredicate` /// instances to normalize the LHS. -#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash)] pub struct ProjectionPredicate<'tcx> { pub projection_ty: ProjectionTy<'tcx>, pub ty: Ty<'tcx>, @@ -2495,7 +2514,7 @@ impl<'tcx> Predicate<'tcx> { /// `[[], [U:Bar]]`. Now if there were some particular reference /// like `Foo`, then the `InstantiatedPredicates` would be `[[], /// [usize:Bar]]`. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct InstantiatedPredicates<'tcx> { pub predicates: VecPerParamSpace>, } @@ -3679,7 +3698,7 @@ impl<'tcx> ItemSubsts<'tcx> { impl<'tcx> ParamBounds<'tcx> { pub fn empty() -> ParamBounds<'tcx> { ParamBounds { - builtin_bounds: empty_builtin_bounds(), + builtin_bounds: BuiltinBounds::empty(), trait_bounds: Vec::new(), region_bounds: Vec::new(), projection_bounds: Vec::new(), @@ -5316,138 +5335,132 @@ pub fn ty_sort_string(cx: &ctxt, ty: Ty) -> String { } } -impl<'tcx> Repr for ty::type_err<'tcx> { - fn repr(&self) -> String { - tls::with(|tcx| ty::type_err_to_str(tcx, self)) - } -} - /// Explains the source of a type err in a short, human readable way. This is meant to be placed /// in parentheses after some larger message. You should also invoke `note_and_explain_type_err()` /// afterwards to present additional details, particularly when it comes to lifetime-related /// errors. -pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String { - match *err { - terr_cyclic_ty => "cyclic type of infinite size".to_string(), - terr_mismatch => "types differ".to_string(), - terr_unsafety_mismatch(values) => { - format!("expected {} fn, found {} fn", - values.expected, - values.found) - } - terr_abi_mismatch(values) => { - format!("expected {} fn, found {} fn", - values.expected, - values.found) - } - terr_mutability => "values differ in mutability".to_string(), - terr_box_mutability => { - "boxed values differ in mutability".to_string() - } - terr_vec_mutability => "vectors differ in mutability".to_string(), - terr_ptr_mutability => "pointers differ in mutability".to_string(), - terr_ref_mutability => "references differ in mutability".to_string(), - terr_ty_param_size(values) => { - format!("expected a type with {} type params, \ - found one with {} type params", - values.expected, - values.found) - } - terr_fixed_array_size(values) => { - format!("expected an array with a fixed size of {} elements, \ - found one with {} elements", - values.expected, - values.found) - } - terr_tuple_size(values) => { - format!("expected a tuple with {} elements, \ - found one with {} elements", - values.expected, - values.found) - } - terr_arg_count => { - "incorrect number of function parameters".to_string() - } - terr_regions_does_not_outlive(..) => { - "lifetime mismatch".to_string() - } - terr_regions_not_same(..) => { - "lifetimes are not the same".to_string() - } - terr_regions_no_overlap(..) => { - "lifetimes do not intersect".to_string() - } - terr_regions_insufficiently_polymorphic(br, _) => { - format!("expected bound lifetime parameter {}, \ - found concrete lifetime", - br.user_string()) - } - terr_regions_overly_polymorphic(br, _) => { - format!("expected concrete lifetime, \ - found bound lifetime parameter {}", - br.user_string()) - } - terr_sorts(values) => { - // A naive approach to making sure that we're not reporting silly errors such as: - // (expected closure, found closure). - let expected_str = ty_sort_string(cx, values.expected); - let found_str = ty_sort_string(cx, values.found); - if expected_str == found_str { - format!("expected {}, found a different {}", expected_str, found_str) - } else { - format!("expected {}, found {}", expected_str, found_str) +impl<'tcx> fmt::Display for type_err<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + terr_cyclic_ty => write!(f, "cyclic type of infinite size"), + terr_mismatch => write!(f, "types differ"), + terr_unsafety_mismatch(values) => { + write!(f, "expected {} fn, found {} fn", + values.expected, + values.found) } - } - terr_traits(values) => { - format!("expected trait `{}`, found trait `{}`", - item_path_str(cx, values.expected), - item_path_str(cx, values.found)) - } - terr_builtin_bounds(values) => { - if values.expected.is_empty() { - format!("expected no bounds, found `{}`", - values.found.user_string()) - } else if values.found.is_empty() { - format!("expected bounds `{}`, found no bounds", - values.expected.user_string()) - } else { - format!("expected bounds `{}`, found bounds `{}`", - values.expected.user_string(), - values.found.user_string()) + terr_abi_mismatch(values) => { + write!(f, "expected {} fn, found {} fn", + values.expected, + values.found) + } + terr_mutability => write!(f, "values differ in mutability"), + terr_box_mutability => { + write!(f, "boxed values differ in mutability") + } + terr_vec_mutability => write!(f, "vectors differ in mutability"), + terr_ptr_mutability => write!(f, "pointers differ in mutability"), + terr_ref_mutability => write!(f, "references differ in mutability"), + terr_ty_param_size(values) => { + write!(f, "expected a type with {} type params, \ + found one with {} type params", + values.expected, + values.found) + } + terr_fixed_array_size(values) => { + write!(f, "expected an array with a fixed size of {} elements, \ + found one with {} elements", + values.expected, + values.found) + } + terr_tuple_size(values) => { + write!(f, "expected a tuple with {} elements, \ + found one with {} elements", + values.expected, + values.found) + } + terr_arg_count => { + write!(f, "incorrect number of function parameters") + } + terr_regions_does_not_outlive(..) => { + write!(f, "lifetime mismatch") + } + terr_regions_not_same(..) => { + write!(f, "lifetimes are not the same") + } + terr_regions_no_overlap(..) => { + write!(f, "lifetimes do not intersect") + } + terr_regions_insufficiently_polymorphic(br, _) => { + write!(f, "expected bound lifetime parameter {}, \ + found concrete lifetime", br) + } + terr_regions_overly_polymorphic(br, _) => { + write!(f, "expected concrete lifetime, \ + found bound lifetime parameter {}", br) + } + terr_sorts(values) => tls::with(|tcx| { + // A naive approach to making sure that we're not reporting silly errors such as: + // (expected closure, found closure). + let expected_str = ty_sort_string(tcx, values.expected); + let found_str = ty_sort_string(tcx, values.found); + if expected_str == found_str { + write!(f, "expected {}, found a different {}", expected_str, found_str) + } else { + write!(f, "expected {}, found {}", expected_str, found_str) + } + }), + terr_traits(values) => tls::with(|tcx| { + write!(f, "expected trait `{}`, found trait `{}`", + item_path_str(tcx, values.expected), + item_path_str(tcx, values.found)) + }), + terr_builtin_bounds(values) => { + if values.expected.is_empty() { + write!(f, "expected no bounds, found `{}`", + values.found) + } else if values.found.is_empty() { + write!(f, "expected bounds `{}`, found no bounds", + values.expected) + } else { + write!(f, "expected bounds `{}`, found bounds `{}`", + values.expected, + values.found) + } + } + terr_integer_as_char => { + write!(f, "expected an integral type, found `char`") + } + terr_int_mismatch(ref values) => { + write!(f, "expected `{:?}`, found `{:?}`", + values.expected, + values.found) + } + terr_float_mismatch(ref values) => { + write!(f, "expected `{:?}`, found `{:?}`", + values.expected, + values.found) + } + terr_variadic_mismatch(ref values) => { + write!(f, "expected {} fn, found {} function", + if values.expected { "variadic" } else { "non-variadic" }, + if values.found { "variadic" } else { "non-variadic" }) + } + terr_convergence_mismatch(ref values) => { + write!(f, "expected {} fn, found {} function", + if values.expected { "converging" } else { "diverging" }, + if values.found { "converging" } else { "diverging" }) + } + terr_projection_name_mismatched(ref values) => { + write!(f, "expected {}, found {}", + values.expected, + values.found) + } + terr_projection_bounds_length(ref values) => { + write!(f, "expected {} associated type bindings, found {}", + values.expected, + values.found) } - } - terr_integer_as_char => { - "expected an integral type, found `char`".to_string() - } - terr_int_mismatch(ref values) => { - format!("expected `{:?}`, found `{:?}`", - values.expected, - values.found) - } - terr_float_mismatch(ref values) => { - format!("expected `{:?}`, found `{:?}`", - values.expected, - values.found) - } - terr_variadic_mismatch(ref values) => { - format!("expected {} fn, found {} function", - if values.expected { "variadic" } else { "non-variadic" }, - if values.found { "variadic" } else { "non-variadic" }) - } - terr_convergence_mismatch(ref values) => { - format!("expected {} fn, found {} function", - if values.expected { "converging" } else { "diverging" }, - if values.found { "converging" } else { "diverging" }) - } - terr_projection_name_mismatched(ref values) => { - format!("expected {}, found {}", - token::get_name(values.expected), - token::get_name(values.found)) - } - terr_projection_bounds_length(ref values) => { - format!("expected {} associated type bindings, found {}", - values.expected, - values.found) } } } @@ -6914,14 +6927,14 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) - } } -impl Variance { - pub fn to_string(self) -> &'static str { - match self { +impl fmt::Debug for Variance { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(match *self { Covariant => "+", Contravariant => "-", Invariant => "o", Bivariant => "*", - } + }) } } @@ -7265,7 +7278,7 @@ pub fn liberate_late_bound_regions<'tcx, T>( all_outlive_scope: region::DestructionScopeData, value: &Binder) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { ty_fold::replace_late_bound_regions( tcx, value, @@ -7276,7 +7289,7 @@ pub fn count_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> usize - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { let (_, skol_map) = ty_fold::replace_late_bound_regions(tcx, value, |_| ty::ReStatic); skol_map.len() @@ -7286,7 +7299,7 @@ pub fn binds_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> bool - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { count_late_bound_regions(tcx, value) > 0 } @@ -7297,7 +7310,7 @@ pub fn flatten_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, bound2_value: &Binder>) -> Binder - where T: TypeFoldable<'tcx> + Repr + where T: TypeFoldable<'tcx> { let bound0_value = bound2_value.skip_binder().skip_binder(); let value = ty_fold::fold_regions(tcx, bound0_value, |region, current_depth| { @@ -7319,7 +7332,7 @@ pub fn no_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> Option - where T : TypeFoldable<'tcx> + Repr + Clone + where T : TypeFoldable<'tcx> { if binds_late_bound_regions(tcx, value) { None @@ -7334,7 +7347,7 @@ pub fn erase_late_bound_regions<'tcx, T>( tcx: &ty::ctxt<'tcx>, value: &Binder) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { ty_fold::replace_late_bound_regions(tcx, value, |_| ty::ReStatic).0 } @@ -7351,7 +7364,7 @@ pub fn anonymize_late_bound_regions<'tcx, T>( tcx: &ctxt<'tcx>, sig: &Binder) -> Binder - where T : TypeFoldable<'tcx> + Repr, + where T : TypeFoldable<'tcx>, { let mut counter = 0; ty::Binder(ty_fold::replace_late_bound_regions(tcx, sig, |_| { @@ -7371,58 +7384,45 @@ impl DebruijnIndex { } } -impl<'tcx> Repr for AutoAdjustment<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for AutoAdjustment<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { AdjustReifyFnPointer => { - format!("AdjustReifyFnPointer") + write!(f, "AdjustReifyFnPointer") } AdjustUnsafeFnPointer => { - format!("AdjustUnsafeFnPointer") + write!(f, "AdjustUnsafeFnPointer") } AdjustDerefRef(ref data) => { - data.repr() + write!(f, "{:?}", data) } } } } -impl<'tcx> Repr for AutoDerefRef<'tcx> { - fn repr(&self) -> String { - format!("AutoDerefRef({}, unsize={}, {})", - self.autoderefs, self.unsize.repr(), self.autoref.repr()) - } -} - -impl<'tcx> Repr for AutoRef<'tcx> { - fn repr(&self) -> String { - match *self { - AutoPtr(a, b) => { - format!("AutoPtr({},{:?})", a.repr(), b) - } - AutoUnsafe(ref a) => { - format!("AutoUnsafe({:?})", a) - } - } +impl<'tcx> fmt::Debug for AutoDerefRef<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "AutoDerefRef({}, unsize={:?}, {:?})", + self.autoderefs, self.unsize, self.autoref) } } -impl<'tcx> Repr for TraitTy<'tcx> { - fn repr(&self) -> String { - format!("TraitTy({},{})", - self.principal.repr(), - self.bounds.repr()) +impl<'tcx> fmt::Debug for TraitTy<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "TraitTy({:?},{:?})", + self.principal, + self.bounds) } } -impl<'tcx> Repr for ty::Predicate<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for ty::Predicate<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - Predicate::Trait(ref a) => a.repr(), - Predicate::Equate(ref pair) => pair.repr(), - Predicate::RegionOutlives(ref pair) => pair.repr(), - Predicate::TypeOutlives(ref pair) => pair.repr(), - Predicate::Projection(ref pair) => pair.repr(), + Predicate::Trait(ref a) => write!(f, "{:?}", a), + Predicate::Equate(ref pair) => write!(f, "{:?}", pair), + Predicate::RegionOutlives(ref pair) => write!(f, "{:?}", pair), + Predicate::TypeOutlives(ref pair) => write!(f, "{:?}", pair), + Predicate::Projection(ref pair) => write!(f, "{:?}", pair), } } } @@ -7628,14 +7628,6 @@ impl<'tcx> RegionEscape for ProjectionTy<'tcx> { } } -impl<'tcx> Repr for ty::ProjectionPredicate<'tcx> { - fn repr(&self) -> String { - format!("ProjectionPredicate({}, {})", - self.projection_ty.repr(), - self.ty.repr()) - } -} - pub trait HasProjectionTypes { fn has_projection_types(&self) -> bool; } @@ -7870,48 +7862,46 @@ impl ReferencesError for Region } } -impl<'tcx> Repr for ClosureTy<'tcx> { - fn repr(&self) -> String { - format!("ClosureTy({},{},{})", - self.unsafety, - self.sig.repr(), - self.abi) +impl<'tcx> fmt::Debug for ClosureTy<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ClosureTy({},{:?},{})", + self.unsafety, + self.sig, + self.abi) } } -impl<'tcx> Repr for ClosureUpvar<'tcx> { - fn repr(&self) -> String { - format!("ClosureUpvar({},{})", - self.def.repr(), - self.ty.repr()) +impl<'tcx> fmt::Debug for ClosureUpvar<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ClosureUpvar({:?},{:?})", + self.def, + self.ty) } } -impl<'tcx> Repr for field<'tcx> { - fn repr(&self) -> String { - format!("field({},{})", - self.name.repr(), - self.mt.repr()) +impl<'tcx> fmt::Debug for field<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "field({},{})", self.name, self.mt) } } -impl<'a, 'tcx> Repr for ParameterEnvironment<'a, 'tcx> { - fn repr(&self) -> String { - format!("ParameterEnvironment(\ - free_substs={}, \ - implicit_region_bound={}, \ - caller_bounds={})", - self.free_substs.repr(), - self.implicit_region_bound.repr(), - self.caller_bounds.repr()) +impl<'a, 'tcx> fmt::Debug for ParameterEnvironment<'a, 'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ParameterEnvironment(\ + free_substs={:?}, \ + implicit_region_bound={:?}, \ + caller_bounds={:?})", + self.free_substs, + self.implicit_region_bound, + self.caller_bounds) } } -impl<'tcx> Repr for ObjectLifetimeDefault { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for ObjectLifetimeDefault { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ObjectLifetimeDefault::Ambiguous => format!("Ambiguous"), - ObjectLifetimeDefault::Specific(ref r) => r.repr(), + ObjectLifetimeDefault::Ambiguous => write!(f, "Ambiguous"), + ObjectLifetimeDefault::Specific(ref r) => write!(f, "{:?}", r), } } } diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index 00905eda1498e..adc282bc2fdd5 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -38,6 +38,8 @@ use middle::subst; use middle::subst::VecPerParamSpace; use middle::ty::{self, Ty}; use middle::traits; + +use std::fmt; use std::rc::Rc; use syntax::abi; use syntax::ast; @@ -50,7 +52,7 @@ use util::ppaux::Repr; /// The TypeFoldable trait is implemented for every type that can be folded. /// Basically, every type that has a corresponding method in TypeFolder. -pub trait TypeFoldable<'tcx>: Repr + Clone { +pub trait TypeFoldable<'tcx>: fmt::Debug + Clone { fn fold_with>(&self, folder: &mut F) -> Self; } @@ -74,7 +76,7 @@ pub trait TypeFolder<'tcx> : Sized { fn exit_region_binder(&mut self) { } fn fold_binder(&mut self, t: &ty::Binder) -> ty::Binder - where T : TypeFoldable<'tcx> + Repr + Clone + where T : TypeFoldable<'tcx> { // FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`. super_fold_binder(self, t) @@ -197,7 +199,7 @@ impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec { } } -impl<'tcx, T:TypeFoldable<'tcx>+Repr+Clone> TypeFoldable<'tcx> for ty::Binder { +impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder { fn fold_with>(&self, folder: &mut F) -> ty::Binder { folder.fold_binder(self) } @@ -885,7 +887,7 @@ pub fn replace_late_bound_regions<'tcx,T,F>(tcx: &ty::ctxt<'tcx>, mut f: F) -> (T, FnvHashMap) where F : FnMut(ty::BoundRegion) -> ty::Region, - T : TypeFoldable<'tcx> + Repr, + T : TypeFoldable<'tcx>, { debug!("replace_late_bound_regions({})", value.repr()); let mut replacer = RegionReplacer::new(tcx, &mut f); @@ -994,8 +996,8 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region { } } -pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>+Repr>(tcx: &ty::ctxt<'tcx>, - amount: u32, value: &T) -> T { +pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>, + amount: u32, value: &T) -> T { debug!("shift_regions(value={}, amount={})", value.repr(), amount); diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 3851eb6573ba1..5d524c51b5eb3 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -9,15 +9,12 @@ // except according to those terms. -use middle::def; -use middle::region; -use middle::subst::{VecPerParamSpace,Subst}; -use middle::subst; +use middle::subst::{self, Subst}; use middle::ty::{BoundRegion, BrAnon, BrNamed}; use middle::ty::{ReEarlyBound, BrFresh, ctxt}; use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, ReEmpty}; use middle::ty::{ReSkolemized, ReVar, BrEnv}; -use middle::ty::{mt, Ty, ParamTy}; +use middle::ty::{mt, Ty}; use middle::ty::{TyBool, TyChar, TyStruct, TyEnum}; use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyBareFn}; use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple}; @@ -26,16 +23,10 @@ use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; use middle::ty; use middle::ty_fold::{self, TypeFoldable}; -use std::collections::HashMap; -use std::collections::hash_state::HashState; -use std::hash::Hash; -use std::rc::Rc; +use std::fmt; use syntax::abi; -use syntax::codemap::Span; use syntax::parse::token; -use syntax::ptr::P; use syntax::{ast, ast_util}; -use syntax::owned_slice::OwnedSlice; /// Produces a string suitable for debugging output. pub trait Repr { @@ -47,51 +38,114 @@ pub trait UserString { fn user_string(&self) -> String; } +impl Repr for T { + fn repr(&self) -> String { + format!("{:?}", *self) + } +} + +impl UserString for T { + fn user_string(&self) -> String { + format!("{}", *self) + } +} + pub fn verbose() -> bool { ty::tls::with(|tcx| tcx.sess.verbose()) } -fn parameterized(substs: &subst::Substs, +fn fn_sig(f: &mut fmt::Formatter, + inputs: &[Ty], + variadic: bool, + output: ty::FnOutput) + -> fmt::Result { + try!(write!(f, "(")); + let mut inputs = inputs.iter(); + if let Some(&ty) = inputs.next() { + try!(write!(f, "{}", ty)); + for &ty in inputs { + try!(write!(f, ", {}", ty)); + } + if variadic { + try!(write!(f, ", ...")); + } + } + try!(write!(f, ")")); + + match output { + ty::FnConverging(ty) => { + if !ty::type_is_nil(ty) { + try!(write!(f, " -> {}", ty)); + } + Ok(()) + } + ty::FnDiverging => { + write!(f, " -> !") + } + } +} + +fn parameterized(f: &mut fmt::Formatter, + substs: &subst::Substs, did: ast::DefId, projections: &[ty::ProjectionPredicate], get_generics: GG) - -> String + -> fmt::Result where GG: for<'tcx> FnOnce(&ty::ctxt<'tcx>) -> ty::Generics<'tcx> { - let base = ty::tls::with(|tcx| ty::item_path_str(tcx, did)); - if verbose() { - let mut strings = vec![]; + let (fn_trait_kind, verbose) = try!(ty::tls::with(|tcx| { + try!(write!(f, "{}", ty::item_path_str(tcx, did))); + Ok((tcx.lang_items.fn_trait_kind(did), tcx.sess.verbose())) + })); + + let mut empty = true; + let mut start_or_continue = |f: &mut fmt::Formatter, start: &str, cont: &str| { + if empty { + empty = false; + write!(f, "{}", start) + } else { + write!(f, "{}", cont) + } + }; + + if verbose { match substs.regions { subst::ErasedRegions => { - strings.push(format!("..")); + try!(start_or_continue(f, "<", ", ")); + try!(write!(f, "..")); } subst::NonerasedRegions(ref regions) => { for region in regions { - strings.push(region.repr()); + try!(start_or_continue(f, "<", ", ")); + try!(write!(f, "{:?}", region)); } } } - for ty in &substs.types { - strings.push(ty.repr()); + for &ty in &substs.types { + try!(start_or_continue(f, "<", ", ")); + try!(write!(f, "{}", ty)); } for projection in projections { - strings.push(format!("{}={}", - projection.projection_ty.item_name.user_string(), - projection.ty.user_string())); + try!(start_or_continue(f, "<", ", ")); + try!(write!(f, "{}={}", + projection.projection_ty.item_name, + projection.ty)); } - return if strings.is_empty() { - format!("{}", base) - } else { - format!("{}<{}>", base, strings.connect(",")) - }; + return start_or_continue(f, "", ">"); } - let mut strs = Vec::new(); + if fn_trait_kind.is_some() && projections.len() == 1 { + let projection_ty = projections[0].ty; + if let TyTuple(ref args) = substs.types.get_slice(subst::TypeSpace)[0].sty { + return fn_sig(f, args, false, ty::FnConverging(projection_ty)); + } + } match substs.regions { subst::ErasedRegions => { } subst::NonerasedRegions(ref regions) => { for &r in regions { + try!(start_or_continue(f, "<", ", ")); let s = r.user_string(); if s.is_empty() { // This happens when the value of the region @@ -99,9 +153,9 @@ fn parameterized(substs: &subst::Substs, // because the user omitted it in the first place, // or because it refers to some block in the code, // etc. I'm not sure how best to serialize this. - strs.push(format!("'_")); + try!(write!(f, "'_")); } else { - strs.push(s) + try!(write!(f, "{}", s)); } } } @@ -112,14 +166,13 @@ fn parameterized(substs: &subst::Substs, // ICEs trying to fetch the generics early in the pipeline. This // is kind of a hacky workaround in that -Z verbose is required to // avoid those ICEs. - ty::tls::with(|tcx| { + let tps = substs.types.get_slice(subst::TypeSpace); + let num_defaults = ty::tls::with(|tcx| { let generics = get_generics(tcx); let has_self = substs.self_ty().is_some(); - let tps = substs.types.get_slice(subst::TypeSpace); let ty_params = generics.types.get_slice(subst::TypeSpace); - let has_defaults = ty_params.last().map_or(false, |def| def.default.is_some()); - let num_defaults = if has_defaults { + if ty_params.last().map_or(false, |def| def.default.is_some()) { let substs = tcx.lift(&substs); ty_params.iter().zip(tps).rev().take_while(|&(def, &actual)| { match def.default { @@ -142,49 +195,29 @@ fn parameterized(substs: &subst::Substs, }).count() } else { 0 - }; - - for t in &tps[..tps.len() - num_defaults] { - strs.push(t.user_string()) } }); - for projection in projections { - strs.push(format!("{}={}", - projection.projection_ty.item_name.user_string(), - projection.ty.user_string())); + for &ty in &tps[..tps.len() - num_defaults] { + try!(start_or_continue(f, "<", ", ")); + try!(write!(f, "{}", ty)); } - let fn_trait_kind = ty::tls::with(|tcx| tcx.lang_items.fn_trait_kind(did)); - if fn_trait_kind.is_some() && projections.len() == 1 { - let projection_ty = projections[0].ty; - let tail = - if ty::type_is_nil(projection_ty) { - format!("") - } else { - format!(" -> {}", projection_ty.user_string()) - }; - format!("{}({}){}", - base, - if strs[0].starts_with("(") && strs[0].ends_with(",)") { - &strs[0][1 .. strs[0].len() - 2] // Remove '(' and ',)' - } else if strs[0].starts_with("(") && strs[0].ends_with(")") { - &strs[0][1 .. strs[0].len() - 1] // Remove '(' and ')' - } else { - &strs[0][..] - }, - tail) - } else if !strs.is_empty() { - format!("{}<{}>", base, strs.connect(", ")) - } else { - format!("{}", base) + for projection in projections { + try!(start_or_continue(f, "<", ", ")); + try!(write!(f, "{}={}", + projection.projection_ty.item_name, + projection.ty)); } + + start_or_continue(f, "", ">") } -fn in_binder<'tcx, T, U>(tcx: &ty::ctxt<'tcx>, +fn in_binder<'tcx, T, U>(f: &mut fmt::Formatter, + tcx: &ty::ctxt<'tcx>, original: &ty::Binder, - lifted: Option>) -> String - where T: UserString, U: UserString + TypeFoldable<'tcx> + lifted: Option>) -> fmt::Result + where T: fmt::Display, U: fmt::Display + TypeFoldable<'tcx> { // Replace any anonymous late-bound regions with named // variants, using gensym'd identifiers, so that we can @@ -194,110 +227,38 @@ fn in_binder<'tcx, T, U>(tcx: &ty::ctxt<'tcx>, let value = if let Some(v) = lifted { v } else { - return original.0.user_string(); + return write!(f, "{}", original.0); + }; + + let mut empty = true; + let mut start_or_continue = |f: &mut fmt::Formatter, start: &str, cont: &str| { + if empty { + empty = false; + write!(f, "{}", start) + } else { + write!(f, "{}", cont) + } }; - let mut names = Vec::new(); - let value_str = ty_fold::replace_late_bound_regions(tcx, &value, |br| { + + let new_value = ty_fold::replace_late_bound_regions(tcx, &value, |br| { + let _ = start_or_continue(f, "for<", ", "); ty::ReLateBound(ty::DebruijnIndex::new(1), match br { ty::BrNamed(_, name) => { - names.push(token::get_name(name).to_string()); + let _ = write!(f, "{}", name); br } ty::BrAnon(_) | ty::BrFresh(_) | ty::BrEnv => { - let name = token::gensym("'r"); - names.push(token::get_name(name).to_string()); + let name = token::intern("'r"); + let _ = write!(f, "{}", name); ty::BrNamed(ast_util::local_def(ast::DUMMY_NODE_ID), name) } }) - }).0.user_string(); - - if names.is_empty() { - value_str - } else { - format!("for<{}> {}", names.connect(","), value_str) - } -} - -impl Repr for Option { - fn repr(&self) -> String { - match self { - &None => "None".to_string(), - &Some(ref t) => t.repr(), - } - } -} + }).0; -impl Repr for P { - fn repr(&self) -> String { - (**self).repr() - } -} - -impl Repr for Result { - fn repr(&self) -> String { - match self { - &Ok(ref t) => t.repr(), - &Err(ref u) => format!("Err({})", u.repr()) - } - } -} - -impl Repr for () { - fn repr(&self) -> String { - "()".to_string() - } -} - -impl<'a, T: ?Sized +Repr> Repr for &'a T { - fn repr(&self) -> String { - (**self).repr() - } -} - -impl Repr for Rc { - fn repr(&self) -> String { - (&**self).repr() - } -} - -impl Repr for Box { - fn repr(&self) -> String { - (&**self).repr() - } -} - -impl Repr for [T] { - fn repr(&self) -> String { - format!("[{}]", self.iter().map(|t| t.repr()).collect::>().connect(", ")) - } -} - -impl Repr for OwnedSlice { - fn repr(&self) -> String { - self[..].repr() - } -} - -// This is necessary to handle types like Option>, for which -// autoderef cannot convert the &[T] handler -impl Repr for Vec { - fn repr(&self) -> String { - self[..].repr() - } -} - -impl<'a, T: ?Sized +UserString> UserString for &'a T { - fn user_string(&self) -> String { - (**self).user_string() - } -} - -impl Repr for def::Def { - fn repr(&self) -> String { - format!("{:?}", *self) - } + try!(start_or_continue(f, "", "> ")); + write!(f, "{}", new_value) } /// This curious type is here to help pretty-print trait objects. In @@ -311,274 +272,194 @@ impl Repr for def::Def { /// Right now there is only one trait in an object that can have /// projection bounds, so we just stuff them altogether. But in /// reality we should eventually sort things out better. -type TraitAndProjections<'tcx> = - (ty::TraitRef<'tcx>, Vec>); +#[derive(Clone, Debug)] +struct TraitAndProjections<'tcx>(ty::TraitRef<'tcx>, Vec>); -impl<'tcx> UserString for TraitAndProjections<'tcx> { - fn user_string(&self) -> String { - let &(ref trait_ref, ref projection_bounds) = self; - parameterized(trait_ref.substs, +impl<'tcx> TypeFoldable<'tcx> for TraitAndProjections<'tcx> { + fn fold_with>(&self, folder: &mut F) + -> TraitAndProjections<'tcx> { + TraitAndProjections(self.0.fold_with(folder), self.1.fold_with(folder)) + } +} + +impl<'tcx> fmt::Display for TraitAndProjections<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let TraitAndProjections(ref trait_ref, ref projection_bounds) = *self; + parameterized(f, trait_ref.substs, trait_ref.def_id, - &projection_bounds[..], + projection_bounds, |tcx| ty::lookup_trait_def(tcx, trait_ref.def_id).generics.clone()) } } -impl<'tcx> UserString for ty::TraitTy<'tcx> { - fn user_string(&self) -> String { - let &ty::TraitTy { ref principal, ref bounds } = self; - - let mut components = vec![]; - - let tap: ty::Binder> = - ty::Binder((principal.0.clone(), - bounds.projection_bounds.iter().map(|x| x.0.clone()).collect())); +impl<'tcx> fmt::Display for ty::TraitTy<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let bounds = &self.bounds; // Generate the main trait ref, including associated types. - components.push(tap.user_string()); + try!(ty::tls::with(|tcx| { + let principal = tcx.lift(&self.principal.0) + .expect("could not lift TraitRef for printing"); + let projections = tcx.lift(&bounds.projection_bounds[..]) + .expect("could not lift projections for printing"); + let projections = projections.map_in_place(|p| p.0); + + let tap = ty::Binder(TraitAndProjections(principal, projections)); + in_binder(f, tcx, &ty::Binder(""), Some(tap)) + })); // Builtin bounds. for bound in &bounds.builtin_bounds { - components.push(bound.user_string()); + try!(write!(f, " + {:?}", bound)); } // Region, if not obviously implied by builtin bounds. if bounds.region_bound != ty::ReStatic { // Region bound is implied by builtin bounds: - components.push(bounds.region_bound.user_string()); + let bound = bounds.region_bound.user_string(); + if !bound.is_empty() { + try!(write!(f, " + {}", bound)); + } } - components.retain(|s| !s.is_empty()); - - components.connect(" + ") + Ok(()) } } -impl<'tcx> Repr for ty::TypeParameterDef<'tcx> { - fn repr(&self) -> String { - format!("TypeParameterDef({:?}, {:?}/{})", - self.def_id, - self.space, - self.index) +impl<'tcx> fmt::Debug for ty::TypeParameterDef<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "TypeParameterDef({:?}, {:?}/{})", + self.def_id, self.space, self.index) } } -impl Repr for ty::RegionParameterDef { - fn repr(&self) -> String { - format!("RegionParameterDef(name={}, def_id={}, bounds={})", - token::get_name(self.name), - self.def_id.repr(), - self.bounds.repr()) +impl<'tcx> fmt::Debug for ty::TyS<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", *self) } } -impl<'tcx> Repr for ty::TyS<'tcx> { - fn repr(&self) -> String { - self.user_string() +impl<'tcx> fmt::Display for ty::mt<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}{}", + if self.mutbl == ast::MutMutable { "mut " } else { "" }, + self.ty) } } -impl<'tcx> Repr for ty::mt<'tcx> { - fn repr(&self) -> String { - format!("{}{}", - if self.mutbl == ast::MutMutable { "mut " } else { "" }, - self.ty.user_string()) +impl<'tcx> fmt::Debug for subst::Substs<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Substs[types={:?}, regions={:?}]", + self.types, self.regions) } } -impl<'tcx> Repr for subst::Substs<'tcx> { - fn repr(&self) -> String { - format!("Substs[types={}, regions={}]", - self.types.repr(), - self.regions.repr()) +impl<'tcx> fmt::Debug for ty::ItemSubsts<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ItemSubsts({:?})", self.substs) } } -impl Repr for subst::VecPerParamSpace { - fn repr(&self) -> String { - format!("[{};{};{}]", - self.get_slice(subst::TypeSpace).repr(), - self.get_slice(subst::SelfSpace).repr(), - self.get_slice(subst::FnSpace).repr()) - } -} - -impl<'tcx> Repr for ty::ItemSubsts<'tcx> { - fn repr(&self) -> String { - format!("ItemSubsts({})", self.substs.repr()) - } -} - -impl Repr for subst::RegionSubsts { - fn repr(&self) -> String { +impl fmt::Debug for subst::RegionSubsts { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - subst::ErasedRegions => "erased".to_string(), - subst::NonerasedRegions(ref regions) => regions.repr() + subst::ErasedRegions => write!(f, "erased"), + subst::NonerasedRegions(ref regions) => write!(f, "{:?}", regions) } } } -impl Repr for ty::BuiltinBounds { - fn repr(&self) -> String { - let mut res = Vec::new(); - for b in self { - res.push(match b { - ty::BoundSend => "Send".to_string(), - ty::BoundSized => "Sized".to_string(), - ty::BoundCopy => "Copy".to_string(), - ty::BoundSync => "Sync".to_string(), - }); - } - res.connect("+") - } -} -impl<'tcx> Repr for ty::ParamBounds<'tcx> { - fn repr(&self) -> String { - let mut res = Vec::new(); - res.push(self.builtin_bounds.repr()); - for t in &self.trait_bounds { - res.push(t.repr()); +impl<'tcx> fmt::Debug for ty::ParamBounds<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "{:?}", self.builtin_bounds)); + let mut bounds = self.trait_bounds.iter(); + if self.builtin_bounds.is_empty() { + if let Some(bound) = bounds.next() { + try!(write!(f, "{:?}", bound)); + } + } + for bound in bounds { + try!(write!(f, " + {:?}", bound)); } - res.connect("+") + Ok(()) } } -impl<'tcx> Repr for ty::TraitRef<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for ty::TraitRef<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // when printing out the debug representation, we don't need // to enumerate the `for<...>` etc because the debruijn index // tells you everything you need to know. - let result = self.user_string(); match self.substs.self_ty() { - None => result, - Some(sty) => format!("<{} as {}>", sty.repr(), result) + None => write!(f, "{}", *self), + Some(self_ty) => write!(f, "<{:?} as {}>", self_ty, *self) } } } -impl<'tcx> Repr for ty::TraitDef<'tcx> { - fn repr(&self) -> String { - format!("TraitDef(generics={}, trait_ref={})", - self.generics.repr(), - self.trait_ref.repr()) - } -} - -impl Repr for ast::Expr { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ast::Path { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl UserString for ast::Path { - fn user_string(&self) -> String { - format!("{}", *self) - } -} - -impl Repr for ast::Ty { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ast::Lifetime { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ast::Stmt { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ast::Pat { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ty::BoundRegion { - fn repr(&self) -> String { - match *self { - ty::BrAnon(id) => format!("BrAnon({})", id), - ty::BrNamed(id, name) => { - format!("BrNamed({}, {})", id.repr(), token::get_name(name)) - } - ty::BrFresh(id) => format!("BrFresh({})", id), - ty::BrEnv => "BrEnv".to_string() - } +impl<'tcx> fmt::Debug for ty::TraitDef<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "TraitDef(generics={:?}, trait_ref={:?})", + self.generics, self.trait_ref) } } -impl UserString for ty::BoundRegion { - fn user_string(&self) -> String { +impl fmt::Display for ty::BoundRegion { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if verbose() { - return self.repr(); + return write!(f, "{:?}", *self); } match *self { - BrNamed(_, name) => token::get_name(name).to_string(), - BrAnon(_) | BrFresh(_) | BrEnv => String::new() + BrNamed(_, name) => write!(f, "{}", name), + BrAnon(_) | BrFresh(_) | BrEnv => Ok(()) } } } -impl Repr for ty::Region { - fn repr(&self) -> String { +impl fmt::Debug for ty::Region { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ty::ReEarlyBound(ref data) => { - format!("ReEarlyBound({}, {:?}, {}, {})", - data.param_id, - data.space, - data.index, - token::get_name(data.name)) + write!(f, "ReEarlyBound({}, {:?}, {}, {})", + data.param_id, + data.space, + data.index, + data.name) } ty::ReLateBound(binder_id, ref bound_region) => { - format!("ReLateBound({:?}, {})", - binder_id, - bound_region.repr()) + write!(f, "ReLateBound({:?}, {:?})", + binder_id, + bound_region) } - ty::ReFree(ref fr) => fr.repr(), + ty::ReFree(ref fr) => write!(f, "{:?}", fr), ty::ReScope(id) => { - format!("ReScope({:?})", id) + write!(f, "ReScope({:?})", id) } - ty::ReStatic => { - "ReStatic".to_string() - } + ty::ReStatic => write!(f, "ReStatic"), ty::ReInfer(ReVar(ref vid)) => { - format!("{:?}", vid) + write!(f, "{:?}", vid) } ty::ReInfer(ReSkolemized(id, ref bound_region)) => { - format!("re_skolemized({}, {})", id, bound_region.repr()) + write!(f, "ReSkolemized({}, {:?})", id, bound_region) } - ty::ReEmpty => { - "ReEmpty".to_string() - } + ty::ReEmpty => write!(f, "ReEmpty") } } } -impl UserString for ty::Region { - fn user_string(&self) -> String { +impl fmt::Display for ty::Region { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if verbose() { - return self.repr(); + return write!(f, "{:?}", *self); } // These printouts are concise. They do not contain all the information @@ -587,672 +468,344 @@ impl UserString for ty::Region { // `explain_region()` or `note_and_explain_region()`. match *self { ty::ReEarlyBound(ref data) => { - token::get_name(data.name).to_string() + write!(f, "{}", data.name) } ty::ReLateBound(_, br) | ty::ReFree(ty::FreeRegion { bound_region: br, .. }) | ty::ReInfer(ReSkolemized(_, br)) => { - br.user_string() + write!(f, "{}", br) } ty::ReScope(_) | - ty::ReInfer(ReVar(_)) => String::new(), - ty::ReStatic => "'static".to_owned(), - ty::ReEmpty => "'".to_owned(), - } - } -} - -impl Repr for ty::FreeRegion { - fn repr(&self) -> String { - format!("ReFree({}, {})", - self.scope.repr(), - self.bound_region.repr()) - } -} - -impl Repr for region::CodeExtent { - fn repr(&self) -> String { - match *self { - region::CodeExtent::ParameterScope { fn_id, body_id } => - format!("ParameterScope({}, {})", fn_id, body_id), - region::CodeExtent::Misc(node_id) => - format!("Misc({})", node_id), - region::CodeExtent::DestructionScope(node_id) => - format!("DestructionScope({})", node_id), - region::CodeExtent::Remainder(rem) => - format!("Remainder({}, {})", rem.block, rem.first_statement_index), - } - } -} - -impl Repr for region::DestructionScopeData { - fn repr(&self) -> String { - match *self { - region::DestructionScopeData{ node_id } => - format!("DestructionScopeData {{ node_id: {} }}", node_id), + ty::ReInfer(ReVar(_)) => Ok(()), + ty::ReStatic => write!(f, "'static"), + ty::ReEmpty => write!(f, "'"), } } } -impl Repr for ast::DefId { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl<'tcx> Repr for ty::TypeScheme<'tcx> { - fn repr(&self) -> String { - format!("TypeScheme {{generics: {}, ty: {}}}", - self.generics.repr(), - self.ty.repr()) - } -} - -impl<'tcx> Repr for ty::Generics<'tcx> { - fn repr(&self) -> String { - format!("Generics(types: {}, regions: {})", - self.types.repr(), - self.regions.repr()) - } -} - -impl<'tcx> Repr for ty::GenericPredicates<'tcx> { - fn repr(&self) -> String { - format!("GenericPredicates(predicates: {})", - self.predicates.repr()) - } -} - -impl<'tcx> Repr for ty::InstantiatedPredicates<'tcx> { - fn repr(&self) -> String { - format!("InstantiatedPredicates({})", - self.predicates.repr()) - } -} - -impl Repr for ty::ItemVariances { - fn repr(&self) -> String { - format!("ItemVariances(types={}, \ - regions={})", - self.types.repr(), - self.regions.repr()) - } -} - -impl Repr for ty::Variance { - fn repr(&self) -> String { - // The first `.to_string()` returns a &'static str (it is not an implementation - // of the ToString trait). Because of that, we need to call `.to_string()` again - // if we want to have a `String`. - let result: &'static str = (*self).to_string(); - result.to_string() - } -} - -impl<'tcx> Repr for ty::ImplOrTraitItem<'tcx> { - fn repr(&self) -> String { - format!("ImplOrTraitItem({})", - match *self { - ty::ImplOrTraitItem::MethodTraitItem(ref i) => i.repr(), - ty::ImplOrTraitItem::ConstTraitItem(ref i) => i.repr(), - ty::ImplOrTraitItem::TypeTraitItem(ref i) => i.repr(), - }) - } -} - -impl<'tcx> Repr for ty::AssociatedConst<'tcx> { - fn repr(&self) -> String { - format!("AssociatedConst(name: {}, ty: {}, vis: {}, def_id: {})", - self.name.repr(), - self.ty.repr(), - self.vis.repr(), - self.def_id.repr()) +impl fmt::Debug for ty::FreeRegion { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ReFree({:?}, {:?})", + self.scope, self.bound_region) } } -impl<'tcx> Repr for ty::AssociatedType<'tcx> { - fn repr(&self) -> String { - format!("AssociatedType(name: {}, vis: {}, def_id: {})", - self.name.repr(), - self.vis.repr(), - self.def_id.repr()) +impl fmt::Debug for ty::ItemVariances { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ItemVariances(types={:?}, regions={:?})", + self.types, self.regions) } } -impl<'tcx> Repr for ty::Method<'tcx> { - fn repr(&self) -> String { - format!("Method(name: {}, generics: {}, predicates: {}, fty: {}, \ - explicit_self: {}, vis: {}, def_id: {})", - self.name.repr(), - self.generics.repr(), - self.predicates.repr(), - self.fty.repr(), - self.explicit_self.repr(), - self.vis.repr(), - self.def_id.repr()) +impl<'tcx> fmt::Debug for ty::GenericPredicates<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "GenericPredicates({:?})", self.predicates) } } -impl Repr for ast::Name { - fn repr(&self) -> String { - format!("{:?}", *self) +impl<'tcx> fmt::Debug for ty::InstantiatedPredicates<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "InstantiatedPredicates({:?})", + self.predicates) } } -impl UserString for ast::Name { - fn user_string(&self) -> String { - format!("{}", *self) +impl<'tcx> fmt::Debug for ty::ImplOrTraitItem<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "ImplOrTraitItem(")); + try!(match *self { + ty::ImplOrTraitItem::MethodTraitItem(ref i) => write!(f, "{:?}", i), + ty::ImplOrTraitItem::ConstTraitItem(ref i) => write!(f, "{:?}", i), + ty::ImplOrTraitItem::TypeTraitItem(ref i) => write!(f, "{:?}", i), + }); + write!(f, ")") } } -impl Repr for ast::ExplicitSelf_ { - fn repr(&self) -> String { - format!("{:?}", *self) +impl<'tcx> fmt::Display for ty::FnSig<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "fn")); + fn_sig(f, &self.inputs, self.variadic, self.output) } } -impl Repr for ast::Visibility { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl<'tcx> Repr for ty::BareFnTy<'tcx> { - fn repr(&self) -> String { - format!("BareFnTy {{unsafety: {}, abi: {}, sig: {}}}", - self.unsafety, - self.abi.to_string(), - self.sig.repr()) - } -} - - -impl<'tcx> Repr for ty::FnSig<'tcx> { - fn repr(&self) -> String { - format!("fn{} -> {}", self.inputs.repr(), self.output.repr()) - } -} - -impl<'tcx> Repr for ty::FnOutput<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for ty::MethodOrigin<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ty::FnConverging(ty) => - format!("FnConverging({0})", ty.repr()), - ty::FnDiverging => - "FnDiverging".to_string() - } - } -} - -impl<'tcx> Repr for ty::MethodCallee<'tcx> { - fn repr(&self) -> String { - format!("MethodCallee {{origin: {}, ty: {}, {}}}", - self.origin.repr(), - self.ty.repr(), - self.substs.repr()) - } -} - -impl<'tcx> Repr for ty::MethodOrigin<'tcx> { - fn repr(&self) -> String { - match self { - &ty::MethodStatic(def_id) => { - format!("MethodStatic({})", def_id.repr()) - } - &ty::MethodStaticClosure(def_id) => { - format!("MethodStaticClosure({})", def_id.repr()) + ty::MethodStatic(def_id) => { + write!(f, "MethodStatic({:?})", def_id) } - &ty::MethodTypeParam(ref p) => { - p.repr() - } - &ty::MethodTraitObject(ref p) => { - p.repr() + ty::MethodStaticClosure(def_id) => { + write!(f, "MethodStaticClosure({:?})", def_id) } + ty::MethodTypeParam(ref p) => write!(f, "{:?}", p), + ty::MethodTraitObject(ref p) => write!(f, "{:?}", p) } } } -impl<'tcx> Repr for ty::MethodParam<'tcx> { - fn repr(&self) -> String { - format!("MethodParam({},{})", - self.trait_ref.repr(), - self.method_num) - } -} - -impl<'tcx> Repr for ty::MethodObject<'tcx> { - fn repr(&self) -> String { - format!("MethodObject({},{},{})", - self.trait_ref.repr(), - self.method_num, - self.vtable_index) - } -} - -impl Repr for ty::BuiltinBound { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl UserString for ty::BuiltinBound { - fn user_string(&self) -> String { - match *self { - ty::BoundSend => "Send".to_string(), - ty::BoundSized => "Sized".to_string(), - ty::BoundCopy => "Copy".to_string(), - ty::BoundSync => "Sync".to_string(), - } +impl<'tcx> fmt::Debug for ty::MethodParam<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "MethodParam({:?},{})", + self.trait_ref, + self.method_num) } } -impl Repr for Span { - fn repr(&self) -> String { - format!("{:?}", *self) +impl<'tcx> fmt::Debug for ty::MethodObject<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "MethodObject({:?},{},{})", + self.trait_ref, + self.method_num, + self.vtable_index) } } -impl UserString for Rc { - fn user_string(&self) -> String { - let this: &A = &**self; - this.user_string() - } -} - -impl<'tcx> UserString for ty::ParamBounds<'tcx> { - fn user_string(&self) -> String { - let mut result = Vec::new(); - let s = self.builtin_bounds.user_string(); - if !s.is_empty() { - result.push(s); +impl<'tcx> fmt::Display for ty::ParamBounds<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + try!(write!(f, "{}", self.builtin_bounds)); + let mut bounds = self.trait_bounds.iter(); + if self.builtin_bounds.is_empty() { + if let Some(bound) = bounds.next() { + try!(write!(f, "{}", bound)); + } } - for n in &self.trait_bounds { - result.push(n.user_string()); + for bound in bounds { + try!(write!(f, " + {}", bound)); } - result.connect(" + ") + Ok(()) } } -impl<'tcx> Repr for ty::ExistentialBounds<'tcx> { - fn repr(&self) -> String { - let mut res = Vec::new(); +impl<'tcx> fmt::Debug for ty::ExistentialBounds<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut empty = true; + let mut maybe_continue = |f: &mut fmt::Formatter| { + if empty { + empty = false; + Ok(()) + } else { + write!(f, " + ") + } + }; let region_str = self.region_bound.repr(); if !region_str.is_empty() { - res.push(region_str); + try!(maybe_continue(f)); + try!(write!(f, "{}", region_str)); } for bound in &self.builtin_bounds { - res.push(bound.repr()); + try!(maybe_continue(f)); + try!(write!(f, "{:?}", bound)); } for projection_bound in &self.projection_bounds { - res.push(projection_bound.repr()); + try!(maybe_continue(f)); + try!(write!(f, "{:?}", projection_bound)); } - res.connect("+") + Ok(()) } } -impl UserString for ty::BuiltinBounds { - fn user_string(&self) -> String { - self.iter() - .map(|bb| bb.user_string()) - .collect::>() - .connect("+") - .to_string() +impl fmt::Display for ty::BuiltinBounds { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let mut bounds = self.iter(); + if let Some(bound) = bounds.next() { + try!(write!(f, "{:?}", bound)); + for bound in bounds { + try!(write!(f, " + {:?}", bound)); + } + } + Ok(()) } } // The generic impl doesn't work yet because projections are not // normalized under HRTB. -/*impl UserString for ty::Binder - where T: UserString + for<'a> ty::Lift<'a>, - for<'a> >::Lifted: UserString + TypeFoldable<'a> +/*impl fmt::Display for ty::Binder + where T: fmt::Display + for<'a> ty::Lift<'a>, + for<'a> >::Lifted: fmt::Display + TypeFoldable<'a> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } }*/ -impl<'tcx> UserString for ty::Binder> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) - } -} - -impl<'tcx> UserString for ty::Binder> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) +impl<'tcx> fmt::Display for ty::Binder> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } } -impl<'tcx> UserString for ty::Binder> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) +impl<'tcx> fmt::Display for ty::Binder> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } } -impl<'tcx> UserString for ty::Binder> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) +impl<'tcx> fmt::Display for ty::Binder> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } } -impl<'tcx> UserString for ty::Binder> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) +impl<'tcx> fmt::Display for ty::Binder> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } } -impl<'tcx> UserString for ty::Binder, ty::Region>> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) +impl<'tcx> fmt::Display for ty::Binder, ty::Region>> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } } -impl UserString for ty::Binder> { - fn user_string(&self) -> String { - ty::tls::with(|tcx| in_binder(tcx, self, tcx.lift(self))) +impl fmt::Display for ty::Binder> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + ty::tls::with(|tcx| in_binder(f, tcx, self, tcx.lift(self))) } } -impl<'tcx> UserString for ty::TraitRef<'tcx> { - fn user_string(&self) -> String { - parameterized(self.substs, self.def_id, &[], +impl<'tcx> fmt::Display for ty::TraitRef<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + parameterized(f, self.substs, self.def_id, &[], |tcx| ty::lookup_trait_def(tcx, self.def_id).generics.clone()) } } -impl<'tcx> UserString for ty::TyS<'tcx> { - fn user_string(&self) -> String { - fn bare_fn_to_string(opt_def_id: Option, - unsafety: ast::Unsafety, - abi: abi::Abi, - ident: Option, - sig: &ty::PolyFnSig) - -> String { - let mut s = String::new(); - - match unsafety { - ast::Unsafety::Normal => {} - ast::Unsafety::Unsafe => { - s.push_str(&unsafety.to_string()); - s.push(' '); - } - }; - - if abi != abi::Rust { - s.push_str(&format!("extern {} ", abi.to_string())); - }; - - s.push_str("fn"); - - match ident { - Some(i) => { - s.push(' '); - s.push_str(&token::get_ident(i)); - } - _ => { } - } - - push_sig_to_string(&mut s, '(', ')', sig); - - match opt_def_id { - Some(def_id) => { - s.push_str(" {"); - let path_str = ty::tls::with(|tcx| ty::item_path_str(tcx, def_id)); - s.push_str(&path_str[..]); - s.push_str("}"); - } - None => { } - } - - s - } - - fn push_sig_to_string(s: &mut String, - bra: char, - ket: char, - sig: &ty::PolyFnSig) { - s.push(bra); - let strs = sig.0.inputs - .iter() - .map(|a| a.user_string()) - .collect::>(); - s.push_str(&strs.connect(", ")); - if sig.0.variadic { - s.push_str(", ..."); - } - s.push(ket); - - match sig.0.output { - ty::FnConverging(t) => { - if !ty::type_is_nil(t) { - s.push_str(" -> "); - s.push_str(&t.user_string()); - } - } - ty::FnDiverging => { - s.push_str(" -> !"); - } - } - } - - // pretty print the structural type representation: - match self.sty { - TyBool => "bool".to_string(), - TyChar => "char".to_string(), - TyInt(t) => ast_util::int_ty_to_string(t, None).to_string(), - TyUint(t) => ast_util::uint_ty_to_string(t, None).to_string(), - TyFloat(t) => ast_util::float_ty_to_string(t).to_string(), - TyBox(typ) => format!("Box<{}>", typ.user_string()), +impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + TyBool => write!(f, "bool"), + TyChar => write!(f, "char"), + TyInt(t) => write!(f, "{}", ast_util::int_ty_to_string(t, None)), + TyUint(t) => write!(f, "{}", ast_util::uint_ty_to_string(t, None)), + TyFloat(t) => write!(f, "{}", ast_util::float_ty_to_string(t)), + TyBox(typ) => write!(f, "Box<{}>", typ), TyRawPtr(ref tm) => { - format!("*{} {}", match tm.mutbl { + write!(f, "*{} {}", match tm.mutbl { ast::MutMutable => "mut", ast::MutImmutable => "const", - }, tm.ty.user_string()) + }, tm.ty) } TyRef(r, ref tm) => { - let mut buf = "&".to_owned(); - buf.push_str(&r.user_string()); - if buf.len() > 1 { - buf.push_str(" "); + try!(write!(f, "&")); + let s = r.user_string(); + try!(write!(f, "{}", s)); + if !s.is_empty() { + try!(write!(f, " ")); } - buf.push_str(&tm.repr()); - buf - } - TyTuple(ref elems) => { - let strs = elems - .iter() - .map(|elem| elem.user_string()) - .collect::>(); - match &strs[..] { - [ref string] => format!("({},)", string), - strs => format!("({})", strs.connect(", ")) + write!(f, "{}", tm) + } + TyTuple(ref tys) => { + try!(write!(f, "(")); + let mut tys = tys.iter(); + if let Some(&ty) = tys.next() { + try!(write!(f, "{},", ty)); + if let Some(&ty) = tys.next() { + try!(write!(f, " {}", ty)); + for &ty in tys { + try!(write!(f, ", {}", ty)); + } + } } + write!(f, ")") } - TyBareFn(opt_def_id, ref f) => { - bare_fn_to_string(opt_def_id, f.unsafety, f.abi, None, &f.sig) + TyBareFn(opt_def_id, ref bare_fn) => { + if bare_fn.unsafety == ast::Unsafety::Unsafe { + try!(write!(f, "unsafe ")); + } + + if bare_fn.abi != abi::Rust { + try!(write!(f, "extern {} ", bare_fn.abi)); + } + + try!(write!(f, "{}", bare_fn.sig.0)); + + if let Some(def_id) = opt_def_id { + try!(write!(f, " {{{}}}", ty::tls::with(|tcx| { + ty::item_path_str(tcx, def_id) + }))); + } + Ok(()) } - TyInfer(infer_ty) => infer_ty.repr(), - TyError => "[type error]".to_string(), - TyParam(ref param_ty) => param_ty.user_string(), + TyInfer(infer_ty) => write!(f, "{}", infer_ty), + TyError => write!(f, "[type error]"), + TyParam(ref param_ty) => write!(f, "{}", param_ty), TyEnum(did, substs) | TyStruct(did, substs) => { - parameterized(substs, did, &[], + parameterized(f, substs, did, &[], |tcx| ty::lookup_item_type(tcx, did).generics) } - TyTrait(ref data) => { - data.user_string() - } - ty::TyProjection(ref data) => { - format!("<{} as {}>::{}", - data.trait_ref.self_ty().user_string(), - data.trait_ref.user_string(), - data.item_name.user_string()) - } - TyStr => "str".to_string(), + TyTrait(ref data) => write!(f, "{}", data), + ty::TyProjection(ref data) => write!(f, "{}", data), + TyStr => write!(f, "str"), TyClosure(ref did, substs) => ty::tls::with(|tcx| { + try!(write!(f, "[closure")); let closure_tys = tcx.closure_tys.borrow(); - closure_tys.get(did).map(|cty| &cty.sig).and_then(|sig| { + try!(closure_tys.get(did).map(|cty| &cty.sig).and_then(|sig| { tcx.lift(&substs).map(|substs| sig.subst(tcx, substs)) }).map(|sig| { - let mut s = String::new(); - s.push_str("[closure"); - push_sig_to_string(&mut s, '(', ')', &sig); - if verbose() { - s.push_str(&format!(" id={:?}]", did)); - } else { - s.push(']'); - } - s + fn_sig(f, &sig.0.inputs, false, sig.0.output) }).unwrap_or_else(|| { - let id_str = if verbose() { - format!(" id={:?}", did) - } else { - "".to_owned() - }; - if did.krate == ast::LOCAL_CRATE { - let span = ty::tls::with(|tcx| tcx.map.span(did.node)); - format!("[closure {}{}]", span.repr(), id_str) - } else { - format!("[closure{}]", id_str) + try!(write!(f, " {:?}", tcx.map.span(did.node))); } - }) + Ok(()) + })); + if verbose() { + try!(write!(f, " id={:?}", did)); + } + write!(f, "]") }), - TyArray(t, sz) => { - format!("[{}; {}]", t.user_string(), sz) - } - TySlice(t) => { - format!("[{}]", t.user_string()) - } - } - } -} - -impl UserString for ast::Ident { - fn user_string(&self) -> String { - format!("{}", *self) - } -} - -impl Repr for abi::Abi { - fn repr(&self) -> String { - self.to_string() - } -} - -impl UserString for abi::Abi { - fn user_string(&self) -> String { - self.to_string() - } -} - -impl Repr for ty::UpvarId { - fn repr(&self) -> String { - format!("UpvarId({};`{}`;{})", - self.var_id, - ty::tls::with(|tcx| ty::local_var_name_str(tcx, self.var_id)), - self.closure_expr_id) - } -} - -impl Repr for ast::Mutability { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ty::BorrowKind { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ty::UpvarBorrow { - fn repr(&self) -> String { - format!("UpvarBorrow({}, {})", - self.kind.repr(), - self.region.repr()) - } -} - -impl Repr for ty::UpvarCapture { - fn repr(&self) -> String { - match *self { - ty::UpvarCapture::ByValue => format!("ByValue"), - ty::UpvarCapture::ByRef(ref data) => format!("ByRef({})", data.repr()), + TyArray(ty, sz) => write!(f, "[{}; {}]", ty, sz), + TySlice(ty) => write!(f, "[{}]", ty) } } } -impl Repr for ty::IntVid { - fn repr(&self) -> String { - format!("{:?}", self) - } -} - -impl Repr for ty::FloatVid { - fn repr(&self) -> String { - format!("{:?}", self) - } -} - -impl Repr for ty::RegionVid { - fn repr(&self) -> String { - format!("{:?}", self) +impl<'tcx> fmt::Display for ty::TyS<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.sty) } } -impl Repr for ty::TyVid { - fn repr(&self) -> String { - format!("{:?}", self) +impl fmt::Debug for ty::UpvarId { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "UpvarId({};`{}`;{})", + self.var_id, + ty::tls::with(|tcx| ty::local_var_name_str(tcx, self.var_id)), + self.closure_expr_id) } } -impl Repr for ty::IntVarValue { - fn repr(&self) -> String { - format!("{:?}", *self) +impl fmt::Debug for ty::UpvarBorrow { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "UpvarBorrow({:?}, {:?})", + self.kind, self.region) } } -impl Repr for ty::InferTy { - fn repr(&self) -> String { +impl fmt::Display for ty::InferTy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let print_var_ids = verbose(); match *self { - ty::TyVar(ref vid) if print_var_ids => vid.repr(), - ty::IntVar(ref vid) if print_var_ids => vid.repr(), - ty::FloatVar(ref vid) if print_var_ids => vid.repr(), - ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => format!("_"), - ty::FreshTy(v) => format!("FreshTy({})", v), - ty::FreshIntTy(v) => format!("FreshIntTy({})", v), - ty::FreshFloatTy(v) => format!("FreshFloatTy({})", v) + ty::TyVar(ref vid) if print_var_ids => write!(f, "{:?}", vid), + ty::IntVar(ref vid) if print_var_ids => write!(f, "{:?}", vid), + ty::FloatVar(ref vid) if print_var_ids => write!(f, "{:?}", vid), + ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => write!(f, "_"), + ty::FreshTy(v) => write!(f, "FreshTy({})", v), + ty::FreshIntTy(v) => write!(f, "FreshIntTy({})", v), + ty::FreshFloatTy(v) => write!(f, "FreshFloatTy({})", v) } } } -impl Repr for ast::IntTy { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ast::UintTy { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ast::FloatTy { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl Repr for ty::ExplicitSelfCategory { - fn repr(&self) -> String { - match *self { +impl fmt::Display for ty::ExplicitSelfCategory { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + f.write_str(match *self { ty::StaticExplicitSelfCategory => "static", ty::ByValueExplicitSelfCategory => "self", ty::ByReferenceExplicitSelfCategory(_, ast::MutMutable) => { @@ -1260,142 +813,83 @@ impl Repr for ty::ExplicitSelfCategory { } ty::ByReferenceExplicitSelfCategory(_, ast::MutImmutable) => "&self", ty::ByBoxExplicitSelfCategory => "Box", - }.to_owned() - } -} - -impl UserString for ParamTy { - fn user_string(&self) -> String { - format!("{}", token::get_name(self.name)) - } -} - -impl Repr for ParamTy { - fn repr(&self) -> String { - let ident = self.user_string(); - format!("{}/{:?}.{}", ident, self.space, self.idx) - } -} - -impl Repr for (A,B) { - fn repr(&self) -> String { - let &(ref a, ref b) = self; - format!("({},{})", a.repr(), b.repr()) - } -} - -impl Repr for ty::Binder { - fn repr(&self) -> String { - format!("Binder({})", self.0.repr()) + }) } } -impl Repr for HashMap - where K: Hash + Eq + Repr, - V: Repr, - S: HashState, -{ - fn repr(&self) -> String { - format!("HashMap({})", - self.iter() - .map(|(k,v)| format!("{} => {}", k.repr(), v.repr())) - .collect::>() - .connect(", ")) +impl fmt::Display for ty::ParamTy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name) } } -impl<'tcx, T, U> Repr for ty::OutlivesPredicate - where T : Repr + TypeFoldable<'tcx>, - U : Repr + TypeFoldable<'tcx>, -{ - fn repr(&self) -> String { - format!("OutlivesPredicate({}, {})", - self.0.repr(), - self.1.repr()) +impl fmt::Debug for ty::ParamTy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}/{:?}.{}", self, self.space, self.idx) } } -impl<'tcx, T, U> UserString for ty::OutlivesPredicate - where T : UserString + TypeFoldable<'tcx>, - U : UserString + TypeFoldable<'tcx>, +impl<'tcx, T, U> fmt::Display for ty::OutlivesPredicate + where T: fmt::Display, U: fmt::Display { - fn user_string(&self) -> String { - format!("{} : {}", - self.0.user_string(), - self.1.user_string()) - } -} - -impl<'tcx> Repr for ty::EquatePredicate<'tcx> { - fn repr(&self) -> String { - format!("EquatePredicate({}, {})", - self.0.repr(), - self.1.repr()) + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} : {}", self.0, self.1) } } -impl<'tcx> UserString for ty::EquatePredicate<'tcx> { - fn user_string(&self) -> String { - format!("{} == {}", - self.0.user_string(), - self.1.user_string()) +impl<'tcx> fmt::Display for ty::EquatePredicate<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} == {}", self.0, self.1) } } -impl<'tcx> Repr for ty::TraitPredicate<'tcx> { - fn repr(&self) -> String { - format!("TraitPredicate({})", - self.trait_ref.repr()) +impl<'tcx> fmt::Debug for ty::TraitPredicate<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "TraitPredicate({:?})", + self.trait_ref) } } -impl<'tcx> UserString for ty::TraitPredicate<'tcx> { - fn user_string(&self) -> String { - format!("{} : {}", - self.trait_ref.self_ty().user_string(), - self.trait_ref.user_string()) +impl<'tcx> fmt::Display for ty::TraitPredicate<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} : {}", + self.trait_ref.self_ty(), + self.trait_ref) } } -impl<'tcx> UserString for ty::ProjectionPredicate<'tcx> { - fn user_string(&self) -> String { - format!("{} == {}", - self.projection_ty.user_string(), - self.ty.user_string()) +impl<'tcx> fmt::Debug for ty::ProjectionPredicate<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "ProjectionPredicate({:?}, {:?})", + self.projection_ty, + self.ty) } } -impl<'tcx> Repr for ty::ProjectionTy<'tcx> { - fn repr(&self) -> String { - format!("{}::{}", - self.trait_ref.repr(), - self.item_name.repr()) +impl<'tcx> fmt::Display for ty::ProjectionPredicate<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{} == {}", + self.projection_ty, + self.ty) } } -impl<'tcx> UserString for ty::ProjectionTy<'tcx> { - fn user_string(&self) -> String { - format!("<{} as {}>::{}", - self.trait_ref.self_ty().user_string(), - self.trait_ref.user_string(), - self.item_name.user_string()) +impl<'tcx> fmt::Display for ty::ProjectionTy<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{:?}::{}", + self.trait_ref, + self.item_name) } } -impl<'tcx> UserString for ty::Predicate<'tcx> { - fn user_string(&self) -> String { +impl<'tcx> fmt::Display for ty::Predicate<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ty::Predicate::Trait(ref data) => data.user_string(), - ty::Predicate::Equate(ref predicate) => predicate.user_string(), - ty::Predicate::RegionOutlives(ref predicate) => predicate.user_string(), - ty::Predicate::TypeOutlives(ref predicate) => predicate.user_string(), - ty::Predicate::Projection(ref predicate) => predicate.user_string(), + ty::Predicate::Trait(ref data) => write!(f, "{}", data), + ty::Predicate::Equate(ref predicate) => write!(f, "{}", predicate), + ty::Predicate::RegionOutlives(ref predicate) => write!(f, "{}", predicate), + ty::Predicate::TypeOutlives(ref predicate) => write!(f, "{}", predicate), + ty::Predicate::Projection(ref predicate) => write!(f, "{}", predicate), } } } - -impl Repr for ast::Unsafety { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 93b16795fe8d0..63d9383d69d55 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -34,9 +34,10 @@ use rustc::middle::mem_categorization as mc; use rustc::middle::region; use rustc::middle::ty::{self, Ty}; use rustc::util::ppaux::{Repr, UserString}; + +use std::fmt; use std::mem; use std::rc::Rc; -use std::string::String; use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; @@ -329,7 +330,7 @@ impl<'tcx> Loan<'tcx> { } } -#[derive(Eq, Hash, Debug)] +#[derive(Eq, Hash)] pub struct LoanPath<'tcx> { kind: LoanPathKind<'tcx>, ty: ty::Ty<'tcx>, @@ -369,7 +370,7 @@ const DOWNCAST_PRINTED_OPERATOR: &'static str = " as "; // information that is not relevant to loan-path analysis. (In // particular, the distinction between how precisely a array-element // is tracked is irrelevant here.) -#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] +#[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum InteriorKind { InteriorField(mc::FieldName), InteriorElement(mc::ElementKind), @@ -1148,39 +1149,38 @@ impl DataFlowOperator for LoanDataFlowOperator { } } -impl<'tcx> Repr for InteriorKind { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for InteriorKind { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - InteriorField(mc::NamedField(fld)) => - format!("{}", token::get_name(fld)), - InteriorField(mc::PositionalField(i)) => format!("#{}", i), - InteriorElement(..) => "[]".to_string(), + InteriorField(mc::NamedField(fld)) => write!(f, "{}", fld), + InteriorField(mc::PositionalField(i)) => write!(f, "#{}", i), + InteriorElement(..) => write!(f, "[]"), } } } -impl<'tcx> Repr for Loan<'tcx> { - fn repr(&self) -> String { - format!("Loan_{}({}, {:?}, {:?}-{:?}, {})", - self.index, - self.loan_path.repr(), - self.kind, - self.gen_scope, - self.kill_scope, - self.restricted_paths.repr()) +impl<'tcx> fmt::Debug for Loan<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "Loan_{}({:?}, {:?}, {:?}-{:?}, {:?})", + self.index, + self.loan_path, + self.kind, + self.gen_scope, + self.kill_scope, + self.restricted_paths) } } -impl<'tcx> Repr for LoanPath<'tcx> { - fn repr(&self) -> String { +impl<'tcx> fmt::Debug for LoanPath<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.kind { LpVar(id) => { - format!("$({})", ty::tls::with(|tcx| tcx.map.node_to_string(id))) + write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_string(id))) } LpUpvar(ty::UpvarId{ var_id, closure_expr_id }) => { let s = ty::tls::with(|tcx| tcx.map.node_to_string(var_id)); - format!("$({} captured by id={})", s, closure_expr_id) + write!(f, "$({} captured by id={})", s, closure_expr_id) } LpDowncast(ref lp, variant_def_id) => { @@ -1189,30 +1189,30 @@ impl<'tcx> Repr for LoanPath<'tcx> { } else { variant_def_id.repr() }; - format!("({}{}{})", lp.repr(), DOWNCAST_PRINTED_OPERATOR, variant_str) + write!(f, "({:?}{}{})", lp, DOWNCAST_PRINTED_OPERATOR, variant_str) } LpExtend(ref lp, _, LpDeref(_)) => { - format!("{}.*", lp.repr()) + write!(f, "{:?}.*", lp) } LpExtend(ref lp, _, LpInterior(ref interior)) => { - format!("{}.{}", lp.repr(), interior.repr()) + write!(f, "{:?}.{:?}", lp, interior) } } } } -impl<'tcx> UserString for LoanPath<'tcx> { - fn user_string(&self) -> String { +impl<'tcx> fmt::Display for LoanPath<'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.kind { LpVar(id) => { - format!("$({})", ty::tls::with(|tcx| tcx.map.node_to_user_string(id))) + write!(f, "$({})", ty::tls::with(|tcx| tcx.map.node_to_user_string(id))) } LpUpvar(ty::UpvarId{ var_id, closure_expr_id: _ }) => { let s = ty::tls::with(|tcx| tcx.map.node_to_user_string(var_id)); - format!("$({} captured by closure)", s) + write!(f, "$({} captured by closure)", s) } LpDowncast(ref lp, variant_def_id) => { @@ -1221,15 +1221,15 @@ impl<'tcx> UserString for LoanPath<'tcx> { } else { variant_def_id.repr() }; - format!("({}{}{})", lp.user_string(), DOWNCAST_PRINTED_OPERATOR, variant_str) + write!(f, "({}{}{})", lp, DOWNCAST_PRINTED_OPERATOR, variant_str) } LpExtend(ref lp, _, LpDeref(_)) => { - format!("{}.*", lp.user_string()) + write!(f, "{}.*", lp) } LpExtend(ref lp, _, LpInterior(ref interior)) => { - format!("{}.{}", lp.user_string(), interior.repr()) + write!(f, "{}.{:?}", lp, interior) } } } diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 16f35a8c10a8b..658d5166ef5fc 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -227,8 +227,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn make_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> bool { match infer::mk_subty(self.infcx, true, infer::Misc(DUMMY_SP), a, b) { Ok(_) => true, - Err(ref e) => panic!("Encountered error: {}", - ty::type_err_to_str(self.infcx.tcx, e)) + Err(ref e) => panic!("Encountered error: {}", e) } } @@ -376,8 +375,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn make_lub_ty(&self, t1: Ty<'tcx>, t2: Ty<'tcx>) -> Ty<'tcx> { match self.lub().relate(&t1, &t2) { Ok(t) => t, - Err(ref e) => panic!("unexpected error computing LUB: {}", - ty::type_err_to_str(self.infcx.tcx, e)) + Err(ref e) => panic!("unexpected error computing LUB: {}", e) } } @@ -390,7 +388,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { panic!("unexpected error computing sub({},{}): {}", t1.repr(), t2.repr(), - ty::type_err_to_str(self.infcx.tcx, e)); + e); } } } @@ -415,8 +413,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { self.assert_eq(t, t_lub); } Err(ref e) => { - panic!("unexpected error in LUB: {}", - ty::type_err_to_str(self.infcx.tcx, e)) + panic!("unexpected error in LUB: {}", e) } } } diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 065aad96f7943..7f68e654c2c53 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -221,6 +221,7 @@ use util::ppaux::{self, Repr}; use std; use std::cmp::Ordering; +use std::fmt; use std::rc::Rc; use syntax::ast; use syntax::ast::{DUMMY_NODE_ID, NodeId}; @@ -371,13 +372,13 @@ struct Match<'a, 'p: 'a, 'blk: 'a, 'tcx: 'blk> { pat_renaming_map: Option<&'a FnvHashMap<(NodeId, Span), NodeId>> } -impl<'a, 'p, 'blk, 'tcx> Repr for Match<'a, 'p, 'blk, 'tcx> { - fn repr(&self) -> String { +impl<'a, 'p, 'blk, 'tcx> fmt::Debug for Match<'a, 'p, 'blk, 'tcx> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { if ppaux::verbose() { // for many programs, this just take too long to serialize - self.pats.repr() + write!(f, "{:?}", self.pats) } else { - format!("{} pats", self.pats.len()) + write!(f, "{} pats", self.pats.len()) } } } diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 1f8e7e07568eb..22582787c7c0b 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -64,7 +64,7 @@ pub use trans::context::CrateContext; /// subtyping, but they are anonymized and normalized as well). This /// is a stronger, caching version of `ty_fold::erase_regions`. pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { let value1 = value.fold_with(&mut RegionEraser(cx)); debug!("erase_regions({}) = {}", @@ -88,7 +88,7 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T } fn fold_binder(&mut self, t: &ty::Binder) -> ty::Binder - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { let u = ty::anonymize_late_bound_regions(self.tcx(), t); ty_fold::super_fold_binder(self, &u) @@ -518,7 +518,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { } pub fn monomorphize(&self, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + HasProjectionTypes { monomorphize::apply_param_substs(self.ccx.tcx(), self.param_substs, @@ -624,7 +624,7 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { } pub fn monomorphize(&self, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + HasProjectionTypes { monomorphize::apply_param_substs(self.tcx(), self.fcx.param_substs, @@ -1135,7 +1135,7 @@ pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span, fulfill_cx: &mut traits::FulfillmentContext<'tcx>, result: &T) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { match drain_fulfillment_cx(infcx, fulfill_cx, result) { Ok(v) => v, @@ -1159,7 +1159,7 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &infer::InferCtxt<'a,'tcx>, fulfill_cx: &mut traits::FulfillmentContext<'tcx>, result: &T) -> StdResult>> - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { debug!("drain_fulfillment_cx(result={})", result.repr()); diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index e885f56ef8e42..e0ac4391d67d1 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -205,19 +205,6 @@ impl<'tcx> DropGlueKind<'tcx> { } } -impl<'tcx> Repr for DropGlueKind<'tcx> { - fn repr(&self) -> String { - match *self { - DropGlueKind::Ty(ty) => { - format!("DropGlueKind::Ty({})", ty.repr()) - } - DropGlueKind::TyContents(ty) => { - format!("DropGlueKind::TyContents({})", ty.repr()) - } - } - } -} - fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKind<'tcx>) -> ValueRef { debug!("make drop glue for {}", g.repr()); diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index 3744716960009..4a81610dd852f 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -303,7 +303,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>, param_substs: &Substs<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + HasProjectionTypes { let substituted = value.subst(tcx, param_substs); normalize_associated_type(tcx, &substituted) @@ -314,7 +314,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>, /// and hence we can be sure that all associated types will be /// completely normalized away. pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + HasProjectionTypes + Clone + where T : TypeFoldable<'tcx> + HasProjectionTypes { debug!("normalize_associated_type(t={})", value.repr()); diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index b7516530e6f18..dee8eefd9da5f 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -2106,7 +2106,7 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt, ast_bounds: &'a [ast::TyParamBound]) -> PartitionedBounds<'a> { - let mut builtin_bounds = ty::empty_builtin_bounds(); + let mut builtin_bounds = ty::BuiltinBounds::empty(); let mut region_bounds = Vec::new(); let mut trait_bounds = Vec::new(); for ast_bound in ast_bounds { diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs index 5e25404bf738d..ec5752fb50fff 100644 --- a/src/librustc_typeck/check/assoc.rs +++ b/src/librustc_typeck/check/assoc.rs @@ -24,7 +24,7 @@ pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, body_id: ast::NodeId, value: &T) -> T - where T : TypeFoldable<'tcx> + HasProjectionTypes + Clone + Repr + where T : TypeFoldable<'tcx> + HasProjectionTypes { debug!("normalize_associated_types_in(value={})", value.repr()); let mut selcx = SelectionContext::new(infcx, typer); diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index a5422e1e58e57..da1c44604f9fc 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -328,6 +328,7 @@ fn write_overloaded_call_method_map<'a,'tcx>(fcx: &FnCtxt<'a, 'tcx>, fcx.inh.method_map.borrow_mut().insert(method_call, method_callee); } +#[derive(Debug)] struct CallResolution<'tcx> { call_expr: &'tcx ast::Expr, callee_expr: &'tcx ast::Expr, @@ -337,19 +338,6 @@ struct CallResolution<'tcx> { closure_def_id: ast::DefId, } -impl<'tcx> Repr for CallResolution<'tcx> { - fn repr(&self) -> String { - format!("CallResolution(call_expr={}, callee_expr={}, adjusted_ty={}, \ - autoderefs={}, fn_sig={}, closure_def_id={})", - self.call_expr.repr(), - self.callee_expr.repr(), - self.adjusted_ty.repr(), - self.autoderefs, - self.fn_sig.repr(), - self.closure_def_id.repr()) - } -} - impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> { fn resolve<'a>(&mut self, fcx: &FnCtxt<'a,'tcx>) { debug!("DeferredCallResolution::resolve() {}", diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index eb50b231155bb..3c38f471c8535 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -341,7 +341,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, span_err!(tcx.sess, impl_m_span, E0053, "method `{}` has an incompatible type for trait: {}", token::get_name(trait_m.name), - ty::type_err_to_str(tcx, &terr)); + terr); return; } } @@ -487,7 +487,7 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, "implemented const `{}` has an incompatible type for \ trait: {}", token::get_name(trait_c.name), - ty::type_err_to_str(tcx, &terr)); + terr); return; } } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 2b8394f2e1659..2b5fb524b524f 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -657,7 +657,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { } fn replace_late_bound_regions_with_fresh_var(&self, value: &ty::Binder) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { self.infcx().replace_late_bound_regions_with_fresh_var( self.span, infer::FnCall, value).0 diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index eeccb576749cb..d71b91762e920 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -46,18 +46,21 @@ struct ProbeContext<'a, 'tcx:'a> { static_candidates: Vec, } +#[derive(Debug)] struct CandidateStep<'tcx> { self_ty: Ty<'tcx>, autoderefs: usize, unsize: bool } +#[derive(Debug)] struct Candidate<'tcx> { xform_self_ty: Ty<'tcx>, item: ty::ImplOrTraitItem<'tcx>, kind: CandidateKind<'tcx>, } +#[derive(Debug)] enum CandidateKind<'tcx> { InherentImplCandidate(/* Impl */ ast::DefId, subst::Substs<'tcx>, /* Normalize obligations */ Vec>), @@ -70,6 +73,7 @@ enum CandidateKind<'tcx> { ProjectionCandidate(ast::DefId, ItemIndex), } +#[derive(Debug)] pub struct Pick<'tcx> { pub item: ty::ImplOrTraitItem<'tcx>, pub kind: PickKind<'tcx>, @@ -1264,7 +1268,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { /// and/or tracking the substitution and /// so forth. fn erase_late_bound_regions(&self, value: &ty::Binder) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { ty::erase_late_bound_regions(self.tcx(), value) } @@ -1370,59 +1374,3 @@ impl<'tcx> Candidate<'tcx> { } } } - -impl<'tcx> Repr for Candidate<'tcx> { - fn repr(&self) -> String { - format!("Candidate(xform_self_ty={}, kind={})", - self.xform_self_ty.repr(), - self.kind.repr()) - } -} - -impl<'tcx> Repr for CandidateKind<'tcx> { - fn repr(&self) -> String { - match *self { - InherentImplCandidate(ref a, ref b, ref c) => - format!("InherentImplCandidate({},{},{})", a.repr(), b.repr(), - c.repr()), - ObjectCandidate(a, b, c) => - format!("ObjectCandidate({},{},{})", a.repr(), b, c), - ExtensionImplCandidate(ref a, ref b, ref c, ref d, ref e) => - format!("ExtensionImplCandidate({},{},{},{},{})", a.repr(), b.repr(), - c.repr(), d, e.repr()), - ClosureCandidate(ref a, ref b) => - format!("ClosureCandidate({},{})", a.repr(), b), - WhereClauseCandidate(ref a, ref b) => - format!("WhereClauseCandidate({},{})", a.repr(), b), - ProjectionCandidate(ref a, ref b) => - format!("ProjectionCandidate({},{})", a.repr(), b), - } - } -} - -impl<'tcx> Repr for CandidateStep<'tcx> { - fn repr(&self) -> String { - format!("CandidateStep({}, autoderefs={}, unsize={})", - self.self_ty.repr(), - self.autoderefs, - self.unsize) - } -} - -impl<'tcx> Repr for PickKind<'tcx> { - fn repr(&self) -> String { - format!("{:?}", self) - } -} - -impl<'tcx> Repr for Pick<'tcx> { - fn repr(&self) -> String { - format!("Pick(item={}, autoderefs={}, - autoref={}, unsize={}, kind={:?})", - self.item.repr(), - self.autoderefs, - self.autoref.repr(), - self.unsize.repr(), - self.kind) - } -} diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b728c01291939..cc57ec8a8cd8f 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -193,7 +193,7 @@ type DeferredCallResolutionHandler<'tcx> = Box+'tcx /// When type-checking an expression, we propagate downward /// whatever type hint we are able in the form of an `Expectation`. -#[derive(Copy, Clone)] +#[derive(Copy, Clone, Debug)] pub enum Expectation<'tcx> { /// We know nothing about what type this expression should have. NoExpectation, @@ -398,7 +398,7 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> { body_id: ast::NodeId, value: &T) -> T - where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr + where T : TypeFoldable<'tcx> + HasProjectionTypes { let mut fulfillment_cx = self.fulfillment_cx.borrow_mut(); assoc::normalize_associated_types_in(&self.infcx, @@ -1444,7 +1444,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { substs: &Substs<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr + where T : TypeFoldable<'tcx> + HasProjectionTypes { let value = value.subst(self.tcx(), substs); let result = self.normalize_associated_types_in(span, &value); @@ -1470,7 +1470,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn normalize_associated_types_in(&self, span: Span, value: &T) -> T - where T : TypeFoldable<'tcx> + Clone + HasProjectionTypes + Repr + where T : TypeFoldable<'tcx> + HasProjectionTypes { self.inh.normalize_associated_types_in(self, span, self.body_id, value) } @@ -3605,8 +3605,6 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, type_and_substs.ty) { Ok(()) => {} Err(type_error) => { - let type_error_description = - ty::type_err_to_str(tcx, &type_error); span_err!(fcx.tcx().sess, path.span, E0235, "structure constructor specifies a \ structure of type `{}`, but this \ @@ -3616,7 +3614,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, fcx.infcx() .ty_to_string( actual_structure_type), - type_error_description); + type_error); ty::note_and_explain_type_err(tcx, &type_error, path.span); } } @@ -3907,20 +3905,6 @@ impl<'tcx> Expectation<'tcx> { } } -impl<'tcx> Repr for Expectation<'tcx> { - fn repr(&self) -> String { - match *self { - NoExpectation => format!("NoExpectation"), - ExpectHasType(t) => format!("ExpectHasType({})", - t.repr()), - ExpectCastableToType(t) => format!("ExpectCastableToType({})", - t.repr()), - ExpectRvalueLikeUnsized(t) => format!("ExpectRvalueLikeUnsized({})", - t.repr()), - } - } -} - pub fn check_decl_initializer<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, local: &'tcx ast::Local, init: &'tcx ast::Expr) diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs index bd7b212d32063..7bcd3ddf59048 100644 --- a/src/librustc_typeck/check/wf.rs +++ b/src/librustc_typeck/check/wf.rs @@ -536,7 +536,7 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> { } fn fold_binder(&mut self, binder: &ty::Binder) -> ty::Binder - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { self.binding_count += 1; let value = liberate_late_bound_regions( diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 4bb9aa4955779..9987b884cf282 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -2235,7 +2235,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( scope: region::DestructionScopeData, value: &T) -> T - where T : TypeFoldable<'tcx> + Repr + where T : TypeFoldable<'tcx> { /*! * Convert early-bound regions into free regions; normally this is done by diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 3f779d6794482..b56bb895b9ed6 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -199,11 +199,7 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>, match result { Ok(_) => true, Err(ref terr) => { - span_err!(tcx.sess, span, E0211, - "{}: {}", - msg(), - ty::type_err_to_str(tcx, - terr)); + span_err!(tcx.sess, span, E0211, "{}: {}", msg(), terr); ty::note_and_explain_type_err(tcx, terr, span); false } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 77409f2746a57..d40a9522f23a9 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -522,7 +522,7 @@ pub enum TyParamBound { impl TyParamBound { fn maybe_sized(cx: &DocContext) -> TyParamBound { use syntax::ast::TraitBoundModifier as TBM; - let mut sized_bound = ty::BuiltinBound::BoundSized.clean(cx); + let mut sized_bound = ty::BoundSized.clean(cx); if let TyParamBound::TraitBound(_, ref mut tbm) = sized_bound { *tbm = TBM::Maybe }; diff --git a/src/test/compile-fail/object-lifetime-default.rs b/src/test/compile-fail/object-lifetime-default.rs index ac03c085b7b6c..b71eadd6d08af 100644 --- a/src/test/compile-fail/object-lifetime-default.rs +++ b/src/test/compile-fail/object-lifetime-default.rs @@ -29,6 +29,6 @@ struct E<'a,'b:'a,T:'b>(&'a T, &'b T); //~ ERROR 'b struct F<'a,'b,T:'a,U:'b>(&'a T, &'b U); //~ ERROR 'a,'b #[rustc_object_lifetime_default] -struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Ambiguous +struct G<'a,'b,T:'a,U:'a+'b>(&'a T, &'b U); //~ ERROR 'a,Some(Ambiguous) fn main() { } From 0b58fdf9252ccd08bf610e13625f49380e769e06 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Thu, 18 Jun 2015 20:25:05 +0300 Subject: [PATCH 46/48] rustc: remove Repr and UserString. --- src/librustc/middle/astconv_util.rs | 3 +- src/librustc/middle/astencode.rs | 5 +- src/librustc/middle/check_match.rs | 7 +- src/librustc/middle/check_rvalues.rs | 5 +- src/librustc/middle/const_eval.rs | 9 +- src/librustc/middle/effect.rs | 17 +- src/librustc/middle/expr_use_visitor.rs | 75 +++-- src/librustc/middle/free_region.rs | 11 +- src/librustc/middle/implicator.rs | 25 +- src/librustc/middle/infer/bivariate.rs | 5 +- src/librustc/middle/infer/combine.rs | 19 +- src/librustc/middle/infer/equate.rs | 11 +- src/librustc/middle/infer/error_reporting.rs | 31 +- src/librustc/middle/infer/glb.rs | 7 +- .../middle/infer/higher_ranked/mod.rs | 77 +++-- src/librustc/middle/infer/lattice.rs | 7 +- src/librustc/middle/infer/lub.rs | 7 +- src/librustc/middle/infer/mod.rs | 48 ++- .../middle/infer/region_inference/graphviz.rs | 5 +- .../middle/infer/region_inference/mod.rs | 139 +++++---- src/librustc/middle/infer/resolve.rs | 5 +- src/librustc/middle/infer/sub.rs | 9 +- src/librustc/middle/intrinsicck.rs | 11 +- src/librustc/middle/mem_categorization.rs | 76 +++-- src/librustc/middle/stability.rs | 5 +- src/librustc/middle/subst.rs | 23 +- src/librustc/middle/traits/coherence.rs | 47 ++- src/librustc/middle/traits/error_reporting.rs | 66 ++-- src/librustc/middle/traits/fulfill.rs | 27 +- src/librustc/middle/traits/mod.rs | 33 +- src/librustc/middle/traits/object_safety.rs | 9 +- src/librustc/middle/traits/project.rs | 102 ++++--- src/librustc/middle/traits/select.rs | 283 +++++++++--------- src/librustc/middle/traits/util.rs | 9 +- src/librustc/middle/ty.rs | 67 ++--- src/librustc/middle/ty_fold.rs | 19 +- src/librustc/middle/ty_match.rs | 11 +- src/librustc/middle/ty_relate/mod.rs | 25 +- src/librustc/util/ppaux.rs | 30 +- src/librustc_borrowck/borrowck/check_loans.rs | 47 ++- src/librustc_borrowck/borrowck/fragments.rs | 34 +-- .../borrowck/gather_loans/gather_moves.rs | 12 +- .../borrowck/gather_loans/lifetime.rs | 12 +- .../borrowck/gather_loans/mod.rs | 40 +-- .../borrowck/gather_loans/move_error.rs | 5 +- .../borrowck/gather_loans/restrictions.rs | 3 +- src/librustc_borrowck/borrowck/mod.rs | 13 +- src/librustc_borrowck/borrowck/move_data.rs | 26 +- src/librustc_driver/pretty.rs | 3 +- src/librustc_driver/test.rs | 60 ++-- src/librustc_lint/builtin.rs | 4 +- src/librustc_trans/back/link.rs | 3 +- src/librustc_trans/save/dump_csv.rs | 6 +- src/librustc_trans/save/mod.rs | 4 +- src/librustc_trans/trans/_match.rs | 39 ++- src/librustc_trans/trans/adt.rs | 6 +- src/librustc_trans/trans/base.rs | 29 +- src/librustc_trans/trans/callee.rs | 53 ++-- src/librustc_trans/trans/cleanup.rs | 15 +- src/librustc_trans/trans/closure.rs | 15 +- src/librustc_trans/trans/common.rs | 47 ++- src/librustc_trans/trans/consts.rs | 35 ++- src/librustc_trans/trans/context.rs | 5 +- src/librustc_trans/trans/controlflow.rs | 9 +- src/librustc_trans/trans/datum.rs | 5 +- .../trans/debuginfo/metadata.rs | 19 +- .../trans/debuginfo/type_names.rs | 3 +- src/librustc_trans/trans/declare.rs | 15 +- src/librustc_trans/trans/expr.rs | 59 ++-- src/librustc_trans/trans/foreign.rs | 37 ++- src/librustc_trans/trans/glue.rs | 19 +- src/librustc_trans/trans/intrinsic.rs | 13 +- src/librustc_trans/trans/meth.rs | 73 +++-- src/librustc_trans/trans/monomorphize.rs | 31 +- src/librustc_trans/trans/tvec.rs | 19 +- src/librustc_trans/trans/type_of.rs | 27 +- src/librustc_typeck/astconv.rs | 76 +++-- src/librustc_typeck/check/_match.rs | 9 +- src/librustc_typeck/check/assoc.rs | 9 +- src/librustc_typeck/check/callee.rs | 15 +- src/librustc_typeck/check/cast.rs | 9 +- src/librustc_typeck/check/closure.rs | 43 ++- src/librustc_typeck/check/coercion.rs | 41 ++- src/librustc_typeck/check/compare_method.rs | 81 +++-- src/librustc_typeck/check/demand.rs | 7 +- src/librustc_typeck/check/dropck.rs | 67 ++--- src/librustc_typeck/check/method/confirm.rs | 74 +++-- src/librustc_typeck/check/method/mod.rs | 35 ++- src/librustc_typeck/check/method/probe.rs | 110 +++---- src/librustc_typeck/check/method/suggest.rs | 13 +- src/librustc_typeck/check/mod.rs | 157 +++++----- src/librustc_typeck/check/op.rs | 37 ++- src/librustc_typeck/check/regionck.rs | 163 +++++----- src/librustc_typeck/check/upvar.rs | 33 +- src/librustc_typeck/check/wf.rs | 15 +- src/librustc_typeck/check/writeback.rs | 21 +- src/librustc_typeck/coherence/mod.rs | 61 ++-- src/librustc_typeck/coherence/orphan.rs | 11 +- src/librustc_typeck/coherence/overlap.rs | 15 +- src/librustc_typeck/coherence/unsafety.rs | 5 +- src/librustc_typeck/collect.rs | 67 ++--- src/librustc_typeck/lib.rs | 21 +- src/librustc_typeck/variance.rs | 29 +- 103 files changed, 1637 insertions(+), 1802 deletions(-) diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index d955cda9b77b7..33d37b285890a 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -17,7 +17,6 @@ use middle::def; use middle::ty::{self, Ty}; use syntax::ast; -use util::ppaux::Repr; pub const NO_REGIONS: usize = 1; pub const NO_TPS: usize = 2; @@ -63,7 +62,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty) let def = match tcx.def_map.borrow().get(&ast_ty.id) { None => { tcx.sess.span_bug(ast_ty.span, - &format!("unbound path {}", path.repr())) + &format!("unbound path {:?}", path)) } Some(d) => d.full_def() }; diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index a6386d941f5fe..21e2ad198810e 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -31,7 +31,6 @@ use middle::privacy::{AllPublic, LastMod}; use middle::subst; use middle::subst::VecPerParamSpace; use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin}; -use util::ppaux::Repr; use syntax::{ast, ast_util, codemap, fold}; use syntax::codemap::Span; @@ -1623,8 +1622,8 @@ fn decode_side_tables(dcx: &DecodeContext, } c::tag_table_node_type => { let ty = val_dsr.read_ty(dcx); - debug!("inserting ty for node {}: {}", - id, ty.repr()); + debug!("inserting ty for node {}: {:?}", + id, ty); dcx.tcx.node_type_insert(id, ty); } c::tag_table_item_subst => { diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index 8982a45cee8f4..e1f8e24253b39 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -36,7 +36,6 @@ use syntax::print::pprust::pat_to_string; use syntax::parse::token; use syntax::ptr::P; use syntax::visit::{self, Visitor, FnKind}; -use util::ppaux::UserString; use util::nodemap::FnvHashMap; pub const DUMMY_WILD_PAT: &'static Pat = &Pat { @@ -210,7 +209,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) { // We know the type is inhabited, so this must be wrong span_err!(cx.tcx.sess, ex.span, E0002, "non-exhaustive patterns: type {} is non-empty", - pat_ty.user_string()); + pat_ty); } // If the type *is* empty, it's vacuously exhaustive return; @@ -243,11 +242,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat) span_warn!(cx.tcx.sess, p.span, E0170, "pattern binding `{}` is named the same as one \ of the variants of the type `{}`", - &token::get_ident(ident.node), pat_ty.user_string()); + &token::get_ident(ident.node), pat_ty); fileline_help!(cx.tcx.sess, p.span, "if you meant to match on a variant, \ consider making the path in the pattern qualified: `{}::{}`", - pat_ty.user_string(), &token::get_ident(ident.node)); + pat_ty, &token::get_ident(ident.node)); } } } diff --git a/src/librustc/middle/check_rvalues.rs b/src/librustc/middle/check_rvalues.rs index a3881327b96ad..f5934751c58b2 100644 --- a/src/librustc/middle/check_rvalues.rs +++ b/src/librustc/middle/check_rvalues.rs @@ -15,7 +15,6 @@ use middle::expr_use_visitor as euv; use middle::mem_categorization as mc; use middle::ty::ParameterEnvironment; use middle::ty; -use util::ppaux::{Repr, UserString}; use syntax::ast; use syntax::codemap::Span; @@ -59,11 +58,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> { span: Span, cmt: mc::cmt<'tcx>, _: euv::ConsumeMode) { - debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr()); + debug!("consume; cmt: {:?}; type: {:?}", *cmt, cmt.ty); if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) { span_err!(self.tcx.sess, span, E0161, "cannot move a value of type {0}: the size of {0} cannot be statically determined", - cmt.ty.user_string()); + cmt.ty); } } diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 657115e781925..23ad3f0d4b904 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -23,7 +23,6 @@ use middle::pat_util::def_to_path; use middle::ty::{self, Ty}; use middle::astconv_util::ast_ty_to_prim_ty; use util::num::ToPrimitive; -use util::ppaux::Repr; use syntax::ast::{self, Expr}; use syntax::ast_util; @@ -1030,8 +1029,8 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, rcvr_self, Vec::new())); let trait_substs = tcx.mk_substs(trait_substs); - debug!("resolve_trait_associated_const: trait_substs={}", - trait_substs.repr()); + debug!("resolve_trait_associated_const: trait_substs={:?}", + trait_substs); let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id, substs: trait_substs }); @@ -1052,10 +1051,10 @@ fn resolve_trait_associated_const<'a, 'tcx: 'a>(tcx: &'a ty::ctxt<'tcx>, } Err(e) => { tcx.sess.span_bug(ti.span, - &format!("Encountered error `{}` when trying \ + &format!("Encountered error `{:?}` when trying \ to select an implementation for \ constant trait item reference.", - e.repr())) + e)) } }; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index 7a593da3432c9..bb63ec42d8c0c 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -15,7 +15,6 @@ use self::UnsafeContext::*; use middle::def; use middle::ty::{self, Ty}; use middle::ty::MethodCall; -use util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; @@ -66,8 +65,8 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> { ast::ExprIndex(ref base, _) => ty::node_id_to_type(self.tcx, base.id), _ => return }; - debug!("effect: checking index with base type {}", - base_type.repr()); + debug!("effect: checking index with base type {:?}", + base_type); match base_type.sty { ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty { span_err!(self.tcx.sess, e.span, E0134, @@ -142,8 +141,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { ast::ExprMethodCall(_, _, _) => { let method_call = MethodCall::expr(expr.id); let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty; - debug!("effect: method call case, base type is {}", - base_type.repr()); + debug!("effect: method call case, base type is {:?}", + base_type); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "invocation of unsafe method") @@ -151,16 +150,16 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { } ast::ExprCall(ref base, _) => { let base_type = ty::node_id_to_type(self.tcx, base.id); - debug!("effect: call case, base type is {}", - base_type.repr()); + debug!("effect: call case, base type is {:?}", + base_type); if type_is_unsafe_function(base_type) { self.require_unsafe(expr.span, "call to unsafe function") } } ast::ExprUnary(ast::UnDeref, ref base) => { let base_type = ty::node_id_to_type(self.tcx, base.id); - debug!("effect: unary case, base type is {}", - base_type.repr()); + debug!("effect: unary case, base type is {:?}", + base_type); if let ty::TyRawPtr(_) = base_type.sty { self.require_unsafe(expr.span, "dereference of raw pointer") } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 7d4f93fb1326f..ab67c68be124b 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -27,7 +27,6 @@ use middle::ty::{self}; use middle::ty::{MethodCall, MethodObject, MethodTraitObject}; use middle::ty::{MethodOrigin, MethodParam, MethodTypeParam}; use middle::ty::{MethodStatic, MethodStaticClosure}; -use util::ppaux::Repr; use syntax::{ast, ast_util}; use syntax::ptr::P; @@ -362,8 +361,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { consume_id: ast::NodeId, consume_span: Span, cmt: mc::cmt<'tcx>) { - debug!("delegate_consume(consume_id={}, cmt={})", - consume_id, cmt.repr()); + debug!("delegate_consume(consume_id={}, cmt={:?})", + consume_id, cmt); let mode = copy_or_move(self.typer, &cmt, DirectRefMove); self.delegate.consume(consume_id, consume_span, cmt, mode); @@ -376,7 +375,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } pub fn consume_expr(&mut self, expr: &ast::Expr) { - debug!("consume_expr(expr={})", expr.repr()); + debug!("consume_expr(expr={:?})", expr); let cmt = return_if_err!(self.mc.cat_expr(expr)); self.delegate_consume(expr.id, expr.span, cmt); @@ -397,8 +396,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { r: ty::Region, bk: ty::BorrowKind, cause: LoanCause) { - debug!("borrow_expr(expr={}, r={}, bk={})", - expr.repr(), r.repr(), bk.repr()); + debug!("borrow_expr(expr={:?}, r={:?}, bk={:?})", + expr, r, bk); let cmt = return_if_err!(self.mc.cat_expr(expr)); self.delegate.borrow(expr.id, expr.span, cmt, r, bk, cause); @@ -414,7 +413,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } pub fn walk_expr(&mut self, expr: &ast::Expr) { - debug!("walk_expr(expr={})", expr.repr()); + debug!("walk_expr(expr={:?})", expr); self.walk_adjustment(expr); @@ -618,8 +617,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { fn walk_callee(&mut self, call: &ast::Expr, callee: &ast::Expr) { let callee_ty = return_if_err!(self.typer.expr_ty_adjusted(callee)); - debug!("walk_callee: callee={} callee_ty={}", - callee.repr(), callee_ty.repr()); + debug!("walk_callee: callee={:?} callee_ty={:?}", + callee, callee_ty); let call_scope = region::CodeExtent::from_node_id(call.id); match callee_ty.sty { ty::TyBareFn(..) => { @@ -637,7 +636,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { None => { self.tcx().sess.span_bug( callee.span, - &format!("unexpected callee type {}", callee_ty.repr())) + &format!("unexpected callee type {}", callee_ty)) } }; match overloaded_call_type { @@ -811,7 +810,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { fn walk_autoderefs(&mut self, expr: &ast::Expr, autoderefs: usize) { - debug!("walk_autoderefs expr={} autoderefs={}", expr.repr(), autoderefs); + debug!("walk_autoderefs expr={:?} autoderefs={}", expr, autoderefs); for i in 0..autoderefs { let deref_id = ty::MethodCall::autoderef(expr.id, i as u32); @@ -828,8 +827,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { let (m, r) = match self_ty.sty { ty::TyRef(r, ref m) => (m.mutbl, r), _ => self.tcx().sess.span_bug(expr.span, - &format!("bad overloaded deref type {}", - method_ty.repr())) + &format!("bad overloaded deref type {:?}", + method_ty)) }; let bk = ty::BorrowKind::from_mutbl(m); self.delegate.borrow(expr.id, expr.span, cmt, @@ -842,9 +841,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { fn walk_autoderefref(&mut self, expr: &ast::Expr, adj: &ty::AutoDerefRef<'tcx>) { - debug!("walk_autoderefref expr={} adj={}", - expr.repr(), - adj.repr()); + debug!("walk_autoderefref expr={:?} adj={:?}", + expr, + adj); self.walk_autoderefs(expr, adj.autoderefs); @@ -875,9 +874,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { opt_autoref: Option>) -> mc::cmt<'tcx> { - debug!("walk_autoref(expr.id={} cmt_derefd={} opt_autoref={:?})", + debug!("walk_autoref(expr.id={} cmt_derefd={:?} opt_autoref={:?})", expr.id, - cmt_base.repr(), + cmt_base, opt_autoref); let cmt_base_ty = cmt_base.ty; @@ -901,9 +900,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } ty::AutoUnsafe(m) => { - debug!("walk_autoref: expr.id={} cmt_base={}", + debug!("walk_autoref: expr.id={} cmt_base={:?}", expr.id, - cmt_base.repr()); + cmt_base); // Converting from a &T to *T (or &mut T to *mut T) is // treated as borrowing it for the enclosing temporary @@ -1011,8 +1010,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { cmt_discr: mc::cmt<'tcx>, pat: &ast::Pat, mode: &mut TrackMatchMode) { - debug!("determine_pat_move_mode cmt_discr={} pat={}", cmt_discr.repr(), - pat.repr()); + debug!("determine_pat_move_mode cmt_discr={:?} pat={:?}", cmt_discr, + pat); return_if_err!(self.mc.cat_pattern(cmt_discr, pat, |_mc, cmt_pat, pat| { let tcx = self.tcx(); let def_map = &self.tcx().def_map; @@ -1043,8 +1042,8 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { cmt_discr: mc::cmt<'tcx>, pat: &ast::Pat, match_mode: MatchMode) { - debug!("walk_pat cmt_discr={} pat={}", cmt_discr.repr(), - pat.repr()); + debug!("walk_pat cmt_discr={:?} pat={:?}", cmt_discr, + pat); let mc = &self.mc; let typer = self.typer; @@ -1054,9 +1053,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { if pat_util::pat_is_binding(def_map, pat) { let tcx = typer.tcx(); - debug!("binding cmt_pat={} pat={} match_mode={:?}", - cmt_pat.repr(), - pat.repr(), + debug!("binding cmt_pat={:?} pat={:?} match_mode={:?}", + cmt_pat, + pat, match_mode); // pat_ty: the type of the binding being produced. @@ -1160,9 +1159,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { mc.cat_downcast(pat, cmt_pat, cmt_pat_ty, variant_did) }; - debug!("variant downcast_cmt={} pat={}", - downcast_cmt.repr(), - pat.repr()); + debug!("variant downcast_cmt={:?} pat={:?}", + downcast_cmt, + pat); delegate.matched_pat(pat, downcast_cmt, match_mode); } @@ -1172,9 +1171,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { // namespace; we encounter the former on // e.g. patterns for unit structs). - debug!("struct cmt_pat={} pat={}", - cmt_pat.repr(), - pat.repr()); + debug!("struct cmt_pat={:?} pat={:?}", + cmt_pat, + pat); delegate.matched_pat(pat, cmt_pat, match_mode); } @@ -1192,9 +1191,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { // pattern. if !tcx.sess.has_errors() { - let msg = format!("Pattern has unexpected type: {:?} and type {}", + let msg = format!("Pattern has unexpected type: {:?} and type {:?}", def, - cmt_pat.ty.repr()); + cmt_pat.ty); tcx.sess.span_bug(pat.span, &msg) } } @@ -1209,9 +1208,9 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { // reported. if !tcx.sess.has_errors() { - let msg = format!("Pattern has unexpected def: {:?} and type {}", + let msg = format!("Pattern has unexpected def: {:?} and type {:?}", def, - cmt_pat.ty.repr()); + cmt_pat.ty); tcx.sess.span_bug(pat.span, &msg[..]) } } @@ -1237,7 +1236,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> { } fn walk_captures(&mut self, closure_expr: &ast::Expr) { - debug!("walk_captures({})", closure_expr.repr()); + debug!("walk_captures({:?})", closure_expr); ty::with_freevars(self.tcx(), closure_expr.id, |freevars| { for freevar in freevars { diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index ed1ce3458a26b..e08da94c7314a 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -14,7 +14,6 @@ use middle::implicator::Implication; use middle::ty::{self, FreeRegion}; use util::common::can_reach; use util::nodemap::FnvHashMap; -use util::ppaux::Repr; #[derive(Clone)] pub struct FreeRegionMap { @@ -32,7 +31,7 @@ impl FreeRegionMap { implications: &[Implication<'tcx>]) { for implication in implications { - debug!("implication: {}", implication.repr()); + debug!("implication: {:?}", implication); match *implication { Implication::RegionSubRegion(_, ty::ReFree(free_a), ty::ReFree(free_b)) => { self.relate_free_regions(free_a, free_b); @@ -49,7 +48,7 @@ impl FreeRegionMap { pub fn relate_free_regions_from_predicates<'tcx>(&mut self, tcx: &ty::ctxt<'tcx>, predicates: &[ty::Predicate<'tcx>]) { - debug!("relate_free_regions_from_predicates(predicates={})", predicates.repr()); + debug!("relate_free_regions_from_predicates(predicates={:?})", predicates); for predicate in predicates { match *predicate { ty::Predicate::Projection(..) | @@ -67,9 +66,9 @@ impl FreeRegionMap { _ => { // All named regions are instantiated with free regions. tcx.sess.bug( - &format!("record_region_bounds: non free region: {} / {}", - r_a.repr(), - r_b.repr())); + &format!("record_region_bounds: non free region: {:?} / {:?}", + r_a, + r_b)); } } } diff --git a/src/librustc/middle/implicator.rs b/src/librustc/middle/implicator.rs index abdaa9f38c0e1..d26df43286d9c 100644 --- a/src/librustc/middle/implicator.rs +++ b/src/librustc/middle/implicator.rs @@ -21,7 +21,6 @@ use syntax::codemap::Span; use util::common::ErrorReported; use util::nodemap::FnvHashSet; -use util::ppaux::Repr; // Helper functions related to manipulating region types. @@ -54,10 +53,10 @@ pub fn implications<'a,'tcx>( span: Span) -> Vec> { - debug!("implications(body_id={}, ty={}, outer_region={})", + debug!("implications(body_id={}, ty={:?}, outer_region={:?})", body_id, - ty.repr(), - outer_region.repr()); + ty, + outer_region); let mut stack = Vec::new(); stack.push((outer_region, None)); @@ -69,7 +68,7 @@ pub fn implications<'a,'tcx>( out: Vec::new(), visited: FnvHashSet() }; wf.accumulate_from_ty(ty); - debug!("implications: out={}", wf.out.repr()); + debug!("implications: out={:?}", wf.out); wf.out } @@ -79,8 +78,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { } fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) { - debug!("accumulate_from_ty(ty={})", - ty.repr()); + debug!("accumulate_from_ty(ty={:?})", + ty); // When expanding out associated types, we can visit a cyclic // set of types. Issue #23003. @@ -313,8 +312,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { fn accumulate_from_assoc_types_transitive(&mut self, data: &ty::PolyTraitPredicate<'tcx>) { - debug!("accumulate_from_assoc_types_transitive({})", - data.repr()); + debug!("accumulate_from_assoc_types_transitive({:?})", + data); for poly_trait_ref in traits::supertraits(self.tcx(), data.to_poly_trait_ref()) { match ty::no_late_bound_regions(self.tcx(), &poly_trait_ref) { @@ -327,8 +326,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { fn accumulate_from_assoc_types(&mut self, trait_ref: ty::TraitRef<'tcx>) { - debug!("accumulate_from_assoc_types({})", - trait_ref.repr()); + debug!("accumulate_from_assoc_types({:?})", + trait_ref); let trait_def_id = trait_ref.def_id; let trait_def = ty::lookup_trait_def(self.tcx(), trait_def_id); @@ -337,8 +336,8 @@ impl<'a, 'tcx> Implicator<'a, 'tcx> { .iter() .map(|&name| ty::mk_projection(self.tcx(), trait_ref.clone(), name)) .collect(); - debug!("accumulate_from_assoc_types: assoc_type_projections={}", - assoc_type_projections.repr()); + debug!("accumulate_from_assoc_types: assoc_type_projections={:?}", + assoc_type_projections); let tys = match self.fully_normalize(&assoc_type_projections) { Ok(tys) => { tys } Err(ErrorReported) => { return; } diff --git a/src/librustc/middle/infer/bivariate.rs b/src/librustc/middle/infer/bivariate.rs index 87eb08955117f..742ad3f29b780 100644 --- a/src/librustc/middle/infer/bivariate.rs +++ b/src/librustc/middle/infer/bivariate.rs @@ -31,7 +31,6 @@ use super::type_variable::{BiTo}; use middle::ty::{self, Ty}; use middle::ty::TyVar; use middle::ty_relate::{Relate, RelateResult, TypeRelation}; -use util::ppaux::{Repr}; pub struct Bivariate<'a, 'tcx: 'a> { fields: CombineFields<'a, 'tcx> @@ -73,8 +72,8 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Bivariate<'a, 'tcx> { } fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - debug!("{}.tys({}, {})", self.tag(), - a.repr(), b.repr()); + debug!("{}.tys({:?}, {:?})", self.tag(), + a, b); if a == b { return Ok(a); } let infcx = self.fields.infcx; diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/middle/infer/combine.rs index 30242dac695d9..17d545212c281 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/middle/infer/combine.rs @@ -47,7 +47,6 @@ use middle::ty::{self, Ty}; use middle::ty_fold; use middle::ty_fold::{TypeFolder, TypeFoldable}; use middle::ty_relate::{self, Relate, RelateResult, TypeRelation}; -use util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; @@ -212,10 +211,10 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> { Some(e) => e, }; - debug!("instantiate(a_ty={} dir={:?} b_vid={})", - a_ty.repr(), + debug!("instantiate(a_ty={:?} dir={:?} b_vid={:?})", + a_ty, dir, - b_vid.repr()); + b_vid); // Check whether `vid` has been instantiated yet. If not, // make a generalized form of `ty` and instantiate with @@ -229,10 +228,10 @@ impl<'a, 'tcx> CombineFields<'a, 'tcx> { EqTo => self.generalize(a_ty, b_vid, false), BiTo | SupertypeOf | SubtypeOf => self.generalize(a_ty, b_vid, true), }); - debug!("instantiate(a_ty={}, dir={:?}, \ - b_vid={}, generalized_ty={})", - a_ty.repr(), dir, b_vid.repr(), - generalized_ty.repr()); + debug!("instantiate(a_ty={:?}, dir={:?}, \ + b_vid={:?}, generalized_ty={:?})", + a_ty, dir, b_vid, + generalized_ty); self.infcx.type_variables .borrow_mut() .instantiate_and_push( @@ -334,8 +333,8 @@ impl<'cx, 'tcx> ty_fold::TypeFolder<'tcx> for Generalizer<'cx, 'tcx> { ty::ReEarlyBound(..) => { self.tcx().sess.span_bug( self.span, - &format!("Encountered early bound region when generalizing: {}", - r.repr())); + &format!("Encountered early bound region when generalizing: {:?}", + r)); } // Always make a fresh region variable for skolemized regions; diff --git a/src/librustc/middle/infer/equate.rs b/src/librustc/middle/infer/equate.rs index 0d97535ed3abe..cbbf73d942073 100644 --- a/src/librustc/middle/infer/equate.rs +++ b/src/librustc/middle/infer/equate.rs @@ -16,7 +16,6 @@ use super::type_variable::{EqTo}; use middle::ty::{self, Ty}; use middle::ty::TyVar; use middle::ty_relate::{Relate, RelateResult, TypeRelation}; -use util::ppaux::{Repr}; pub struct Equate<'a, 'tcx: 'a> { fields: CombineFields<'a, 'tcx> @@ -45,8 +44,8 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> { } fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - debug!("{}.tys({}, {})", self.tag(), - a.repr(), b.repr()); + debug!("{}.tys({:?}, {:?})", self.tag(), + a, b); if a == b { return Ok(a); } let infcx = self.fields.infcx; @@ -75,10 +74,10 @@ impl<'a, 'tcx> TypeRelation<'a,'tcx> for Equate<'a, 'tcx> { } fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { - debug!("{}.regions({}, {})", + debug!("{}.regions({:?}, {:?})", self.tag(), - a.repr(), - b.repr()); + a, + b); let origin = Subtype(self.fields.trace.clone()); self.fields.infcx.region_vars.make_eqregion(origin, a, b); Ok(a) diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 9f3dd0a4b736b..4ae618d45b728 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -79,9 +79,10 @@ use middle::region; use middle::subst; use middle::ty::{self, Ty}; use middle::ty::{Region, ReFree}; + use std::cell::{Cell, RefCell}; use std::char::from_u32; -use std::string::String; +use std::fmt; use syntax::ast; use syntax::ast_util::name_to_dummy_lifetime; use syntax::owned_slice::OwnedSlice; @@ -90,10 +91,6 @@ use syntax::parse::token; use syntax::print::pprust; use syntax::ptr::P; -// Note: only import UserString, not Repr, since user-facing error -// messages shouldn't include debug serializations. -use util::ppaux::UserString; - pub fn note_and_explain_region(tcx: &ty::ctxt, prefix: &str, region: ty::Region, @@ -170,7 +167,7 @@ pub fn note_and_explain_region(tcx: &ty::ctxt, ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(), _ => { format!("the lifetime {} as defined on", - fr.bound_region.user_string()) + fr.bound_region) } }; @@ -229,7 +226,7 @@ pub trait ErrorReporting<'tcx> { fn values_str(&self, values: &ValuePairs<'tcx>) -> Option; - fn expected_found_str>( + fn expected_found_str>( &self, exp_found: &ty::expected_found) -> Option; @@ -507,7 +504,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { } } - fn expected_found_str>( + fn expected_found_str>( &self, exp_found: &ty::expected_found) -> Option @@ -523,8 +520,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { } Some(format!("expected `{}`, found `{}`", - expected.user_string(), - found.user_string())) + expected, + found)) } fn report_generic_bound_failure(&self, @@ -540,9 +537,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { let labeled_user_string = match bound_kind { GenericKind::Param(ref p) => - format!("the parameter type `{}`", p.user_string()), + format!("the parameter type `{}`", p), GenericKind::Projection(ref p) => - format!("the associated type `{}`", p.user_string()), + format!("the associated type `{}`", p), }; match sub { @@ -554,8 +551,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { origin.span(), &format!( "consider adding an explicit lifetime bound `{}: {}`...", - bound_kind.user_string(), - sub.user_string())); + bound_kind, + sub)); } ty::ReStatic => { @@ -566,7 +563,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { origin.span(), &format!( "consider adding an explicit lifetime bound `{}: 'static`...", - bound_kind.user_string())); + bound_kind)); } _ => { @@ -578,7 +575,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> { origin.span(), &format!( "consider adding an explicit lifetime bound for `{}`", - bound_kind.user_string())); + bound_kind)); note_and_explain_region( self.tcx, &format!("{} must be valid for ", labeled_user_string), @@ -1561,7 +1558,7 @@ impl<'a, 'tcx> ErrorReportingHelpers<'tcx> for InferCtxt<'a, 'tcx> { fn report_inference_failure(&self, var_origin: RegionVariableOrigin) { let br_string = |br: ty::BoundRegion| { - let mut s = br.user_string(); + let mut s = br.to_string(); if !s.is_empty() { s.push_str(" "); } diff --git a/src/librustc/middle/infer/glb.rs b/src/librustc/middle/infer/glb.rs index b611565c151ca..d6b03266b1fe7 100644 --- a/src/librustc/middle/infer/glb.rs +++ b/src/librustc/middle/infer/glb.rs @@ -16,7 +16,6 @@ use super::Subtype; use middle::ty::{self, Ty}; use middle::ty_relate::{Relate, RelateResult, TypeRelation}; -use util::ppaux::Repr; /// "Greatest lower bound" (common subtype) pub struct Glb<'a, 'tcx: 'a> { @@ -55,10 +54,10 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Glb<'a, 'tcx> { } fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { - debug!("{}.regions({}, {})", + debug!("{}.regions({:?}, {:?})", self.tag(), - a.repr(), - b.repr()); + a, + b); let origin = Subtype(self.fields.trace.clone()); Ok(self.fields.infcx.region_vars.glb_regions(origin, a, b)) diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/middle/infer/higher_ranked/mod.rs index 37f3a12b05f61..7b26f6b153733 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/middle/infer/higher_ranked/mod.rs @@ -20,7 +20,6 @@ use middle::ty_fold::{self, TypeFoldable}; use middle::ty_relate::{Relate, RelateResult, TypeRelation}; use syntax::codemap::Span; use util::nodemap::{FnvHashMap, FnvHashSet}; -use util::ppaux::Repr; pub trait HigherRankedRelations<'a,'tcx> { fn higher_ranked_sub(&self, a: &Binder, b: &Binder) -> RelateResult<'tcx, Binder> @@ -46,8 +45,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { -> RelateResult<'tcx, Binder> where T: Relate<'a,'tcx> { - debug!("higher_ranked_sub(a={}, b={})", - a.repr(), b.repr()); + debug!("higher_ranked_sub(a={:?}, b={:?})", + a, b); // Rather than checking the subtype relationship between `a` and `b` // as-is, we need to do some extra work here in order to make sure @@ -73,8 +72,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { let (b_prime, skol_map) = self.infcx.skolemize_late_bound_regions(b, snapshot); - debug!("a_prime={}", a_prime.repr()); - debug!("b_prime={}", b_prime.repr()); + debug!("a_prime={:?}", a_prime); + debug!("b_prime={:?}", b_prime); // Compare types now that bound regions have been replaced. let result = try!(self.sub().relate(&a_prime, &b_prime)); @@ -96,8 +95,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { } } - debug!("higher_ranked_sub: OK result={}", - result.repr()); + debug!("higher_ranked_sub: OK result={:?}", + result); Ok(ty::Binder(result)) }); @@ -123,7 +122,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { try!(self.lub().relate(&a_with_fresh, &b_with_fresh)); let result0 = self.infcx.resolve_type_vars_if_possible(&result0); - debug!("lub result0 = {}", result0.repr()); + debug!("lub result0 = {:?}", result0); // Generalize the regions appearing in result0 if possible let new_vars = self.infcx.region_vars_confined_to_snapshot(snapshot); @@ -135,10 +134,10 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { |r, debruijn| generalize_region(self.infcx, span, snapshot, debruijn, &new_vars, &a_map, r)); - debug!("lub({},{}) = {}", - a.repr(), - b.repr(), - result1.repr()); + debug!("lub({:?},{:?}) = {:?}", + a, + b, + result1); Ok(ty::Binder(result1)) }); @@ -196,8 +195,8 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { fn higher_ranked_glb(&self, a: &Binder, b: &Binder) -> RelateResult<'tcx, Binder> where T: Relate<'a,'tcx> { - debug!("higher_ranked_glb({}, {})", - a.repr(), b.repr()); + debug!("higher_ranked_glb({:?}, {:?})", + a, b); // Make a snapshot so we can examine "all bindings that were // created as part of this type comparison". @@ -217,7 +216,7 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { try!(self.glb().relate(&a_with_fresh, &b_with_fresh)); let result0 = self.infcx.resolve_type_vars_if_possible(&result0); - debug!("glb result0 = {}", result0.repr()); + debug!("glb result0 = {:?}", result0); // Generalize the regions appearing in result0 if possible let new_vars = self.infcx.region_vars_confined_to_snapshot(snapshot); @@ -231,10 +230,10 @@ impl<'a,'tcx> HigherRankedRelations<'a,'tcx> for CombineFields<'a,'tcx> { &a_map, &a_vars, &b_vars, r)); - debug!("glb({},{}) = {}", - a.repr(), - b.repr(), - result1.repr()); + debug!("glb({:?},{:?}) = {:?}", + a, + b, + result1); Ok(ty::Binder(result1)) }); @@ -449,9 +448,9 @@ impl<'a,'tcx> InferCtxtExt for InferCtxt<'a,'tcx> { !escaping_region_vars.contains(&r) }); - debug!("region_vars_confined_to_snapshot: region_vars={} escaping_types={}", - region_vars.repr(), - escaping_types.repr()); + debug!("region_vars_confined_to_snapshot: region_vars={:?} escaping_types={:?}", + region_vars, + escaping_types); region_vars } @@ -532,10 +531,10 @@ pub fn skolemize_late_bound_regions<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, infcx.region_vars.new_skolemized(br, &snapshot.region_vars_snapshot) }); - debug!("skolemize_bound_regions(binder={}, result={}, map={})", - binder.repr(), - result.repr(), - map.repr()); + debug!("skolemize_bound_regions(binder={:?}, result={:?}, map={:?})", + binder, + result, + map); (result, map) } @@ -553,8 +552,8 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, * hold. See `README.md` for more details. */ - debug!("leak_check: skol_map={}", - skol_map.repr()); + debug!("leak_check: skol_map={:?}", + skol_map); let new_vars = infcx.region_vars_confined_to_snapshot(snapshot); for (&skol_br, &skol) in skol_map { @@ -571,10 +570,10 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, } }; - debug!("{} (which replaced {}) is tainted by {}", - skol.repr(), - skol_br.repr(), - tainted_region.repr()); + debug!("{:?} (which replaced {:?}) is tainted by {:?}", + skol, + skol_br, + tainted_region); // A is not as polymorphic as B: return Err((skol_br, tainted_region)); @@ -620,9 +619,9 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, { debug_assert!(leak_check(infcx, &skol_map, snapshot).is_ok()); - debug!("plug_leaks(skol_map={}, value={})", - skol_map.repr(), - value.repr()); + debug!("plug_leaks(skol_map={:?}, value={:?})", + skol_map, + value); // Compute a mapping from the "taint set" of each skolemized // region back to the `ty::BoundRegion` that it originally @@ -638,8 +637,8 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, }) .collect(); - debug!("plug_leaks: inv_skol_map={}", - inv_skol_map.repr()); + debug!("plug_leaks: inv_skol_map={:?}", + inv_skol_map); // Remove any instantiated type variables from `value`; those can hide // references to regions from the `fold_regions` code below. @@ -667,8 +666,8 @@ pub fn plug_leaks<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, } }); - debug!("plug_leaks: result={}", - result.repr()); + debug!("plug_leaks: result={:?}", + result); result } diff --git a/src/librustc/middle/infer/lattice.rs b/src/librustc/middle/infer/lattice.rs index 6257b6e6a2579..7b34fda24064e 100644 --- a/src/librustc/middle/infer/lattice.rs +++ b/src/librustc/middle/infer/lattice.rs @@ -35,7 +35,6 @@ use super::InferCtxt; use middle::ty::TyVar; use middle::ty::{self, Ty}; use middle::ty_relate::{RelateResult, TypeRelation}; -use util::ppaux::Repr; pub trait LatticeDir<'f,'tcx> : TypeRelation<'f,'tcx> { fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>; @@ -51,10 +50,10 @@ pub fn super_lattice_tys<'a,'tcx,L:LatticeDir<'a,'tcx>>(this: &mut L, -> RelateResult<'tcx, Ty<'tcx>> where 'tcx: 'a { - debug!("{}.lattice_tys({}, {})", + debug!("{}.lattice_tys({:?}, {:?})", this.tag(), - a.repr(), - b.repr()); + a, + b); if a == b { return Ok(a); diff --git a/src/librustc/middle/infer/lub.rs b/src/librustc/middle/infer/lub.rs index f4ba639547bf1..9d993ead5ca20 100644 --- a/src/librustc/middle/infer/lub.rs +++ b/src/librustc/middle/infer/lub.rs @@ -16,7 +16,6 @@ use super::Subtype; use middle::ty::{self, Ty}; use middle::ty_relate::{Relate, RelateResult, TypeRelation}; -use util::ppaux::Repr; /// "Least upper bound" (common supertype) pub struct Lub<'a, 'tcx: 'a> { @@ -55,10 +54,10 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Lub<'a, 'tcx> { } fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { - debug!("{}.regions({}, {})", + debug!("{}.regions({:?}, {:?})", self.tag(), - a.repr(), - b.repr()); + a, + b); let origin = Subtype(self.fields.trace.clone()); Ok(self.fields.infcx.region_vars.lub_regions(origin, a, b)) diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 71febd981e045..2df335b5c3c0a 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -36,7 +36,6 @@ use syntax::ast; use syntax::codemap; use syntax::codemap::Span; use util::nodemap::FnvHashMap; -use util::ppaux::{Repr, UserString}; use self::combine::CombineFields; use self::region_inference::{RegionVarBindings, RegionSnapshot}; @@ -330,8 +329,8 @@ pub fn common_supertype<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, b: Ty<'tcx>) -> Ty<'tcx> { - debug!("common_supertype({}, {})", - a.repr(), b.repr()); + debug!("common_supertype({:?}, {:?})", + a, b); let trace = TypeTrace { origin: origin, @@ -355,7 +354,7 @@ pub fn mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("mk_subty({} <: {})", a.repr(), b.repr()); + debug!("mk_subty({:?} <: {:?})", a, b); cx.sub_types(a_is_expected, origin, a, b) } @@ -363,7 +362,7 @@ pub fn can_mk_subty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("can_mk_subty({} <: {})", a.repr(), b.repr()); + debug!("can_mk_subty({:?} <: {:?})", a, b); cx.probe(|_| { let trace = TypeTrace { origin: Misc(codemap::DUMMY_SP), @@ -383,7 +382,7 @@ pub fn mk_subr<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, origin: SubregionOrigin<'tcx>, a: ty::Region, b: ty::Region) { - debug!("mk_subr({} <: {})", a.repr(), b.repr()); + debug!("mk_subr({:?} <: {:?})", a, b); let snapshot = cx.region_vars.start_snapshot(); cx.region_vars.make_subregion(origin, a, b); cx.region_vars.commit(snapshot); @@ -396,7 +395,7 @@ pub fn mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("mk_eqty({} <: {})", a.repr(), b.repr()); + debug!("mk_eqty({:?} <: {:?})", a, b); cx.commit_if_ok(|_| cx.eq_types(a_is_expected, origin, a, b)) } @@ -407,8 +406,8 @@ pub fn mk_sub_poly_trait_refs<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>, b: ty::PolyTraitRef<'tcx>) -> UnitResult<'tcx> { - debug!("mk_sub_trait_refs({} <: {})", - a.repr(), b.repr()); + debug!("mk_sub_trait_refs({:?} <: {:?})", + a, b); cx.commit_if_ok(|_| cx.sub_poly_trait_refs(a_is_expected, origin, a.clone(), b.clone())) } @@ -637,7 +636,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { b: Ty<'tcx>) -> UnitResult<'tcx> { - debug!("sub_types({} <: {})", a.repr(), b.repr()); + debug!("sub_types({:?} <: {:?})", a, b); self.commit_if_ok(|_| { let trace = TypeTrace::types(origin, a_is_expected, a, b); self.sub(a_is_expected, trace).relate(&a, &b).map(|_| ()) @@ -664,9 +663,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { b: ty::TraitRef<'tcx>) -> UnitResult<'tcx> { - debug!("sub_trait_refs({} <: {})", - a.repr(), - b.repr()); + debug!("sub_trait_refs({:?} <: {:?})", + a, + b); self.commit_if_ok(|_| { let trace = TypeTrace { origin: origin, @@ -683,9 +682,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { b: ty::PolyTraitRef<'tcx>) -> UnitResult<'tcx> { - debug!("sub_poly_trait_refs({} <: {})", - a.repr(), - b.repr()); + debug!("sub_poly_trait_refs({:?} <: {:?})", + a, + b); self.commit_if_ok(|_| { let trace = TypeTrace { origin: origin, @@ -861,7 +860,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } pub fn ty_to_string(&self, t: Ty<'tcx>) -> String { - self.resolve_type_vars_if_possible(&t).user_string() + self.resolve_type_vars_if_possible(&t).to_string() } pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String { @@ -870,8 +869,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } pub fn trait_ref_to_string(&self, t: &ty::TraitRef<'tcx>) -> String { - let t = self.resolve_type_vars_if_possible(t); - t.user_string() + self.resolve_type_vars_if_possible(t).to_string() } pub fn shallow_resolve(&self, typ: Ty<'tcx>) -> Ty<'tcx> { @@ -1047,18 +1045,18 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { kind: GenericKind<'tcx>, a: ty::Region, bs: Vec) { - debug!("verify_generic_bound({}, {} <: {})", - kind.repr(), - a.repr(), - bs.repr()); + debug!("verify_generic_bound({:?}, {:?} <: {:?})", + kind, + a, + bs); self.region_vars.verify_generic_bound(origin, kind, a, bs); } pub fn can_equate<'b,T>(&'b self, a: &T, b: &T) -> UnitResult<'tcx> - where T: Relate<'b,'tcx> + Repr + where T: Relate<'b,'tcx> + fmt::Debug { - debug!("can_equate({}, {})", a.repr(), b.repr()); + debug!("can_equate({:?}, {:?})", a, b); self.probe(|_| { // Gin up a dummy trace, since this won't be committed // anyhow. We should make this typetrace stuff more diff --git a/src/librustc/middle/infer/region_inference/graphviz.rs b/src/librustc/middle/infer/region_inference/graphviz.rs index be606e6fa4afd..869f4d011cefe 100644 --- a/src/librustc/middle/infer/region_inference/graphviz.rs +++ b/src/librustc/middle/infer/region_inference/graphviz.rs @@ -24,7 +24,6 @@ use super::Constraint; use middle::infer::SubregionOrigin; use middle::infer::region_inference::RegionVarBindings; use util::nodemap::{FnvHashMap, FnvHashSet}; -use util::ppaux::Repr; use std::borrow::Cow; use std::collections::hash_map::Entry::Vacant; @@ -191,13 +190,13 @@ impl<'a, 'tcx> dot::Labeller<'a, Node, Edge> for ConstraintGraph<'a, 'tcx> { Node::RegionVid(n_vid) => dot::LabelText::label(format!("{:?}", n_vid)), Node::Region(n_rgn) => - dot::LabelText::label(format!("{}", n_rgn.repr())), + dot::LabelText::label(format!("{:?}", n_rgn)), } } fn edge_label(&self, e: &Edge) -> dot::LabelText { match *e { Edge::Constraint(ref c) => - dot::LabelText::label(format!("{}", self.map.get(c).unwrap().repr())), + dot::LabelText::label(format!("{:?}", self.map.get(c).unwrap())), Edge::EnclScope(..) => dot::LabelText::label(format!("(enclosed)")), } diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/middle/infer/region_inference/mod.rs index 024889d08290b..ddd352fcb430a 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/middle/infer/region_inference/mod.rs @@ -30,7 +30,6 @@ use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh}; use middle::ty_relate::RelateResult; use util::common::indenter; use util::nodemap::{FnvHashMap, FnvHashSet}; -use util::ppaux::Repr; use std::cell::{Cell, RefCell}; use std::cmp::Ordering::{self, Less, Greater, Equal}; @@ -324,8 +323,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { if self.in_snapshot() { self.undo_log.borrow_mut().push(AddVar(vid)); } - debug!("created new region variable {:?} with origin {}", - vid, origin.repr()); + debug!("created new region variable {:?} with origin {:?}", + vid, origin); return vid; } @@ -392,8 +391,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // cannot add constraints once regions are resolved assert!(self.values_are_none()); - debug!("RegionVarBindings: add_constraint({})", - constraint.repr()); + debug!("RegionVarBindings: add_constraint({:?})", + constraint); if self.constraints.borrow_mut().insert(constraint, origin).is_none() { if self.in_snapshot() { @@ -407,8 +406,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // cannot add verifys once regions are resolved assert!(self.values_are_none()); - debug!("RegionVarBindings: add_verify({})", - verify.repr()); + debug!("RegionVarBindings: add_verify({:?})", + verify); let mut verifys = self.verifys.borrow_mut(); let index = verifys.len(); @@ -426,8 +425,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { let mut givens = self.givens.borrow_mut(); if givens.insert((sub, sup)) { - debug!("add_given({} <= {:?})", - sub.repr(), + debug!("add_given({:?} <= {:?})", + sub, sup); self.undo_log.borrow_mut().push(AddGiven(sub, sup)); @@ -453,10 +452,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // cannot add constraints once regions are resolved assert!(self.values_are_none()); - debug!("RegionVarBindings: make_subregion({}, {}) due to {}", - sub.repr(), - sup.repr(), - origin.repr()); + debug!("RegionVarBindings: make_subregion({:?}, {:?}) due to {:?}", + sub, + sup, + origin); match (sub, sup) { (ReEarlyBound(..), ReEarlyBound(..)) => { @@ -472,9 +471,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { (_, ReLateBound(..)) => { self.tcx.sess.span_bug( origin.span(), - &format!("cannot relate bound region: {} <= {}", - sub.repr(), - sup.repr())); + &format!("cannot relate bound region: {:?} <= {:?}", + sub, + sup)); } (_, ReStatic) => { // all regions are subregions of static, so we can ignore this @@ -511,9 +510,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // cannot add constraints once regions are resolved assert!(self.values_are_none()); - debug!("RegionVarBindings: lub_regions({}, {})", - a.repr(), - b.repr()); + debug!("RegionVarBindings: lub_regions({:?}, {:?})", + a, + b); match (a, b) { (ReStatic, _) | (_, ReStatic) => { ReStatic // nothing lives longer than static @@ -536,9 +535,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { // cannot add constraints once regions are resolved assert!(self.values_are_none()); - debug!("RegionVarBindings: glb_regions({}, {})", - a.repr(), - b.repr()); + debug!("RegionVarBindings: glb_regions({:?}, {:?})", + a, + b); match (a, b) { (ReStatic, r) | (r, ReStatic) => { // static lives longer than everything else @@ -564,7 +563,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } Some(ref values) => { let r = lookup(values, rid); - debug!("resolve_var({:?}) = {}", rid, r.repr()); + debug!("resolve_var({:?}) = {:?}", rid, r); r } } @@ -621,7 +620,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { /// made---`r0` itself will be the first entry. This is used when checking whether skolemized /// regions are being improperly related to other regions. pub fn tainted(&self, mark: &RegionSnapshot, r0: Region) -> Vec { - debug!("tainted(mark={:?}, r0={})", mark, r0.repr()); + debug!("tainted(mark={:?}, r0={:?})", mark, r0); let _indenter = indenter(); // `result_set` acts as a worklist: we explore all outgoing @@ -732,9 +731,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { (ReEarlyBound(..), _) | (_, ReEarlyBound(..)) => { self.tcx.sess.bug( - &format!("cannot relate bound region: LUB({}, {})", - a.repr(), - b.repr())); + &format!("cannot relate bound region: LUB({:?}, {:?})", + a, + b)); } (ReStatic, _) | (_, ReStatic) => { @@ -837,9 +836,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { (ReEarlyBound(..), _) | (_, ReEarlyBound(..)) => { self.tcx.sess.bug( - &format!("cannot relate bound region: GLB({}, {})", - a.repr(), - b.repr())); + &format!("cannot relate bound region: GLB({:?}, {:?})", + a, + b)); } (ReStatic, r) | (r, ReStatic) => { @@ -1014,18 +1013,18 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { fn dump_constraints(&self) { debug!("----() Start constraint listing ()----"); for (idx, (constraint, _)) in self.constraints.borrow().iter().enumerate() { - debug!("Constraint {} => {}", idx, constraint.repr()); + debug!("Constraint {} => {:?}", idx, constraint); } } fn expansion(&self, free_regions: &FreeRegionMap, var_data: &mut [VarData]) { self.iterate_until_fixed_point("Expansion", |constraint| { - debug!("expansion: constraint={} origin={}", - constraint.repr(), + debug!("expansion: constraint={:?} origin={:?}", + constraint, self.constraints.borrow() .get(constraint) .unwrap() - .repr()); + ); match *constraint { ConstrainRegSubVar(a_region, b_vid) => { let b_data = &mut var_data[b_vid.index as usize]; @@ -1055,10 +1054,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { b_data: &mut VarData) -> bool { - debug!("expand_node({}, {:?} == {})", - a_region.repr(), + debug!("expand_node({:?}, {:?} == {:?})", + a_region, b_vid, - b_data.value.repr()); + b_data.value); // Check if this relationship is implied by a given. match a_region { @@ -1074,8 +1073,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { b_data.classification = Expanding; match b_data.value { NoValue => { - debug!("Setting initial value of {:?} to {}", - b_vid, a_region.repr()); + debug!("Setting initial value of {:?} to {:?}", + b_vid, a_region); b_data.value = Value(a_region); return true; @@ -1087,10 +1086,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { return false; } - debug!("Expanding value of {:?} from {} to {}", + debug!("Expanding value of {:?} from {:?} to {:?}", b_vid, - cur_region.repr(), - lub.repr()); + cur_region, + lub); b_data.value = Value(lub); return true; @@ -1106,12 +1105,12 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { free_regions: &FreeRegionMap, var_data: &mut [VarData]) { self.iterate_until_fixed_point("Contraction", |constraint| { - debug!("contraction: constraint={} origin={}", - constraint.repr(), + debug!("contraction: constraint={:?} origin={:?}", + constraint, self.constraints.borrow() .get(constraint) .unwrap() - .repr()); + ); match *constraint { ConstrainRegSubVar(..) => { // This is an expansion constraint. Ignore. @@ -1140,9 +1139,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { a_data: &mut VarData, b_region: Region) -> bool { - debug!("contract_node({:?} == {}/{:?}, {})", - a_vid, a_data.value.repr(), - a_data.classification, b_region.repr()); + debug!("contract_node({:?} == {:?}/{:?}, {:?})", + a_vid, a_data.value, + a_data.classification, b_region); return match a_data.value { NoValue => { @@ -1172,10 +1171,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { -> bool { if !free_regions.is_subregion_of(this.tcx, a_region, b_region) { - debug!("Setting {:?} to ErrorValue: {} not subregion of {}", + debug!("Setting {:?} to ErrorValue: {:?} not subregion of {:?}", a_vid, - a_region.repr(), - b_region.repr()); + a_region, + b_region); a_data.value = ErrorValue; } false @@ -1193,19 +1192,19 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { if glb == a_region { false } else { - debug!("Contracting value of {:?} from {} to {}", + debug!("Contracting value of {:?} from {:?} to {:?}", a_vid, - a_region.repr(), - glb.repr()); + a_region, + glb); a_data.value = Value(glb); true } } Err(_) => { - debug!("Setting {:?} to ErrorValue: no glb of {}, {}", + debug!("Setting {:?} to ErrorValue: no glb of {:?}, {:?}", a_vid, - a_region.repr(), - b_region.repr()); + a_region, + b_region); a_data.value = ErrorValue; false } @@ -1230,9 +1229,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { continue; } - debug!("ConcreteFailure: !(sub <= sup): sub={}, sup={}", - sub.repr(), - sup.repr()); + debug!("ConcreteFailure: !(sub <= sup): sub={:?}, sup={:?}", + sub, + sup); errors.push(ConcreteFailure((*origin).clone(), sub, sup)); } @@ -1432,10 +1431,10 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { self.tcx.sess.span_bug( (*self.var_origins.borrow())[node_idx.index as usize].span(), &format!("collect_error_for_expanding_node() could not find error \ - for var {:?}, lower_bounds={}, upper_bounds={}", + for var {:?}, lower_bounds={:?}, upper_bounds={:?}", node_idx, - lower_bounds.repr(), - upper_bounds.repr())); + lower_bounds, + upper_bounds)); } fn collect_error_for_contracting_node( @@ -1479,9 +1478,9 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { self.tcx.sess.span_bug( (*self.var_origins.borrow())[node_idx.index as usize].span(), &format!("collect_error_for_contracting_node() could not find error \ - for var {:?}, upper_bounds={}", + for var {:?}, upper_bounds={:?}", node_idx, - upper_bounds.repr())); + upper_bounds)); } fn collect_concrete_regions(&self, @@ -1579,8 +1578,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { for (constraint, _) in self.constraints.borrow().iter() { let edge_changed = body(constraint); if edge_changed { - debug!("Updated due to constraint {}", - constraint.repr()); + debug!("Updated due to constraint {:?}", + constraint); changed = true; } } @@ -1620,9 +1619,9 @@ fn lookup(values: &Vec, rid: ty::RegionVid) -> ty::Region { impl<'tcx> fmt::Debug for RegionAndOrigin<'tcx> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "RegionAndOrigin({},{})", - self.region.repr(), - self.origin.repr()) + write!(f, "RegionAndOrigin({:?},{:?})", + self.region, + self.origin) } } diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/middle/infer/resolve.rs index c22aa6a4f996e..b67437fd12781 100644 --- a/src/librustc/middle/infer/resolve.rs +++ b/src/librustc/middle/infer/resolve.rs @@ -11,7 +11,6 @@ use super::{InferCtxt, fixup_err, fres, unresolved_ty, unresolved_int_ty, unresolved_float_ty}; use middle::ty::{self, Ty}; use middle::ty_fold::{self, TypeFoldable}; -use util::ppaux::Repr; /////////////////////////////////////////////////////////////////////////// // OPPORTUNISTIC TYPE RESOLVER @@ -95,8 +94,8 @@ impl<'a, 'tcx> ty_fold::TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> { } ty::TyInfer(_) => { self.infcx.tcx.sess.bug( - &format!("Unexpected type in full type resolver: {}", - t.repr())); + &format!("Unexpected type in full type resolver: {:?}", + t)); } _ => { ty_fold::super_fold_ty(self, t) diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/middle/infer/sub.rs index 24eae6307fafd..2b7f9a74b8bd5 100644 --- a/src/librustc/middle/infer/sub.rs +++ b/src/librustc/middle/infer/sub.rs @@ -16,7 +16,6 @@ use super::type_variable::{SubtypeOf, SupertypeOf}; use middle::ty::{self, Ty}; use middle::ty::TyVar; use middle::ty_relate::{Relate, RelateResult, TypeRelation}; -use util::ppaux::{Repr}; /// "Greatest lower bound" (common subtype) pub struct Sub<'a, 'tcx: 'a> { @@ -49,7 +48,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> { } fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - debug!("{}.tys({}, {})", self.tag(), a.repr(), b.repr()); + debug!("{}.tys({:?}, {:?})", self.tag(), a, b); if a == b { return Ok(a); } @@ -85,10 +84,10 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> { } fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { - debug!("{}.regions({}, {})", + debug!("{}.regions({:?}, {:?})", self.tag(), - a.repr(), - b.repr()); + a, + b); let origin = Subtype(self.fields.trace.clone()); self.fields.infcx.region_vars.make_subregion(origin, a, b); Ok(a) diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 6ff774b4bb01f..c4d924d676c89 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -14,7 +14,6 @@ use middle::def::DefFn; use middle::subst::{Subst, Substs, EnumeratedItems}; use middle::ty::{TransmuteRestriction, ctxt, TyBareFn}; use middle::ty::{self, Ty}; -use util::ppaux::Repr; use std::fmt; @@ -204,15 +203,15 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> { match types_in_scope.next() { None => { - debug!("with_each_combination(substs={})", - substs.repr()); + debug!("with_each_combination(substs={:?})", + substs); callback(substs); } Some((space, index, ¶m_ty)) => { - debug!("with_each_combination: space={:?}, index={}, param_ty={}", - space, index, param_ty.repr()); + debug!("with_each_combination: space={:?}, index={}, param_ty={:?}", + space, index, param_ty); if !ty::type_is_sized(Some(param_env), self.tcx, span, param_ty) { debug!("with_each_combination: param_ty is not known to be sized"); @@ -230,7 +229,7 @@ impl<'a, 'tcx> IntrinsicCheckingVisitor<'a, 'tcx> { } fn push_transmute_restriction(&self, restriction: TransmuteRestriction<'tcx>) { - debug!("Pushing transmute restriction: {}", restriction.repr()); + debug!("Pushing transmute restriction: {:?}", restriction); self.tcx.transmute_restrictions.borrow_mut().push(restriction); } } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 935c077b6338f..ca8de74b35bda 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -78,12 +78,10 @@ use middle::def; use middle::region; use middle::ty::{self, Ty}; use util::nodemap::NodeMap; -use util::ppaux::{Repr, UserString}; use syntax::ast::{MutImmutable, MutMutable}; use syntax::ast; use syntax::codemap::Span; -use syntax::print::pprust; use std::cell::RefCell; use std::fmt; @@ -435,8 +433,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } _ => base_ty, }; - debug!("pat_ty(pat={}) base_ty={} ret_ty={}", - pat.repr(), base_ty.repr(), ret_ty.repr()); + debug!("pat_ty(pat={:?}) base_ty={:?} ret_ty={:?}", + pat, base_ty, ret_ty); Ok(ret_ty) } @@ -459,9 +457,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty::AdjustReifyFnPointer | ty::AdjustUnsafeFnPointer | ty::AdjustDerefRef(_) => { - debug!("cat_expr({}): {}", - adjustment.repr(), - expr.repr()); + debug!("cat_expr({:?}): {:?}", + adjustment, + expr); // Result is an rvalue. let expr_ty = try!(self.expr_ty_adjusted(expr)); Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty)) @@ -476,9 +474,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { autoderefs: usize) -> McResult> { let mut cmt = try!(self.cat_expr_unadjusted(expr)); - debug!("cat_expr_autoderefd: autoderefs={}, cmt={}", + debug!("cat_expr_autoderefd: autoderefs={}, cmt={:?}", autoderefs, - cmt.repr()); + cmt); for deref in 1..autoderefs + 1 { cmt = try!(self.cat_deref(expr, cmt, deref, None)); } @@ -486,7 +484,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult> { - debug!("cat_expr: id={} expr={}", expr.id, expr.repr()); + debug!("cat_expr: id={} expr={:?}", expr.id, expr); let expr_ty = try!(self.expr_ty(expr)); match expr.node { @@ -497,10 +495,10 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ast::ExprField(ref base, f_name) => { let base_cmt = try!(self.cat_expr(&**base)); - debug!("cat_expr(cat_field): id={} expr={} base={}", + debug!("cat_expr(cat_field): id={} expr={:?} base={:?}", expr.id, - expr.repr(), - base_cmt.repr()); + expr, + base_cmt); Ok(self.cat_field(expr, base_cmt, f_name.node.name, expr_ty)) } @@ -523,8 +521,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let elem_ty = match ret_ty.sty { ty::TyRef(_, mt) => mt.ty, _ => { - debug!("cat_expr_unadjusted: return type of overloaded index is {}?", - ret_ty.repr()); + debug!("cat_expr_unadjusted: return type of overloaded index is {:?}?", + ret_ty); return Err(()); } }; @@ -582,8 +580,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { expr_ty: Ty<'tcx>, def: def::Def) -> McResult> { - debug!("cat_def: id={} expr={} def={:?}", - id, expr_ty.repr(), def); + debug!("cat_def: id={} expr={:?} def={:?}", + id, expr_ty, def); match def { def::DefStruct(..) | def::DefVariant(..) | def::DefConst(..) | @@ -634,9 +632,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { _ => { self.tcx().sess.span_bug( span, - &format!("Upvar of non-closure {} - {}", + &format!("Upvar of non-closure {} - {:?}", fn_node_id, - ty.repr())); + ty)); } } } @@ -745,7 +743,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { }; let ret = Rc::new(cmt_result); - debug!("cat_upvar ret={}", ret.repr()); + debug!("cat_upvar ret={:?}", ret); Ok(ret) } @@ -816,7 +814,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { note: NoteClosureEnv(upvar_id) }; - debug!("env_deref ret {}", ret.repr()); + debug!("env_deref ret {:?}", ret); ret } @@ -854,7 +852,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty::ReStatic }; let ret = self.cat_rvalue(id, span, re, expr_ty); - debug!("cat_rvalue_node ret {}", ret.repr()); + debug!("cat_rvalue_node ret {:?}", ret); ret } @@ -871,7 +869,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty:expr_ty, note: NoteNone }); - debug!("cat_rvalue ret {}", ret.repr()); + debug!("cat_rvalue ret {:?}", ret); ret } @@ -889,7 +887,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: f_ty, note: NoteNone }); - debug!("cat_field ret {}", ret.repr()); + debug!("cat_field ret {:?}", ret); ret } @@ -907,7 +905,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: f_ty, note: NoteNone }); - debug!("cat_tup_field ret {}", ret.repr()); + debug!("cat_tup_field ret {:?}", ret); ret } @@ -924,7 +922,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let method_ty = self.typer.node_method_ty(method_call); debug!("cat_deref: method_call={:?} method_ty={:?}", - method_call, method_ty.map(|ty| ty.repr())); + method_call, method_ty.map(|ty| ty)); let base_cmt = match method_ty { Some(method_ty) => { @@ -942,12 +940,12 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { mt.ty, deref_context, /* implicit: */ false); - debug!("cat_deref ret {}", ret.repr()); + debug!("cat_deref ret {:?}", ret); ret } None => { - debug!("Explicit deref of non-derefable type: {}", - base_cmt_ty.repr()); + debug!("Explicit deref of non-derefable type: {:?}", + base_cmt_ty); return Err(()); } } @@ -990,7 +988,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: deref_ty, note: NoteNone }); - debug!("cat_deref_common ret {}", ret.repr()); + debug!("cat_deref_common ret {:?}", ret); Ok(ret) } @@ -1041,7 +1039,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { let m = base_cmt.mutbl.inherit(); let ret = interior(elt, base_cmt.clone(), base_cmt.ty, m, context, element_ty); - debug!("cat_index ret {}", ret.repr()); + debug!("cat_index ret {:?}", ret); return Ok(ret); fn interior<'tcx, N: ast_node>(elt: &N, @@ -1095,7 +1093,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { base_cmt } }; - debug!("deref_vec ret {}", ret.repr()); + debug!("deref_vec ret {:?}", ret); Ok(ret) } @@ -1154,7 +1152,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: interior_ty, note: NoteNone }); - debug!("cat_imm_interior ret={}", ret.repr()); + debug!("cat_imm_interior ret={:?}", ret); ret } @@ -1172,7 +1170,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { ty: downcast_ty, note: NoteNone }); - debug!("cat_downcast ret={}", ret.repr()); + debug!("cat_downcast ret={:?}", ret); ret } @@ -1232,9 +1230,9 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { // step out of sync again. So you'll see below that we always // get the type of the *subpattern* and use that. - debug!("cat_pattern: id={} pat={} cmt={}", - pat.id, pprust::pat_to_string(pat), - cmt.repr()); + debug!("cat_pattern: {:?} cmt={:?}", + pat, + cmt); (*op)(self, cmt.clone(), pat); @@ -1520,7 +1518,7 @@ impl<'tcx> cmt_<'tcx> { let upvar = self.upvar(); match upvar.as_ref().map(|i| &i.cat) { Some(&cat_upvar(ref var)) => { - var.user_string() + var.to_string() } Some(_) => unreachable!(), None => { @@ -1560,7 +1558,7 @@ impl<'tcx> cmt_<'tcx> { "pattern-bound indexed content".to_string() } cat_upvar(ref var) => { - var.user_string() + var.to_string() } cat_downcast(ref cmt, _) => { cmt.descriptive_string(tcx) diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 3fec62cd8b481..3f00d9ba5e98d 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -28,7 +28,6 @@ use syntax::attr::{Stability, AttrMetaMethods}; use syntax::visit::{FnKind, Visitor}; use syntax::feature_gate::emit_feature_err; use util::nodemap::{DefIdMap, FnvHashSet, FnvHashMap}; -use util::ppaux::Repr; use std::mem::replace; @@ -450,7 +449,7 @@ pub fn check_expr(tcx: &ty::ctxt, e: &ast::Expr, tcx.sess.span_bug(e.span, &format!("stability::check_expr: struct construction \ of non-struct, type {:?}", - type_.repr())); + type_)); } } } @@ -551,7 +550,7 @@ pub fn lookup<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> } fn lookup_uncached<'tcx>(tcx: &ty::ctxt<'tcx>, id: DefId) -> Option<&'tcx Stability> { - debug!("lookup(id={})", id.repr()); + debug!("lookup(id={:?})", id); // is this definition the implementation of a trait method? match ty::trait_item_of_item(tcx, id) { diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index 957bd76bb9426..c3c29d0ade8df 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -15,7 +15,6 @@ pub use self::RegionSubsts::*; use middle::ty::{self, Ty}; use middle::ty_fold::{self, TypeFoldable, TypeFolder}; -use util::ppaux::Repr; use std::fmt; use std::iter::IntoIterator; @@ -618,10 +617,10 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> { self.tcx().sess.span_bug( span, &format!("Type parameter out of range \ - when substituting in region {} (root type={}) \ + when substituting in region {} (root type={:?}) \ (space={:?}, index={})", - data.name.as_str(), - self.root_ty.repr(), + data.name, + self.root_ty, data.space, data.index)); } @@ -673,14 +672,14 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> { let span = self.span.unwrap_or(DUMMY_SP); self.tcx().sess.span_bug( span, - &format!("Type parameter `{}` ({}/{:?}/{}) out of range \ - when substituting (root type={}) substs={}", - p.repr(), - source_ty.repr(), + &format!("Type parameter `{:?}` ({:?}/{:?}/{}) out of range \ + when substituting (root type={:?}) substs={:?}", + p, + source_ty, p.space, p.idx, - self.root_ty.repr(), - self.substs.repr())); + self.root_ty, + self.substs)); } }; @@ -731,14 +730,14 @@ impl<'a,'tcx> SubstFolder<'a,'tcx> { /// is that only in the second case have we passed through a fn binder. fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx> { debug!("shift_regions(ty={:?}, region_binders_passed={:?}, type_has_escaping_regions={:?})", - ty.repr(), self.region_binders_passed, ty::type_has_escaping_regions(ty)); + ty, self.region_binders_passed, ty::type_has_escaping_regions(ty)); if self.region_binders_passed == 0 || !ty::type_has_escaping_regions(ty) { return ty; } let result = ty_fold::shift_regions(self.tcx(), self.region_binders_passed, &ty); - debug!("shift_regions: shifted result = {:?}", result.repr()); + debug!("shift_regions: shifted result = {:?}", result); result } diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 622ed134a6091..a826836b10c62 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -22,7 +22,6 @@ use middle::ty::{self, ToPolyTraitRef, Ty}; use middle::infer::{self, InferCtxt}; use syntax::ast; use syntax::codemap::{DUMMY_SP, Span}; -use util::ppaux::Repr; #[derive(Copy, Clone)] struct InferIsLocal(bool); @@ -34,10 +33,10 @@ pub fn overlapping_impls(infcx: &InferCtxt, -> bool { debug!("impl_can_satisfy(\ - impl1_def_id={}, \ - impl2_def_id={})", - impl1_def_id.repr(), - impl2_def_id.repr()); + impl1_def_id={:?}, \ + impl2_def_id={:?})", + impl1_def_id, + impl2_def_id); let param_env = &ty::empty_parameter_environment(infcx.tcx); let selcx = &mut SelectionContext::intercrate(infcx, param_env); @@ -53,9 +52,9 @@ fn overlap(selcx: &mut SelectionContext, b_def_id: ast::DefId) -> bool { - debug!("overlap(a_def_id={}, b_def_id={})", - a_def_id.repr(), - b_def_id.repr()); + debug!("overlap(a_def_id={:?}, b_def_id={:?})", + a_def_id, + b_def_id); let (a_trait_ref, a_obligations) = impl_trait_ref_and_oblig(selcx, a_def_id, @@ -65,9 +64,9 @@ fn overlap(selcx: &mut SelectionContext, b_def_id, util::fresh_type_vars_for_impl); - debug!("overlap: a_trait_ref={}", a_trait_ref.repr()); + debug!("overlap: a_trait_ref={:?}", a_trait_ref); - debug!("overlap: b_trait_ref={}", b_trait_ref.repr()); + debug!("overlap: b_trait_ref={:?}", b_trait_ref); // Does `a <: b` hold? If not, no overlap. if let Err(_) = infer::mk_sub_poly_trait_refs(selcx.infcx(), @@ -89,7 +88,7 @@ fn overlap(selcx: &mut SelectionContext, .find(|o| !selcx.evaluate_obligation(o)); if let Some(failing_obligation) = opt_failing_obligation { - debug!("overlap: obligation unsatisfiable {}", failing_obligation.repr()); + debug!("overlap: obligation unsatisfiable {:?}", failing_obligation); return false } @@ -98,7 +97,7 @@ fn overlap(selcx: &mut SelectionContext, pub fn trait_ref_is_knowable<'tcx>(tcx: &ty::ctxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> bool { - debug!("trait_ref_is_knowable(trait_ref={})", trait_ref.repr()); + debug!("trait_ref_is_knowable(trait_ref={:?})", trait_ref); // if the orphan rules pass, that means that no ancestor crate can // impl this, so it's up to us. @@ -180,17 +179,17 @@ pub fn orphan_check<'tcx>(tcx: &ty::ctxt<'tcx>, impl_def_id: ast::DefId) -> Result<(), OrphanCheckErr<'tcx>> { - debug!("orphan_check({})", impl_def_id.repr()); + debug!("orphan_check({:?})", impl_def_id); // We only except this routine to be invoked on implementations // of a trait, not inherent implementations. let trait_ref = ty::impl_trait_ref(tcx, impl_def_id).unwrap(); - debug!("orphan_check: trait_ref={}", trait_ref.repr()); + debug!("orphan_check: trait_ref={:?}", trait_ref); // If the *trait* is local to the crate, ok. if trait_ref.def_id.krate == ast::LOCAL_CRATE { - debug!("trait {} is local to current crate", - trait_ref.def_id.repr()); + debug!("trait {:?} is local to current crate", + trait_ref.def_id); return Ok(()); } @@ -202,8 +201,8 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, infer_is_local: InferIsLocal) -> Result<(), OrphanCheckErr<'tcx>> { - debug!("orphan_check_trait_ref(trait_ref={}, infer_is_local={})", - trait_ref.repr(), infer_is_local.0); + debug!("orphan_check_trait_ref(trait_ref={:?}, infer_is_local={})", + trait_ref, infer_is_local.0); // First, create an ordered iterator over all the type parameters to the trait, with the self // type appearing first. @@ -214,14 +213,14 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, // some local type. for input_ty in input_tys { if ty_is_local(tcx, input_ty, infer_is_local) { - debug!("orphan_check_trait_ref: ty_is_local `{}`", input_ty.repr()); + debug!("orphan_check_trait_ref: ty_is_local `{:?}`", input_ty); // First local input type. Check that there are no // uncovered type parameters. let uncovered_tys = uncovered_tys(tcx, input_ty, infer_is_local); for uncovered_ty in uncovered_tys { if let Some(param) = uncovered_ty.walk().find(|t| is_type_parameter(t)) { - debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr()); + debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); return Err(OrphanCheckErr::UncoveredTy(param)); } } @@ -234,7 +233,7 @@ fn orphan_check_trait_ref<'tcx>(tcx: &ty::ctxt<'tcx>, // parameters reachable. if !infer_is_local.0 { if let Some(param) = input_ty.walk().find(|t| is_type_parameter(t)) { - debug!("orphan_check_trait_ref: uncovered type `{}`", param.repr()); + debug!("orphan_check_trait_ref: uncovered type `{:?}`", param); return Err(OrphanCheckErr::UncoveredTy(param)); } } @@ -294,7 +293,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, infer_is_local: InferIsLocal) -> bool { - debug!("ty_is_local_constructor({})", ty.repr()); + debug!("ty_is_local_constructor({:?})", ty); match ty.sty { ty::TyBool | @@ -335,8 +334,8 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, ty::TyClosure(..) | ty::TyError => { tcx.sess.bug( - &format!("ty_is_local invoked on unexpected type: {}", - ty.repr())) + &format!("ty_is_local invoked on unexpected type: {:?}", + ty)) } } } diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/middle/traits/error_reporting.rs index 7d4bbb5d7f03f..8618f52152907 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/middle/traits/error_reporting.rs @@ -28,9 +28,9 @@ use middle::infer::InferCtxt; use middle::ty::{self, AsPredicate, ReferencesError, ToPolyTraitRef, TraitRef}; use middle::ty_fold::TypeFoldable; use std::collections::HashMap; +use std::fmt; use syntax::codemap::{DUMMY_SP, Span}; use syntax::attr::{AttributeMethods, AttrMetaMethods}; -use util::ppaux::{Repr, UserString}; pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, errors: &Vec>) { @@ -68,7 +68,7 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, if !infcx.tcx.sess.has_errors() || !predicate.references_error() { span_err!(infcx.tcx.sess, obligation.cause.span, E0271, "type mismatch resolving `{}`: {}", - predicate.user_string(), + predicate, error.err); note_obligation_cause(infcx, obligation); } @@ -87,16 +87,16 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, item.meta().span }; let def = ty::lookup_trait_def(infcx.tcx, def_id); - let trait_str = def.trait_ref.user_string(); + let trait_str = def.trait_ref.to_string(); if let Some(ref istring) = item.value_str() { let mut generic_map = def.generics.types.iter_enumerated() .map(|(param, i, gen)| { (gen.name.as_str().to_string(), trait_ref.substs.types.get(param, i) - .user_string()) + .to_string()) }).collect::>(); generic_map.insert("Self".to_string(), - trait_ref.self_ty().user_string()); + trait_ref.self_ty().to_string()); let parser = Parser::new(&istring); let mut errored = false; let err: String = parser.filter_map(|p| { @@ -157,13 +157,13 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, pub fn report_overflow_error<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, obligation: &Obligation<'tcx, T>) -> ! - where T: UserString + TypeFoldable<'tcx> + where T: fmt::Display + TypeFoldable<'tcx> { let predicate = infcx.resolve_type_vars_if_possible(&obligation.predicate); span_err!(infcx.tcx.sess, obligation.cause.span, E0275, "overflow evaluating the requirement `{}`", - predicate.user_string()); + predicate); suggest_new_overflow_limit(infcx.tcx, obligation.cause.span); @@ -184,7 +184,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0276, "the requirement `{}` appears on the impl \ method but not on the corresponding trait method", - obligation.predicate.user_string());; + obligation.predicate);; } _ => { match obligation.predicate { @@ -197,8 +197,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let trait_ref = trait_predicate.to_poly_trait_ref(); span_err!(infcx.tcx.sess, obligation.cause.span, E0277, "the trait `{}` is not implemented for the type `{}`", - trait_ref.user_string(), - trait_ref.self_ty().user_string()); + trait_ref, + trait_ref.self_ty()); // Check if it has a custom "#[rustc_on_unimplemented]" // error message, report with that message if it does let custom_note = report_on_unimplemented(infcx, &trait_ref.0, @@ -216,7 +216,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, &predicate).err().unwrap(); span_err!(infcx.tcx.sess, obligation.cause.span, E0278, "the requirement `{}` is not satisfied (`{}`)", - predicate.user_string(), + predicate, err); } @@ -226,7 +226,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, &predicate).err().unwrap(); span_err!(infcx.tcx.sess, obligation.cause.span, E0279, "the requirement `{}` is not satisfied (`{}`)", - predicate.user_string(), + predicate, err); } @@ -235,7 +235,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.resolve_type_vars_if_possible(&obligation.predicate); span_err!(infcx.tcx.sess, obligation.cause.span, E0280, "the requirement `{}` is not satisfied", - predicate.user_string()); + predicate); } } } @@ -249,9 +249,9 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0281, "type mismatch: the type `{}` implements the trait `{}`, \ but the trait `{}` is required ({})", - expected_trait_ref.self_ty().user_string(), - expected_trait_ref.user_string(), - actual_trait_ref.user_string(), + expected_trait_ref.self_ty(), + expected_trait_ref, + actual_trait_ref, e); note_obligation_cause(infcx, obligation); } @@ -282,7 +282,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.tcx.sess.span_note( obligation.cause.span, &format!("method `{}` has no receiver", - method.name.user_string())); + method.name)); } ObjectSafetyViolation::Method(method, @@ -291,7 +291,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, obligation.cause.span, &format!("method `{}` references the `Self` type \ in its arguments or return type", - method.name.user_string())); + method.name)); } ObjectSafetyViolation::Method(method, @@ -299,7 +299,7 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.tcx.sess.span_note( obligation.cause.span, &format!("method `{}` has generic type parameters", - method.name.user_string())); + method.name)); } } } @@ -316,9 +316,9 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, let predicate = infcx.resolve_type_vars_if_possible(&obligation.predicate); - debug!("maybe_report_ambiguity(predicate={}, obligation={})", - predicate.repr(), - obligation.repr()); + debug!("maybe_report_ambiguity(predicate={:?}, obligation={:?})", + predicate, + obligation); match predicate { ty::Predicate::Trait(ref data) => { @@ -349,11 +349,11 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, span_err!(infcx.tcx.sess, obligation.cause.span, E0282, "unable to infer enough type information about `{}`; \ type annotations or generic parameter binding required", - self_ty.user_string()); + self_ty); } else { span_err!(infcx.tcx.sess, obligation.cause.span, E0283, "type annotations required: cannot resolve `{}`", - predicate.user_string());; + predicate);; note_obligation_cause(infcx, obligation); } } @@ -365,8 +365,8 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, "coherence failed to report ambiguity: \ cannot locate the impl of the trait `{}` for \ the type `{}`", - trait_ref.user_string(), - self_ty.user_string())); + trait_ref, + self_ty)); } } @@ -374,7 +374,7 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, if !infcx.tcx.sess.has_errors() { span_err!(infcx.tcx.sess, obligation.cause.span, E0284, "type annotations required: cannot resolve `{}`", - predicate.user_string());; + predicate);; note_obligation_cause(infcx, obligation); } } @@ -383,7 +383,7 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, fn note_obligation_cause<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, obligation: &Obligation<'tcx, T>) - where T: UserString + where T: fmt::Display { note_obligation_cause_code(infcx, &obligation.predicate, @@ -395,7 +395,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, predicate: &T, cause_span: Span, cause_code: &ObligationCauseCode<'tcx>) - where T: UserString + where T: fmt::Display { let tcx = infcx.tcx; match *cause_code { @@ -463,7 +463,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, let parent_trait_ref = infcx.resolve_type_vars_if_possible(&data.parent_trait_ref); span_note!(tcx.sess, cause_span, "required because it appears within the type `{}`", - parent_trait_ref.0.self_ty().user_string()); + parent_trait_ref.0.self_ty()); let parent_predicate = parent_trait_ref.as_predicate(); note_obligation_cause_code(infcx, &parent_predicate, cause_span, &*data.parent_code); } @@ -471,8 +471,8 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, let parent_trait_ref = infcx.resolve_type_vars_if_possible(&data.parent_trait_ref); span_note!(tcx.sess, cause_span, "required because of the requirements on the impl of `{}` for `{}`", - parent_trait_ref.user_string(), - parent_trait_ref.0.self_ty().user_string()); + parent_trait_ref, + parent_trait_ref.0.self_ty()); let parent_predicate = parent_trait_ref.as_predicate(); note_obligation_cause_code(infcx, &parent_predicate, cause_span, &*data.parent_code); } @@ -480,7 +480,7 @@ fn note_obligation_cause_code<'a, 'tcx, T>(infcx: &InferCtxt<'a, 'tcx>, span_note!(tcx.sess, cause_span, "the requirement `{}` appears on the impl method \ but not on the corresponding trait method", - predicate.user_string()); + predicate); } } } diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/middle/traits/fulfill.rs index 0828a67c6c678..593a71a30fe2a 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/middle/traits/fulfill.rs @@ -15,7 +15,6 @@ use std::collections::HashSet; use std::fmt; use syntax::ast; use util::common::ErrorReported; -use util::ppaux::Repr; use util::nodemap::NodeMap; use super::CodeAmbiguity; @@ -138,8 +137,8 @@ impl<'tcx> FulfillmentContext<'tcx> { cause: ObligationCause<'tcx>) -> Ty<'tcx> { - debug!("normalize_associated_type(projection_ty={})", - projection_ty.repr()); + debug!("normalize_associated_type(projection_ty={:?})", + projection_ty); assert!(!projection_ty.has_escaping_regions()); @@ -152,7 +151,7 @@ impl<'tcx> FulfillmentContext<'tcx> { self.register_predicate_obligation(infcx, obligation); } - debug!("normalize_associated_type: result={}", normalized.value.repr()); + debug!("normalize_associated_type: result={:?}", normalized.value); normalized.value } @@ -190,11 +189,11 @@ impl<'tcx> FulfillmentContext<'tcx> { assert!(!obligation.has_escaping_regions()); if self.is_duplicate_or_add(infcx.tcx, &obligation.predicate) { - debug!("register_predicate({}) -- already seen, skip", obligation.repr()); + debug!("register_predicate({:?}) -- already seen, skip", obligation); return; } - debug!("register_predicate({})", obligation.repr()); + debug!("register_predicate({:?})", obligation); self.predicates.push(obligation); } @@ -378,9 +377,9 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, true } Err(selection_err) => { - debug!("predicate: {} error: {}", - obligation.repr(), - selection_err.repr()); + debug!("predicate: {:?} error: {:?}", + obligation, + selection_err); errors.push( FulfillmentError::new( obligation.clone(), @@ -439,9 +438,9 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>, ty::Predicate::Projection(ref data) => { let project_obligation = obligation.with(data.clone()); let result = project::poly_project_and_unify_type(selcx, &project_obligation); - debug!("process_predicate: poly_project_and_unify_type({}) returned {}", - project_obligation.repr(), - result.repr()); + debug!("process_predicate: poly_project_and_unify_type({:?}) returned {:?}", + project_obligation, + result); match result { Ok(Some(obligations)) => { new_obligations.extend(obligations); @@ -479,8 +478,8 @@ fn register_region_obligation<'tcx>(t_a: Ty<'tcx>, sub_region: r_b, cause: cause }; - debug!("register_region_obligation({})", - region_obligation.repr()); + debug!("register_region_obligation({:?})", + region_obligation); region_obligations.entry(region_obligation.cause.body_id).or_insert(vec![]) .push(region_obligation); diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index 35855767e6098..e3c122e2f1f59 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -23,7 +23,6 @@ use middle::infer::{self, fixup_err_to_string, InferCtxt}; use std::rc::Rc; use syntax::ast; use syntax::codemap::{Span, DUMMY_SP}; -use util::ppaux::Repr; pub use self::error_reporting::report_fulfillment_errors; pub use self::error_reporting::report_overflow_error; @@ -319,8 +318,8 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, span: Span) -> bool { - debug!("type_known_to_meet_builtin_bound(ty={}, bound={:?})", - ty.repr(), + debug!("type_known_to_meet_builtin_bound(ty={:?}, bound={:?})", + ty, bound); let mut fulfill_cx = FulfillmentContext::new(false); @@ -337,16 +336,16 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, // assume it is move; linear is always ok. match fulfill_cx.select_all_or_error(infcx, typer) { Ok(()) => { - debug!("type_known_to_meet_builtin_bound: ty={} bound={:?} success", - ty.repr(), + debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} success", + ty, bound); true } Err(e) => { - debug!("type_known_to_meet_builtin_bound: ty={} bound={:?} errors={}", - ty.repr(), + debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} errors={:?}", + ty, bound, - e.repr()); + e); false } } @@ -376,8 +375,8 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi let span = cause.span; let body_id = cause.body_id; - debug!("normalize_param_env_or_error(unnormalized_env={})", - unnormalized_env.repr()); + debug!("normalize_param_env_or_error(unnormalized_env={:?})", + unnormalized_env); let predicates: Vec<_> = util::elaborate_predicates(tcx, unnormalized_env.caller_bounds.clone()) @@ -392,8 +391,8 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi // constructed, but I am not currently doing so out of laziness. // -nmatsakis - debug!("normalize_param_env_or_error: elaborated-predicates={}", - predicates.repr()); + debug!("normalize_param_env_or_error: elaborated-predicates={:?}", + predicates); let elaborated_env = unnormalized_env.with_caller_bounds(predicates); @@ -435,21 +434,21 @@ pub fn fully_normalize<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, -> Result>> where T : TypeFoldable<'tcx> + HasProjectionTypes { - debug!("normalize_param_env(value={})", value.repr()); + debug!("normalize_param_env(value={:?})", value); let mut selcx = &mut SelectionContext::new(infcx, closure_typer); let mut fulfill_cx = FulfillmentContext::new(false); let Normalized { value: normalized_value, obligations } = project::normalize(selcx, cause, value); - debug!("normalize_param_env: normalized_value={} obligations={}", - normalized_value.repr(), - obligations.repr()); + debug!("normalize_param_env: normalized_value={:?} obligations={:?}", + normalized_value, + obligations); for obligation in obligations { fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation); } try!(fulfill_cx.select_all_or_error(infcx, closure_typer)); let resolved_value = infcx.resolve_type_vars_if_possible(&normalized_value); - debug!("normalize_param_env: resolved_value={}", resolved_value.repr()); + debug!("normalize_param_env: resolved_value={:?}", resolved_value); Ok(resolved_value) } diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/middle/traits/object_safety.rs index daa03c5160c01..afb30716c3669 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/middle/traits/object_safety.rs @@ -25,7 +25,6 @@ use middle::traits; use middle::ty::{self, ToPolyTraitRef, Ty}; use std::rc::Rc; use syntax::ast; -use util::ppaux::Repr; #[derive(Debug)] pub enum ObjectSafetyViolation<'tcx> { @@ -71,7 +70,7 @@ pub fn is_object_safe<'tcx>(tcx: &ty::ctxt<'tcx>, result }); - debug!("is_object_safe({}) = {}", trait_def_id.repr(), result); + debug!("is_object_safe({:?}) = {}", trait_def_id, result); result } @@ -112,9 +111,9 @@ fn object_safety_violations_for_trait<'tcx>(tcx: &ty::ctxt<'tcx>, violations.push(ObjectSafetyViolation::SupertraitSelf); } - debug!("object_safety_violations_for_trait(trait_def_id={}) = {}", - trait_def_id.repr(), - violations.repr()); + debug!("object_safety_violations_for_trait(trait_def_id={:?}) = {:?}", + trait_def_id, + violations); violations } diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index 967edabc0b9c1..3ac58dafa4a7a 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -28,7 +28,6 @@ use middle::ty::{self, AsPredicate, ReferencesError, RegionEscape, use middle::ty_fold::{self, TypeFoldable, TypeFolder}; use syntax::parse::token; use util::common::FN_OUTPUT_NAME; -use util::ppaux::Repr; use std::fmt; @@ -79,8 +78,8 @@ pub fn poly_project_and_unify_type<'cx,'tcx>( obligation: &PolyProjectionObligation<'tcx>) -> Result>>, MismatchedProjectionTypes<'tcx>> { - debug!("poly_project_and_unify_type(obligation={})", - obligation.repr()); + debug!("poly_project_and_unify_type(obligation={:?})", + obligation); let infcx = selcx.infcx(); infcx.commit_if_ok(|snapshot| { @@ -112,8 +111,8 @@ fn project_and_unify_type<'cx,'tcx>( obligation: &ProjectionObligation<'tcx>) -> Result>>, MismatchedProjectionTypes<'tcx>> { - debug!("project_and_unify_type(obligation={})", - obligation.repr()); + debug!("project_and_unify_type(obligation={:?})", + obligation); let Normalized { value: normalized_ty, obligations } = match opt_normalize_projection_type(selcx, @@ -127,9 +126,9 @@ fn project_and_unify_type<'cx,'tcx>( } }; - debug!("project_and_unify_type: normalized_ty={} obligations={}", - normalized_ty.repr(), - obligations.repr()); + debug!("project_and_unify_type: normalized_ty={:?} obligations={:?}", + normalized_ty, + obligations); let infcx = selcx.infcx(); let origin = infer::RelateOutputImplTypes(obligation.cause.span); @@ -141,8 +140,8 @@ fn project_and_unify_type<'cx,'tcx>( fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext<'cx,'tcx>, obligation: &ProjectionObligation<'tcx>) { - debug!("consider_unification_despite_ambiguity(obligation={})", - obligation.repr()); + debug!("consider_unification_despite_ambiguity(obligation={:?})", + obligation); let def_id = obligation.predicate.projection_ty.trait_ref.def_id; match selcx.tcx().lang_items.fn_trait_kind(def_id) { @@ -176,7 +175,7 @@ fn consider_unification_despite_ambiguity<'cx,'tcx>(selcx: &mut SelectionContext &ty::Binder(ret_type)); debug!("consider_unification_despite_ambiguity: ret_type={:?}", - ret_type.repr()); + ret_type); let origin = infer::RelateOutputImplTypes(obligation.cause.span); let obligation_ty = obligation.predicate.ty; match infer::mk_eqty(infcx, true, origin, obligation_ty, ret_type) { @@ -357,9 +356,9 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( -> Option> { debug!("normalize_projection_type(\ - projection_ty={}, \ + projection_ty={:?}, \ depth={})", - projection_ty.repr(), + projection_ty, depth); let obligation = Obligation::with_depth(cause.clone(), depth, projection_ty.clone()); @@ -370,17 +369,17 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( // an impl, where-clause etc) and hence we must // re-normalize it - debug!("normalize_projection_type: projected_ty={} depth={} obligations={}", - projected_ty.repr(), + debug!("normalize_projection_type: projected_ty={:?} depth={} obligations={:?}", + projected_ty, depth, - obligations.repr()); + obligations); if ty::type_has_projection(projected_ty) { let mut normalizer = AssociatedTypeNormalizer::new(selcx, cause, depth); let normalized_ty = normalizer.fold(&projected_ty); - debug!("normalize_projection_type: normalized_ty={} depth={}", - normalized_ty.repr(), + debug!("normalize_projection_type: normalized_ty={:?} depth={}", + normalized_ty, depth); obligations.extend(normalizer.obligations); @@ -396,8 +395,8 @@ fn opt_normalize_projection_type<'a,'b,'tcx>( } } Ok(ProjectedTy::NoProgress(projected_ty)) => { - debug!("normalize_projection_type: projected_ty={} no progress", - projected_ty.repr()); + debug!("normalize_projection_type: projected_ty={:?} no progress", + projected_ty); Some(Normalized { value: projected_ty, obligations: vec!() @@ -451,8 +450,8 @@ fn project_type<'cx,'tcx>( obligation: &ProjectionTyObligation<'tcx>) -> Result, ProjectionTyError<'tcx>> { - debug!("project(obligation={})", - obligation.repr()); + debug!("project(obligation={:?})", + obligation); let recursion_limit = selcx.tcx().sess.recursion_limit.get(); if obligation.recursion_depth >= recursion_limit { @@ -463,7 +462,7 @@ fn project_type<'cx,'tcx>( let obligation_trait_ref = selcx.infcx().resolve_type_vars_if_possible(&obligation.predicate.trait_ref); - debug!("project: obligation_trait_ref={}", obligation_trait_ref.repr()); + debug!("project: obligation_trait_ref={:?}", obligation_trait_ref); if obligation_trait_ref.references_error() { return Ok(ProjectedTy::Progress(selcx.tcx().types.err, vec!())); @@ -591,12 +590,12 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>( env_predicates: I) where I: Iterator> { - debug!("assemble_candidates_from_predicates(obligation={})", - obligation.repr()); + debug!("assemble_candidates_from_predicates(obligation={:?})", + obligation); let infcx = selcx.infcx(); for predicate in env_predicates { - debug!("assemble_candidates_from_predicates: predicate={}", - predicate.repr()); + debug!("assemble_candidates_from_predicates: predicate={:?}", + predicate); match predicate { ty::Predicate::Projection(ref data) => { let same_name = data.item_name() == obligation.predicate.item_name; @@ -613,10 +612,9 @@ fn assemble_candidates_from_predicates<'cx,'tcx,I>( obligation_poly_trait_ref).is_ok() }); - debug!("assemble_candidates_from_predicates: candidate {} is_match {} same_name {}", - data.repr(), - is_match, - same_name); + debug!("assemble_candidates_from_predicates: candidate={:?} \ + is_match={} same_name={}", + data, is_match, same_name); if is_match { candidate_set.vec.push( @@ -635,15 +633,15 @@ fn assemble_candidates_from_object_type<'cx,'tcx>( candidate_set: &mut ProjectionTyCandidateSet<'tcx>, object_ty: Ty<'tcx>) { - debug!("assemble_candidates_from_object_type(object_ty={})", - object_ty.repr()); + debug!("assemble_candidates_from_object_type(object_ty={:?})", + object_ty); let data = match object_ty.sty { ty::TyTrait(ref data) => data, _ => { selcx.tcx().sess.span_bug( obligation.cause.span, - &format!("assemble_candidates_from_object_type called with non-object: {}", - object_ty.repr())); + &format!("assemble_candidates_from_object_type called with non-object: {:?}", + object_ty)); } }; let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty); @@ -673,16 +671,16 @@ fn assemble_candidates_from_impls<'cx,'tcx>( return Ok(()); } Err(e) => { - debug!("assemble_candidates_from_impls: selection error {}", - e.repr()); + debug!("assemble_candidates_from_impls: selection error {:?}", + e); return Err(e); } }; match vtable { super::VtableImpl(data) => { - debug!("assemble_candidates_from_impls: impl candidate {}", - data.repr()); + debug!("assemble_candidates_from_impls: impl candidate {:?}", + data); candidate_set.vec.push( ProjectionTyCandidate::Impl(data)); @@ -732,8 +730,8 @@ fn assemble_candidates_from_impls<'cx,'tcx>( // These traits have no associated types. selcx.tcx().sess.span_bug( obligation.cause.span, - &format!("Cannot project an associated type from `{}`", - vtable.repr())); + &format!("Cannot project an associated type from `{:?}`", + vtable)); } } @@ -746,9 +744,9 @@ fn confirm_candidate<'cx,'tcx>( candidate: ProjectionTyCandidate<'tcx>) -> (Ty<'tcx>, Vec>) { - debug!("confirm_candidate(candidate={}, obligation={})", - candidate.repr(), - obligation.repr()); + debug!("confirm_candidate(candidate={:?}, obligation={:?})", + candidate, + obligation); match candidate { ProjectionTyCandidate::ParamEnv(poly_projection) => { @@ -812,9 +810,9 @@ fn confirm_callable_candidate<'cx,'tcx>( { let tcx = selcx.tcx(); - debug!("confirm_callable_candidate({},{})", - obligation.repr(), - fn_sig.repr()); + debug!("confirm_callable_candidate({:?},{:?})", + obligation, + fn_sig); // the `Output` associated type is declared on `FnOnce` let fn_once_def_id = tcx.lang_items.fn_once_trait().unwrap(); @@ -864,9 +862,9 @@ fn confirm_param_env_candidate<'cx,'tcx>( Err(e) => { selcx.tcx().sess.span_bug( obligation.cause.span, - &format!("Failed to unify `{}` and `{}` in projection: {}", - obligation.repr(), - projection.repr(), + &format!("Failed to unify `{:?}` and `{:?}` in projection: {}", + obligation, + projection, e)); } } @@ -914,8 +912,8 @@ fn confirm_impl_candidate<'cx,'tcx>( } selcx.tcx().sess.span_bug(obligation.cause.span, - &format!("No associated type for {}", - trait_ref.repr())); + &format!("No associated type for {:?}", + trait_ref)); } impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Normalized<'tcx, T> { diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 96d48faf9e092..1653cac68e6e0 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -51,7 +51,6 @@ use std::rc::Rc; use syntax::{abi, ast}; use util::common::ErrorReported; use util::nodemap::FnvHashMap; -use util::ppaux::Repr; pub struct SelectionContext<'cx, 'tcx:'cx> { infcx: &'cx InferCtxt<'cx, 'tcx>, @@ -300,7 +299,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { /// type environment by performing unification. pub fn select(&mut self, obligation: &TraitObligation<'tcx>) -> SelectionResult<'tcx, Selection<'tcx>> { - debug!("select({})", obligation.repr()); + debug!("select({:?})", obligation); assert!(!obligation.predicate.has_escaping_regions()); let stack = self.push_stack(TraitObligationStackList::empty(), obligation); @@ -389,8 +388,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &PredicateObligation<'tcx>) -> bool { - debug!("evaluate_obligation({})", - obligation.repr()); + debug!("evaluate_obligation({:?})", + obligation); self.evaluate_predicate_recursively(TraitObligationStackList::empty(), obligation) .may_apply() @@ -442,8 +441,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &PredicateObligation<'tcx>) -> EvaluationResult<'tcx> { - debug!("evaluate_predicate_recursively({})", - obligation.repr()); + debug!("evaluate_predicate_recursively({:?})", + obligation); // Check the cache from the tcx of predicates that we know // have been proven elsewhere. This cache only contains @@ -501,8 +500,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &TraitObligation<'tcx>) -> EvaluationResult<'tcx> { - debug!("evaluate_obligation_recursively({})", - obligation.repr()); + debug!("evaluate_obligation_recursively({:?})", + obligation); let stack = self.push_stack(previous_stack, obligation); @@ -549,8 +548,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |prev| self.match_fresh_trait_refs(&stack.fresh_trait_ref, &prev.fresh_trait_ref))) { - debug!("evaluate_stack({}) --> unbound argument, recursion --> ambiguous", - stack.fresh_trait_ref.repr()); + debug!("evaluate_stack({:?}) --> unbound argument, recursion --> ambiguous", + stack.fresh_trait_ref); return EvaluatedToAmbig; } @@ -578,8 +577,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { .skip(1) // skip top-most frame .any(|prev| stack.fresh_trait_ref == prev.fresh_trait_ref) { - debug!("evaluate_stack({}) --> recursive", - stack.fresh_trait_ref.repr()); + debug!("evaluate_stack({:?}) --> recursive", + stack.fresh_trait_ref); return EvaluatedToOk; } @@ -597,9 +596,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &TraitObligation<'tcx>) -> bool { - debug!("evaluate_impl(impl_def_id={}, obligation={})", - impl_def_id.repr(), - obligation.repr()); + debug!("evaluate_impl(impl_def_id={:?}, obligation={:?})", + impl_def_id, + obligation); self.infcx.probe(|snapshot| { match self.match_impl(impl_def_id, obligation, snapshot) { @@ -645,16 +644,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // with fresh skolemized types starting from index 0. let cache_fresh_trait_pred = self.infcx.freshen(stack.obligation.predicate.clone()); - debug!("candidate_from_obligation(cache_fresh_trait_pred={}, obligation={})", - cache_fresh_trait_pred.repr(), - stack.repr()); + debug!("candidate_from_obligation(cache_fresh_trait_pred={:?}, obligation={:?})", + cache_fresh_trait_pred, + stack); assert!(!stack.obligation.predicate.has_escaping_regions()); match self.check_candidate_cache(&cache_fresh_trait_pred) { Some(c) => { - debug!("CACHE HIT: cache_fresh_trait_pred={}, candidate={}", - cache_fresh_trait_pred.repr(), - c.repr()); + debug!("CACHE HIT: cache_fresh_trait_pred={:?}, candidate={:?}", + cache_fresh_trait_pred, + c); return c; } None => { } @@ -664,8 +663,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let candidate = self.candidate_from_obligation_no_cache(stack); if self.should_update_candidate_cache(&cache_fresh_trait_pred, &candidate) { - debug!("CACHE MISS: cache_fresh_trait_pred={}, candidate={}", - cache_fresh_trait_pred.repr(), candidate.repr()); + debug!("CACHE MISS: cache_fresh_trait_pred={:?}, candidate={:?}", + cache_fresh_trait_pred, candidate); self.insert_candidate_cache(cache_fresh_trait_pred, candidate.clone()); } @@ -694,10 +693,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let mut candidates = candidate_set.vec; - debug!("assembled {} candidates for {}: {}", + debug!("assembled {} candidates for {:?}: {:?}", candidates.len(), - stack.repr(), - candidates.repr()); + stack, + candidates); // At this point, we know that each of the entries in the // candidate set is *individually* applicable. Now we have to @@ -737,12 +736,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { .any(|j| self.candidate_should_be_dropped_in_favor_of(&candidates[i], &candidates[j])); if is_dup { - debug!("Dropping candidate #{}/{}: {}", - i, candidates.len(), candidates[i].repr()); + debug!("Dropping candidate #{}/{}: {:?}", + i, candidates.len(), candidates[i]); candidates.swap_remove(i); } else { - debug!("Retaining candidate #{}/{}: {}", - i, candidates.len(), candidates[i].repr()); + debug!("Retaining candidate #{}/{}: {:?}", + i, candidates.len(), candidates[i]); i += 1; } } @@ -908,8 +907,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { match self.tcx().lang_items.to_builtin_kind(obligation.predicate.def_id()) { Some(ty::BoundCopy) => { - debug!("obligation self ty is {}", - obligation.predicate.0.self_ty().repr()); + debug!("obligation self ty is {:?}", + obligation.predicate.0.self_ty()); // User-defined copy impls are permitted, but only for // structs and enums. @@ -959,9 +958,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let poly_trait_predicate = self.infcx().resolve_type_vars_if_possible(&obligation.predicate); - debug!("assemble_candidates_for_projected_tys({},{})", - obligation.repr(), - poly_trait_predicate.repr()); + debug!("assemble_candidates_for_projected_tys({:?},{:?})", + obligation, + poly_trait_predicate); // FIXME(#20297) -- just examining the self-type is very simplistic @@ -983,8 +982,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { _ => { return; } }; - debug!("assemble_candidates_for_projected_tys: trait_def_id={}", - trait_def_id.repr()); + debug!("assemble_candidates_for_projected_tys: trait_def_id={:?}", + trait_def_id); let result = self.infcx.probe(|snapshot| { self.match_projection_obligation_against_bounds_from_trait(obligation, @@ -1007,9 +1006,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let (skol_trait_predicate, skol_map) = self.infcx().skolemize_late_bound_regions(&poly_trait_predicate, snapshot); debug!("match_projection_obligation_against_bounds_from_trait: \ - skol_trait_predicate={} skol_map={}", - skol_trait_predicate.repr(), - skol_map.repr()); + skol_trait_predicate={:?} skol_map={:?}", + skol_trait_predicate, + skol_map); let projection_trait_ref = match skol_trait_predicate.trait_ref.self_ty().sty { ty::TyProjection(ref data) => &data.trait_ref, @@ -1017,19 +1016,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.tcx().sess.span_bug( obligation.cause.span, &format!("match_projection_obligation_against_bounds_from_trait() called \ - but self-ty not a projection: {}", - skol_trait_predicate.trait_ref.self_ty().repr())); + but self-ty not a projection: {:?}", + skol_trait_predicate.trait_ref.self_ty())); } }; debug!("match_projection_obligation_against_bounds_from_trait: \ - projection_trait_ref={}", - projection_trait_ref.repr()); + projection_trait_ref={:?}", + projection_trait_ref); let trait_predicates = ty::lookup_predicates(self.tcx(), projection_trait_ref.def_id); let bounds = trait_predicates.instantiate(self.tcx(), projection_trait_ref.substs); debug!("match_projection_obligation_against_bounds_from_trait: \ - bounds={}", - bounds.repr()); + bounds={:?}", + bounds); let matching_bound = util::elaborate_predicates(self.tcx(), bounds.predicates.into_vec()) @@ -1043,8 +1042,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { snapshot))); debug!("match_projection_obligation_against_bounds_from_trait: \ - matching_bound={}", - matching_bound.repr()); + matching_bound={:?}", + matching_bound); match matching_bound { None => false, Some(bound) => { @@ -1090,8 +1089,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidates: &mut SelectionCandidateSet<'tcx>) -> Result<(),SelectionError<'tcx>> { - debug!("assemble_candidates_from_caller_bounds({})", - stack.obligation.repr()); + debug!("assemble_candidates_from_caller_bounds({:?})", + stack.obligation); let all_bounds = self.param_env().caller_bounds @@ -1157,10 +1156,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { _ => { return Ok(()); } }; - debug!("assemble_unboxed_candidates: self_ty={} kind={:?} obligation={}", - self_ty.repr(), + debug!("assemble_unboxed_candidates: self_ty={:?} kind={:?} obligation={:?}", + self_ty, kind, - obligation.repr()); + obligation); match self.closure_typer.closure_kind(closure_def_id) { Some(closure_kind) => { @@ -1223,7 +1222,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidates: &mut SelectionCandidateSet<'tcx>) -> Result<(), SelectionError<'tcx>> { - debug!("assemble_candidates_from_impls(obligation={})", obligation.repr()); + debug!("assemble_candidates_from_impls(obligation={:?})", obligation); let def = ty::lookup_trait_def(self.tcx(), obligation.predicate.def_id()); @@ -1249,7 +1248,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { { // OK to skip binder here because the tests we do below do not involve bound regions let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()); - debug!("assemble_candidates_from_default_impls(self_ty={})", self_ty.repr()); + debug!("assemble_candidates_from_default_impls(self_ty={:?})", self_ty); let def_id = obligation.predicate.def_id(); @@ -1318,8 +1317,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &TraitObligation<'tcx>, candidates: &mut SelectionCandidateSet<'tcx>) { - debug!("assemble_candidates_from_object_ty(self_ty={})", - self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()).repr()); + debug!("assemble_candidates_from_object_ty(self_ty={:?})", + self.infcx.shallow_resolve(*obligation.self_ty().skip_binder())); // Object-safety candidates are only applicable to object-safe // traits. Including this check is useful because it helps @@ -1364,8 +1363,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } }; - debug!("assemble_candidates_from_object_ty: poly_trait_ref={}", - poly_trait_ref.repr()); + debug!("assemble_candidates_from_object_ty: poly_trait_ref={:?}", + poly_trait_ref); // see whether the object trait can be upcast to the trait we are looking for let upcast_trait_refs = self.upcast(poly_trait_ref, obligation); @@ -1408,8 +1407,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let source = self.infcx.shallow_resolve(self_ty); let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]); - debug!("assemble_candidates_for_unsizing(source={}, target={})", - source.repr(), target.repr()); + debug!("assemble_candidates_for_unsizing(source={:?}, target={:?})", + source, target); let may_apply = match (&source.sty, &target.sty) { // Trait+Kx+'a -> Trait+Ky+'b (upcasts). @@ -1475,7 +1474,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidate: &SelectionCandidate<'tcx>) -> EvaluationResult<'tcx> { - debug!("winnow_candidate: candidate={}", candidate.repr()); + debug!("winnow_candidate: candidate={:?}", candidate); let result = self.infcx.probe(|_| { let candidate = (*candidate).clone(); match self.confirm_candidate(stack.obligation, candidate) { @@ -1567,8 +1566,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { { match self.builtin_bound(bound, stack.obligation) { Ok(If(..)) => { - debug!("builtin_bound: bound={}", - bound.repr()); + debug!("builtin_bound: bound={:?}", + bound); candidates.vec.push(BuiltinCandidate(bound)); Ok(()) } @@ -1776,8 +1775,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { | ty::TyInfer(ty::FreshFloatTy(_)) => { self.tcx().sess.bug( &format!( - "asked to assemble builtin bounds of unexpected type: {}", - self_ty.repr())); + "asked to assemble builtin bounds of unexpected type: {:?}", + self_ty)); } }; @@ -1839,8 +1838,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::TyInfer(ty::FreshFloatTy(_)) => { self.tcx().sess.bug( &format!( - "asked to assemble constituent types of unexpected type: {}", - t.repr())); + "asked to assemble constituent types of unexpected type: {:?}", + t)); } ty::TyBox(referent_ty) => { // Box @@ -1974,9 +1973,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { candidate: SelectionCandidate<'tcx>) -> Result,SelectionError<'tcx>> { - debug!("confirm_candidate({}, {})", - obligation.repr(), - candidate.repr()); + debug!("confirm_candidate({:?}, {:?})", + obligation, + candidate); match candidate { BuiltinCandidate(builtin_bound) => { @@ -2066,9 +2065,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { param: ty::PolyTraitRef<'tcx>) -> Vec> { - debug!("confirm_param_candidate({},{})", - obligation.repr(), - param.repr()); + debug!("confirm_param_candidate({:?},{:?})", + obligation, + param); // During evaluation, we already checked that this // where-clause trait-ref could be unified with the obligation @@ -2078,9 +2077,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Ok(obligations) => obligations, Err(()) => { self.tcx().sess.bug( - &format!("Where clause `{}` was applicable to `{}` but now is not", - param.repr(), - obligation.repr())); + &format!("Where clause `{:?}` was applicable to `{:?}` but now is not", + param, + obligation)); } } } @@ -2091,16 +2090,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Result>, SelectionError<'tcx>> { - debug!("confirm_builtin_candidate({})", - obligation.repr()); + debug!("confirm_builtin_candidate({:?})", + obligation); match try!(self.builtin_bound(bound, obligation)) { If(nested) => Ok(self.vtable_builtin_data(obligation, bound, nested)), AmbiguousBuiltin | ParameterBuiltin => { self.tcx().sess.span_bug( obligation.cause.span, - &format!("builtin bound for {} was ambig", - obligation.repr())); + &format!("builtin bound for {:?} was ambig", + obligation)); } } } @@ -2120,8 +2119,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let obligations = self.collect_predicates_for_types(obligation, trait_def, nested); - debug!("vtable_builtin_data: obligations={}", - obligations.repr()); + debug!("vtable_builtin_data: obligations={:?}", + obligations); VtableBuiltinData { nested: obligations } } @@ -2136,9 +2135,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { trait_def_id: ast::DefId) -> VtableDefaultImplData> { - debug!("confirm_default_impl_candidate({}, {})", - obligation.repr(), - trait_def_id.repr()); + debug!("confirm_default_impl_candidate({:?}, {:?})", + obligation, + trait_def_id); // binder is moved below let self_ty = self.infcx.shallow_resolve(obligation.predicate.skip_binder().self_ty()); @@ -2147,8 +2146,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { None => { self.tcx().sess.bug( &format!( - "asked to confirm default implementation for ambiguous type: {}", - self_ty.repr())); + "asked to confirm default implementation for ambiguous type: {:?}", + self_ty)); } } } @@ -2158,9 +2157,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { trait_def_id: ast::DefId) -> VtableDefaultImplData> { - debug!("confirm_default_impl_object_candidate({}, {})", - obligation.repr(), - trait_def_id.repr()); + debug!("confirm_default_impl_object_candidate({:?}, {:?})", + obligation, + trait_def_id); assert!(ty::has_attr(self.tcx(), trait_def_id, "rustc_reflect_like")); @@ -2186,8 +2185,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { _ => { self.tcx().sess.bug( &format!( - "asked to confirm default object implementation for non-object type: {}", - self_ty.repr())); + "asked to confirm default object implementation for non-object type: {:?}", + self_ty)); } } } @@ -2199,7 +2198,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { nested: ty::Binder>>) -> VtableDefaultImplData> { - debug!("vtable_default_impl_data: nested={}", nested.repr()); + debug!("vtable_default_impl_data: nested={:?}", nested); let mut obligations = self.collect_predicates_for_types(obligation, trait_def_id, @@ -2220,7 +2219,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { // no Errors in that code above obligations.append(&mut trait_obligations.unwrap()); - debug!("vtable_default_impl_data: obligations={}", obligations.repr()); + debug!("vtable_default_impl_data: obligations={:?}", obligations); VtableDefaultImplData { trait_def_id: trait_def_id, @@ -2234,9 +2233,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Result>, SelectionError<'tcx>> { - debug!("confirm_impl_candidate({},{})", - obligation.repr(), - impl_def_id.repr()); + debug!("confirm_impl_candidate({:?},{:?})", + obligation, + impl_def_id); // First, create the substitutions by matching the impl again, // this time not in a probe. @@ -2244,7 +2243,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let (substs, skol_map) = self.rematch_impl(impl_def_id, obligation, snapshot); - debug!("confirm_impl_candidate substs={}", substs.repr()); + debug!("confirm_impl_candidate substs={:?}", substs); Ok(self.vtable_impl(impl_def_id, substs, obligation.cause.clone(), obligation.recursion_depth + 1, skol_map, snapshot)) }) @@ -2259,11 +2258,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { snapshot: &infer::CombinedSnapshot) -> VtableImplData<'tcx, PredicateObligation<'tcx>> { - debug!("vtable_impl(impl_def_id={}, substs={}, recursion_depth={}, skol_map={})", - impl_def_id.repr(), - substs.repr(), + debug!("vtable_impl(impl_def_id={:?}, substs={:?}, recursion_depth={}, skol_map={:?})", + impl_def_id, + substs, recursion_depth, - skol_map.repr()); + skol_map); let mut impl_obligations = self.impl_or_trait_obligations(cause, @@ -2273,9 +2272,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { skol_map, snapshot); - debug!("vtable_impl: impl_def_id={} impl_obligations={}", - impl_def_id.repr(), - impl_obligations.repr()); + debug!("vtable_impl: impl_def_id={:?} impl_obligations={:?}", + impl_def_id, + impl_obligations); impl_obligations.append(&mut substs.obligations); @@ -2288,8 +2287,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &TraitObligation<'tcx>) -> VtableObjectData<'tcx> { - debug!("confirm_object_candidate({})", - obligation.repr()); + debug!("confirm_object_candidate({:?})", + obligation); // FIXME skipping binder here seems wrong -- we should // probably flatten the binder from the obligation and the @@ -2330,8 +2329,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation: &TraitObligation<'tcx>) -> Result,SelectionError<'tcx>> { - debug!("confirm_fn_pointer_candidate({})", - obligation.repr()); + debug!("confirm_fn_pointer_candidate({:?})", + obligation); // ok to skip binder; it is reintroduced below let self_ty = self.infcx.shallow_resolve(*obligation.self_ty().skip_binder()); @@ -2357,20 +2356,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { -> Result>, SelectionError<'tcx>> { - debug!("confirm_closure_candidate({},{},{})", - obligation.repr(), - closure_def_id.repr(), - substs.repr()); + debug!("confirm_closure_candidate({:?},{:?},{:?})", + obligation, + closure_def_id, + substs); let Normalized { value: trait_ref, obligations } = self.closure_trait_ref(obligation, closure_def_id, substs); - debug!("confirm_closure_candidate(closure_def_id={}, trait_ref={}, obligations={})", - closure_def_id.repr(), - trait_ref.repr(), - obligations.repr()); + debug!("confirm_closure_candidate(closure_def_id={:?}, trait_ref={:?}, obligations={:?})", + closure_def_id, + trait_ref, + obligations); try!(self.confirm_poly_trait_refs(obligation.cause.clone(), obligation.predicate.to_poly_trait_ref(), @@ -2438,8 +2437,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { ty::no_late_bound_regions(tcx, &obligation.self_ty()).unwrap()); let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]); - debug!("confirm_builtin_unsize_candidate(source={}, target={})", - source.repr(), target.repr()); + debug!("confirm_builtin_unsize_candidate(source={:?}, target={:?})", + source, target); let mut nested = vec![]; match (&source.sty, &target.sty) { @@ -2615,9 +2614,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { Ok((substs, skol_map)) => (substs, skol_map), Err(()) => { self.tcx().sess.bug( - &format!("Impl {} was matchable against {} but now is not", - impl_def_id.repr(), - obligation.repr())); + &format!("Impl {:?} was matchable against {:?} but now is not", + impl_def_id, + obligation)); } } } @@ -2656,12 +2655,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligation.recursion_depth + 1, &impl_trait_ref); - debug!("match_impl(impl_def_id={}, obligation={}, \ - impl_trait_ref={}, skol_obligation_trait_ref={})", - impl_def_id.repr(), - obligation.repr(), - impl_trait_ref.repr(), - skol_obligation_trait_ref.repr()); + debug!("match_impl(impl_def_id={:?}, obligation={:?}, \ + impl_trait_ref={:?}, skol_obligation_trait_ref={:?})", + impl_def_id, + obligation, + impl_trait_ref, + skol_obligation_trait_ref); let origin = infer::RelateOutputImplTypes(obligation.cause.span); if let Err(e) = self.infcx.sub_trait_refs(false, @@ -2677,7 +2676,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { return Err(()); } - debug!("match_impl: success impl_substs={}", impl_substs.repr()); + debug!("match_impl: success impl_substs={:?}", impl_substs); Ok((Normalized { value: impl_substs, obligations: impl_trait_ref.obligations @@ -2728,9 +2727,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { poly_trait_ref: ty::PolyTraitRef<'tcx>) -> Result<(),()> { - debug!("match_poly_trait_ref: obligation={} poly_trait_ref={}", - obligation.repr(), - poly_trait_ref.repr()); + debug!("match_poly_trait_ref: obligation={:?} poly_trait_ref={:?}", + obligation, + poly_trait_ref); let origin = infer::RelateOutputImplTypes(obligation.cause.span); match self.infcx.sub_poly_trait_refs(false, @@ -2769,15 +2768,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { let impl_self_ty = ty::lookup_item_type(self.tcx(), impl_def_id).ty; let impl_self_ty = impl_self_ty.subst(self.tcx(), &impl_substs); - debug!("match_impl_self_types(obligation_self_ty={}, impl_self_ty={})", - obligation_self_ty.repr(), - impl_self_ty.repr()); + debug!("match_impl_self_types(obligation_self_ty={:?}, impl_self_ty={:?})", + obligation_self_ty, + impl_self_ty); match self.match_self_types(obligation_cause, impl_self_ty, obligation_self_ty) { Ok(()) => { - debug!("Matched impl_substs={}", impl_substs.repr()); + debug!("Matched impl_substs={:?}", impl_substs); Ok(impl_substs) } Err(()) => { @@ -2889,7 +2888,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { snapshot: &infer::CombinedSnapshot) -> Vec> { - debug!("impl_or_trait_obligations(def_id={})", def_id.repr()); + debug!("impl_or_trait_obligations(def_id={:?})", def_id); let predicates = ty::lookup_predicates(self.tcx(), def_id); let predicates = predicates.instantiate(self.tcx(), substs); @@ -2939,9 +2938,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { fn upcast(&mut self, obj_trait_ref: ty::PolyTraitRef<'tcx>, obligation: &TraitObligation<'tcx>) -> Vec> { - debug!("upcast(obj_trait_ref={}, obligation={})", - obj_trait_ref.repr(), - obligation.repr()); + debug!("upcast(obj_trait_ref={:?}, obligation={:?})", + obj_trait_ref, + obligation); let obligation_def_id = obligation.predicate.def_id(); let mut upcast_trait_refs = util::upcast(self.tcx(), obj_trait_ref, obligation_def_id); @@ -2957,7 +2956,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { self.infcx.probe(|_| self.match_poly_trait_ref(obligation, upcast_trait_ref)).is_ok() }); - debug!("upcast: upcast_trait_refs={}", upcast_trait_refs.repr()); + debug!("upcast: upcast_trait_refs={:?}", upcast_trait_refs); upcast_trait_refs } } diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index 2c6feb66fa8ca..6fb085c8838d7 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -16,7 +16,6 @@ use syntax::ast; use syntax::codemap::Span; use util::common::ErrorReported; use util::nodemap::FnvHashSet; -use util::ppaux::Repr; use super::{Obligation, ObligationCause, PredicateObligation, VtableImpl, VtableParam, VtableImplData, VtableDefaultImplData}; @@ -125,8 +124,8 @@ impl<'cx, 'tcx> Elaborator<'cx, 'tcx> { .map(|p| p.subst_supertrait(self.tcx, &data.to_poly_trait_ref())) .collect(); - debug!("super_predicates: data={} predicates={}", - data.repr(), predicates.repr()); + debug!("super_predicates: data={:?} predicates={:?}", + data, predicates); // Only keep those bounds that we haven't already // seen. This is necessary to prevent infinite @@ -314,8 +313,8 @@ pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, generic_bounds: &ty::InstantiatedPredicates<'tcx>) -> Vec> { - debug!("predicates_for_generics(generic_bounds={})", - generic_bounds.repr()); + debug!("predicates_for_generics(generic_bounds={:?})", + generic_bounds); generic_bounds.predicates.iter().map(|predicate| { Obligation { cause: cause.clone(), diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 1274b3498fd33..e82754680a5e9 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -66,7 +66,6 @@ use middle::traits; use middle::ty; use middle::ty_fold::{self, TypeFoldable, TypeFolder}; use middle::ty_walk::{self, TypeWalker}; -use util::ppaux::{Repr, UserString}; use util::common::{memoized, ErrorReported}; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; use util::nodemap::FnvHashMap; @@ -2848,8 +2847,8 @@ impl<'tcx> TraitDef<'tcx> { tcx: &ctxt<'tcx>, impl_def_id: DefId, impl_trait_ref: TraitRef<'tcx>) { - debug!("TraitDef::record_impl for {}, from {}", - self.repr(), impl_trait_ref.repr()); + debug!("TraitDef::record_impl for {:?}, from {:?}", + self, impl_trait_ref); // We don't want to borrow_mut after we already populated all impls, // so check if an impl is present with an immutable borrow first. @@ -3773,7 +3772,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> { TyArray(ty, _) | TySlice(ty) => ty, TyStr => mk_mach_uint(cx, ast::TyU8), _ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}", - ty.user_string())), + ty)), } } @@ -4242,8 +4241,8 @@ fn type_impls_bound<'a,'tcx>(param_env: Option<&ParameterEnvironment<'a,'tcx>>, let is_impld = traits::type_known_to_meet_builtin_bound(&infcx, param_env, ty, bound, span); - debug!("type_impls_bound({}, {:?}) = {:?}", - ty.repr(), + debug!("type_impls_bound({:?}, {:?}) = {:?}", + ty, bound, is_impld); @@ -4344,20 +4343,20 @@ pub fn is_ffi_safe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool { pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec, r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool { - debug!("type_requires({}, {})?", - r_ty.repr(), ty.repr()); + debug!("type_requires({:?}, {:?})?", + r_ty, ty); let r = r_ty == ty || subtypes_require(cx, seen, r_ty, ty); - debug!("type_requires({}, {})? {:?}", - r_ty.repr(), ty.repr(), r); + debug!("type_requires({:?}, {:?})? {:?}", + r_ty, ty, r); return r; } fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec, r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool { - debug!("subtypes_require({}, {})?", - r_ty.repr(), ty.repr()); + debug!("subtypes_require({:?}, {:?})?", + r_ty, ty); let r = match ty.sty { // fixed length vectors need special treatment compared to @@ -4435,8 +4434,8 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool { } }; - debug!("subtypes_require({}, {})? {:?}", - r_ty.repr(), ty.repr(), r); + debug!("subtypes_require({:?}, {:?})? {:?}", + r_ty, ty, r); return r; } @@ -4542,7 +4541,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span, seen: &mut Vec>, ty: Ty<'tcx>) -> Representability { - debug!("is_type_structurally_recursive: {}", ty.repr()); + debug!("is_type_structurally_recursive: {:?}", ty); match ty.sty { TyStruct(did, _) | TyEnum(did, _) => { @@ -4561,9 +4560,9 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) match iter.next() { Some(&seen_type) => { if same_struct_or_enum_def_id(seen_type, did) { - debug!("SelfRecursive: {} contains {}", - seen_type.repr(), - ty.repr()); + debug!("SelfRecursive: {:?} contains {:?}", + seen_type, + ty); return SelfRecursive; } } @@ -4581,9 +4580,9 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) for &seen_type in iter { if same_type(ty, seen_type) { - debug!("ContainsRecursive: {} contains {}", - seen_type.repr(), - ty.repr()); + debug!("ContainsRecursive: {:?} contains {:?}", + seen_type, + ty); return ContainsRecursive; } } @@ -4603,14 +4602,14 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>) } } - debug!("is_type_representable: {}", ty.repr()); + debug!("is_type_representable: {:?}", ty); // To avoid a stack overflow when checking an enum variant or struct that // contains a different, structurally recursive type, maintain a stack // of seen types and check recursion for each of them (issues #3008, #3779). let mut seen: Vec = Vec::new(); let r = is_type_structurally_recursive(cx, sp, &mut seen, ty); - debug!("is_type_representable: {} is {:?}", ty.repr(), r); + debug!("is_type_representable: {:?} is {:?}", ty, r); r } @@ -5012,7 +5011,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>, _ => { cx.sess.bug( &format!("AdjustReifyFnPointer adjustment on non-fn-item: \ - {}", unadjusted_ty.repr())); + {:?}", unadjusted_ty)); } } } @@ -5053,7 +5052,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>, span, &format!("the {}th autoderef failed: {}", i, - adjusted_ty.user_string()) + adjusted_ty) ); } } @@ -5298,8 +5297,8 @@ pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem]) pub fn ty_sort_string(cx: &ctxt, ty: Ty) -> String { match ty.sty { TyBool | TyChar | TyInt(_) | - TyUint(_) | TyFloat(_) | TyStr => ty.user_string(), - TyTuple(ref tys) if tys.is_empty() => ty.user_string(), + TyUint(_) | TyFloat(_) | TyStr => ty.to_string(), + TyTuple(ref tys) if tys.is_empty() => ty.to_string(), TyEnum(id, _) => format!("enum `{}`", item_path_str(cx, id)), TyBox(_) => "box".to_string(), @@ -6067,7 +6066,7 @@ fn report_discrim_overflow(cx: &ctxt, let computed_value = repr_type.disr_wrap_incr(Some(prev_val)); let computed_value = repr_type.disr_string(computed_value); let prev_val = repr_type.disr_string(prev_val); - let repr_type = repr_type.to_ty(cx).user_string(); + let repr_type = repr_type.to_ty(cx); span_err!(cx.sess, variant_span, E0370, "enum discriminant overflowed on value after {}: {}; \ set explicitly via {} = {} if that is desired outcome", @@ -6560,8 +6559,8 @@ pub fn required_region_bounds<'tcx>(tcx: &ctxt<'tcx>, -> Vec { debug!("required_region_bounds(erased_self_ty={:?}, predicates={:?})", - erased_self_ty.repr(), - predicates.repr()); + erased_self_ty, + predicates); assert!(!erased_self_ty.has_escaping_regions()); @@ -6679,7 +6678,7 @@ pub fn populate_implementations_for_trait_if_necessary(tcx: &ctxt, trait_id: ast return; } - debug!("populate_implementations_for_trait_if_necessary: searching for {}", def.repr()); + debug!("populate_implementations_for_trait_if_necessary: searching for {:?}", def); if csearch::is_defaulted_trait(&tcx.sess.cstore, trait_id) { record_trait_has_default_impl(tcx, trait_id); @@ -6988,7 +6987,7 @@ pub fn construct_free_substs<'a,'tcx>( defs: &[TypeParameterDef<'tcx>]) { for def in defs { debug!("construct_parameter_environment(): push_types_from_defs: def={:?}", - def.repr()); + def); let ty = ty::mk_param_from_def(tcx, def); types.push(def.space, ty); } @@ -7021,8 +7020,8 @@ pub fn construct_parameter_environment<'a,'tcx>( debug!("construct_parameter_environment: free_id={:?} free_subst={:?} predicates={:?}", free_id, - free_substs.repr(), - predicates.repr()); + free_substs, + predicates); // // Finally, we have to normalize the bounds in the environment, in diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index adc282bc2fdd5..63c46032479a4 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -45,7 +45,6 @@ use syntax::abi; use syntax::ast; use syntax::owned_slice::OwnedSlice; use util::nodemap::FnvHashMap; -use util::ppaux::Repr; /////////////////////////////////////////////////////////////////////////// // Two generic traits @@ -844,13 +843,13 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionFolder<'a, 'tcx> fn fold_region(&mut self, r: ty::Region) -> ty::Region { match r { ty::ReLateBound(debruijn, _) if debruijn.depth < self.current_depth => { - debug!("RegionFolder.fold_region({}) skipped bound region (current depth={})", - r.repr(), self.current_depth); + debug!("RegionFolder.fold_region({:?}) skipped bound region (current depth={})", + r, self.current_depth); r } _ => { - debug!("RegionFolder.fold_region({}) folding free region (current_depth={})", - r.repr(), self.current_depth); + debug!("RegionFolder.fold_region({:?}) folding free region (current_depth={})", + r, self.current_depth); (self.fld_r)(r, self.current_depth) } } @@ -889,7 +888,7 @@ pub fn replace_late_bound_regions<'tcx,T,F>(tcx: &ty::ctxt<'tcx>, where F : FnMut(ty::BoundRegion) -> ty::Region, T : TypeFoldable<'tcx>, { - debug!("replace_late_bound_regions({})", value.repr()); + debug!("replace_late_bound_regions({:?})", value); let mut replacer = RegionReplacer::new(tcx, &mut f); let result = value.skip_binder().fold_with(&mut replacer); (result, replacer.map) @@ -918,8 +917,8 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionReplacer<'a, 'tcx> fn fold_region(&mut self, r: ty::Region) -> ty::Region { match r { ty::ReLateBound(debruijn, br) if debruijn.depth == self.current_depth => { - debug!("RegionReplacer.fold_region({}) folding region (current_depth={})", - r.repr(), self.current_depth); + debug!("RegionReplacer.fold_region({:?}) folding region (current_depth={})", + r, self.current_depth); let fld_r = &mut self.fld_r; let region = *self.map.entry(br).or_insert_with(|| fld_r(br)); if let ty::ReLateBound(debruijn1, br) = region { @@ -998,8 +997,8 @@ pub fn shift_region(region: ty::Region, amount: u32) -> ty::Region { pub fn shift_regions<'tcx, T:TypeFoldable<'tcx>>(tcx: &ty::ctxt<'tcx>, amount: u32, value: &T) -> T { - debug!("shift_regions(value={}, amount={})", - value.repr(), amount); + debug!("shift_regions(value={:?}, amount={})", + value, amount); value.fold_with(&mut RegionFolder::new(tcx, &mut |region, _current_depth| { shift_region(region, amount) diff --git a/src/librustc/middle/ty_match.rs b/src/librustc/middle/ty_match.rs index 3c9777935706f..135118820a771 100644 --- a/src/librustc/middle/ty_match.rs +++ b/src/librustc/middle/ty_match.rs @@ -10,7 +10,6 @@ use middle::ty::{self, Ty}; use middle::ty_relate::{self, Relate, TypeRelation, RelateResult}; -use util::ppaux::Repr; /// A type "A" *matches* "B" if the fresh types in B could be /// substituted with values so as to make it equal to A. Matching is @@ -53,16 +52,16 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Match<'a, 'tcx> { } fn regions(&mut self, a: ty::Region, b: ty::Region) -> RelateResult<'tcx, ty::Region> { - debug!("{}.regions({}, {})", + debug!("{}.regions({:?}, {:?})", self.tag(), - a.repr(), - b.repr()); + a, + b); Ok(a) } fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { - debug!("{}.tys({}, {})", self.tag(), - a.repr(), b.repr()); + debug!("{}.tys({:?}, {:?})", self.tag(), + a, b); if a == b { return Ok(a); } match (&a.sty, &b.sty) { diff --git a/src/librustc/middle/ty_relate/mod.rs b/src/librustc/middle/ty_relate/mod.rs index e9c84f4c9ce2a..b8c212fe3f20b 100644 --- a/src/librustc/middle/ty_relate/mod.rs +++ b/src/librustc/middle/ty_relate/mod.rs @@ -19,7 +19,6 @@ use middle::ty_fold::TypeFoldable; use std::rc::Rc; use syntax::abi; use syntax::ast; -use util::ppaux::Repr; pub type RelateResult<'tcx, T> = Result>; @@ -79,10 +78,10 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::mt<'tcx> { -> RelateResult<'tcx, ty::mt<'tcx>> where R: TypeRelation<'a,'tcx> { - debug!("{}.mts({}, {})", + debug!("{}.mts({:?}, {:?})", relation.tag(), - a.repr(), - b.repr()); + a, + b); if a.mutbl != b.mutbl { Err(ty::terr_mutability) } else { @@ -107,10 +106,10 @@ fn relate_item_substs<'a,'tcx:'a,R>(relation: &mut R, -> RelateResult<'tcx, Substs<'tcx>> where R: TypeRelation<'a,'tcx> { - debug!("substs: item_def_id={} a_subst={} b_subst={}", - item_def_id.repr(), - a_subst.repr(), - b_subst.repr()); + debug!("substs: item_def_id={:?} a_subst={:?} b_subst={:?}", + item_def_id, + a_subst, + b_subst); let variances; let opt_variances = if relation.tcx().variance_computed.get() { @@ -193,11 +192,11 @@ fn relate_region_params<'a,'tcx:'a,R>(relation: &mut R, { let num_region_params = a_rs.len(); - debug!("relate_region_params(a_rs={}, \ - b_rs={}, variances={})", - a_rs.repr(), - b_rs.repr(), - variances.repr()); + debug!("relate_region_params(a_rs={:?}, \ + b_rs={:?}, variances={:?})", + a_rs, + b_rs, + variances); assert_eq!(num_region_params, variances.map_or(num_region_params, diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 5d524c51b5eb3..485d856ac2508 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -28,28 +28,6 @@ use syntax::abi; use syntax::parse::token; use syntax::{ast, ast_util}; -/// Produces a string suitable for debugging output. -pub trait Repr { - fn repr(&self) -> String; -} - -/// Produces a string suitable for showing to the user. -pub trait UserString { - fn user_string(&self) -> String; -} - -impl Repr for T { - fn repr(&self) -> String { - format!("{:?}", *self) - } -} - -impl UserString for T { - fn user_string(&self) -> String { - format!("{}", *self) - } -} - pub fn verbose() -> bool { ty::tls::with(|tcx| tcx.sess.verbose()) } @@ -146,7 +124,7 @@ fn parameterized(f: &mut fmt::Formatter, subst::NonerasedRegions(ref regions) => { for &r in regions { try!(start_or_continue(f, "<", ", ")); - let s = r.user_string(); + let s = r.to_string(); if s.is_empty() { // This happens when the value of the region // parameter is not easily serialized. This may be @@ -316,7 +294,7 @@ impl<'tcx> fmt::Display for ty::TraitTy<'tcx> { // Region, if not obviously implied by builtin bounds. if bounds.region_bound != ty::ReStatic { // Region bound is implied by builtin bounds: - let bound = bounds.region_bound.user_string(); + let bound = bounds.region_bound.to_string(); if !bound.is_empty() { try!(write!(f, " + {}", bound)); } @@ -589,7 +567,7 @@ impl<'tcx> fmt::Debug for ty::ExistentialBounds<'tcx> { } }; - let region_str = self.region_bound.repr(); + let region_str = format!("{:?}", self.region_bound); if !region_str.is_empty() { try!(maybe_continue(f)); try!(write!(f, "{}", region_str)); @@ -693,7 +671,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> { } TyRef(r, ref tm) => { try!(write!(f, "&")); - let s = r.user_string(); + let s = r.to_string(); try!(write!(f, "{}", s)); if !s.is_empty() { try!(write!(f, " ")); diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index b15586cc2b455..49933441cf01e 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -24,7 +24,6 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::region; use rustc::middle::ty; -use rustc::util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; @@ -97,8 +96,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { consume_span: Span, cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume(consume_id={}, cmt={}, mode={:?})", - consume_id, cmt.repr(), mode); + debug!("consume(consume_id={}, cmt={:?}, mode={:?})", + consume_id, cmt, mode); self.consume_common(consume_id, consume_span, cmt, mode); } @@ -112,9 +111,9 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { consume_pat: &ast::Pat, cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume_pat(consume_pat={}, cmt={}, mode={:?})", - consume_pat.repr(), - cmt.repr(), + debug!("consume_pat(consume_pat={:?}, cmt={:?}, mode={:?})", + consume_pat, + cmt, mode); self.consume_common(consume_pat.id, consume_pat.span, cmt, mode); @@ -128,9 +127,9 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { bk: ty::BorrowKind, loan_cause: euv::LoanCause) { - debug!("borrow(borrow_id={}, cmt={}, loan_region={:?}, \ + debug!("borrow(borrow_id={}, cmt={:?}, loan_region={:?}, \ bk={:?}, loan_cause={:?})", - borrow_id, cmt.repr(), loan_region, + borrow_id, cmt, loan_region, bk, loan_cause); match opt_loan_path(&cmt) { @@ -153,8 +152,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for CheckLoanCtxt<'a, 'tcx> { assignee_cmt: mc::cmt<'tcx>, mode: euv::MutateMode) { - debug!("mutate(assignment_id={}, assignee_cmt={})", - assignment_id, assignee_cmt.repr()); + debug!("mutate(assignment_id={}, assignee_cmt={:?})", + assignment_id, assignee_cmt); match opt_loan_path(&assignee_cmt) { Some(lp) => { @@ -384,9 +383,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! Checks whether `old_loan` and `new_loan` can safely be issued //! simultaneously. - debug!("report_error_if_loans_conflict(old_loan={}, new_loan={})", - old_loan.repr(), - new_loan.repr()); + debug!("report_error_if_loans_conflict(old_loan={:?}, new_loan={:?})", + old_loan, + new_loan); // Should only be called for loans that are in scope at the same time. assert!(self.tcx().region_maps.scopes_intersect(old_loan.kill_scope, @@ -408,9 +407,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! prohibit `loan2`. Returns false if an error is reported. debug!("report_error_if_loan_conflicts_with_restriction(\ - loan1={}, loan2={})", - loan1.repr(), - loan2.repr()); + loan1={:?}, loan2={:?})", + loan1, + loan2); if compatible_borrow_kinds(loan1.kind, loan2.kind) { return true; @@ -672,9 +671,9 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { use_path: &LoanPath<'tcx>, borrow_kind: ty::BorrowKind) -> UseError<'tcx> { - debug!("analyze_restrictions_on_use(expr_id={}, use_path={})", + debug!("analyze_restrictions_on_use(expr_id={}, use_path={:?})", self.tcx().map.node_to_string(expr_id), - use_path.repr()); + use_path); let mut ret = UseOk; @@ -698,8 +697,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { span: Span, use_kind: MovedValueUseKind, lp: &Rc>) { - debug!("check_if_path_is_moved(id={}, use_kind={:?}, lp={})", - id, use_kind, lp.repr()); + debug!("check_if_path_is_moved(id={}, use_kind={:?}, lp={:?})", + id, use_kind, lp); // FIXME (22079): if you find yourself tempted to cut and paste // the body below and then specializing the error reporting, @@ -792,7 +791,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { assignment_span: Span, assignee_cmt: mc::cmt<'tcx>, mode: euv::MutateMode) { - debug!("check_assignment(assignee_cmt={})", assignee_cmt.repr()); + debug!("check_assignment(assignee_cmt={:?})", assignee_cmt); // Mutable values can be assigned, as long as they obey loans // and aliasing restrictions: @@ -884,7 +883,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! `used_mut_nodes` table here. loop { - debug!("mark_variable_as_used_mut(cmt={})", cmt.repr()); + debug!("mark_variable_as_used_mut(cmt={:?})", cmt); match cmt.cat.clone() { mc::cat_upvar(mc::Upvar { id: ty::UpvarId { var_id: id, .. }, .. }) | mc::cat_local(id) => { @@ -929,8 +928,8 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> { //! Safety checks related to writes to aliasable, mutable locations let guarantor = cmt.guarantor(); - debug!("check_for_aliasable_mutable_writes(cmt={}, guarantor={})", - cmt.repr(), guarantor.repr()); + debug!("check_for_aliasable_mutable_writes(cmt={:?}, guarantor={:?})", + cmt, guarantor); if let mc::cat_deref(ref b, _, mc::BorrowedPtr(ty::MutBorrow, _)) = guarantor.cat { // Statically prohibit writes to `&mut` when aliasable check_for_aliasability_violation(this, span, b.clone()); diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index 6f896fffd3db3..93f5ac529d3fd 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -22,7 +22,7 @@ use borrowck::move_data::InvalidMovePathIndex; use borrowck::move_data::{MoveData, MovePathIndex}; use rustc::middle::ty; use rustc::middle::mem_categorization as mc; -use rustc::util::ppaux::{Repr, UserString}; + use std::mem; use std::rc::Rc; use syntax::ast; @@ -43,18 +43,18 @@ enum Fragment { impl Fragment { fn loan_path_repr(&self, move_data: &MoveData) -> String { - let repr = |mpi| move_data.path_loan_path(mpi).repr(); + let lp = |mpi| move_data.path_loan_path(mpi); match *self { - Just(mpi) => repr(mpi), - AllButOneFrom(mpi) => format!("$(allbutone {})", repr(mpi)), + Just(mpi) => format!("{:?}", lp(mpi)), + AllButOneFrom(mpi) => format!("$(allbutone {:?})", lp(mpi)), } } fn loan_path_user_string(&self, move_data: &MoveData) -> String { - let user_string = |mpi| move_data.path_loan_path(mpi).user_string(); + let lp = |mpi| move_data.path_loan_path(mpi); match *self { - Just(mpi) => user_string(mpi), - AllButOneFrom(mpi) => format!("$(allbutone {})", user_string(mpi)), + Just(mpi) => lp(mpi).to_string(), + AllButOneFrom(mpi) => format!("$(allbutone {})", lp(mpi)), } } } @@ -124,12 +124,12 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>, let instrument_all_paths = |kind, vec_rc: &Vec| { for (i, mpi) in vec_rc.iter().enumerate() { - let render = || this.path_loan_path(*mpi).user_string(); + let lp = || this.path_loan_path(*mpi); if span_err { - tcx.sess.span_err(sp, &format!("{}: `{}`", kind, render())); + tcx.sess.span_err(sp, &format!("{}: `{}`", kind, lp())); } if print { - println!("id:{} {}[{}] `{}`", id, kind, i, render()); + println!("id:{} {}[{}] `{}`", id, kind, i, lp()); } } }; @@ -170,7 +170,7 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) { let mut assigned = mem::replace(&mut fragments.assigned_leaf_paths, vec![]); let path_lps = |mpis: &[MovePathIndex]| -> Vec { - mpis.iter().map(|mpi| this.path_loan_path(*mpi).repr()).collect() + mpis.iter().map(|mpi| format!("{:?}", this.path_loan_path(*mpi))).collect() }; let frag_lps = |fs: &[Fragment]| -> Vec { @@ -341,8 +341,8 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>, let tuple_idx = match *origin_field_name { mc::PositionalField(tuple_idx) => tuple_idx, mc::NamedField(_) => - panic!("tuple type {} should not have named fields.", - parent_ty.repr()), + panic!("tuple type {:?} should not have named fields.", + parent_ty), }; let tuple_len = v.len(); for i in 0..tuple_len { @@ -416,8 +416,8 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>, } ref sty_and_variant_info => { - let msg = format!("type {} ({:?}) is not fragmentable", - parent_ty.repr(), sty_and_variant_info); + let msg = format!("type {:?} ({:?}) is not fragmentable", + parent_ty, sty_and_variant_info); let opt_span = origin_id.and_then(|id|tcx.map.opt_span(id)); tcx.sess.opt_span_bug(opt_span, &msg[..]) } @@ -448,8 +448,8 @@ fn add_fragment_sibling_core<'tcx>(this: &MoveData<'tcx>, }; let new_lp_variant = LpExtend(parent, mc, loan_path_elem); let new_lp = LoanPath::new(new_lp_variant, new_lp_type.unwrap()); - debug!("add_fragment_sibling_core(new_lp={}, origin_lp={})", - new_lp.repr(), origin_lp.repr()); + debug!("add_fragment_sibling_core(new_lp={:?}, origin_lp={:?})", + new_lp, origin_lp); let mp = this.move_path(tcx, Rc::new(new_lp)); // Do not worry about checking for duplicates here; we will sort diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index e1410daf279fe..7b6c54dbaca44 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -18,7 +18,7 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::InteriorOffsetKind as Kind; use rustc::middle::ty; -use rustc::util::ppaux::Repr; + use std::rc::Rc; use syntax::ast; use syntax::codemap::Span; @@ -66,8 +66,8 @@ pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, cmt: mc::cmt<'tcx>, mode: euv::MatchMode) { let tcx = bccx.tcx; - debug!("gather_match_variant(move_pat={}, cmt={}, mode={:?})", - move_pat.id, cmt.repr(), mode); + debug!("gather_match_variant(move_pat={}, cmt={:?}, mode={:?})", + move_pat.id, cmt, mode); let opt_lp = opt_loan_path(&cmt); match opt_lp { @@ -115,14 +115,14 @@ fn gather_move<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_data: &MoveData<'tcx>, move_error_collector: &MoveErrorCollector<'tcx>, move_info: GatherMoveInfo<'tcx>) { - debug!("gather_move(move_id={}, cmt={})", - move_info.id, move_info.cmt.repr()); + debug!("gather_move(move_id={}, cmt={:?})", + move_info.id, move_info.cmt); let potentially_illegal_move = check_and_get_illegal_move_origin(bccx, &move_info.cmt); match potentially_illegal_move { Some(illegal_move_origin) => { - debug!("illegal_move_origin={}", illegal_move_origin.repr()); + debug!("illegal_move_origin={:?}", illegal_move_origin); let error = MoveError::with_move_info(illegal_move_origin, move_info.span_path_opt); move_error_collector.add_error(error); diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index e4911543e6b54..427d78e89b3e2 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -16,7 +16,7 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::region; use rustc::middle::ty; -use rustc::util::ppaux::Repr; + use syntax::ast; use syntax::codemap::Span; @@ -33,8 +33,8 @@ pub fn guarantee_lifetime<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, //! Reports error if `loan_region` is larger than S //! where S is `item_scope` if `cmt` is an upvar, //! and is scope of `cmt` otherwise. - debug!("guarantee_lifetime(cmt={}, loan_region={})", - cmt.repr(), loan_region.repr()); + debug!("guarantee_lifetime(cmt={:?}, loan_region={:?})", + cmt, loan_region); let ctxt = GuaranteeLifetimeContext {bccx: bccx, item_scope: item_scope, span: span, @@ -65,9 +65,9 @@ impl<'a, 'tcx> GuaranteeLifetimeContext<'a, 'tcx> { //! Main routine. Walks down `cmt` until we find the //! "guarantor". Reports an error if `self.loan_region` is //! larger than scope of `cmt`. - debug!("guarantee_lifetime.check(cmt={}, loan_region={})", - cmt.repr(), - self.loan_region.repr()); + debug!("guarantee_lifetime.check(cmt={:?}, loan_region={:?})", + cmt, + self.loan_region); match cmt.cat { mc::cat_rvalue(..) | diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index a33104bff7053..f00eb872642f4 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -22,7 +22,7 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::region; use rustc::middle::ty; -use rustc::util::ppaux::Repr; + use syntax::ast; use syntax::codemap::Span; use syntax::visit; @@ -76,8 +76,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { _consume_span: Span, cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume(consume_id={}, cmt={}, mode={:?})", - consume_id, cmt.repr(), mode); + debug!("consume(consume_id={}, cmt={:?}, mode={:?})", + consume_id, cmt, mode); match mode { euv::Move(move_reason) => { @@ -93,9 +93,9 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { matched_pat: &ast::Pat, cmt: mc::cmt<'tcx>, mode: euv::MatchMode) { - debug!("matched_pat(matched_pat={}, cmt={}, mode={:?})", - matched_pat.repr(), - cmt.repr(), + debug!("matched_pat(matched_pat={:?}, cmt={:?}, mode={:?})", + matched_pat, + cmt, mode); if let mc::cat_downcast(..) = cmt.cat { @@ -109,9 +109,9 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { consume_pat: &ast::Pat, cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume_pat(consume_pat={}, cmt={}, mode={:?})", - consume_pat.repr(), - cmt.repr(), + debug!("consume_pat(consume_pat={:?}, cmt={:?}, mode={:?})", + consume_pat, + cmt, mode); match mode { @@ -132,9 +132,9 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { bk: ty::BorrowKind, loan_cause: euv::LoanCause) { - debug!("borrow(borrow_id={}, cmt={}, loan_region={:?}, \ + debug!("borrow(borrow_id={}, cmt={:?}, loan_region={:?}, \ bk={:?}, loan_cause={:?})", - borrow_id, cmt.repr(), loan_region, + borrow_id, cmt, loan_region, bk, loan_cause); self.guarantee_valid(borrow_id, @@ -152,8 +152,8 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for GatherLoanCtxt<'a, 'tcx> { mode: euv::MutateMode) { let opt_lp = opt_loan_path(&assignee_cmt); - debug!("mutate(assignment_id={}, assignee_cmt={}) opt_lp={:?}", - assignment_id, assignee_cmt.repr(), opt_lp); + debug!("mutate(assignment_id={}, assignee_cmt={:?}) opt_lp={:?}", + assignment_id, assignee_cmt, opt_lp); match opt_lp { Some(lp) => { @@ -234,10 +234,10 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { req_kind: ty::BorrowKind, loan_region: ty::Region, cause: euv::LoanCause) { - debug!("guarantee_valid(borrow_id={}, cmt={}, \ + debug!("guarantee_valid(borrow_id={}, cmt={:?}, \ req_mutbl={:?}, loan_region={:?})", borrow_id, - cmt.repr(), + cmt, req_kind, loan_region); @@ -336,8 +336,8 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { } }; - debug!("guarantee_valid(borrow_id={}), loan={}", - borrow_id, loan.repr()); + debug!("guarantee_valid(borrow_id={}), loan={:?}", + borrow_id, loan); // let loan_path = loan.loan_path; // let loan_gen_scope = loan.gen_scope; @@ -376,8 +376,8 @@ impl<'a, 'tcx> GatherLoanCtxt<'a, 'tcx> { req_kind: ty::BorrowKind) -> Result<(),()> { //! Implements the M-* rules in README.md. - debug!("check_mutability(cause={:?} cmt={} req_kind={:?}", - cause, cmt.repr(), req_kind); + debug!("check_mutability(cause={:?} cmt={:?} req_kind={:?}", + cause, cmt, req_kind); match req_kind { ty::UniqueImmBorrow | ty::ImmBorrow => { match cmt.mutbl { @@ -507,7 +507,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for StaticInitializerCtxt<'a, 'tcx> { pub fn gather_loans_in_static_initializer(bccx: &mut BorrowckCtxt, expr: &ast::Expr) { - debug!("gather_loans_in_static_initializer(expr={})", expr.repr()); + debug!("gather_loans_in_static_initializer(expr={:?})", expr); let mut sicx = StaticInitializerCtxt { bccx: bccx diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index bc52fc7622cf1..9a29ed91339e2 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -12,7 +12,6 @@ use borrowck::BorrowckCtxt; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::InteriorOffsetKind as Kind; use rustc::middle::ty; -use rustc::util::ppaux::UserString; use std::cell::RefCell; use syntax::ast; use syntax::codemap; @@ -130,7 +129,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, bccx.span_err(move_from.span, &format!("cannot move out of type `{}`, \ a non-copy fixed-size array", - b.ty.user_string())); + b.ty)); } } @@ -143,7 +142,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, move_from.span, &format!("cannot move out of type `{}`, \ which defines the `Drop` trait", - b.ty.user_string())); + b.ty)); }, _ => { bccx.span_bug(move_from.span, "this path should not cause illegal move") diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index 274a08dfe1108..345f5378f69e1 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -16,7 +16,6 @@ use borrowck::*; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::ty; -use rustc::util::ppaux::Repr; use syntax::codemap::Span; use borrowck::ToInteriorKind; @@ -58,7 +57,7 @@ struct RestrictionsContext<'a, 'tcx: 'a> { impl<'a, 'tcx> RestrictionsContext<'a, 'tcx> { fn restrict(&self, cmt: mc::cmt<'tcx>) -> RestrictionResult<'tcx> { - debug!("restrict(cmt={})", cmt.repr()); + debug!("restrict(cmt={:?})", cmt); let new_lp = |v: LoanPathKind<'tcx>| Rc::new(LoanPath::new(v, cmt.ty)); diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 63d9383d69d55..6369621779cbd 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -33,7 +33,6 @@ use rustc::middle::infer::error_reporting::note_and_explain_region; use rustc::middle::mem_categorization as mc; use rustc::middle::region; use rustc::middle::ty::{self, Ty}; -use rustc::util::ppaux::{Repr, UserString}; use std::fmt; use std::mem; @@ -683,7 +682,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { which is {}", ol, moved_lp_msg, - expr_ty.user_string(), + expr_ty, suggestion)); } else { self.tcx.sess.span_note( @@ -691,7 +690,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { &format!("`{}` moved here{} because it has type `{}`, which is {}", ol, moved_lp_msg, - expr_ty.user_string(), + expr_ty, suggestion)); } } @@ -704,7 +703,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { which is moved by default", ol, moved_lp_msg, - pat_ty.user_string())); + pat_ty)); self.tcx.sess.fileline_help(span, "use `ref` to override"); } @@ -735,7 +734,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { has type `{}`, which is {}", ol, moved_lp_msg, - expr_ty.user_string(), + expr_ty, suggestion)); self.tcx.sess.fileline_help(expr_span, help); } @@ -1187,7 +1186,7 @@ impl<'tcx> fmt::Debug for LoanPath<'tcx> { let variant_str = if variant_def_id.krate == ast::LOCAL_CRATE { ty::tls::with(|tcx| ty::item_path_str(tcx, variant_def_id)) } else { - variant_def_id.repr() + format!("{:?}", variant_def_id) }; write!(f, "({:?}{}{})", lp, DOWNCAST_PRINTED_OPERATOR, variant_str) } @@ -1219,7 +1218,7 @@ impl<'tcx> fmt::Display for LoanPath<'tcx> { let variant_str = if variant_def_id.krate == ast::LOCAL_CRATE { ty::tls::with(|tcx| ty::item_path_str(tcx, variant_def_id)) } else { - variant_def_id.repr() + format!("{:?}", variant_def_id) }; write!(f, "({}{}{})", lp, DOWNCAST_PRINTED_OPERATOR, variant_str) } diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 1b9b15a673aea..b38915612c5b0 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -22,7 +22,7 @@ use rustc::middle::dataflow::KillFrom; use rustc::middle::expr_use_visitor as euv; use rustc::middle::ty; use rustc::util::nodemap::{FnvHashMap, NodeSet}; -use rustc::util::ppaux::Repr; + use std::cell::RefCell; use std::rc::Rc; use std::usize; @@ -313,8 +313,8 @@ impl<'tcx> MoveData<'tcx> { } }; - debug!("move_path(lp={}, index={:?})", - lp.repr(), + debug!("move_path(lp={:?}, index={:?})", + lp, index); assert_eq!(index.get(), self.paths.borrow().len() - 1); @@ -364,8 +364,8 @@ impl<'tcx> MoveData<'tcx> { lp: Rc>, id: ast::NodeId, kind: MoveKind) { - debug!("add_move(lp={}, id={}, kind={:?})", - lp.repr(), + debug!("add_move(lp={:?}, id={}, kind={:?})", + lp, id, kind); @@ -394,8 +394,8 @@ impl<'tcx> MoveData<'tcx> { span: Span, assignee_id: ast::NodeId, mode: euv::MutateMode) { - debug!("add_assignment(lp={}, assign_id={}, assignee_id={}", - lp.repr(), assign_id, assignee_id); + debug!("add_assignment(lp={:?}, assign_id={}, assignee_id={}", + lp, assign_id, assignee_id); let path_index = self.move_path(tcx, lp.clone()); @@ -415,13 +415,13 @@ impl<'tcx> MoveData<'tcx> { }; if self.is_var_path(path_index) { - debug!("add_assignment[var](lp={}, assignment={}, path_index={:?})", - lp.repr(), self.var_assignments.borrow().len(), path_index); + debug!("add_assignment[var](lp={:?}, assignment={}, path_index={:?})", + lp, self.var_assignments.borrow().len(), path_index); self.var_assignments.borrow_mut().push(assignment); } else { - debug!("add_assignment[path](lp={}, path_index={:?})", - lp.repr(), path_index); + debug!("add_assignment[path](lp={:?}, path_index={:?})", + lp, path_index); self.path_assignments.borrow_mut().push(assignment); } @@ -437,8 +437,8 @@ impl<'tcx> MoveData<'tcx> { pattern_id: ast::NodeId, base_lp: Rc>, mode: euv::MatchMode) { - debug!("add_variant_match(lp={}, pattern_id={})", - lp.repr(), pattern_id); + debug!("add_variant_match(lp={:?}, pattern_id={})", + lp, pattern_id); let path_index = self.move_path(tcx, lp.clone()); let base_path_index = self.move_path(tcx, base_lp.clone()); diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 7f07966991105..a40cb94204d9c 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -25,7 +25,6 @@ use rustc::middle::cfg; use rustc::middle::cfg::graphviz::LabelledCFG; use rustc::session::Session; use rustc::session::config::Input; -use rustc::util::ppaux::UserString; use rustc_borrowck as borrowck; use rustc_borrowck::graphviz as borrowck_dot; use rustc_resolve as resolve; @@ -318,7 +317,7 @@ impl<'a, 'tcx> pprust::PpAnn for TypedAnnotation<'a, 'tcx> { try!(pp::word(&mut s.s, "as")); try!(pp::space(&mut s.s)); try!(pp::word(&mut s.s, - &ty::expr_ty(self.tcx, expr).user_string())); + &ty::expr_ty(self.tcx, expr).to_string())); s.pclose() } _ => Ok(()) diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 658d5166ef5fc..5183fa01a8ac4 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -28,7 +28,6 @@ use rustc_typeck::middle::infer; use rustc_typeck::middle::infer::lub::Lub; use rustc_typeck::middle::infer::glb::Glb; use rustc_typeck::middle::infer::sub::Sub; -use rustc_typeck::util::ppaux::{Repr, UserString}; use rustc::ast_map; use rustc::session::{self,config}; use syntax::{abi, ast}; @@ -188,7 +187,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { -> Option { assert!(idx < names.len()); for item in &m.items { - if item.ident.user_string() == names[idx] { + if item.ident.to_string() == names[idx] { return search(this, &**item, idx+1, names); } } @@ -240,9 +239,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { pub fn assert_subtype(&self, a: Ty<'tcx>, b: Ty<'tcx>) { if !self.is_subtype(a, b) { - panic!("{} is not a subtype of {}, but it should be", - self.ty_to_string(a), - self.ty_to_string(b)); + panic!("{} is not a subtype of {}, but it should be", a, b); } } @@ -251,10 +248,6 @@ impl<'a, 'tcx> Env<'a, 'tcx> { self.assert_subtype(b, a); } - pub fn ty_to_string(&self, a: Ty<'tcx>) -> String { - a.user_string() - } - pub fn t_fn(&self, input_tys: &[Ty<'tcx>], output_ty: Ty<'tcx>) @@ -385,9 +378,9 @@ impl<'a, 'tcx> Env<'a, 'tcx> { match self.sub().relate(&t1, &t2) { Ok(_) => { } Err(ref e) => { - panic!("unexpected error computing sub({},{}): {}", - t1.repr(), - t2.repr(), + panic!("unexpected error computing sub({:?},{:?}): {}", + t1, + t2, e); } } @@ -399,9 +392,9 @@ impl<'a, 'tcx> Env<'a, 'tcx> { match self.sub().relate(&t1, &t2) { Err(_) => { } Ok(_) => { - panic!("unexpected success computing sub({},{})", - t1.repr(), - t2.repr()); + panic!("unexpected success computing sub({:?},{:?})", + t1, + t2); } } } @@ -420,10 +413,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> { /// Checks that `GLB(t1,t2) == t_glb` pub fn check_glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_glb: Ty<'tcx>) { - debug!("check_glb(t1={}, t2={}, t_glb={})", - self.ty_to_string(t1), - self.ty_to_string(t2), - self.ty_to_string(t_glb)); + debug!("check_glb(t1={}, t2={}, t_glb={})", t1, t2, t_glb); match self.glb().relate(&t1, &t2) { Err(e) => { panic!("unexpected error computing LUB: {:?}", e) @@ -656,7 +646,7 @@ fn glb_bound_free_infer() { let t_resolve1 = env.infcx.shallow_resolve(t_infer1); match t_resolve1.sty { ty::TyRef(..) => { } - _ => { panic!("t_resolve1={}", t_resolve1.repr()); } + _ => { panic!("t_resolve1={:?}", t_resolve1); } } }) } @@ -698,11 +688,11 @@ fn subst_ty_renumber_bound() { env.t_fn(&[t_ptr_bound2], env.t_nil()) }; - debug!("subst_bound: t_source={} substs={} t_substituted={} t_expected={}", - t_source.repr(), - substs.repr(), - t_substituted.repr(), - t_expected.repr()); + debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", + t_source, + substs, + t_substituted, + t_expected); assert_eq!(t_substituted, t_expected); }) @@ -735,11 +725,11 @@ fn subst_ty_renumber_some_bounds() { env.t_pair(t_rptr_bound1, env.t_fn(&[t_rptr_bound2], env.t_nil())) }; - debug!("subst_bound: t_source={} substs={} t_substituted={} t_expected={}", - t_source.repr(), - substs.repr(), - t_substituted.repr(), - t_expected.repr()); + debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", + t_source, + substs, + t_substituted, + t_expected); assert_eq!(t_substituted, t_expected); }) @@ -796,11 +786,11 @@ fn subst_region_renumber_region() { env.t_fn(&[t_rptr_bound2], env.t_nil()) }; - debug!("subst_bound: t_source={} substs={} t_substituted={} t_expected={}", - t_source.repr(), - substs.repr(), - t_substituted.repr(), - t_expected.repr()); + debug!("subst_bound: t_source={:?} substs={:?} t_substituted={:?} t_expected={:?}", + t_source, + substs, + t_substituted, + t_expected); assert_eq!(t_substituted, t_expected); }) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index ed8f7372b660c..47713859dd8cb 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -37,7 +37,6 @@ use middle::const_eval::{eval_const_expr_partial, const_int, const_uint}; use middle::cfg; use rustc::ast_map; use util::nodemap::{FnvHashMap, NodeSet}; -use util::ppaux::UserString; use lint::{Level, Context, LintPass, LintArray, Lint}; use std::collections::{HashSet, BitSet}; @@ -495,8 +494,7 @@ impl BoxPointers { }); if n_uniq > 0 { - let s = ty.user_string(); - let m = format!("type uses owned (Box type) pointers: {}", s); + let m = format!("type uses owned (Box type) pointers: {}", ty); cx.span_lint(BOX_POINTERS, span, &m[..]); } } diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index eeebe03c21ba1..f6f9afa02215a 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -25,7 +25,6 @@ use middle::ty::{self, Ty}; use rustc::ast_map::{PathElem, PathElems, PathName}; use trans::{CrateContext, CrateTranslation, gensym_name}; use util::common::time; -use util::ppaux::UserString; use util::sha2::{Digest, Sha256}; use util::fs::fix_windows_verbatim_for_gcc; use rustc_back::tempdir::TempDir; @@ -347,7 +346,7 @@ pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathEl pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, name: &str) -> String { - let path = [PathName(token::intern(&t.user_string())), + let path = [PathName(token::intern(&t.to_string())), gensym_name(name)]; let hash = get_symbol_hash(ccx, t); mangle(path.iter().cloned(), Some(&hash[..])) diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index fb174d8ff276e..65d9d9809c926 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -52,8 +52,6 @@ use syntax::ptr::P; use super::span_utils::SpanUtils; use super::recorder::{Recorder, FmtStrs}; -use util::ppaux::UserString; - macro_rules! down_cast_data { ($id:ident, $kind:ident, $this:ident, $sp:expr) => { let $id = if let super::Data::$kind(data) = $id { @@ -287,7 +285,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { collector.visit_pat(&arg.pat); let span_utils = self.span.clone(); for &(id, ref p, _, _) in &collector.collected_paths { - let typ = self.tcx.node_types().get(&id).unwrap().user_string(); + let typ = self.tcx.node_types().get(&id).unwrap().to_string(); // get the span only for the name of the variable (I hope the path is only ever a // variable name, but who knows?) self.fmt.formal_str(p.span, @@ -1392,7 +1390,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> { "".to_string() }; let types = self.tcx.node_types(); - let typ = types.get(&id).unwrap().user_string(); + let typ = types.get(&id).unwrap().to_string(); // Get the span only for the name of the variable (I hope the path // is only ever a variable name, but who knows?). let sub_span = self.span.span_for_last_ident(p.span); diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index efdc1195a9528..fdfb101ed78cc 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -23,8 +23,6 @@ use syntax::parse::token::{self, get_ident, keywords}; use syntax::visit::{self, Visitor}; use syntax::print::pprust::ty_to_string; -use util::ppaux::UserString; - use self::span_utils::SpanUtils; @@ -293,7 +291,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { self.tcx.map.path_to_string(parent), name); let typ = self.tcx.node_types().get(&field.node.id).unwrap() - .user_string(); + .to_string(); let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon); Some(Data::VariableData(VariableData { id: field.node.id, diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 7f68e654c2c53..05672153b018a 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -217,7 +217,7 @@ use middle::ty::{self, Ty}; use session::config::{NoDebugInfo, FullDebugInfo}; use util::common::indenter; use util::nodemap::FnvHashMap; -use util::ppaux::{self, Repr}; +use util::ppaux; use std; use std::cmp::Ordering; @@ -398,9 +398,9 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, col: usize, val: ValueRef) -> Vec> { - debug!("expand_nested_bindings(bcx={}, m={}, col={}, val={})", + debug!("expand_nested_bindings(bcx={}, m={:?}, col={}, val={})", bcx.to_str(), - m.repr(), + m, col, bcx.val_to_string(val)); let _indenter = indenter(); @@ -438,9 +438,9 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>, -> Vec> where F: FnMut(&[&'p ast::Pat]) -> Option>, { - debug!("enter_match(bcx={}, m={}, col={}, val={})", + debug!("enter_match(bcx={}, m={:?}, col={}, val={})", bcx.to_str(), - m.repr(), + m, col, bcx.val_to_string(val)); let _indenter = indenter(); @@ -481,9 +481,9 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, col: usize, val: ValueRef) -> Vec> { - debug!("enter_default(bcx={}, m={}, col={}, val={})", + debug!("enter_default(bcx={}, m={:?}, col={}, val={})", bcx.to_str(), - m.repr(), + m, col, bcx.val_to_string(val)); let _indenter = indenter(); @@ -538,9 +538,9 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>( variant_size: usize, val: ValueRef) -> Vec> { - debug!("enter_opt(bcx={}, m={}, opt={:?}, col={}, val={})", + debug!("enter_opt(bcx={}, m={:?}, opt={:?}, col={}, val={})", bcx.to_str(), - m.repr(), + m, *opt, col, bcx.val_to_string(val)); @@ -826,8 +826,7 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>, -> Result<'blk, 'tcx> { let did = langcall(cx, None, - &format!("comparison of `{}`", - cx.ty_to_string(rhs_t)), + &format!("comparison of `{}`", rhs_t), StrEqFnLangItem); let t = ty::mk_str_slice(cx.tcx(), cx.tcx().mk_region(ty::ReStatic), ast::MutImmutable); // The comparison function gets the slices by value, so we have to make copies here. Even @@ -938,10 +937,10 @@ fn compile_guard<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, chk: &FailureHandler, has_genuine_default: bool) -> Block<'blk, 'tcx> { - debug!("compile_guard(bcx={}, guard_expr={}, m={}, vals=[{}])", + debug!("compile_guard(bcx={}, guard_expr={:?}, m={:?}, vals=[{}])", bcx.to_str(), - bcx.expr_to_string(guard_expr), - m.repr(), + guard_expr, + m, vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); let _indenter = indenter(); @@ -984,9 +983,9 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, vals: &[ValueRef], chk: &FailureHandler, has_genuine_default: bool) { - debug!("compile_submatch(bcx={}, m={}, vals=[{}])", + debug!("compile_submatch(bcx={}, m={:?}, vals=[{}])", bcx.to_str(), - m.repr(), + m, vals.iter().map(|v| bcx.val_to_string(*v)).collect::>().connect(", ")); let _indenter = indenter(); let _icx = push_ctxt("match::compile_submatch"); @@ -1697,13 +1696,13 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, val: ValueRef, cleanup_scope: cleanup::ScopeId) -> Block<'blk, 'tcx> { - debug!("bind_irrefutable_pat(bcx={}, pat={})", + debug!("bind_irrefutable_pat(bcx={}, pat={:?})", bcx.to_str(), - pat.repr()); + pat); if bcx.sess().asm_comments() { - add_comment(bcx, &format!("bind_irrefutable_pat(pat={})", - pat.repr())); + add_comment(bcx, &format!("bind_irrefutable_pat(pat={:?})", + pat)); } let _indenter = indenter(); diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index dc5d3ea2f6248..2a1c2457b9d32 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -66,7 +66,6 @@ use trans::machine; use trans::monomorphize; use trans::type_::Type; use trans::type_of; -use util::ppaux::Repr as PrettyPrintRepr; type Hint = attr::ReprAttr; @@ -143,7 +142,7 @@ pub fn represent_node<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Rc> { - debug!("Representing: {}", t.repr()); + debug!("Representing: {}", t); match cx.adt_reprs().borrow().get(&t) { Some(repr) => return repr.clone(), None => {} @@ -381,8 +380,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, General(ity, fields, dtor_to_init_u8(dtor)) } - _ => cx.sess().bug(&format!("adt::represent_type called on non-ADT type: {}", - t.repr())) + _ => cx.sess().bug(&format!("adt::represent_type called on non-ADT type: {}", t)) } } diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 81657c9537066..eb0d19efef00a 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -80,7 +80,6 @@ use trans::type_of; use trans::type_of::*; use trans::value::Value; use util::common::indenter; -use util::ppaux::Repr; use util::sha2::Sha256; use util::nodemap::NodeMap; @@ -250,9 +249,7 @@ fn require_alloc_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, match bcx.tcx().lang_items.require(it) { Ok(id) => id, Err(s) => { - bcx.sess().fatal(&format!("allocation of `{}` {}", - bcx.ty_to_string(info_ty), - s)); + bcx.sess().fatal(&format!("allocation of `{}` {}", info_ty, s)); } } } @@ -530,8 +527,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>, } } _ => { - cx.sess().unimpl(&format!("type in iter_structural_ty: {}", - t.repr())) + cx.sess().unimpl(&format!("type in iter_structural_ty: {}", t)) } } return cx; @@ -640,8 +636,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>( (res, false) } _ => { - cx.sess().bug(&format!("fail-if-zero on unexpected type: {}", - rhs_t.repr())); + cx.sess().bug(&format!("fail-if-zero on unexpected type: {}", rhs_t)); } }; let bcx = with_cond(cx, is_zero, |bcx| { @@ -1187,13 +1182,13 @@ pub fn new_fn_ctxt<'a, 'tcx>(ccx: &'a CrateContext<'a, 'tcx>, -> FunctionContext<'a, 'tcx> { common::validate_substs(param_substs); - debug!("new_fn_ctxt(path={}, id={}, param_substs={})", + debug!("new_fn_ctxt(path={}, id={}, param_substs={:?})", if id == !0 { "".to_string() } else { ccx.tcx().map.path_to_string(id).to_string() }, - id, param_substs.repr()); + id, param_substs); let uses_outptr = match output_type { ty::FnConverging(output_type) => { @@ -1510,8 +1505,8 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let _icx = push_ctxt("trans_closure"); attributes::emit_uwtable(llfndecl, true); - debug!("trans_closure(..., param_substs={})", - param_substs.repr()); + debug!("trans_closure(..., param_substs={:?})", + param_substs); let has_env = match closure_env { closure::ClosureEnv::Closure(_) => true, @@ -1553,8 +1548,8 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } }; for monomorphized_arg_type in &monomorphized_arg_types { - debug!("trans_closure: monomorphized_arg_type: {}", - monomorphized_arg_type.repr()); + debug!("trans_closure: monomorphized_arg_type: {:?}", + monomorphized_arg_type); } debug!("trans_closure: function lltype: {}", bcx.fcx.ccx.tn().val_to_string(bcx.fcx.llfn)); @@ -1636,7 +1631,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, id: ast::NodeId, attrs: &[ast::Attribute]) { let _s = StatRecorder::new(ccx, ccx.tcx().map.path_to_string(id).to_string()); - debug!("trans_fn(param_substs={})", param_substs.repr()); + debug!("trans_fn(param_substs={:?})", param_substs); let _icx = push_ctxt("trans_fn"); let fn_ty = ty::node_id_to_type(ccx.tcx(), id); let output_type = ty::erase_late_bound_regions(ccx.tcx(), &ty::ty_fn_ret(fn_ty)); @@ -1679,7 +1674,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, _ => ccx.sess().bug( &format!("trans_enum_variant_constructor: \ unexpected ctor return type {}", - ctor_ty.repr())) + ctor_ty)) }; // Get location to store the result. If the user does not care about @@ -1757,7 +1752,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx _ => ccx.sess().bug( &format!("trans_enum_variant_or_tuple_like_struct: \ unexpected ctor return type {}", - ctor_ty.repr())) + ctor_ty)) }; let (arena, fcx): (TypedArena<_>, FunctionContext); diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index a06598a7cbe33..46f762a519585 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -54,7 +54,6 @@ use trans::type_of; use middle::ty::{self, Ty}; use middle::ty::MethodCall; use rustc::ast_map; -use util::ppaux::Repr; use syntax::abi as synabi; use syntax::ast; @@ -89,7 +88,7 @@ pub struct Callee<'blk, 'tcx: 'blk> { fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) -> Callee<'blk, 'tcx> { let _icx = push_ctxt("trans_callee"); - debug!("callee::trans(expr={})", expr.repr()); + debug!("callee::trans(expr={:?})", expr); // pick out special kinds of expressions that can be called: match expr.node { @@ -117,7 +116,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) bcx.tcx().sess.span_bug( expr.span, &format!("type of callee is neither bare-fn nor closure: {}", - bcx.ty_to_string(datum.ty))); + datum.ty)); } } } @@ -134,7 +133,7 @@ fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) def: def::Def, ref_expr: &ast::Expr) -> Callee<'blk, 'tcx> { - debug!("trans_def(def={}, ref_expr={})", def.repr(), ref_expr.repr()); + debug!("trans_def(def={:?}, ref_expr={:?})", def, ref_expr); let expr_ty = common::node_id_type(bcx, ref_expr.id); match def { def::DefFn(did, _) if { @@ -228,10 +227,10 @@ pub fn trans_fn_ref<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let _icx = push_ctxt("trans_fn_ref"); let substs = common::node_id_substs(ccx, node, param_substs); - debug!("trans_fn_ref(def_id={}, node={:?}, substs={})", - def_id.repr(), + debug!("trans_fn_ref(def_id={:?}, node={:?}, substs={:?})", + def_id, node, - substs.repr()); + substs); trans_fn_ref_with_substs(ccx, def_id, node, param_substs, substs) } @@ -291,8 +290,8 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( None => { } } - debug!("trans_fn_pointer_shim(bare_fn_ty={})", - bare_fn_ty.repr()); + debug!("trans_fn_pointer_shim(bare_fn_ty={:?})", + bare_fn_ty); // Construct the "tuply" version of `bare_fn_ty`. It takes two arguments: `self`, // which is the fn pointer, and `args`, which is the arguments tuple. @@ -307,7 +306,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( _ => { tcx.sess.bug(&format!("trans_fn_pointer_shim invoked on invalid type: {}", - bare_fn_ty.repr())); + bare_fn_ty)); } }; let sig = ty::erase_late_bound_regions(tcx, sig); @@ -323,7 +322,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>( output: sig.output, variadic: false })})); - debug!("tuple_fn_ty: {}", tuple_fn_ty.repr()); + debug!("tuple_fn_ty: {:?}", tuple_fn_ty); // let function_name = link::mangle_internal_name_by_type_and_seq(ccx, bare_fn_ty, @@ -401,12 +400,12 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>( let _icx = push_ctxt("trans_fn_ref_with_substs"); let tcx = ccx.tcx(); - debug!("trans_fn_ref_with_substs(def_id={}, node={:?}, \ - param_substs={}, substs={})", - def_id.repr(), + debug!("trans_fn_ref_with_substs(def_id={:?}, node={:?}, \ + param_substs={:?}, substs={:?})", + def_id, node, - param_substs.repr(), - substs.repr()); + param_substs, + substs); assert!(substs.types.all(|t| !ty::type_needs_infer(*t))); assert!(substs.types.all(|t| !ty::type_has_escaping_regions(*t))); @@ -457,10 +456,10 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>( let new_substs = tcx.mk_substs(first_subst.subst(tcx, &substs)); debug!("trans_fn_with_vtables - default method: \ - substs = {}, trait_subst = {}, \ - first_subst = {}, new_subst = {}", - substs.repr(), trait_ref.substs.repr(), - first_subst.repr(), new_substs.repr()); + substs = {:?}, trait_subst = {:?}, \ + first_subst = {:?}, new_subst = {:?}", + substs, trait_ref.substs, + first_subst, new_substs); (true, source_id, new_substs) } @@ -504,8 +503,8 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>( false }; - debug!("trans_fn_ref_with_substs({}) must_monomorphise: {}", - def_id.repr(), must_monomorphise); + debug!("trans_fn_ref_with_substs({:?}) must_monomorphise: {}", + def_id, must_monomorphise); // Create a monomorphic version of generic functions if must_monomorphise { @@ -615,7 +614,7 @@ pub fn trans_method_call<'a, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, dest: expr::Dest) -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_method_call"); - debug!("trans_method_call(call_expr={})", call_expr.repr()); + debug!("trans_method_call(call_expr={:?})", call_expr); let method_call = MethodCall::expr(call_expr.id); let method_ty = match bcx.tcx().method_map.borrow().get(&method_call) { Some(method) => match method.origin { @@ -1125,8 +1124,8 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let mut bcx = bcx; let ccx = bcx.ccx(); - debug!("trans_arg_datum({})", - formal_arg_ty.repr()); + debug!("trans_arg_datum({:?})", + formal_arg_ty); let arg_datum_ty = arg_datum.ty; @@ -1165,8 +1164,8 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty); debug!("casting actual type ({}) to match formal ({})", bcx.val_to_string(val), bcx.llty_str(llformal_arg_ty)); - debug!("Rust types: {}; {}", arg_datum_ty.repr(), - formal_arg_ty.repr()); + debug!("Rust types: {:?}; {:?}", arg_datum_ty, + formal_arg_ty); val = PointerCast(bcx, val, llformal_arg_ty); } diff --git a/src/librustc_trans/trans/cleanup.rs b/src/librustc_trans/trans/cleanup.rs index 97fe4dfb2a7a6..6355a713a2ce6 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/trans/cleanup.rs @@ -133,7 +133,6 @@ use trans::type_::Type; use middle::ty::{self, Ty}; use std::fmt; use syntax::ast; -use util::ppaux::Repr; pub struct CleanupScope<'blk, 'tcx: 'blk> { // The id of this cleanup scope. If the id is None, @@ -397,10 +396,10 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { skip_dtor: false, }; - debug!("schedule_drop_mem({:?}, val={}, ty={}) fill_on_drop={} skip_dtor={}", + debug!("schedule_drop_mem({:?}, val={}, ty={:?}) fill_on_drop={} skip_dtor={}", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(), + ty, drop.fill_on_drop, drop.skip_dtor); @@ -423,10 +422,10 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { skip_dtor: false, }; - debug!("schedule_drop_and_fill_mem({:?}, val={}, ty={}, fill_on_drop={}, skip_dtor={})", + debug!("schedule_drop_and_fill_mem({:?}, val={}, ty={:?}, fill_on_drop={}, skip_dtor={})", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(), + ty, drop.fill_on_drop, drop.skip_dtor); @@ -455,10 +454,10 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { skip_dtor: true, }; - debug!("schedule_drop_adt_contents({:?}, val={}, ty={}) fill_on_drop={} skip_dtor={}", + debug!("schedule_drop_adt_contents({:?}, val={}, ty={:?}) fill_on_drop={} skip_dtor={}", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(), + ty, drop.fill_on_drop, drop.skip_dtor); @@ -484,7 +483,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> { debug!("schedule_drop_immediate({:?}, val={}, ty={:?}) fill_on_drop={} skip_dtor={}", cleanup_scope, self.ccx.tn().val_to_string(val), - ty.repr(), + ty, drop.fill_on_drop, drop.skip_dtor); diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index ef8839c6d5d14..91b0a6c00696f 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -28,7 +28,6 @@ use trans::type_of::*; use middle::ty::{self, ClosureTyper}; use middle::subst::Substs; use session::config::FullDebugInfo; -use util::ppaux::Repr; use syntax::abi::RustCall; use syntax::ast; @@ -353,9 +352,9 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( llreffn: ValueRef) -> ValueRef { - debug!("trans_fn_once_adapter_shim(closure_def_id={}, substs={}, llreffn={})", - closure_def_id.repr(), - substs.repr(), + debug!("trans_fn_once_adapter_shim(closure_def_id={:?}, substs={:?}, llreffn={})", + closure_def_id, + substs, ccx.tn().val_to_string(llreffn)); let tcx = ccx.tcx(); @@ -374,8 +373,8 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( abi: abi, sig: sig.clone() }); let llref_fn_ty = ty::mk_bare_fn(tcx, None, llref_bare_fn_ty); - debug!("trans_fn_once_adapter_shim: llref_fn_ty={}", - llref_fn_ty.repr()); + debug!("trans_fn_once_adapter_shim: llref_fn_ty={:?}", + llref_fn_ty); // Make a version of the closure type with the same arguments, but // with argument #0 being by value. @@ -423,8 +422,8 @@ fn trans_fn_once_adapter_shim<'a, 'tcx>( let input_tys = match sig.inputs[1].sty { ty::TyTuple(ref tys) => &**tys, _ => bcx.sess().bug(&format!("trans_fn_once_adapter_shim: not rust-call! \ - closure_def_id={}", - closure_def_id.repr())) + closure_def_id={:?}", + closure_def_id)) }; let llargs: Vec<_> = input_tys.iter() diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index 22582787c7c0b..5dddf161e69fb 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -41,7 +41,6 @@ use middle::ty::{self, HasProjectionTypes, Ty}; use middle::ty_fold; use middle::ty_fold::{TypeFolder, TypeFoldable}; use rustc::ast_map::{PathElem, PathName}; -use util::ppaux::Repr; use util::nodemap::{FnvHashMap, NodeMap}; use arena::TypedArena; @@ -67,8 +66,8 @@ pub fn erase_regions<'tcx,T>(cx: &ty::ctxt<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> { let value1 = value.fold_with(&mut RegionEraser(cx)); - debug!("erase_regions({}) = {}", - value.repr(), value1.repr()); + debug!("erase_regions({:?}) = {:?}", + value, value1); return value1; struct RegionEraser<'a, 'tcx: 'a>(&'a ty::ctxt<'tcx>); @@ -212,7 +211,7 @@ fn type_needs_drop_given_env<'a,'tcx>(cx: &ty::ctxt<'tcx>, // destructor (e.g. zero its memory on move). let contents = ty::type_contents(cx, ty); - debug!("type_needs_drop ty={} contents={:?}", ty.repr(), contents); + debug!("type_needs_drop ty={:?} contents={:?}", ty, contents); contents.needs_drop(cx) } @@ -593,10 +592,6 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { self.tcx().map.node_to_string(id).to_string() } - pub fn expr_to_string(&self, e: &ast::Expr) -> String { - e.repr() - } - pub fn def(&self, nid: ast::NodeId) -> def::Def { match self.tcx().def_map.borrow().get(&nid) { Some(v) => v.full_def(), @@ -615,10 +610,6 @@ impl<'blk, 'tcx> BlockS<'blk, 'tcx> { self.ccx().tn().type_to_string(ty) } - pub fn ty_to_string(&self, t: Ty<'tcx>) -> String { - t.repr() - } - pub fn to_str(&self) -> String { format!("[block {:p}]", self) } @@ -994,14 +985,14 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // First check the cache. match ccx.trait_cache().borrow().get(&trait_ref) { Some(vtable) => { - info!("Cache hit: {}", trait_ref.repr()); + info!("Cache hit: {:?}", trait_ref); return (*vtable).clone(); } None => { } } - debug!("trans fulfill_obligation: trait_ref={} def_id={:?}", - trait_ref.repr(), trait_ref.def_id()); + debug!("trans fulfill_obligation: trait_ref={:?} def_id={:?}", + trait_ref, trait_ref.def_id()); ty::populate_implementations_for_trait_if_necessary(tcx, trait_ref.def_id()); let infcx = infer::new_infer_ctxt(tcx); @@ -1022,9 +1013,9 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // leading to an ambiguous result. So report this as an // overflow bug, since I believe this is the only case // where ambiguity can result. - debug!("Encountered ambiguity selecting `{}` during trans, \ + debug!("Encountered ambiguity selecting `{:?}` during trans, \ presuming due to overflow", - trait_ref.repr()); + trait_ref); ccx.sess().span_fatal( span, "reached the recursion limit during monomorphization"); @@ -1032,9 +1023,9 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, Err(e) => { tcx.sess.span_bug( span, - &format!("Encountered error `{}` selecting `{}` during trans", - e.repr(), - trait_ref.repr())) + &format!("Encountered error `{:?}` selecting `{:?}` during trans", + e, + trait_ref)) } }; @@ -1047,7 +1038,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }); let vtable = drain_fulfillment_cx_or_panic(span, &infcx, &mut fulfill_cx, &vtable); - info!("Cache miss: {}", trait_ref.repr()); + info!("Cache miss: {:?}", trait_ref); ccx.trait_cache().borrow_mut().insert(trait_ref, vtable.clone()); @@ -1062,8 +1053,8 @@ pub fn normalize_and_test_predicates<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, predicates: Vec>) -> bool { - debug!("normalize_and_test_predicates(predicates={})", - predicates.repr()); + debug!("normalize_and_test_predicates(predicates={:?})", + predicates); let tcx = ccx.tcx(); let infcx = infer::new_infer_ctxt(tcx); @@ -1142,8 +1133,8 @@ pub fn drain_fulfillment_cx_or_panic<'a,'tcx,T>(span: Span, Err(errors) => { infcx.tcx.sess.span_bug( span, - &format!("Encountered errors `{}` fulfilling during trans", - errors.repr())); + &format!("Encountered errors `{:?}` fulfilling during trans", + errors)); } } } @@ -1161,8 +1152,8 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(infcx: &infer::InferCtxt<'a,'tcx>, -> StdResult>> where T : TypeFoldable<'tcx> { - debug!("drain_fulfillment_cx(result={})", - result.repr()); + debug!("drain_fulfillment_cx(result={:?})", + result); // In principle, we only need to do this so long as `result` // contains unbound type parameters. It could be a slight @@ -1210,7 +1201,7 @@ pub fn node_id_substs<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, if substs.types.any(|t| ty::type_needs_infer(*t)) { tcx.sess.bug(&format!("type parameters for node {:?} include inference types: {:?}", - node, substs.repr())); + node, substs)); } monomorphize::apply_param_substs(tcx, diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 09f5509c5ac90..ad6358e057367 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -32,7 +32,6 @@ use trans::type_of; use middle::cast::{CastTy,IntTy}; use middle::subst::Substs; use middle::ty::{self, Ty}; -use util::ppaux::Repr; use util::nodemap::NodeMap; use std::iter::repeat; @@ -66,9 +65,9 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit) C_integral(Type::uint_from_ty(cx, t), i as u64, false) } _ => cx.sess().span_bug(lit.span, - &format!("integer literal has type {} (expected int \ + &format!("integer literal has type {:?} (expected int \ or usize)", - lit_int_ty.repr())) + lit_int_ty)) } } ast::LitFloat(ref fs, t) => { @@ -160,8 +159,8 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } } None => { - cx.sess().bug(&format!("unexpected dereferenceable type {}", - ty.repr())) + cx.sess().bug(&format!("unexpected dereferenceable type {:?}", + ty)) } } } @@ -368,8 +367,8 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, llvm::LLVMDumpValue(llconst); llvm::LLVMDumpValue(C_undef(llty)); } - cx.sess().bug(&format!("const {} of type {} has size {} instead of {}", - e.repr(), ety_adjusted.repr(), + cx.sess().bug(&format!("const {:?} of type {:?} has size {} instead of {}", + e, ety_adjusted, csize, tsize)); } (llconst, ety_adjusted) @@ -476,10 +475,10 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fn_args: FnArgMap) -> ValueRef { - debug!("const_expr_unadjusted(e={}, ety={}, param_substs={})", - e.repr(), - ety.repr(), - param_substs.repr()); + debug!("const_expr_unadjusted(e={:?}, ety={:?}, param_substs={:?})", + e, + ety, + param_substs); let map_list = |exprs: &[P]| -> Vec { exprs.iter() @@ -496,9 +495,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, /* Neither type is bottom, and we expect them to be unified * already, so the following is safe. */ let (te1, ty) = const_expr(cx, &**e1, param_substs, fn_args); - debug!("const_expr_unadjusted: te1={}, ty={}", + debug!("const_expr_unadjusted: te1={}, ty={:?}", cx.tn().val_to_string(te1), - ty.repr()); + ty); let is_simd = ty::type_is_simd(cx.tcx(), ty); let intype = if is_simd { ty::simd_type(cx.tcx(), ty) @@ -620,13 +619,13 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, }, _ => cx.sess().span_bug(base.span, &format!("index-expr base must be a vector \ - or string type, found {}", - bt.repr())) + or string type, found {:?}", + bt)) }, _ => cx.sess().span_bug(base.span, &format!("index-expr base must be a vector \ - or string type, found {}", - bt.repr())) + or string type, found {:?}", + bt)) }; let len = llvm::LLVMConstIntGetZExtValue(len) as u64; @@ -654,7 +653,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let t_cast = ety; let llty = type_of::type_of(cx, t_cast); let (v, t_expr) = const_expr(cx, &**base, param_substs, fn_args); - debug!("trans_const_cast({} as {})", t_expr.repr(), t_cast.repr()); + debug!("trans_const_cast({:?} as {:?})", t_expr, t_cast); if expr::cast_is_noop(cx.tcx(), base, t_expr, t_cast) { return v; } diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index ab76942ceee4b..0ae69682f914a 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -28,7 +28,6 @@ use middle::subst::Substs; use middle::ty::{self, Ty}; use session::config::NoDebugInfo; use session::Session; -use util::ppaux::Repr; use util::sha2::Sha256; use util::nodemap::{NodeMap, NodeSet, DefIdMap, FnvHashMap, FnvHashSet}; @@ -766,8 +765,8 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { pub fn report_overbig_object(&self, obj: Ty<'tcx>) -> ! { self.sess().fatal( - &format!("the type `{}` is too big for the current architecture", - obj.repr())) + &format!("the type `{:?}` is too big for the current architecture", + obj)) } pub fn check_overflow(&self) -> bool { diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/trans/controlflow.rs index b2cd99fc3ca89..ceef07207acb8 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -24,7 +24,6 @@ use trans::debuginfo::{DebugLoc, ToDebugLoc}; use trans::expr; use trans; use middle::ty; -use util::ppaux::Repr; use syntax::ast; use syntax::ast_util; @@ -36,14 +35,14 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>, -> Block<'blk, 'tcx> { let _icx = push_ctxt("trans_stmt"); let fcx = cx.fcx; - debug!("trans_stmt({})", s.repr()); + debug!("trans_stmt({:?})", s); if cx.unreachable.get() { return cx; } if cx.sess().asm_comments() { - add_span_comment(cx, s.span, &s.repr()); + add_span_comment(cx, s.span, &format!("{:?}", s)); } let mut bcx = cx; @@ -151,8 +150,8 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, els: Option<&ast::Expr>, dest: expr::Dest) -> Block<'blk, 'tcx> { - debug!("trans_if(bcx={}, if_id={}, cond={}, thn={}, dest={})", - bcx.to_str(), if_id, bcx.expr_to_string(cond), thn.id, + debug!("trans_if(bcx={}, if_id={}, cond={:?}, thn={}, dest={})", + bcx.to_str(), if_id, cond, thn.id, dest.to_string(bcx.ccx())); let _icx = push_ctxt("trans_if"); diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index e6b47fdee7eec..e60e4e4abe053 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -102,7 +102,6 @@ use trans::expr; use trans::tvec; use trans::type_of; use middle::ty::{self, Ty}; -use util::ppaux::Repr; use std::fmt; use syntax::ast; @@ -614,9 +613,9 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> { #[allow(dead_code)] // useful for debugging pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { - format!("Datum({}, {}, {:?})", + format!("Datum({}, {:?}, {:?})", ccx.tn().val_to_string(self.val), - self.ty.repr(), + self.ty, self.kind) } diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index 5ced8452b5f70..7660f59e1d08b 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -34,7 +34,6 @@ use trans::type_::Type; use middle::ty::{self, Ty, ClosureTyper}; use session::config::{self, FullDebugInfo}; use util::nodemap::FnvHashMap; -use util::ppaux::{Repr, UserString}; use util::common::path2cstr; use libc::{c_uint, c_longlong}; @@ -105,7 +104,7 @@ impl<'tcx> TypeMap<'tcx> { metadata: DIType) { if self.type_to_metadata.insert(type_, metadata).is_some() { cx.sess().bug(&format!("Type metadata for Ty '{}' is already in the TypeMap!", - type_.repr())); + type_)); } } @@ -297,8 +296,8 @@ impl<'tcx> TypeMap<'tcx> { &mut unique_type_id); }, _ => { - cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}", - type_.repr(), type_.sty)) + cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {:?}", + type_)) } }; @@ -488,8 +487,8 @@ impl<'tcx> RecursiveTypeDescription<'tcx> { if type_map.find_metadata_for_unique_id(unique_type_id).is_none() || type_map.find_metadata_for_type(unfinished_type).is_none() { cx.sess().bug(&format!("Forward declaration of potentially recursive type \ - '{}' was not found in TypeMap!", - unfinished_type.repr()) + '{:?}' was not found in TypeMap!", + unfinished_type) ); } } @@ -676,8 +675,8 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::TyTrait(ref data) => data.principal_def_id(), _ => { cx.sess().bug(&format!("debuginfo: Unexpected trait-object type in \ - trait_pointer_metadata(): {}", - trait_type.repr())); + trait_pointer_metadata(): {:?}", + trait_type)); } }; @@ -839,7 +838,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, the debuginfo::TypeMap but it \ was not. (Ty = {})", &unique_type_id_str[..], - t.user_string()); + t); cx.sess().span_bug(usage_site_span, &error_message[..]); } }; @@ -854,7 +853,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, debuginfo::TypeMap. \ UniqueTypeId={}, Ty={}", &unique_type_id_str[..], - t.user_string()); + t); cx.sess().span_bug(usage_site_span, &error_message[..]); } } diff --git a/src/librustc_trans/trans/debuginfo/type_names.rs b/src/librustc_trans/trans/debuginfo/type_names.rs index e33f059a94554..5ba5ecb02c024 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/trans/debuginfo/type_names.rs @@ -15,7 +15,6 @@ use super::namespace::crate_root_namespace; use trans::common::CrateContext; use middle::subst::{self, Substs}; use middle::ty::{self, Ty, ClosureTyper}; -use util::ppaux::Repr; use syntax::ast; use syntax::parse::token; @@ -163,7 +162,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::TyProjection(..) | ty::TyParam(_) => { cx.sess().bug(&format!("debuginfo: Trying to create type name for \ - unexpected type: {}", t.repr())); + unexpected type: {:?}", t)); } } diff --git a/src/librustc_trans/trans/declare.rs b/src/librustc_trans/trans/declare.rs index 56daf7d570f21..8bc3326d30093 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/trans/declare.rs @@ -29,7 +29,6 @@ use trans::context::CrateContext; use trans::monomorphize; use trans::type_::Type; use trans::type_of; -use util::ppaux::Repr; use std::ffi::CString; use libc::c_uint; @@ -106,11 +105,11 @@ pub fn declare_cfn(ccx: &CrateContext, name: &str, fn_type: Type, /// update the declaration and return existing ValueRef instead. pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, fn_type: ty::Ty<'tcx>) -> ValueRef { - debug!("declare_rust_fn(name={:?}, fn_type={})", name, - fn_type.repr()); + debug!("declare_rust_fn(name={:?}, fn_type={:?})", name, + fn_type); let fn_type = monomorphize::normalize_associated_type(ccx.tcx(), &fn_type); - debug!("declare_rust_fn (after normalised associated types) fn_type={}", - fn_type.repr()); + debug!("declare_rust_fn (after normalised associated types) fn_type={:?}", + fn_type); let function_type; // placeholder so that the memory ownership works out ok let (sig, abi, env) = match fn_type.sty { @@ -122,15 +121,15 @@ pub fn declare_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, function_type = typer.closure_type(closure_did, substs); let self_type = base::self_type_for_closure(ccx, closure_did, fn_type); let llenvironment_type = type_of::type_of_explicit_arg(ccx, self_type); - debug!("declare_rust_fn function_type={} self_type={}", - function_type.repr(), self_type.repr()); + debug!("declare_rust_fn function_type={:?} self_type={:?}", + function_type, self_type); (&function_type.sig, abi::RustCall, Some(llenvironment_type)) } _ => ccx.sess().bug("expected closure or fn") }; let sig = ty::Binder(ty::erase_late_bound_regions(ccx.tcx(), sig)); - debug!("declare_rust_fn (after region erasure) sig={}", sig.repr()); + debug!("declare_rust_fn (after region erasure) sig={:?}", sig); let llfty = type_of::type_of_rust_fn(ccx, env, &sig, abi); debug!("declare_rust_fn llfty={}", ccx.tn().type_to_string(llfty)); diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 5a75a595b5c21..48deceeeef73f 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -78,7 +78,6 @@ use middle::ty::{AdjustDerefRef, AdjustReifyFnPointer, AdjustUnsafeFnPointer}; use middle::ty::{self, Ty}; use middle::ty::MethodCall; use util::common::indenter; -use util::ppaux::Repr; use trans::machine::{llsize_of, llsize_of_alloc}; use trans::type_::Type; @@ -181,7 +180,7 @@ pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } - debug!("trans_into() expr={}", expr.repr()); + debug!("trans_into() expr={:?}", expr); let cleanup_debug_loc = debuginfo::get_cleanup_debug_loc_for_ast_node(bcx.ccx(), expr.id, @@ -211,7 +210,7 @@ pub fn trans_into<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pub fn trans<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr) -> DatumBlock<'blk, 'tcx, Expr> { - debug!("trans(expr={})", bcx.expr_to_string(expr)); + debug!("trans(expr={:?})", expr); let mut bcx = bcx; let fcx = bcx.fcx; @@ -329,9 +328,9 @@ pub fn unsized_info<'ccx, 'tcx>(ccx: &CrateContext<'ccx, 'tcx>, consts::ptrcast(meth::get_vtable(ccx, trait_ref, param_substs), Type::vtable_ptr(ccx)) } - _ => ccx.sess().bug(&format!("unsized_info: invalid unsizing {} -> {}", - source.repr(), - target.repr())) + _ => ccx.sess().bug(&format!("unsized_info: invalid unsizing {:?} -> {:?}", + source, + target)) } } @@ -350,8 +349,8 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } Some(adj) => { adj } }; - debug!("unadjusted datum for expr {}: {} adjustment={:?}", - expr.repr(), + debug!("unadjusted datum for expr {:?}: {} adjustment={:?}", + expr, datum.to_string(bcx.ccx()), adjustment); match adjustment { @@ -501,8 +500,8 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ty::custom_coerce_unsized_kind(bcx.tcx(), impl_def_id) } vtable => { - bcx.sess().span_bug(span, &format!("invalid CoerceUnsized vtable: {}", - vtable.repr())); + bcx.sess().span_bug(span, &format!("invalid CoerceUnsized vtable: {:?}", + vtable)); } }; @@ -545,9 +544,9 @@ fn coerce_unsized<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } } } - _ => bcx.sess().bug(&format!("coerce_unsized: invalid coercion {} -> {}", - source.ty.repr(), - target.ty.repr())) + _ => bcx.sess().bug(&format!("coerce_unsized: invalid coercion {:?} -> {:?}", + source.ty, + target.ty)) } bcx } @@ -575,7 +574,7 @@ fn trans_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, -> DatumBlock<'blk, 'tcx, Expr> { let mut bcx = bcx; - debug!("trans_unadjusted(expr={})", bcx.expr_to_string(expr)); + debug!("trans_unadjusted(expr={:?})", expr); let _indenter = indenter(); debuginfo::set_source_location(bcx.fcx, expr.id, expr.span); @@ -1281,9 +1280,9 @@ pub fn trans_def_fn_unadjusted<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } _ => { ccx.tcx().sess.span_bug(ref_expr.span, &format!( - "trans_def_fn_unadjusted invoked on: {:?} for {}", + "trans_def_fn_unadjusted invoked on: {:?} for {:?}", def, - ref_expr.repr())); + ref_expr)); } } } @@ -1317,7 +1316,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } }; debug!("take_local(nid={}, v={}, ty={})", - nid, bcx.val_to_string(datum.val), bcx.ty_to_string(datum.ty)); + nid, bcx.val_to_string(datum.val), datum.ty); datum } _ => { @@ -1354,9 +1353,9 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>, match node_id_opt { None => { tcx.sess.bug(&format!( - "cannot get field types from the enum type {} \ + "cannot get field types from the enum type {:?} \ without a node ID", - ty.repr())); + ty)); } Some(node_id) => { let def = tcx.def_map.borrow().get(&node_id).unwrap().full_def(); @@ -1378,8 +1377,8 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>, _ => { tcx.sess.bug(&format!( - "cannot get field types from the type {}", - ty.repr())); + "cannot get field types from the type {:?}", + ty)); } } } @@ -2060,7 +2059,7 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let t_in = expr_ty_adjusted(bcx, expr); let t_out = node_id_type(bcx, id); - debug!("trans_cast({} as {})", t_in.repr(), t_out.repr()); + debug!("trans_cast({:?} as {:?})", t_in, t_out); let mut ll_t_in = type_of::arg_type_of(ccx, t_in); let ll_t_out = type_of::arg_type_of(ccx, t_out); // Convert the value to be cast into a ValueRef, either by-ref or @@ -2123,9 +2122,9 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, _ => ccx.sess().span_bug(expr.span, &format!("translating unsupported cast: \ - {} -> {}", - t_in.repr(), - t_out.repr()) + {:?} -> {:?}", + t_in, + t_out) ) }; return immediate_rvalue_bcx(bcx, newval, t_out).to_expr_datumblock(); @@ -2140,7 +2139,7 @@ fn trans_assign_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let _icx = push_ctxt("trans_assign_op"); let mut bcx = bcx; - debug!("trans_assign_op(expr={})", bcx.expr_to_string(expr)); + debug!("trans_assign_op(expr={:?})", expr); // User-defined operator methods cannot be used with `+=` etc right now assert!(!bcx.tcx().method_map.borrow().contains_key(&MethodCall::expr(expr.id))); @@ -2210,8 +2209,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, -> DatumBlock<'blk, 'tcx, Expr> { let ccx = bcx.ccx(); - debug!("deref_once(expr={}, datum={}, method_call={:?})", - expr.repr(), + debug!("deref_once(expr={:?}, datum={}, method_call={:?})", + expr, datum.to_string(ccx), method_call); @@ -2295,8 +2294,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, _ => { bcx.tcx().sess.span_bug( expr.span, - &format!("deref invoked on expr of illegal type {}", - datum.ty.repr())); + &format!("deref invoked on expr of illegal type {:?}", + datum.ty)); } }; diff --git a/src/librustc_trans/trans/foreign.rs b/src/librustc_trans/trans/foreign.rs index 66f7a89d7abb2..977d636d253e4 100644 --- a/src/librustc_trans/trans/foreign.rs +++ b/src/librustc_trans/trans/foreign.rs @@ -40,7 +40,6 @@ use syntax::parse::token; use syntax::ast; use syntax::attr; use syntax::print::pprust; -use util::ppaux::Repr; /////////////////////////////////////////////////////////////////////////// // Type definitions @@ -183,11 +182,11 @@ pub fn get_extern_fn(ccx: &CrateContext, pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, abi: Abi, fty: Ty<'tcx>, name: &str) -> ValueRef { - debug!("register_foreign_item_fn(abi={}, \ - ty={}, \ + debug!("register_foreign_item_fn(abi={:?}, \ + ty={:?}, \ name={})", - abi.repr(), - fty.repr(), + abi, + fty, name); let cc = llvm_calling_convention(ccx, abi); @@ -234,10 +233,10 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, { let ccx = bcx.ccx(); - debug!("trans_native_call(callee_ty={}, \ + debug!("trans_native_call(callee_ty={:?}, \ llfn={}, \ llretptr={})", - callee_ty.repr(), + callee_ty, ccx.tn().val_to_string(llfn), ccx.tn().val_to_string(llretptr)); @@ -609,16 +608,16 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, assert!(f.abi != Rust && f.abi != RustIntrinsic); } _ => { - ccx.sess().bug(&format!("build_rust_fn: extern fn {} has ty {}, \ + ccx.sess().bug(&format!("build_rust_fn: extern fn {} has ty {:?}, \ expected a bare fn ty", ccx.tcx().map.path_to_string(id), - t.repr())); + t)); } }; - debug!("build_rust_fn: path={} id={} t={}", + debug!("build_rust_fn: path={} id={} t={:?}", ccx.tcx().map.path_to_string(id), - id, t.repr()); + id, t); let llfn = declare::define_internal_rust_fn(ccx, &ps[..], t).unwrap_or_else(||{ ccx.sess().bug(&format!("symbol `{}` already defined", ps)); @@ -636,10 +635,10 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let _icx = push_ctxt( "foreign::trans_rust_fn_with_foreign_abi::build_wrap_fn"); - debug!("build_wrap_fn(llrustfn={}, llwrapfn={}, t={})", + debug!("build_wrap_fn(llrustfn={}, llwrapfn={}, t={:?})", ccx.tn().val_to_string(llrustfn), ccx.tn().val_to_string(llwrapfn), - t.repr()); + t); // Avoid all the Rust generation stuff and just generate raw // LLVM here. @@ -721,10 +720,10 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, debug!("out pointer, \ allocad={}, \ llrust_ret_ty={}, \ - return_ty={}", + return_ty={:?}", ccx.tn().val_to_string(slot), ccx.tn().type_to_string(llrust_ret_ty), - tys.fn_sig.output.repr()); + tys.fn_sig.output); llrust_args.push(slot); return_alloca = Some(slot); } @@ -815,8 +814,8 @@ pub fn trans_rust_fn_with_foreign_abi<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } // Perform the call itself - debug!("calling llrustfn = {}, t = {}", - ccx.tn().val_to_string(llrustfn), t.repr()); + debug!("calling llrustfn = {}, t = {:?}", + ccx.tn().val_to_string(llrustfn), t); let attributes = attributes::from_fn_type(ccx, t); let llrust_ret_val = builder.call(llrustfn, &llrust_args, Some(attributes)); @@ -934,11 +933,11 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, llsig.llret_ty, llsig.ret_def); debug!("foreign_types_for_fn_ty(\ - ty={}, \ + ty={:?}, \ llsig={} -> {}, \ fn_ty={} -> {}, \ ret_def={}", - ty.repr(), + ty, ccx.tn().types_to_str(&llsig.llarg_tys), ccx.tn().type_to_string(llsig.llret_ty), ccx.tn().types_to_str(&fn_ty.arg_tys.iter().map(|t| t.ty).collect::>()), diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index e0ac4391d67d1..6caf00634b63a 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -39,7 +39,6 @@ use trans::machine::*; use trans::monomorphize; use trans::type_of::{type_of, type_of_dtor, sizing_type_of, align_of}; use trans::type_::Type; -use util::ppaux::Repr; use arena::TypedArena; use libc::c_uint; @@ -140,7 +139,7 @@ pub fn drop_ty_core<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, debug_loc: DebugLoc, skip_dtor: bool) -> Block<'blk, 'tcx> { // NB: v is an *alias* of type t here, not a direct value. - debug!("drop_ty_core(t={}, skip_dtor={})", t.repr(), skip_dtor); + debug!("drop_ty_core(t={:?}, skip_dtor={})", t, skip_dtor); let _icx = push_ctxt("drop_ty"); if bcx.fcx.type_needs_drop(t) { let ccx = bcx.ccx(); @@ -207,9 +206,9 @@ impl<'tcx> DropGlueKind<'tcx> { fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKind<'tcx>) -> ValueRef { - debug!("make drop glue for {}", g.repr()); + debug!("make drop glue for {:?}", g); let g = g.map_ty(|t| get_drop_glue_type(ccx, t)); - debug!("drop glue type {}", g.repr()); + debug!("drop glue type {:?}", g); match ccx.drop_glues().borrow().get(&g) { Some(&glue) => return glue, _ => { } @@ -238,7 +237,7 @@ fn get_drop_glue_core<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }); ccx.available_drop_glues().borrow_mut().insert(g, fn_nm); - let _s = StatRecorder::new(ccx, format!("drop {}", t.repr())); + let _s = StatRecorder::new(ccx, format!("drop {:?}", t)); let empty_substs = ccx.tcx().mk_substs(Substs::trans_empty()); let (arena, fcx): (TypedArena<_>, FunctionContext); @@ -346,7 +345,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, substs: &subst::Substs<'tcx>) -> Block<'blk, 'tcx> { - debug!("trans_struct_drop t: {}", bcx.ty_to_string(t)); + debug!("trans_struct_drop t: {}", t); // Find and call the actual destructor let dtor_addr = get_res_dtor(bcx.ccx(), dtor_did, t, class_did, substs); @@ -381,7 +380,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, info: ValueRef) -> (ValueRef, ValueRef) { debug!("calculate size of DST: {}; with lost info: {}", - bcx.ty_to_string(t), bcx.val_to_string(info)); + t, bcx.val_to_string(info)); if type_is_sized(bcx.tcx(), t) { let sizing_type = sizing_type_of(bcx.ccx(), t); let size = C_uint(bcx.ccx(), llsize_of_alloc(bcx.ccx(), sizing_type)); @@ -436,8 +435,7 @@ pub fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, in (Mul(bcx, info, C_uint(bcx.ccx(), unit_size), DebugLoc::None), C_uint(bcx.ccx(), unit_align)) } - _ => bcx.sess().bug(&format!("Unexpected unsized type, found {}", - bcx.ty_to_string(t))) + _ => bcx.sess().bug(&format!("Unexpected unsized type, found {}", t)) } } @@ -511,8 +509,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK // stupid and dangerous. bcx.sess().warn(&format!("Ignoring drop flag in destructor for {}\ because the struct is unsized. See issue\ - #16758", - bcx.ty_to_string(t))); + #16758", t)); trans_struct_drop(bcx, t, v0, dtor, did, substs) } } diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index c2b0d78ce1f88..41d150ac265c9 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -34,7 +34,6 @@ use middle::ty::{self, Ty}; use syntax::abi::RustIntrinsic; use syntax::ast; use syntax::parse::token; -use util::ppaux::{Repr, UserString}; pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Option { let name = match &token::get_ident(item.ident)[..] { @@ -102,7 +101,7 @@ pub fn check_intrinsics(ccx: &CrateContext) { continue; } - debug!("transmute_restriction: {}", transmute_restriction.repr()); + debug!("transmute_restriction: {:?}", transmute_restriction); assert!(!ty::type_has_params(transmute_restriction.substituted_from)); assert!(!ty::type_has_params(transmute_restriction.substituted_to)); @@ -121,10 +120,10 @@ pub fn check_intrinsics(ccx: &CrateContext) { transmute_restriction.span, &format!("transmute called on types with potentially different sizes: \ {} (could be {} bit{}) to {} (could be {} bit{})", - transmute_restriction.original_from.user_string(), + transmute_restriction.original_from, from_type_size as usize, if from_type_size == 1 {""} else {"s"}, - transmute_restriction.original_to.user_string(), + transmute_restriction.original_to, to_type_size as usize, if to_type_size == 1 {""} else {"s"})); } else { @@ -132,10 +131,10 @@ pub fn check_intrinsics(ccx: &CrateContext) { transmute_restriction.span, &format!("transmute called on types with different sizes: \ {} ({} bit{}) to {} ({} bit{})", - transmute_restriction.original_from.user_string(), + transmute_restriction.original_from, from_type_size as usize, if from_type_size == 1 {""} else {"s"}, - transmute_restriction.original_to.user_string(), + transmute_restriction.original_to, to_type_size as usize, if to_type_size == 1 {""} else {"s"})); } @@ -405,7 +404,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, } (_, "type_name") => { let tp_ty = *substs.types.get(FnSpace, 0); - let ty_name = token::intern_and_get_ident(&tp_ty.user_string()); + let ty_name = token::intern_and_get_ident(&tp_ty.to_string()); C_str_slice(ccx, ty_name) } (_, "type_id") => { diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index ec95bfe483c26..eca6eecff4279 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -39,7 +39,6 @@ use trans::type_::Type; use trans::type_of::*; use middle::ty::{self, Ty}; use middle::ty::MethodCall; -use util::ppaux::Repr; use syntax::abi::{Rust, RustCall}; use syntax::parse::token; @@ -136,15 +135,15 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, }) => { let trait_ref = ty::Binder(bcx.monomorphize(trait_ref)); let span = bcx.tcx().map.span(method_call.expr_id); - debug!("method_call={:?} trait_ref={} trait_ref id={:?} substs={:?}", + debug!("method_call={:?} trait_ref={:?} trait_ref id={:?} substs={:?}", method_call, - trait_ref.repr(), + trait_ref, trait_ref.0.def_id, trait_ref.0.substs); let origin = fulfill_obligation(bcx.ccx(), span, trait_ref.clone()); - debug!("origin = {}", origin.repr()); + debug!("origin = {:?}", origin); trans_monomorphized_callee(bcx, method_call, trait_ref.def_id(), @@ -234,7 +233,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, rcvr_self, Vec::new())); let trait_substs = tcx.mk_substs(trait_substs); - debug!("trait_substs={}", trait_substs.repr()); + debug!("trait_substs={:?}", trait_substs); let trait_ref = ty::Binder(ty::TraitRef { def_id: trait_id, substs: trait_substs }); let vtbl = fulfill_obligation(ccx, @@ -296,8 +295,8 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, immediate_rvalue(llfn, ty) } _ => { - tcx.sess.bug(&format!("static call to invalid vtable: {}", - vtbl.repr())); + tcx.sess.bug(&format!("static call to invalid vtable: {:?}", + vtbl)); } } } @@ -390,8 +389,8 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, traits::VtableDefaultImpl(..) | traits::VtableParam(..) => { bcx.sess().bug( - &format!("resolved vtable bad vtable {} in trans", - vtable.repr())); + &format!("resolved vtable bad vtable {:?} in trans", + vtable)); } } } @@ -415,8 +414,8 @@ fn combine_impl_and_methods_tps<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let node_substs = node_id_substs(ccx, node, bcx.fcx.param_substs); - debug!("rcvr_substs={}", rcvr_substs.repr()); - debug!("node_substs={}", node_substs.repr()); + debug!("rcvr_substs={:?}", rcvr_substs); + debug!("node_substs={:?}", node_substs); // Break apart the type parameters from the node and type // parameters from the receiver. @@ -484,7 +483,7 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Load the data pointer from the object. debug!("trans_trait_callee_from_llval(callee_ty={}, vtable_index={}, llpair={})", - callee_ty.repr(), + callee_ty, vtable_index, bcx.val_to_string(llpair)); let llboxptr = GEPi(bcx, llpair, &[0, abi::FAT_PTR_ADDR]); @@ -556,9 +555,9 @@ pub fn trans_object_shim<'a, 'tcx>( let tcx = ccx.tcx(); let trait_id = upcast_trait_ref.def_id(); - debug!("trans_object_shim(object_ty={}, upcast_trait_ref={}, method_offset_in_trait={})", - object_ty.repr(), - upcast_trait_ref.repr(), + debug!("trans_object_shim(object_ty={:?}, upcast_trait_ref={:?}, method_offset_in_trait={})", + object_ty, + upcast_trait_ref, method_offset_in_trait); let object_trait_ref = @@ -567,15 +566,15 @@ pub fn trans_object_shim<'a, 'tcx>( data.principal_trait_ref_with_self_ty(tcx, object_ty) } _ => { - tcx.sess.bug(&format!("trans_object_shim() called on non-object: {}", - object_ty.repr())); + tcx.sess.bug(&format!("trans_object_shim() called on non-object: {:?}", + object_ty)); } }; // Upcast to the trait in question and extract out the substitutions. let upcast_trait_ref = ty::erase_late_bound_regions(tcx, &upcast_trait_ref); let object_substs = upcast_trait_ref.substs.clone().erase_regions(); - debug!("trans_object_shim: object_substs={}", object_substs.repr()); + debug!("trans_object_shim: object_substs={:?}", object_substs); // Lookup the type of this method as declared in the trait and apply substitutions. let method_ty = match ty::trait_item(tcx, trait_id, method_offset_in_trait) { @@ -587,7 +586,7 @@ pub fn trans_object_shim<'a, 'tcx>( let fty = monomorphize::apply_param_substs(tcx, &object_substs, &method_ty.fty); let fty = tcx.mk_bare_fn(fty); let method_ty = opaque_method_ty(tcx, fty); - debug!("trans_object_shim: fty={} method_ty={}", fty.repr(), method_ty.repr()); + debug!("trans_object_shim: fty={:?} method_ty={:?}", fty, method_ty); // let shim_fn_ty = ty::mk_bare_fn(tcx, None, fty); @@ -627,8 +626,8 @@ pub fn trans_object_shim<'a, 'tcx>( ty::TyTuple(ref tys) => &**tys, _ => { bcx.sess().bug( - &format!("rust-call expects a tuple not {}", - sig.inputs[1].repr())); + &format!("rust-call expects a tuple not {:?}", + sig.inputs[1])); } } } @@ -692,7 +691,7 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let tcx = ccx.tcx(); let _icx = push_ctxt("meth::get_vtable"); - debug!("get_vtable(trait_ref={})", trait_ref.repr()); + debug!("get_vtable(trait_ref={:?})", trait_ref); // Check the cache. match ccx.vtables().borrow().get(&trait_ref) { @@ -739,14 +738,14 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // an object type; this cannot happen because we // cannot cast an unsized type into a trait object tcx.sess.bug( - &format!("cannot get vtable for an object type: {}", - data.repr())); + &format!("cannot get vtable for an object type: {:?}", + data)); } traits::VtableParam(..) => { tcx.sess.bug( - &format!("resolved vtable for {} to bad vtable {} in trans", - trait_ref.repr(), - vtable.repr())); + &format!("resolved vtable for {:?} to bad vtable {:?} in trans", + trait_ref, + vtable)); } } }); @@ -776,10 +775,10 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, { let tcx = ccx.tcx(); - debug!("emit_vtable_methods(impl_id={}, substs={}, param_substs={})", - impl_id.repr(), - substs.repr(), - param_substs.repr()); + debug!("emit_vtable_methods(impl_id={:?}, substs={:?}, param_substs={:?})", + impl_id, + substs, + param_substs); let trt_id = match ty::impl_trait_ref(tcx, impl_id) { Some(t_id) => t_id.def_id, @@ -806,8 +805,8 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // method could never be called from this object, just supply // null. .map(|trait_method_def_id| { - debug!("emit_vtable_methods: trait_method_def_id={}", - trait_method_def_id.repr()); + debug!("emit_vtable_methods: trait_method_def_id={:?}", + trait_method_def_id); let trait_method_type = match ty::impl_or_trait_item(tcx, trait_method_def_id) { ty::MethodTraitItem(m) => m, @@ -821,8 +820,8 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, return nullptr; } - debug!("emit_vtable_methods: trait_method_type={}", - trait_method_type.repr()); + debug!("emit_vtable_methods: trait_method_type={:?}", + trait_method_type); // The substitutions we have are on the impl, so we grab // the method type from the impl to substitute into. @@ -832,8 +831,8 @@ fn emit_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, _ => ccx.sess().bug("should be a method, not other assoc item"), }; - debug!("emit_vtable_methods: impl_method_type={}", - impl_method_type.repr()); + debug!("emit_vtable_methods: impl_method_type={:?}", + impl_method_type); // If this is a default method, it's possible that it // relies on where clauses that do not hold for this diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index 4a81610dd852f..f4bad313bafb1 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -26,7 +26,6 @@ use trans::common::*; use trans::declare; use trans::foreign; use middle::ty::{self, HasProjectionTypes, Ty}; -use util::ppaux::Repr; use syntax::abi; use syntax::ast; @@ -41,11 +40,11 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ref_id: Option) -> (ValueRef, Ty<'tcx>, bool) { debug!("monomorphic_fn(\ - fn_id={}, \ - real_substs={}, \ + fn_id={:?}, \ + real_substs={:?}, \ ref_id={:?})", - fn_id.repr(), - psubsts.repr(), + fn_id, + psubsts, ref_id); assert!(psubsts.types.all(|t| { @@ -61,7 +60,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, let item_ty = ty::lookup_item_type(ccx.tcx(), fn_id).ty; - debug!("monomorphic_fn about to subst into {}", item_ty.repr()); + debug!("monomorphic_fn about to subst into {:?}", item_ty); let mono_ty = item_ty.subst(ccx.tcx(), psubsts); match ccx.monomorphized().borrow().get(&hash_id) { @@ -74,11 +73,11 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } debug!("monomorphic_fn(\ - fn_id={}, \ - psubsts={}, \ + fn_id={:?}, \ + psubsts={:?}, \ hash_id={:?})", - fn_id.repr(), - psubsts.repr(), + fn_id, + psubsts, hash_id); @@ -99,10 +98,10 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, } } - debug!("mono_ty = {} (post-substitution)", mono_ty.repr()); + debug!("mono_ty = {:?} (post-substitution)", mono_ty); let mono_ty = normalize_associated_type(ccx.tcx(), &mono_ty); - debug!("mono_ty = {} (post-normalization)", mono_ty.repr()); + debug!("mono_ty = {:?} (post-normalization)", mono_ty); ccx.stats().n_monos.set(ccx.stats().n_monos.get() + 1); @@ -316,7 +315,7 @@ pub fn apply_param_substs<'tcx,T>(tcx: &ty::ctxt<'tcx>, pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T where T : TypeFoldable<'tcx> + HasProjectionTypes { - debug!("normalize_associated_type(t={})", value.repr()); + debug!("normalize_associated_type(t={:?})", value); let value = erase_regions(tcx, value); @@ -333,9 +332,9 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T let traits::Normalized { value: result, obligations } = traits::normalize(&mut selcx, cause, &value); - debug!("normalize_associated_type: result={} obligations={}", - result.repr(), - obligations.repr()); + debug!("normalize_associated_type: result={:?} obligations={:?}", + result, + obligations); let mut fulfill_cx = traits::FulfillmentContext::new(true); for obligation in obligations { diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index f2168d38c9e57..bba0f6d26083a 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -28,7 +28,6 @@ use trans::machine::llsize_of_alloc; use trans::type_::Type; use trans::type_of; use middle::ty::{self, Ty}; -use util::ppaux::UserString; use syntax::ast; use syntax::parse::token::InternedString; @@ -42,7 +41,7 @@ struct VecTypes<'tcx> { impl<'tcx> VecTypes<'tcx> { pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String { format!("VecTypes {{unit_ty={}, llunit_ty={}}}", - self.unit_ty.user_string(), + self.unit_ty, ccx.tn().type_to_string(self.llunit_ty)) } } @@ -58,8 +57,8 @@ pub fn trans_fixed_vstore<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // to store the array of the suitable size, so all we have to do is // generate the content. - debug!("trans_fixed_vstore(expr={}, dest={})", - bcx.expr_to_string(expr), dest.to_string(bcx.ccx())); + debug!("trans_fixed_vstore(expr={:?}, dest={})", + expr, dest.to_string(bcx.ccx())); let vt = vec_types_from_expr(bcx, expr); @@ -85,8 +84,8 @@ pub fn trans_slice_vec<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let ccx = fcx.ccx; let mut bcx = bcx; - debug!("trans_slice_vec(slice_expr={})", - bcx.expr_to_string(slice_expr)); + debug!("trans_slice_vec(slice_expr={:?})", + slice_expr); let vec_ty = node_id_type(bcx, slice_expr.id); @@ -139,8 +138,8 @@ pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, str_lit: InternedString, dest: Dest) -> Block<'blk, 'tcx> { - debug!("trans_lit_str(lit_expr={}, dest={})", - bcx.expr_to_string(lit_expr), + debug!("trans_lit_str(lit_expr={:?}, dest={})", + lit_expr, dest.to_string(bcx.ccx())); match dest { @@ -167,10 +166,10 @@ fn write_content<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let fcx = bcx.fcx; let mut bcx = bcx; - debug!("write_content(vt={}, dest={}, vstore_expr={})", + debug!("write_content(vt={}, dest={}, vstore_expr={:?})", vt.to_string(bcx.ccx()), dest.to_string(bcx.ccx()), - bcx.expr_to_string(vstore_expr)); + vstore_expr); match content_expr.node { ast::ExprLit(ref lit) => { diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 4ec6edcea714d..26b54142d6316 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -16,7 +16,6 @@ use trans::common::*; use trans::foreign; use trans::machine; use middle::ty::{self, RegionEscape, Ty}; -use util::ppaux::Repr; use trans::type_::Type; @@ -99,8 +98,8 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, abi: abi::Abi) -> Type { - debug!("type_of_rust_fn(sig={},abi={:?})", - sig.repr(), + debug!("type_of_rust_fn(sig={:?},abi={:?})", + sig, abi); let sig = ty::erase_late_bound_regions(cx.tcx(), sig); @@ -228,8 +227,8 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ } ty::TyProjection(..) | ty::TyInfer(..) | ty::TyParam(..) | ty::TyError(..) => { - cx.sess().bug(&format!("fictitious type {} in sizing_type_of()", - t.repr())) + cx.sess().bug(&format!("fictitious type {:?} in sizing_type_of()", + t)) } ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!() }; @@ -298,7 +297,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> None => () } - debug!("type_of {} {:?}", t.repr(), t.sty); + debug!("type_of {:?}", t); assert!(!t.has_escaping_regions()); @@ -311,10 +310,10 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> if t != t_norm { let llty = in_memory_type_of(cx, t_norm); - debug!("--> normalized {} {:?} to {} {:?} llty={}", - t.repr(), + debug!("--> normalized {:?} {:?} to {:?} {:?} llty={}", t, - t_norm.repr(), + t, + t_norm, t_norm, cx.tn().type_to_string(llty)); cx.lltypes().borrow_mut().insert(t, llty); @@ -363,8 +362,8 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> } ty::TyTrait(_) => Type::vtable_ptr(cx), _ => panic!("Unexpected type returned from \ - struct_tail: {} for ty={}", - unsized_part.repr(), ty.repr()) + struct_tail: {:?} for ty={:?}", + unsized_part, ty) }; Type::struct_(cx, &[ptr_ty, info_ty], false) } @@ -418,8 +417,8 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> ty::TyError(..) => cx.sess().bug("type_of with TyError"), }; - debug!("--> mapped t={} {:?} to llty={}", - t.repr(), + debug!("--> mapped t={:?} {:?} to llty={}", + t, t, cx.tn().type_to_string(llty)); @@ -449,7 +448,7 @@ fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, tps: &[Ty<'tcx>]) -> String { let base = ty::item_path_str(cx.tcx(), did); - let strings: Vec = tps.iter().map(|t| t.repr()).collect(); + let strings: Vec = tps.iter().map(|t| t.to_string()).collect(); let tstr = if strings.is_empty() { base } else { diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index dee8eefd9da5f..8e838d991fbe7 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -61,7 +61,6 @@ use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ExplicitRscope ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope}; use util::common::{ErrorReported, FN_OUTPUT_NAME}; use util::nodemap::FnvHashSet; -use util::ppaux::{Repr, UserString}; use std::iter::repeat; use std::slice; @@ -178,10 +177,10 @@ pub fn ast_region_to_region(tcx: &ty::ctxt, lifetime: &ast::Lifetime) } }; - debug!("ast_region_to_region(lifetime={} id={}) yields {}", - lifetime.repr(), + debug!("ast_region_to_region(lifetime={:?} id={}) yields {:?}", + lifetime, lifetime.id, - r.repr()); + r); r } @@ -256,9 +255,9 @@ pub fn opt_ast_region_to_region<'tcx>( } }; - debug!("opt_ast_region_to_region(opt_lifetime={}) yields {}", - opt_lifetime.repr(), - r.repr()); + debug!("opt_ast_region_to_region(opt_lifetime={:?}) yields {:?}", + opt_lifetime, + r); r } @@ -373,10 +372,10 @@ fn create_substs_for_ast_path<'tcx>( { let tcx = this.tcx(); - debug!("create_substs_for_ast_path(decl_generics={}, self_ty={}, \ - types_provided={}, region_substs={}", - decl_generics.repr(), self_ty.repr(), types_provided.repr(), - region_substs.repr()); + debug!("create_substs_for_ast_path(decl_generics={:?}, self_ty={:?}, \ + types_provided={:?}, region_substs={:?}", + decl_generics, self_ty, types_provided, + region_substs); assert_eq!(region_substs.regions().len(TypeSpace), decl_generics.regions.len(TypeSpace)); assert!(region_substs.types.is_empty()); @@ -441,8 +440,8 @@ fn create_substs_for_ast_path<'tcx>( "the type parameter `{}` must be explicitly specified \ in an object type because its default value `{}` references \ the type `Self`", - param.name.user_string(), - default.user_string()); + param.name, + default); substs.types.push(TypeSpace, tcx.types.err); } else { // This is a default type parameter. @@ -649,7 +648,7 @@ fn trait_def_id<'tcx>(this: &AstConv<'tcx>, trait_ref: &ast::TraitRef) -> ast::D def::DefTrait(trait_def_id) => trait_def_id, _ => { span_fatal!(this.tcx().sess, path.span, E0245, "`{}` is not a trait", - path.user_string()); + path); } } } @@ -879,7 +878,7 @@ fn ast_type_binding_to_poly_projection_predicate<'tcx>( let candidate = try!(one_bound_for_assoc_type(tcx, candidates, - &trait_ref.user_string(), + &trait_ref.to_string(), &token::get_name(binding.item_name), binding.span)); @@ -1030,8 +1029,8 @@ fn trait_ref_to_object_type<'tcx>(this: &AstConv<'tcx>, bounds); let result = make_object_type(this, span, trait_ref, existential_bounds); - debug!("trait_ref_to_object_type: result={}", - result.repr()); + debug!("trait_ref_to_object_type: result={:?}", + result); result } @@ -1074,7 +1073,7 @@ fn make_object_type<'tcx>(this: &AstConv<'tcx>, for (trait_def_id, name) in associated_types { span_err!(tcx.sess, span, E0191, "the value of the associated type `{}` (from the trait `{}`) must be specified", - name.user_string(), + name, ty::item_path_str(tcx, trait_def_id)); } @@ -1160,7 +1159,7 @@ fn one_bound_for_assoc_type<'tcx>(tcx: &ty::ctxt<'tcx>, span_note!(tcx.sess, span, "associated type `{}` could derive from `{}`", ty_param_name, - bound.user_string()); + bound); } } @@ -1183,7 +1182,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>, let tcx = this.tcx(); let assoc_name = item_segment.identifier.name; - debug!("associated_path_def_to_ty: {}::{}", ty.repr(), token::get_name(assoc_name)); + debug!("associated_path_def_to_ty: {:?}::{}", ty, assoc_name); check_path_args(tcx, slice::ref_slice(item_segment), NO_TPS | NO_REGIONS); @@ -1239,7 +1238,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>, _ => { report_ambiguous_associated_type(tcx, span, - &ty.user_string(), + &ty.to_string(), "Trait", &token::get_name(assoc_name)); return (tcx.types.err, ty_path_def); @@ -1296,7 +1295,7 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>, return tcx.types.err; }; - debug!("qpath_to_ty: self_type={}", self_ty.repr()); + debug!("qpath_to_ty: self_type={:?}", self_ty); let trait_ref = ast_path_to_mono_trait_ref(this, rscope, @@ -1306,7 +1305,7 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>, Some(self_ty), trait_segment); - debug!("qpath_to_ty: trait_ref={}", trait_ref.repr()); + debug!("qpath_to_ty: trait_ref={:?}", trait_ref); this.projected_ty(span, trait_ref, item_segment.identifier.name) } @@ -1495,8 +1494,8 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, ast_ty: &ast::Ty) -> Ty<'tcx> { - debug!("ast_ty_to_ty(ast_ty={})", - ast_ty.repr()); + debug!("ast_ty_to_ty(ast_ty={:?})", + ast_ty); let tcx = this.tcx(); @@ -1531,7 +1530,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, } ast::TyRptr(ref region, ref mt) => { let r = opt_ast_region_to_region(this, rscope, ast_ty.span, region); - debug!("TyRef r={}", r.repr()); + debug!("TyRef r={:?}", r); let rscope1 = &ObjectLifetimeDefaultRscope::new( rscope, @@ -1568,8 +1567,7 @@ pub fn ast_ty_to_ty<'tcx>(this: &AstConv<'tcx>, depth: path.segments.len() } } else { - tcx.sess.span_bug(ast_ty.span, - &format!("unbound path {}", ast_ty.repr())) + tcx.sess.span_bug(ast_ty.span, &format!("unbound path {:?}", ast_ty)) }; let def = path_res.base_def; let base_ty_end = path.segments.len() - path_res.depth; @@ -1843,11 +1841,11 @@ fn determine_explicit_self_category<'a, 'tcx>(this: &AstConv<'tcx>, let impl_modifiers = count_modifiers(self_info.untransformed_self_ty); let method_modifiers = count_modifiers(explicit_type); - debug!("determine_explicit_self_category(self_info.untransformed_self_ty={} \ - explicit_type={} \ + debug!("determine_explicit_self_category(self_info.untransformed_self_ty={:?} \ + explicit_type={:?} \ modifiers=({},{})", - self_info.untransformed_self_ty.repr(), - explicit_type.repr(), + self_info.untransformed_self_ty, + explicit_type, impl_modifiers, method_modifiers); @@ -1880,8 +1878,8 @@ pub fn ty_of_closure<'tcx>( expected_sig: Option>) -> ty::ClosureTy<'tcx> { - debug!("ty_of_closure(expected_sig={})", - expected_sig.repr()); + debug!("ty_of_closure(expected_sig={:?})", + expected_sig); // new region names that appear inside of the fn decl are bound to // that function type @@ -1919,8 +1917,8 @@ pub fn ty_of_closure<'tcx>( ast::NoReturn(..) => ty::FnDiverging }; - debug!("ty_of_closure: input_tys={}", input_tys.repr()); - debug!("ty_of_closure: output_ty={}", output_ty.repr()); + debug!("ty_of_closure: input_tys={:?}", input_tys); + debug!("ty_of_closure: output_ty={:?}", output_ty); ty::ClosureTy { unsafety: unsafety, @@ -2037,10 +2035,10 @@ fn compute_object_lifetime_bound<'tcx>( let tcx = this.tcx(); debug!("compute_opt_region_bound(explicit_region_bounds={:?}, \ - principal_trait_ref={}, builtin_bounds={})", + principal_trait_ref={:?}, builtin_bounds={:?})", explicit_region_bounds, - principal_trait_ref.repr(), - builtin_bounds.repr()); + principal_trait_ref, + builtin_bounds); if explicit_region_bounds.len() > 1 { span_err!(tcx.sess, explicit_region_bounds[1].span, E0226, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 0f1498e2be7e2..cf086a32ae599 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -22,7 +22,6 @@ use check::{check_expr_with_lvalue_pref, LvaluePreference}; use check::{instantiate_path, resolve_ty_and_def_ufcs, structurally_resolved_type}; use require_same_types; use util::nodemap::FnvHashMap; -use util::ppaux::Repr; use std::cmp::{self, Ordering}; use std::collections::hash_map::Entry::{Occupied, Vacant}; @@ -40,9 +39,9 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, let fcx = pcx.fcx; let tcx = pcx.fcx.ccx.tcx; - debug!("check_pat(pat={},expected={})", - pat.repr(), - expected.repr()); + debug!("check_pat(pat={:?},expected={:?})", + pat, + expected); match pat.node { ast::PatWild(_) => { @@ -222,7 +221,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, } } else { tcx.sess.span_bug(pat.span, - &format!("unbound path {}", pat.repr())) + &format!("unbound path {:?}", pat)) }; if let Some((opt_ty, segments, def)) = resolve_ty_and_def_ufcs(fcx, path_res, Some(self_ty), diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs index ec5752fb50fff..df9fe6b002efb 100644 --- a/src/librustc_typeck/check/assoc.rs +++ b/src/librustc_typeck/check/assoc.rs @@ -15,7 +15,6 @@ use middle::ty::{self, HasProjectionTypes}; use middle::ty_fold::TypeFoldable; use syntax::ast; use syntax::codemap::Span; -use util::ppaux::Repr; pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, typer: &(ty::ClosureTyper<'tcx>+'a), @@ -26,13 +25,13 @@ pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, -> T where T : TypeFoldable<'tcx> + HasProjectionTypes { - debug!("normalize_associated_types_in(value={})", value.repr()); + debug!("normalize_associated_types_in(value={:?})", value); let mut selcx = SelectionContext::new(infcx, typer); let cause = ObligationCause::new(span, body_id, MiscObligation); let Normalized { value: result, obligations } = traits::normalize(&mut selcx, cause, value); - debug!("normalize_associated_types_in: result={} predicates={}", - result.repr(), - obligations.repr()); + debug!("normalize_associated_types_in: result={:?} predicates={:?}", + result, + obligations); for obligation in obligations { fulfillment_cx.register_predicate_obligation(infcx, obligation); } diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index da1c44604f9fc..e7271d2fa88cf 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -32,7 +32,6 @@ use syntax::ast; use syntax::codemap::Span; use syntax::parse::token; use syntax::ptr::P; -use util::ppaux::Repr; /// Check that it is legal to call methods of the trait corresponding /// to `trait_id` (this only cares about the trait, not the specific @@ -120,9 +119,9 @@ fn try_overloaded_call_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, autoderefs: usize) -> Option> { - debug!("try_overloaded_call_step(call_expr={}, adjusted_ty={}, autoderefs={})", - call_expr.repr(), - adjusted_ty.repr(), + debug!("try_overloaded_call_step(call_expr={:?}, adjusted_ty={:?}, autoderefs={})", + call_expr, + adjusted_ty, autoderefs); // If the callee is a bare function or a closure, then we're all set. @@ -340,8 +339,8 @@ struct CallResolution<'tcx> { impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> { fn resolve<'a>(&mut self, fcx: &FnCtxt<'a,'tcx>) { - debug!("DeferredCallResolution::resolve() {}", - self.repr()); + debug!("DeferredCallResolution::resolve() {:?}", + self); // we should not be invoked until the closure kind has been // determined by upvar inference @@ -363,8 +362,8 @@ impl<'tcx> DeferredCallResolution<'tcx> for CallResolution<'tcx> { ty::no_late_bound_regions(fcx.tcx(), ty::ty_fn_sig(method_callee.ty)).unwrap(); - debug!("attempt_resolution: method_callee={}", - method_callee.repr()); + debug!("attempt_resolution: method_callee={:?}", + method_callee); for (&method_arg_ty, &self_arg_ty) in method_sig.inputs[1..].iter().zip(&self.fn_sig.inputs) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 14976bf95593f..9522a21b69ec6 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -45,7 +45,6 @@ use middle::ty::Ty; use syntax::ast; use syntax::ast::UintTy::{TyU8}; use syntax::codemap::Span; -use util::ppaux::Repr; /// Reifies a cast check to be checked once we have full type information for /// a function context. @@ -192,8 +191,8 @@ impl<'tcx> CastCheck<'tcx> { self.expr_ty = structurally_resolved_type(fcx, self.span, self.expr_ty); self.cast_ty = structurally_resolved_type(fcx, self.span, self.cast_ty); - debug!("check_cast({}, {} as {})", self.expr.id, self.expr_ty.repr(), - self.cast_ty.repr()); + debug!("check_cast({}, {:?} as {:?})", self.expr.id, self.expr_ty, + self.cast_ty); if ty::type_is_error(self.expr_ty) || ty::type_is_error(self.cast_ty) { // No sense in giving duplicate error messages @@ -273,8 +272,8 @@ impl<'tcx> CastCheck<'tcx> { m_cast: &'tcx ty::mt<'tcx>) -> Result { - debug!("check_ptr_ptr_cast m_expr={} m_cast={}", - m_expr.repr(), m_cast.repr()); + debug!("check_ptr_ptr_cast m_expr={:?} m_cast={:?}", + m_expr, m_cast); // ptr-ptr cast. vtables must match. // Cast to sized is OK diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index 16d4c0f997ae1..10b2459b220f2 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -20,7 +20,6 @@ use std::cmp; use syntax::abi; use syntax::ast; use syntax::ast_util; -use util::ppaux::Repr; pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, expr: &ast::Expr, @@ -28,9 +27,9 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, decl: &'tcx ast::FnDecl, body: &'tcx ast::Block, expected: Expectation<'tcx>) { - debug!("check_expr_closure(expr={},expected={})", - expr.repr(), - expected.repr()); + debug!("check_expr_closure(expr={:?},expected={:?})", + expr, + expected); // It's always helpful for inference if we know the kind of // closure sooner rather than later, so first examine the expected @@ -50,9 +49,9 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, expected_sig: Option>) { let expr_def_id = ast_util::local_def(expr.id); - debug!("check_closure opt_kind={:?} expected_sig={}", + debug!("check_closure opt_kind={:?} expected_sig={:?}", opt_kind, - expected_sig.repr()); + expected_sig); let mut fn_ty = astconv::ty_of_closure( fcx, @@ -86,9 +85,9 @@ fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, // the `closures` table. fn_ty.sig.0.inputs = vec![ty::mk_tup(fcx.tcx(), fn_ty.sig.0.inputs)]; - debug!("closure for {} --> sig={} opt_kind={:?}", - expr_def_id.repr(), - fn_ty.sig.repr(), + debug!("closure for {:?} --> sig={:?} opt_kind={:?}", + expr_def_id, + fn_ty.sig, opt_kind); fcx.inh.closure_tys.borrow_mut().insert(expr_def_id, fn_ty); @@ -103,8 +102,8 @@ fn deduce_expectations_from_expected_type<'a,'tcx>( expected_ty: Ty<'tcx>) -> (Option>,Option) { - debug!("deduce_expectations_from_expected_type(expected_ty={})", - expected_ty.repr()); + debug!("deduce_expectations_from_expected_type(expected_ty={:?})", + expected_ty); match expected_ty.sty { ty::TyTrait(ref object_type) => { @@ -138,8 +137,8 @@ fn deduce_expectations_from_obligations<'a,'tcx>( .pending_obligations() .iter() .filter_map(|obligation| { - debug!("deduce_expectations_from_obligations: obligation.predicate={}", - obligation.predicate.repr()); + debug!("deduce_expectations_from_obligations: obligation.predicate={:?}", + obligation.predicate); match obligation.predicate { // Given a Projection predicate, we can potentially infer @@ -200,8 +199,8 @@ fn deduce_sig_from_projection<'a,'tcx>( { let tcx = fcx.tcx(); - debug!("deduce_sig_from_projection({})", - projection.repr()); + debug!("deduce_sig_from_projection({:?})", + projection); let trait_ref = projection.to_poly_trait_ref(); @@ -211,24 +210,24 @@ fn deduce_sig_from_projection<'a,'tcx>( let arg_param_ty = *trait_ref.substs().types.get(subst::TypeSpace, 0); let arg_param_ty = fcx.infcx().resolve_type_vars_if_possible(&arg_param_ty); - debug!("deduce_sig_from_projection: arg_param_ty {}", arg_param_ty.repr()); + debug!("deduce_sig_from_projection: arg_param_ty {:?}", arg_param_ty); let input_tys = match arg_param_ty.sty { ty::TyTuple(ref tys) => { (*tys).clone() } _ => { return None; } }; - debug!("deduce_sig_from_projection: input_tys {}", input_tys.repr()); + debug!("deduce_sig_from_projection: input_tys {:?}", input_tys); let ret_param_ty = projection.0.ty; let ret_param_ty = fcx.infcx().resolve_type_vars_if_possible(&ret_param_ty); - debug!("deduce_sig_from_projection: ret_param_ty {}", ret_param_ty.repr()); + debug!("deduce_sig_from_projection: ret_param_ty {:?}", ret_param_ty); let fn_sig = ty::FnSig { inputs: input_tys, output: ty::FnConverging(ret_param_ty), variadic: false }; - debug!("deduce_sig_from_projection: fn_sig {}", fn_sig.repr()); + debug!("deduce_sig_from_projection: fn_sig {:?}", fn_sig); Some(fn_sig) } @@ -240,9 +239,9 @@ fn self_type_matches_expected_vid<'a,'tcx>( -> Option> { let self_ty = fcx.infcx().shallow_resolve(trait_ref.self_ty()); - debug!("self_type_matches_expected_vid(trait_ref={}, self_ty={})", - trait_ref.repr(), - self_ty.repr()); + debug!("self_type_matches_expected_vid(trait_ref={:?}, self_ty={:?})", + trait_ref, + self_ty); match self_ty.sty { ty::TyInfer(ty::TyVar(v)) if expected_vid == v => Some(trait_ref), _ => None, diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index d10a605adb427..785202de92159 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -69,7 +69,6 @@ use middle::ty::{AutoDerefRef, AdjustDerefRef}; use middle::ty::{self, mt, Ty}; use middle::ty_relate::RelateResult; use util::common::indent; -use util::ppaux::Repr; use std::cell::RefCell; use std::collections::VecDeque; @@ -104,9 +103,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { a: Ty<'tcx>, b: Ty<'tcx>) -> CoerceResult<'tcx> { - debug!("Coerce.tys({} => {})", - a.repr(), - b.repr()); + debug!("Coerce.tys({:?} => {:?})", + a, + b); // Consider coercing the subtype to a DST let unsize = self.unpack_actual_value(a, |a| { @@ -166,9 +165,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: Ty<'tcx>, mutbl_b: ast::Mutability) -> CoerceResult<'tcx> { - debug!("coerce_borrowed_pointer(a={}, b={})", - a.repr(), - b.repr()); + debug!("coerce_borrowed_pointer(a={:?}, b={:?})", + a, + b); // If we have a parameter of type `&M T_a` and the value // provided is `expr`, we will be adding an implicit borrow, @@ -238,9 +237,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { source: Ty<'tcx>, target: Ty<'tcx>) -> CoerceResult<'tcx> { - debug!("coerce_unsized(source={}, target={})", - source.repr(), - target.repr()); + debug!("coerce_unsized(source={:?}, target={:?})", + source, + target); let traits = (self.tcx().lang_items.unsize_trait(), self.tcx().lang_items.coerce_unsized_trait()); @@ -294,7 +293,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // inference might unify those two inner type variables later. let traits = [coerce_unsized_did, unsize_did]; while let Some(obligation) = queue.pop_front() { - debug!("coerce_unsized resolve step: {}", obligation.repr()); + debug!("coerce_unsized resolve step: {:?}", obligation); let trait_ref = match obligation.predicate { ty::Predicate::Trait(ref tr) if traits.contains(&tr.def_id()) => { tr.clone() @@ -336,7 +335,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { autoref: reborrow, unsize: Some(target) }; - debug!("Success, coerced with {}", adjustment.repr()); + debug!("Success, coerced with {:?}", adjustment); Ok(Some(AdjustDerefRef(adjustment))) } @@ -352,8 +351,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { */ self.unpack_actual_value(b, |b| { - debug!("coerce_from_fn_pointer(a={}, b={})", - a.repr(), b.repr()); + debug!("coerce_from_fn_pointer(a={:?}, b={:?})", + a, b); if let ty::TyBareFn(None, fn_ty_b) = b.sty { match (fn_ty_a.unsafety, fn_ty_b.unsafety) { @@ -380,8 +379,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { */ self.unpack_actual_value(b, |b| { - debug!("coerce_from_fn_item(a={}, b={})", - a.repr(), b.repr()); + debug!("coerce_from_fn_item(a={:?}, b={:?})", + a, b); match b.sty { ty::TyBareFn(None, _) => { @@ -399,9 +398,9 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { b: Ty<'tcx>, mutbl_b: ast::Mutability) -> CoerceResult<'tcx> { - debug!("coerce_unsafe_ptr(a={}, b={})", - a.repr(), - b.repr()); + debug!("coerce_unsafe_ptr(a={:?}, b={:?})", + a, + b); let (is_ref, mt_a) = match a.sty { ty::TyRef(_, mt) => (true, mt), @@ -436,7 +435,7 @@ pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, ()> { - debug!("mk_assignty({} -> {})", a.repr(), b.repr()); + debug!("mk_assignty({:?} -> {:?})", a, b); let mut unsizing_obligations = vec![]; let adjustment = try!(indent(|| { fcx.infcx().commit_if_ok(|_| { @@ -460,7 +459,7 @@ pub fn mk_assignty<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } if let Some(adjustment) = adjustment { - debug!("Success, coerced with {}", adjustment.repr()); + debug!("Success, coerced with {:?}", adjustment); fcx.write_adjustment(expr.id, adjustment); } Ok(()) diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 3c38f471c8535..7cd5e4548ec2b 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -13,7 +13,6 @@ use middle::infer; use middle::traits; use middle::ty::{self}; use middle::subst::{self, Subst, Substs, VecPerParamSpace}; -use util::ppaux::Repr; use syntax::ast; use syntax::codemap::Span; @@ -38,11 +37,11 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, impl_m_body_id: ast::NodeId, trait_m: &ty::Method<'tcx>, impl_trait_ref: &ty::TraitRef<'tcx>) { - debug!("compare_impl_method(impl_trait_ref={})", - impl_trait_ref.repr()); + debug!("compare_impl_method(impl_trait_ref={:?})", + impl_trait_ref); - debug!("compare_impl_method: impl_trait_ref (liberated) = {}", - impl_trait_ref.repr()); + debug!("compare_impl_method: impl_trait_ref (liberated) = {:?}", + impl_trait_ref); let infcx = infer::new_infer_ctxt(tcx); let mut fulfillment_cx = traits::FulfillmentContext::new(true); @@ -63,16 +62,16 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, span_err!(tcx.sess, impl_m_span, E0185, "method `{}` has a `{}` declaration in the impl, \ but not in the trait", - token::get_name(trait_m.name), - impl_m.explicit_self.repr()); + trait_m.name, + impl_m.explicit_self); return; } (_, &ty::StaticExplicitSelfCategory) => { span_err!(tcx.sess, impl_m_span, E0186, "method `{}` has a `{}` declaration in the trait, \ but not in the impl", - token::get_name(trait_m.name), - trait_m.explicit_self.repr()); + trait_m.name, + trait_m.explicit_self); return; } _ => { @@ -183,8 +182,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, .subst(tcx, impl_to_skol_substs) .with_method(impl_to_skol_substs.types.get_slice(subst::FnSpace).to_vec(), impl_to_skol_substs.regions().get_slice(subst::FnSpace).to_vec()); - debug!("compare_impl_method: trait_to_skol_substs={}", - trait_to_skol_substs.repr()); + debug!("compare_impl_method: trait_to_skol_substs={:?}", + trait_to_skol_substs); // Check region bounds. FIXME(@jroesch) refactor this away when removing // ParamBounds. @@ -211,8 +210,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, impl_m_span, infer::HigherRankedType, &ty::Binder(impl_bounds)); - debug!("compare_impl_method: impl_bounds={}", - impl_bounds.repr()); + debug!("compare_impl_method: impl_bounds={:?}", + impl_bounds); // Normalize the associated types in the trait_bounds. let trait_bounds = trait_m.predicates.instantiate(tcx, &trait_to_skol_substs); @@ -242,8 +241,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, let trait_param_env = traits::normalize_param_env_or_error(trait_param_env, normalize_cause.clone()); - debug!("compare_impl_method: trait_bounds={}", - trait_param_env.caller_bounds.repr()); + debug!("compare_impl_method: trait_bounds={:?}", + trait_param_env.caller_bounds); let mut selcx = traits::SelectionContext::new(&infcx, &trait_param_env); @@ -303,8 +302,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, tcx.mk_bare_fn(ty::BareFnTy { unsafety: impl_m.fty.unsafety, abi: impl_m.fty.abi, sig: ty::Binder(impl_sig) })); - debug!("compare_impl_method: impl_fty={}", - impl_fty.repr()); + debug!("compare_impl_method: impl_fty={:?}", + impl_fty); let (trait_sig, skol_map) = infcx.skolemize_late_bound_regions(&trait_m.fty.sig, snapshot); @@ -324,8 +323,8 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, abi: trait_m.fty.abi, sig: ty::Binder(trait_sig) })); - debug!("compare_impl_method: trait_fty={}", - trait_fty.repr()); + debug!("compare_impl_method: trait_fty={:?}", + trait_fty); try!(infer::mk_subty(&infcx, false, origin, impl_fty, trait_fty)); @@ -335,9 +334,9 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, match err { Ok(()) => { } Err(terr) => { - debug!("checking trait method for compatibility: impl ty {}, trait ty {}", - impl_fty.repr(), - trait_fty.repr()); + debug!("checking trait method for compatibility: impl ty {:?}, trait ty {:?}", + impl_fty, + trait_fty); span_err!(tcx.sess, impl_m_span, E0053, "method `{}` has an incompatible type for trait: {}", token::get_name(trait_m.name), @@ -381,14 +380,14 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>, let impl_params = impl_generics.regions.get_slice(subst::FnSpace); debug!("check_region_bounds_on_impl_method: \ - trait_generics={} \ - impl_generics={} \ - trait_to_skol_substs={} \ - impl_to_skol_substs={}", - trait_generics.repr(), - impl_generics.repr(), - trait_to_skol_substs.repr(), - impl_to_skol_substs.repr()); + trait_generics={:?} \ + impl_generics={:?} \ + trait_to_skol_substs={:?} \ + impl_to_skol_substs={:?}", + trait_generics, + impl_generics, + trait_to_skol_substs, + impl_to_skol_substs); // Must have same number of early-bound lifetime parameters. // Unfortunately, if the user screws up the bounds, then this @@ -416,8 +415,8 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, impl_c_span: Span, trait_c: &ty::AssociatedConst<'tcx>, impl_trait_ref: &ty::TraitRef<'tcx>) { - debug!("compare_const_impl(impl_trait_ref={})", - impl_trait_ref.repr()); + debug!("compare_const_impl(impl_trait_ref={:?})", + impl_trait_ref); let infcx = infer::new_infer_ctxt(tcx); let mut fulfillment_cx = traits::FulfillmentContext::new(true); @@ -443,8 +442,8 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, .subst(tcx, impl_to_skol_substs) .with_method(impl_to_skol_substs.types.get_slice(subst::FnSpace).to_vec(), impl_to_skol_substs.regions().get_slice(subst::FnSpace).to_vec()); - debug!("compare_const_impl: trait_to_skol_substs={}", - trait_to_skol_substs.repr()); + debug!("compare_const_impl: trait_to_skol_substs={:?}", + trait_to_skol_substs); // Compute skolemized form of impl and trait const tys. let impl_ty = impl_c.ty.subst(tcx, impl_to_skol_substs); @@ -461,8 +460,8 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, impl_c_span, 0, &impl_ty); - debug!("compare_const_impl: impl_ty={}", - impl_ty.repr()); + debug!("compare_const_impl: impl_ty={:?}", + impl_ty); let trait_ty = assoc::normalize_associated_types_in(&infcx, @@ -471,8 +470,8 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, impl_c_span, 0, &trait_ty); - debug!("compare_const_impl: trait_ty={}", - trait_ty.repr()); + debug!("compare_const_impl: trait_ty={:?}", + trait_ty); infer::mk_subty(&infcx, false, origin, impl_ty, trait_ty) }); @@ -480,9 +479,9 @@ pub fn compare_const_impl<'tcx>(tcx: &ty::ctxt<'tcx>, match err { Ok(()) => { } Err(terr) => { - debug!("checking associated const for compatibility: impl ty {}, trait ty {}", - impl_ty.repr(), - trait_ty.repr()); + debug!("checking associated const for compatibility: impl ty {:?}, trait ty {:?}", + impl_ty, + trait_ty); span_err!(tcx.sess, impl_c_span, E0326, "implemented const `{}` has an incompatible type for \ trait: {}", diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 3fc833034d221..392515926da0c 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -16,7 +16,6 @@ use middle::infer; use std::result::Result::{Err, Ok}; use syntax::ast; use syntax::codemap::Span; -use util::ppaux::Repr; // Requires that the two types unify, and prints an error message if // they don't. @@ -59,9 +58,9 @@ pub fn coerce<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, expected: Ty<'tcx>, expr: &ast::Expr) { let expr_ty = fcx.expr_ty(expr); - debug!("demand::coerce(expected = {}, expr_ty = {})", - expected.repr(), - expr_ty.repr()); + debug!("demand::coerce(expected = {:?}, expr_ty = {:?})", + expected, + expr_ty); let expr_ty = fcx.resolve_type_vars_if_possible(expr_ty); let expected = fcx.resolve_type_vars_if_possible(expected); match coercion::mk_assignty(fcx, expr, expr_ty, expected) { diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 14238179f87c2..fb17f41d88d9a 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -14,7 +14,6 @@ use middle::infer; use middle::region; use middle::subst::{self, Subst}; use middle::ty::{self, Ty}; -use util::ppaux::{Repr, UserString}; use syntax::ast; use syntax::codemap::{self, Span}; @@ -38,7 +37,7 @@ use syntax::codemap::{self, Span}; /// pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: ast::DefId) -> Result<(), ()> { let ty::TypeScheme { generics: ref dtor_generics, - ty: ref dtor_self_type } = ty::lookup_item_type(tcx, drop_impl_did); + ty: dtor_self_type } = ty::lookup_item_type(tcx, drop_impl_did); let dtor_predicates = ty::lookup_predicates(tcx, drop_impl_did); match dtor_self_type.sty { ty::TyEnum(self_type_did, self_to_impl_substs) | @@ -47,7 +46,7 @@ pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: ast::DefId) -> Result<(), try!(ensure_drop_params_and_item_params_correspond(tcx, drop_impl_did, dtor_generics, - dtor_self_type, + &dtor_self_type, self_type_did)); ensure_drop_predicates_are_implied_by_item_defn(tcx, @@ -62,7 +61,7 @@ pub fn check_drop_impl(tcx: &ty::ctxt, drop_impl_did: ast::DefId) -> Result<(), let span = tcx.map.def_id_span(drop_impl_did, codemap::DUMMY_SP); tcx.sess.span_bug( span, &format!("should have been rejected by coherence check: {}", - dtor_self_type.repr())); + dtor_self_type)); } } } @@ -212,9 +211,8 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>( if !assumptions_in_impl_context.contains(&predicate) { let item_span = tcx.map.span(self_type_did.node); - let req = predicate.user_string(); span_err!(tcx.sess, drop_impl_span, E0367, - "The requirement `{}` is added only by the Drop impl.", req); + "The requirement `{}` is added only by the Drop impl.", predicate); tcx.sess.span_note(item_span, "The same requirement must be part of \ the struct/enum definition"); @@ -257,8 +255,8 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> typ: ty::Ty<'tcx>, span: Span, scope: region::CodeExtent) { - debug!("check_safety_of_destructor_if_necessary typ: {} scope: {:?}", - typ.repr(), scope); + debug!("check_safety_of_destructor_if_necessary typ: {:?} scope: {:?}", + typ, scope); // types that have been traversed so far by `traverse_type_if_unseen` let mut breadcrumbs: Vec> = Vec::new(); @@ -277,8 +275,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> Err(Error::Overflow(ref ctxt, ref detected_on_typ)) => { let tcx = rcx.tcx(); span_err!(tcx.sess, span, E0320, - "overflow while adding drop-check rules for {}", - typ.user_string()); + "overflow while adding drop-check rules for {}", typ); match *ctxt { TypeContext::Root => { // no need for an additional note if the overflow @@ -294,7 +291,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> ty::item_path_str(tcx, def_id), variant, arg_index, - detected_on_typ.user_string()); + detected_on_typ); } TypeContext::Struct { def_id, field } => { span_note!( @@ -303,7 +300,7 @@ pub fn check_safety_of_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx> "overflowed on struct {} field {} type: {}", ty::item_path_str(tcx, def_id), field, - detected_on_typ.user_string()); + detected_on_typ); } } } @@ -372,8 +369,8 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( let tp_def = item_type.generics.types .opt_get(subst::TypeSpace, 0).unwrap(); let new_typ = substs.type_for_def(tp_def); - debug!("replacing phantom {} with {}", - typ.repr(), new_typ.repr()); + debug!("replacing phantom {:?} with {:?}", + typ, new_typ); (new_typ, xref_depth_orig + 1) } else { (typ, xref_depth_orig) @@ -384,8 +381,8 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( // definition of `Box` must carry a PhantomData that // puts us into the previous case. ty::TyBox(new_typ) => { - debug!("replacing TyBox {} with {}", - typ.repr(), new_typ.repr()); + debug!("replacing TyBox {:?} with {:?}", + typ, new_typ); (new_typ, xref_depth_orig + 1) } @@ -411,7 +408,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( debug!("iterate_over_potentially_unsafe_regions_in_type \ {}typ: {} scope: {:?} xref: {}", (0..depth).map(|_| ' ').collect::(), - typ.repr(), scope, xref_depth); + typ, scope, xref_depth); // If `typ` has a destructor, then we must ensure that all // borrowed data reachable via `typ` must outlive the parent @@ -467,8 +464,8 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( match typ.sty { ty::TyStruct(struct_did, substs) => { - debug!("typ: {} is struct; traverse structure and not type-expression", - typ.repr()); + debug!("typ: {:?} is struct; traverse structure and not type-expression", + typ); // Don't recurse; we extract type's substructure, // so do not process subparts of type expression. walker.skip_current_subtree(); @@ -497,8 +494,8 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'tcx>( } ty::TyEnum(enum_did, substs) => { - debug!("typ: {} is enum; traverse structure and not type-expression", - typ.repr()); + debug!("typ: {:?} is enum; traverse structure and not type-expression", + typ); // Don't recurse; we extract type's substructure, // so do not process subparts of type expression. walker.skip_current_subtree(); @@ -571,24 +568,24 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>, match dtor_kind { DtorKind::PureRecur => { has_dtor_of_interest = false; - debug!("typ: {} has no dtor, and thus is uninteresting", - typ.repr()); + debug!("typ: {:?} has no dtor, and thus is uninteresting", + typ); } DtorKind::Unknown(bounds) => { match bounds.region_bound { ty::ReStatic => { - debug!("trait: {} has 'static bound, and thus is uninteresting", - typ.repr()); + debug!("trait: {:?} has 'static bound, and thus is uninteresting", + typ); has_dtor_of_interest = false; } ty::ReEmpty => { - debug!("trait: {} has empty region bound, and thus is uninteresting", - typ.repr()); + debug!("trait: {:?} has empty region bound, and thus is uninteresting", + typ); has_dtor_of_interest = false; } r => { - debug!("trait: {} has non-static bound: {}; assumed interesting", - typ.repr(), r.repr()); + debug!("trait: {:?} has non-static bound: {:?}; assumed interesting", + typ, r); has_dtor_of_interest = true; } } @@ -645,8 +642,8 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>, if result { has_pred_of_interest = true; - debug!("typ: {} has interesting dtor due to generic preds, e.g. {}", - typ.repr(), pred.repr()); + debug!("typ: {:?} has interesting dtor due to generic preds, e.g. {:?}", + typ, pred); break 'items; } } @@ -670,14 +667,14 @@ fn has_dtor_of_interest<'tcx>(tcx: &ty::ctxt<'tcx>, has_pred_of_interest; if has_dtor_of_interest { - debug!("typ: {} has interesting dtor, due to \ + debug!("typ: {:?} has interesting dtor, due to \ region params: {} or pred: {}", - typ.repr(), + typ, has_region_param_of_interest, has_pred_of_interest); } else { - debug!("typ: {} has dtor, but it is uninteresting", - typ.repr()); + debug!("typ: {:?} has dtor, but it is uninteresting", + typ); } } } diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 2b5fb524b524f..fd93a2493db5a 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -24,7 +24,6 @@ use middle::infer::InferCtxt; use syntax::ast; use syntax::codemap::Span; use std::iter::repeat; -use util::ppaux::Repr; struct ConfirmContext<'a, 'tcx:'a> { fcx: &'a FnCtxt<'a, 'tcx>, @@ -56,10 +55,10 @@ pub fn confirm<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, supplied_method_types: Vec>) -> MethodCallee<'tcx> { - debug!("confirm(unadjusted_self_ty={}, pick={}, supplied_method_types={})", - unadjusted_self_ty.repr(), - pick.repr(), - supplied_method_types.repr()); + debug!("confirm(unadjusted_self_ty={:?}, pick={:?}, supplied_method_types={:?})", + unadjusted_self_ty, + pick, + supplied_method_types); let mut confirm_cx = ConfirmContext::new(fcx, span, self_expr, call_expr); confirm_cx.confirm(unadjusted_self_ty, pick, supplied_method_types) @@ -93,7 +92,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { let (method_types, method_regions) = self.instantiate_method_substs(&pick, supplied_method_types); let all_substs = rcvr_substs.with_method(method_types, method_regions); - debug!("all_substs={}", all_substs.repr()); + debug!("all_substs={:?}", all_substs); // Create the final signature for the method, replacing late-bound regions. let InstantiatedMethodSig { @@ -225,10 +224,10 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { this.upcast(original_poly_trait_ref.clone(), trait_def_id); let upcast_trait_ref = this.replace_late_bound_regions_with_fresh_var(&upcast_poly_trait_ref); - debug!("original_poly_trait_ref={} upcast_trait_ref={} target_trait={}", - original_poly_trait_ref.repr(), - upcast_trait_ref.repr(), - trait_def_id.repr()); + debug!("original_poly_trait_ref={:?} upcast_trait_ref={:?} target_trait={:?}", + original_poly_trait_ref, + upcast_trait_ref, + trait_def_id); let substs = upcast_trait_ref.substs.clone(); let origin = MethodTraitObject(MethodObject { trait_ref: upcast_trait_ref, @@ -322,7 +321,7 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { self.tcx().sess.span_bug( self.span, &format!("self-type `{}` for ObjectPick never dereferenced to an object", - self_ty.repr())) + self_ty)) } } } @@ -376,10 +375,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { Err(_) => { self.tcx().sess.span_bug( self.span, - &format!( - "{} was a subtype of {} but now is not?", - self_ty.repr(), - method_self_ty.repr())); + &format!("{} was a subtype of {} but now is not?", + self_ty, method_self_ty)); } } } @@ -392,9 +389,9 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { all_substs: subst::Substs<'tcx>) -> InstantiatedMethodSig<'tcx> { - debug!("instantiate_method_sig(pick={}, all_substs={})", - pick.repr(), - all_substs.repr()); + debug!("instantiate_method_sig(pick={:?}, all_substs={:?})", + pick, + all_substs); // Instantiate the bounds on the method with the // type/early-bound-regions substitutions performed. There can @@ -404,8 +401,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { let method_predicates = self.fcx.normalize_associated_types_in(self.span, &method_predicates); - debug!("method_predicates after subst = {}", - method_predicates.repr()); + debug!("method_predicates after subst = {:?}", + method_predicates); // Instantiate late-bound regions and substitute the trait // parameters into the method type to get the actual method type. @@ -415,12 +412,12 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { // may reference those regions. let method_sig = self.replace_late_bound_regions_with_fresh_var( &pick.item.as_opt_method().unwrap().fty.sig); - debug!("late-bound lifetimes from method instantiated, method_sig={}", - method_sig.repr()); + debug!("late-bound lifetimes from method instantiated, method_sig={:?}", + method_sig); let method_sig = self.fcx.instantiate_type_scheme(self.span, &all_substs, &method_sig); - debug!("type scheme substituted, method_sig={}", - method_sig.repr()); + debug!("type scheme substituted, method_sig={:?}", + method_sig); InstantiatedMethodSig { method_sig: method_sig, @@ -433,10 +430,10 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { pick: &probe::Pick<'tcx>, all_substs: &subst::Substs<'tcx>, method_predicates: &ty::InstantiatedPredicates<'tcx>) { - debug!("add_obligations: pick={} all_substs={} method_predicates={}", - pick.repr(), - all_substs.repr(), - method_predicates.repr()); + debug!("add_obligations: pick={:?} all_substs={:?} method_predicates={:?}", + pick, + all_substs, + method_predicates); self.fcx.add_obligations_for_parameters( traits::ObligationCause::misc(self.span, self.fcx.body_id), @@ -483,8 +480,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { } } - debug!("fixup_derefs_on_method_receiver_if_necessary: exprs={}", - exprs.repr()); + debug!("fixup_derefs_on_method_receiver_if_necessary: exprs={:?}", + exprs); // Fix up autoderefs and derefs. for (i, &expr) in exprs.iter().rev().enumerate() { @@ -498,8 +495,9 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { Some(_) | None => 0, }; - debug!("fixup_derefs_on_method_receiver_if_necessary: i={} expr={} autoderef_count={}", - i, expr.repr(), autoderef_count); + debug!("fixup_derefs_on_method_receiver_if_necessary: i={} expr={:?} \ + autoderef_count={}", + i, expr, autoderef_count); if autoderef_count > 0 { check::autoderef(self.fcx, @@ -545,8 +543,8 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { Some(_) => { self.tcx().sess.span_bug( base_expr.span, - &format!("unexpected adjustment autoref {}", - adr.repr())); + &format!("unexpected adjustment autoref {:?}", + adr)); } }, None => (0, None), @@ -647,10 +645,10 @@ impl<'a,'tcx> ConfirmContext<'a,'tcx> { if upcast_trait_refs.len() != 1 { self.tcx().sess.span_bug( self.span, - &format!("cannot uniquely upcast `{}` to `{}`: `{}`", - source_trait_ref.repr(), - target_trait_def_id.repr(), - upcast_trait_refs.repr())); + &format!("cannot uniquely upcast `{:?}` to `{:?}`: `{:?}`", + source_trait_ref, + target_trait_def_id, + upcast_trait_refs)); } upcast_trait_refs.into_iter().next().unwrap() diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index fd7695b1f0934..85a4b02cf804e 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -18,7 +18,6 @@ use middle::subst; use middle::traits; use middle::ty::{self, AsPredicate, ToPolyTraitRef}; use middle::infer; -use util::ppaux::Repr; use syntax::ast::DefId; use syntax::ast; @@ -96,11 +95,11 @@ pub fn lookup<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, self_expr: &'tcx ast::Expr) -> Result, MethodError> { - debug!("lookup(method_name={}, self_ty={}, call_expr={}, self_expr={})", - method_name.repr(), - self_ty.repr(), - call_expr.repr(), - self_expr.repr()); + debug!("lookup(method_name={}, self_ty={:?}, call_expr={:?}, self_expr={:?})", + method_name, + self_ty, + call_expr, + self_expr); let mode = probe::Mode::MethodCall; let self_ty = fcx.infcx().resolve_type_vars_if_possible(&self_ty); @@ -141,11 +140,11 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, opt_input_types: Option>>) -> Option> { - debug!("lookup_in_trait_adjusted(self_ty={}, self_expr={}, m_name={}, trait_def_id={})", - self_ty.repr(), - self_expr.repr(), - m_name.repr(), - trait_def_id.repr()); + debug!("lookup_in_trait_adjusted(self_ty={:?}, self_expr={:?}, m_name={}, trait_def_id={:?})", + self_ty, + self_expr, + m_name, + trait_def_id); let trait_def = ty::lookup_trait_def(fcx.tcx(), trait_def_id); @@ -190,8 +189,8 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, assert_eq!(method_ty.generics.types.len(subst::FnSpace), 0); assert_eq!(method_ty.generics.regions.len(subst::FnSpace), 0); - debug!("lookup_in_trait_adjusted: method_num={} method_ty={}", - method_num, method_ty.repr()); + debug!("lookup_in_trait_adjusted: method_num={} method_ty={:?}", + method_num, method_ty); // Instantiate late-bound regions and substitute the trait // parameters into the method type to get the actual method type. @@ -210,9 +209,9 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, abi: method_ty.fty.abi.clone(), })); - debug!("lookup_in_trait_adjusted: matched method fty={} obligation={}", - fty.repr(), - obligation.repr()); + debug!("lookup_in_trait_adjusted: matched method fty={:?} obligation={:?}", + fty, + obligation); // Register obligations for the parameters. This will include the // `Self` parameter, which in turn has a bound of the main trait, @@ -272,7 +271,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, span, &format!( "trait method is &self but first arg is: {}", - transformed_self_ty.repr())); + transformed_self_ty)); } } } @@ -296,7 +295,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, substs: trait_ref.substs.clone() }; - debug!("callee = {}", callee.repr()); + debug!("callee = {:?}", callee); Some(callee) } diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index d71b91762e920..ecf6cad32be76 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -28,7 +28,6 @@ use syntax::codemap::{Span, DUMMY_SP}; use std::collections::HashSet; use std::mem; use std::rc::Rc; -use util::ppaux::Repr; use self::CandidateKind::*; pub use self::PickKind::*; @@ -127,8 +126,8 @@ pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, scope_expr_id: ast::NodeId) -> PickResult<'tcx> { - debug!("probe(self_ty={}, item_name={}, scope_expr_id={})", - self_ty.repr(), + debug!("probe(self_ty={:?}, item_name={}, scope_expr_id={})", + self_ty, item_name, scope_expr_id); @@ -167,9 +166,9 @@ pub fn probe<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, Some(simplified_steps) }; - debug!("ProbeContext: steps for self_ty={} are {}", - self_ty.repr(), - steps.repr()); + debug!("ProbeContext: steps for self_ty={:?} are {:?}", + self_ty, + steps); // this creates one big transaction so that all type variables etc // that we create during the probe process are removed later @@ -272,8 +271,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { } fn assemble_probe(&mut self, self_ty: Ty<'tcx>) { - debug!("assemble_probe: self_ty={}", - self_ty.repr()); + debug!("assemble_probe: self_ty={:?}", + self_ty); match self_ty.sty { ty::TyTrait(box ref data) => { @@ -416,7 +415,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let traits::Normalized { value: xform_self_ty, obligations } = traits::normalize(selcx, cause, &xform_self_ty); debug!("assemble_inherent_impl_probe: xform_self_ty = {:?}", - xform_self_ty.repr()); + xform_self_ty); self.inherent_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -428,8 +427,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { fn assemble_inherent_candidates_from_object(&mut self, self_ty: Ty<'tcx>, data: &ty::TraitTy<'tcx>) { - debug!("assemble_inherent_candidates_from_object(self_ty={})", - self_ty.repr()); + debug!("assemble_inherent_candidates_from_object(self_ty={:?})", + self_ty); let tcx = self.tcx(); @@ -500,10 +499,10 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { trait_ref.substs); if let Some(ref m) = item.as_opt_method() { - debug!("found match: trait_ref={} substs={} m={}", - trait_ref.repr(), - trait_ref.substs.repr(), - m.repr()); + debug!("found match: trait_ref={:?} substs={:?} m={:?}", + trait_ref, + trait_ref.substs, + m); assert_eq!(m.generics.types.get_slice(subst::TypeSpace).len(), trait_ref.substs.types.get_slice(subst::TypeSpace).len()); assert_eq!(m.generics.regions.get_slice(subst::TypeSpace).len(), @@ -543,7 +542,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { usize, ), { - debug!("elaborate_bounds(bounds={})", bounds.repr()); + debug!("elaborate_bounds(bounds={:?})", bounds); let tcx = self.tcx(); for bound_trait_ref in traits::transitive_bounds(tcx, bounds) { @@ -592,8 +591,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { trait_def_id: ast::DefId) -> Result<(),MethodError> { - debug!("assemble_extension_candidates_for_trait(trait_def_id={})", - trait_def_id.repr()); + debug!("assemble_extension_candidates_for_trait(trait_def_id={:?})", + trait_def_id); // Check whether `trait_def_id` defines a method with suitable name: let trait_items = @@ -642,9 +641,10 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { // FIXME(arielb1): can we use for_each_relevant_impl here? trait_def.for_each_impl(self.tcx(), |impl_def_id| { - debug!("assemble_extension_candidates_for_trait_impl: trait_def_id={} impl_def_id={}", - trait_def_id.repr(), - impl_def_id.repr()); + debug!("assemble_extension_candidates_for_trait_impl: trait_def_id={:?} \ + impl_def_id={:?}", + trait_def_id, + impl_def_id); if !self.impl_can_possibly_match(impl_def_id) { return; @@ -652,14 +652,14 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let (_, impl_substs) = self.impl_ty_and_substs(impl_def_id); - debug!("impl_substs={}", impl_substs.repr()); + debug!("impl_substs={:?}", impl_substs); let impl_trait_ref = ty::impl_trait_ref(self.tcx(), impl_def_id) .unwrap() // we know this is a trait impl .subst(self.tcx(), &impl_substs); - debug!("impl_trait_ref={}", impl_trait_ref.repr()); + debug!("impl_trait_ref={:?}", impl_trait_ref); // Determine the receiver type that the method itself expects. let xform_self_ty = @@ -675,7 +675,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let traits::Normalized { value: xform_self_ty, obligations } = traits::normalize(selcx, cause, &xform_self_ty); - debug!("xform_self_ty={}", xform_self_ty.repr()); + debug!("xform_self_ty={:?}", xform_self_ty); self.extension_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -773,31 +773,31 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { item_index: usize) { debug!("assemble_projection_candidates(\ - trait_def_id={}, \ - item={}, \ + trait_def_id={:?}, \ + item={:?}, \ item_index={})", - trait_def_id.repr(), - item.repr(), + trait_def_id, + item, item_index); for step in self.steps.iter() { - debug!("assemble_projection_candidates: step={}", - step.repr()); + debug!("assemble_projection_candidates: step={:?}", + step); let projection_trait_ref = match step.self_ty.sty { ty::TyProjection(ref data) => &data.trait_ref, _ => continue, }; - debug!("assemble_projection_candidates: projection_trait_ref={}", - projection_trait_ref.repr()); + debug!("assemble_projection_candidates: projection_trait_ref={:?}", + projection_trait_ref); let trait_predicates = ty::lookup_predicates(self.tcx(), projection_trait_ref.def_id); let bounds = trait_predicates.instantiate(self.tcx(), projection_trait_ref.substs); let predicates = bounds.predicates.into_vec(); - debug!("assemble_projection_candidates: predicates={}", - predicates.repr()); + debug!("assemble_projection_candidates: predicates={:?}", + predicates); for poly_bound in traits::elaborate_predicates(self.tcx(), predicates) .filter_map(|p| p.to_opt_poly_trait_ref()) @@ -805,18 +805,18 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { { let bound = self.erase_late_bound_regions(&poly_bound); - debug!("assemble_projection_candidates: projection_trait_ref={} bound={}", - projection_trait_ref.repr(), - bound.repr()); + debug!("assemble_projection_candidates: projection_trait_ref={:?} bound={:?}", + projection_trait_ref, + bound); if self.infcx().can_equate(&step.self_ty, &bound.self_ty()).is_ok() { let xform_self_ty = self.xform_self_ty(&item, bound.self_ty(), bound.substs); - debug!("assemble_projection_candidates: bound={} xform_self_ty={}", - bound.repr(), - xform_self_ty.repr()); + debug!("assemble_projection_candidates: bound={:?} xform_self_ty={:?}", + bound, + xform_self_ty); self.extension_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -833,8 +833,8 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { item: ty::ImplOrTraitItem<'tcx>, item_index: usize) { - debug!("assemble_where_clause_candidates(trait_def_id={})", - trait_def_id.repr()); + debug!("assemble_where_clause_candidates(trait_def_id={:?})", + trait_def_id); let caller_predicates = self.fcx.inh.param_env.caller_bounds.clone(); for poly_bound in traits::elaborate_predicates(self.tcx(), caller_predicates) @@ -846,9 +846,9 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { bound.self_ty(), bound.substs); - debug!("assemble_where_clause_candidates: bound={} xform_self_ty={}", - bound.repr(), - xform_self_ty.repr()); + debug!("assemble_where_clause_candidates: bound={:?} xform_self_ty={:?}", + bound, + xform_self_ty); self.extension_candidates.push(Candidate { xform_self_ty: xform_self_ty, @@ -914,7 +914,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { } fn pick_step(&mut self, step: &CandidateStep<'tcx>) -> Option> { - debug!("pick_step: step={}", step.repr()); + debug!("pick_step: step={:?}", step); if ty::type_is_error(step.self_ty) { return None; @@ -1012,7 +1012,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { .filter(|&probe| self.consider_probe(self_ty, probe)) .collect(); - debug!("applicable_candidates: {}", applicable_candidates.repr()); + debug!("applicable_candidates: {:?}", applicable_candidates); if applicable_candidates.len() > 1 { match self.collapse_candidates_to_trait_pick(&applicable_candidates[..]) { @@ -1033,9 +1033,9 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { } fn consider_probe(&self, self_ty: Ty<'tcx>, probe: &Candidate<'tcx>) -> bool { - debug!("consider_probe: self_ty={} probe={}", - self_ty.repr(), - probe.repr()); + debug!("consider_probe: self_ty={:?} probe={:?}", + self_ty, + probe); self.infcx().probe(|_| { // First check that the self type can be related. @@ -1068,7 +1068,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { let obligations = traits::predicates_for_generics(cause.clone(), &impl_bounds); - debug!("impl_obligations={}", obligations.repr()); + debug!("impl_obligations={:?}", obligations); // Evaluate those obligations to see if they might possibly hold. obligations.iter() @@ -1180,10 +1180,10 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> { substs: &subst::Substs<'tcx>) -> Ty<'tcx> { - debug!("xform_self_ty(impl_ty={}, self_ty={}, substs={})", - impl_ty.repr(), - method.fty.sig.0.inputs.get(0).repr(), - substs.repr()); + debug!("xform_self_ty(impl_ty={:?}, self_ty={:?}, substs={:?})", + impl_ty, + method.fty.sig.0.inputs.get(0), + substs); assert!(!substs.has_escaping_regions()); diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 52fdf52c35da7..b098fb56d4db6 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -18,7 +18,6 @@ use check::{self, FnCtxt}; use middle::ty::{self, Ty}; use middle::def; use metadata::{csearch, cstore, decoder}; -use util::ppaux::UserString; use syntax::{ast, ast_util}; use syntax::codemap::Span; @@ -45,7 +44,6 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, match error { MethodError::NoMatch(static_sources, out_of_scope_traits, mode) => { let cx = fcx.tcx(); - let item_ustring = item_name.user_string(); fcx.type_error_message( span, @@ -54,7 +52,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, in the current scope", if mode == Mode::MethodCall { "method" } else { "associated item" }, - item_ustring, + item_name, actual) }, rcvr_ty, @@ -66,7 +64,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, if fields.iter().any(|f| f.name == item_name) { cx.sess.span_note(span, &format!("use `(s.{0})(...)` if you meant to call the \ - function stored in the `{0}` field", item_ustring)); + function stored in the `{0}` field", item_name)); } } @@ -93,7 +91,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, let msg = format!("the `{}` method from the `{}` trait cannot be explicitly \ invoked on this closure as we have not yet inferred what \ kind of closure it is", - item_name.user_string(), + item_name, ty::item_path_str(fcx.tcx(), trait_def_id)); let msg = if let Some(callee) = rcvr_expr { format!("{}; use overloaded call notation instead (e.g., `{}()`)", @@ -134,7 +132,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, "candidate #{} is defined in an impl{} for the type `{}`", idx + 1, insertion, - impl_ty.user_string()); + impl_ty); } CandidateSource::TraitSource(trait_did) => { let (_, item) = trait_item(fcx.tcx(), trait_did, item_name).unwrap(); @@ -160,7 +158,6 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, valid_out_of_scope_traits: Vec) { let tcx = fcx.tcx(); - let item_ustring = item_name.user_string(); if !valid_out_of_scope_traits.is_empty() { let mut candidates = valid_out_of_scope_traits; @@ -217,7 +214,7 @@ fn suggest_traits_to_import<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, perhaps you need to implement {one_of_them}:", traits_define = if candidates.len() == 1 {"trait defines"} else {"traits define"}, one_of_them = if candidates.len() == 1 {"it"} else {"one of them"}, - name = item_ustring); + name = item_name); fcx.sess().fileline_help(span, &msg[..]); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index cc57ec8a8cd8f..34df349b7a3db 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -106,7 +106,6 @@ use {CrateCtxt, lookup_full_def, require_same_types}; use TypeAndSubsts; use lint; use util::common::{block_query, ErrorReported, indenter, loop_query}; -use util::ppaux::{Repr, UserString}; use util::nodemap::{DefIdMap, FnvHashMap, NodeMap}; use util::lev_distance::lev_distance; @@ -567,8 +566,8 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { None => None }; self.assign(local.span, local.id, o_ty); - debug!("Local variable {} is assigned type {}", - self.fcx.pat_to_string(&*local.pat), + debug!("Local variable {:?} is assigned type {}", + local.pat, self.fcx.infcx().ty_to_string( self.fcx.inh.locals.borrow().get(&local.id).unwrap().clone())); visit::walk_local(self, local); @@ -583,11 +582,11 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> { self.fcx.require_type_is_sized(var_ty, p.span, traits::VariableType(p.id)); - debug!("Pattern binding {} is assigned to {} with type {}", + debug!("Pattern binding {} is assigned to {} with type {:?}", token::get_ident(path1.node), self.fcx.infcx().ty_to_string( self.fcx.inh.locals.borrow().get(&p.id).unwrap().clone()), - var_ty.repr()); + var_ty); } } visit::walk_pat(self, p); @@ -641,9 +640,9 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, let arg_tys = &fn_sig.inputs; let ret_ty = fn_sig.output; - debug!("check_fn(arg_tys={}, ret_ty={}, fn_id={})", - arg_tys.repr(), - ret_ty.repr(), + debug!("check_fn(arg_tys={:?}, ret_ty={:?}, fn_id={})", + arg_tys, + ret_ty, fn_id); // Create the function context. This is either derived from scratch or, @@ -669,9 +668,9 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>, fn_sig_tys.push(ret_ty); } - debug!("fn-sig-map: fn_id={} fn_sig_tys={}", + debug!("fn-sig-map: fn_id={} fn_sig_tys={:?}", fn_id, - fn_sig_tys.repr()); + fn_sig_tys); inherited.fn_sig_map.borrow_mut().insert(fn_id, fn_sig_tys); @@ -918,12 +917,12 @@ fn check_method_body<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, sig: &'tcx ast::MethodSig, body: &'tcx ast::Block, id: ast::NodeId, span: Span) { - debug!("check_method_body(item_generics={}, id={})", - item_generics.repr(), id); + debug!("check_method_body(item_generics={:?}, id={})", + item_generics, id); let param_env = ParameterEnvironment::for_item(ccx.tcx, id); let fty = ty::node_id_to_type(ccx.tcx, id); - debug!("check_method_body: fty={}", fty.repr()); + debug!("check_method_body: fty={:?}", fty); check_bare_fn(ccx, &sig.decl, body, id, span, fty, param_env); } @@ -963,9 +962,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, _ => { span_err!(tcx.sess, impl_item.span, E0323, "item `{}` is an associated const, \ - which doesn't match its trait `{}`", + which doesn't match its trait `{:?}`", token::get_name(impl_const_ty.name()), - impl_trait_ref.repr()) + impl_trait_ref) } } } @@ -976,9 +975,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_item.span, &format!( "associated const `{}` is not a member of \ - trait `{}`", + trait `{:?}`", token::get_name(impl_const_ty.name()), - impl_trait_ref.repr())); + impl_trait_ref)); } } } @@ -1009,9 +1008,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, _ => { span_err!(tcx.sess, impl_item.span, E0324, "item `{}` is an associated method, \ - which doesn't match its trait `{}`", + which doesn't match its trait `{:?}`", token::get_name(impl_item_ty.name()), - impl_trait_ref.repr()) + impl_trait_ref) } } } @@ -1020,9 +1019,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, // caught in resolve. tcx.sess.span_bug( impl_item.span, - &format!("method `{}` is not a member of trait `{}`", + &format!("method `{}` is not a member of trait `{:?}`", token::get_name(impl_item_ty.name()), - impl_trait_ref.repr())); + impl_trait_ref)); } } } @@ -1043,9 +1042,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, _ => { span_err!(tcx.sess, impl_item.span, E0325, "item `{}` is an associated type, \ - which doesn't match its trait `{}`", + which doesn't match its trait `{:?}`", token::get_name(typedef_ty.name()), - impl_trait_ref.repr()) + impl_trait_ref) } } } @@ -1056,9 +1055,9 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, impl_item.span, &format!( "associated type `{}` is not a member of \ - trait `{}`", + trait `{:?}`", token::get_name(typedef_ty.name()), - impl_trait_ref.repr())); + impl_trait_ref)); } } } @@ -1295,18 +1294,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// version, this version will also select obligations if it seems /// useful, in an effort to get more type information. fn resolve_type_vars_if_possible(&self, mut ty: Ty<'tcx>) -> Ty<'tcx> { - debug!("resolve_type_vars_if_possible(ty={})", ty.repr()); + debug!("resolve_type_vars_if_possible(ty={:?})", ty); // No ty::infer()? Nothing needs doing. if !ty::type_has_ty_infer(ty) { - debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); + debug!("resolve_type_vars_if_possible: ty={:?}", ty); return ty; } // If `ty` is a type variable, see whether we already know what it is. ty = self.infcx().resolve_type_vars_if_possible(&ty); if !ty::type_has_ty_infer(ty) { - debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); + debug!("resolve_type_vars_if_possible: ty={:?}", ty); return ty; } @@ -1314,7 +1313,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.select_new_obligations(); ty = self.infcx().resolve_type_vars_if_possible(&ty); if !ty::type_has_ty_infer(ty) { - debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); + debug!("resolve_type_vars_if_possible: ty={:?}", ty); return ty; } @@ -1325,7 +1324,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.select_obligations_where_possible(); ty = self.infcx().resolve_type_vars_if_possible(&ty); - debug!("resolve_type_vars_if_possible: ty={}", ty.repr()); + debug!("resolve_type_vars_if_possible: ty={:?}", ty); ty } @@ -1395,16 +1394,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { #[inline] pub fn write_ty(&self, node_id: ast::NodeId, ty: Ty<'tcx>) { - debug!("write_ty({}, {}) in fcx {}", - node_id, ty.repr(), self.tag()); + debug!("write_ty({}, {:?}) in fcx {}", + node_id, ty, self.tag()); self.inh.node_types.borrow_mut().insert(node_id, ty); } pub fn write_substs(&self, node_id: ast::NodeId, substs: ty::ItemSubsts<'tcx>) { if !substs.substs.is_noop() { - debug!("write_substs({}, {}) in fcx {}", + debug!("write_substs({}, {:?}) in fcx {}", node_id, - substs.repr(), + substs, self.tag()); self.inh.item_substs.borrow_mut().insert(node_id, substs); @@ -1427,7 +1426,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn write_adjustment(&self, node_id: ast::NodeId, adj: ty::AutoAdjustment<'tcx>) { - debug!("write_adjustment(node_id={}, adj={})", node_id, adj.repr()); + debug!("write_adjustment(node_id={}, adj={:?})", node_id, adj); if adj.is_identity() { return; @@ -1448,10 +1447,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { let value = value.subst(self.tcx(), substs); let result = self.normalize_associated_types_in(span, &value); - debug!("instantiate_type_scheme(value={}, substs={}) = {}", - value.repr(), - substs.repr(), - result.repr()); + debug!("instantiate_type_scheme(value={:?}, substs={:?}) = {:?}", + value, + substs, + result); result } @@ -1615,8 +1614,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn register_predicate(&self, obligation: traits::PredicateObligation<'tcx>) { - debug!("register_predicate({})", - obligation.repr()); + debug!("register_predicate({:?})", + obligation); self.inh.fulfillment_cx .borrow_mut() .register_predicate_obligation(self.infcx(), obligation); @@ -1633,10 +1632,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { t } - pub fn pat_to_string(&self, pat: &ast::Pat) -> String { - pat.repr() - } - pub fn expr_ty(&self, ex: &ast::Expr) -> Ty<'tcx> { match self.inh.node_types.borrow().get(&ex.id) { Some(&t) => t, @@ -1784,8 +1779,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { { assert!(!predicates.has_escaping_regions()); - debug!("add_obligations_for_parameters(predicates={})", - predicates.repr()); + debug!("add_obligations_for_parameters(predicates={:?})", + predicates); for obligation in traits::predicates_for_generics(cause, predicates) { self.register_predicate(obligation); @@ -1940,9 +1935,9 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>, -> (Ty<'tcx>, usize, Option) where F: FnMut(Ty<'tcx>, usize) -> Option, { - debug!("autoderef(base_ty={}, opt_expr={}, lvalue_pref={:?})", - base_ty.repr(), - opt_expr.repr(), + debug!("autoderef(base_ty={:?}, opt_expr={:?}, lvalue_pref={:?})", + base_ty, + opt_expr, lvalue_pref); let mut t = base_ty; @@ -2002,8 +1997,8 @@ pub fn autoderef<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>, // We've reached the recursion limit, error gracefully. span_err!(fcx.tcx().sess, sp, E0055, - "reached the recursion limit while auto-dereferencing {}", - base_ty.repr()); + "reached the recursion limit while auto-dereferencing {:?}", + base_ty); (fcx.tcx().types.err, 0, None) } @@ -2118,14 +2113,14 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)> { let tcx = fcx.tcx(); - debug!("try_index_step(expr={}, base_expr.id={}, adjusted_ty={}, \ - autoderefs={}, unsize={}, index_ty={})", - expr.repr(), - base_expr.repr(), - adjusted_ty.repr(), + debug!("try_index_step(expr={:?}, base_expr.id={:?}, adjusted_ty={:?}, \ + autoderefs={}, unsize={}, index_ty={:?})", + expr, + base_expr, + adjusted_ty, autoderefs, unsize, - index_ty.repr()); + index_ty); let input_ty = fcx.infcx().next_ty_var(); @@ -2604,9 +2599,9 @@ fn expected_types_for_fn_args<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, None } }).unwrap_or(vec![]); - debug!("expected_types_for_fn_args(formal={} -> {}, expected={} -> {})", - formal_args.repr(), formal_ret.repr(), - expected_args.repr(), expected_ret.repr()); + debug!("expected_types_for_fn_args(formal={:?} -> {:?}, expected={:?} -> {:?})", + formal_args, formal_ret, + expected_args, expected_ret); expected_args } @@ -2627,8 +2622,8 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, unifier: F) where F: FnOnce(), { - debug!(">> typechecking: expr={} expected={}", - expr.repr(), expected.repr()); + debug!(">> typechecking: expr={:?} expected={:?}", + expr, expected); // Checks a method call. fn check_method_call<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, @@ -2744,7 +2739,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, |base_t, _| { match base_t.sty { ty::TyStruct(base_id, substs) => { - debug!("struct named {}", base_t.repr()); + debug!("struct named {:?}", base_t); let fields = ty::lookup_struct_fields(tcx, base_id); fcx.lookup_field_ty(expr.span, base_id, &fields[..], field.node.name, &(*substs)) @@ -2848,7 +2843,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, ty::TyStruct(base_id, substs) => { tuple_like = ty::is_tuple_struct(tcx, base_id); if tuple_like { - debug!("tuple struct named {}", base_t.repr()); + debug!("tuple struct named {:?}", base_t); let fields = ty::lookup_struct_fields(tcx, base_id); fcx.lookup_tup_field_ty(expr.span, base_id, &fields[..], idx.node, &(*substs)) @@ -3274,7 +3269,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, } } else { tcx.sess.span_bug(expr.span, - &format!("unbound path {}", expr.repr())) + &format!("unbound path {:?}", expr)) }; if let Some((opt_ty, segments, def)) = @@ -3744,9 +3739,9 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, debug!("type of expr({}) {} is...", expr.id, syntax::print::pprust::expr_to_string(expr)); - debug!("... {}, expected is {}", - fcx.expr_ty(expr).repr(), - expected.repr()); + debug!("... {:?}, expected is {:?}", + fcx.expr_ty(expr), + expected); unifier(); } @@ -4179,8 +4174,8 @@ pub fn check_instantiable(tcx: &ty::ctxt, span_err!(tcx.sess, sp, E0073, "this type cannot be instantiated without an \ instance of itself"); - fileline_help!(tcx.sess, sp, "consider using `Option<{}>`", - item_ty.repr()); + fileline_help!(tcx.sess, sp, "consider using `Option<{:?}>`", + item_ty); false } else { true @@ -4371,11 +4366,11 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, def: def::Def, span: Span, node_id: ast::NodeId) { - debug!("instantiate_path(path={:?}, def={}, node_id={}, type_scheme={})", + debug!("instantiate_path(path={:?}, def={:?}, node_id={}, type_scheme={:?})", segments, - def.repr(), + def, node_id, - type_scheme.repr()); + type_scheme); // We need to extract the type parameters supplied by the user in // the path `path`. Due to the current setup, this is a bit of a @@ -4615,9 +4610,9 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, if fcx.mk_subty(false, infer::Misc(span), self_ty, impl_ty).is_err() { fcx.tcx().sess.span_bug(span, &format!( - "instantiate_path: (UFCS) {} was a subtype of {} but now is not?", - self_ty.repr(), - impl_ty.repr())); + "instantiate_path: (UFCS) {:?} was a subtype of {:?} but now is not?", + self_ty, + impl_ty)); } } @@ -4822,7 +4817,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, } assert_eq!(substs.types.len(space), desired.len()); - debug!("Final substs: {}", substs.repr()); + debug!("Final substs: {:?}", substs); } fn adjust_region_parameters( @@ -4931,8 +4926,8 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, span: Span, tps: &OwnedSlice, ty: Ty<'tcx>) { - debug!("check_bounds_are_used(n_tps={}, ty={})", - tps.len(), ty.repr()); + debug!("check_bounds_are_used(n_tps={}, ty={:?})", + tps.len(), ty); // make a vector of booleans initially false, set to true when used if tps.is_empty() { return; } @@ -5255,7 +5250,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) { fty, || { format!("intrinsic has wrong type: expected `{}`", - fty.user_string()) + fty) }); } } diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index fbff7afb3e59c..a5e4e0fab5963 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -25,7 +25,6 @@ use middle::ty::{self, Ty}; use syntax::ast; use syntax::ast_util; use syntax::parse::token; -use util::ppaux::{Repr, UserString}; /// Check a `a = b` pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, @@ -51,8 +50,8 @@ pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, span_err!(tcx.sess, lhs_expr.span, E0368, "binary assignment operation `{}=` cannot be applied to types `{}` and `{}`", ast_util::binop_to_string(op.node), - lhs_ty.user_string(), - rhs_ty.user_string()); + lhs_ty, + rhs_ty); fcx.write_error(expr.id); } @@ -73,12 +72,12 @@ pub fn check_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, { let tcx = fcx.ccx.tcx; - debug!("check_binop(expr.id={}, expr={}, op={:?}, lhs_expr={}, rhs_expr={})", + debug!("check_binop(expr.id={}, expr={:?}, op={:?}, lhs_expr={:?}, rhs_expr={:?})", expr.id, - expr.repr(), + expr, op, - lhs_expr.repr(), - rhs_expr.repr()); + lhs_expr, + rhs_expr); check_expr(fcx, lhs_expr); let lhs_ty = fcx.resolve_type_vars_if_possible(fcx.expr_ty(lhs_expr)); @@ -180,16 +179,16 @@ fn enforce_builtin_binop_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, // if this is simd, result is same as lhs, else bool if ty::type_is_simd(tcx, lhs_ty) { let unit_ty = ty::simd_type(tcx, lhs_ty); - debug!("enforce_builtin_binop_types: lhs_ty={} unit_ty={}", - lhs_ty.repr(), - unit_ty.repr()); + debug!("enforce_builtin_binop_types: lhs_ty={:?} unit_ty={:?}", + lhs_ty, + unit_ty); if !ty::type_is_integral(unit_ty) { tcx.sess.span_err( lhs_expr.span, &format!("binary comparison operation `{}` not supported \ for floating point SIMD vector `{}`", ast_util::binop_to_string(op.node), - lhs_ty.user_string())); + lhs_ty)); tcx.types.err } else { lhs_ty @@ -209,9 +208,9 @@ fn check_overloaded_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, op: ast::BinOp) -> (Ty<'tcx>, Ty<'tcx>) { - debug!("check_overloaded_binop(expr.id={}, lhs_ty={})", + debug!("check_overloaded_binop(expr.id={}, lhs_ty={:?})", expr.id, - lhs_ty.repr()); + lhs_ty); let (name, trait_def_id) = name_and_trait_def_id(fcx, op); @@ -233,7 +232,7 @@ fn check_overloaded_binop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>, span_err!(fcx.tcx().sess, lhs_expr.span, E0369, "binary operation `{}` cannot be applied to type `{}`", ast_util::binop_to_string(op.node), - lhs_ty.user_string()); + lhs_ty); } fcx.tcx().types.err } @@ -304,12 +303,12 @@ fn lookup_op_method<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>, lhs_expr: &'a ast::Expr) -> Result,()> { - debug!("lookup_op_method(expr={}, lhs_ty={}, opname={:?}, trait_did={}, lhs_expr={})", - expr.repr(), - lhs_ty.repr(), + debug!("lookup_op_method(expr={:?}, lhs_ty={:?}, opname={:?}, trait_did={:?}, lhs_expr={:?})", + expr, + lhs_ty, opname, - trait_did.repr(), - lhs_expr.repr()); + trait_did, + lhs_expr); let method = match trait_did { Some(trait_did) => { diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 949cf118afca4..a96e7864fe679 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -94,7 +94,6 @@ use middle::traits; use middle::ty::{self, ClosureTyper, ReScope, Ty, MethodCall}; use middle::infer::{self, GenericKind}; use middle::pat_util; -use util::ppaux::{Repr, UserString}; use std::mem; use syntax::{ast, ast_util}; @@ -321,8 +320,8 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { .to_vec(); for r_o in ®ion_obligations { - debug!("visit_region_obligations: r_o={}", - r_o.repr()); + debug!("visit_region_obligations: r_o={:?}", + r_o); let sup_type = self.resolve_type(r_o.sup_type); let origin = infer::RelateParamBound(r_o.cause.span, sup_type); type_must_outlive(self, origin, sup_type, r_o.sub_region); @@ -351,7 +350,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { for &ty in fn_sig_tys { let ty = self.resolve_type(ty); - debug!("relate_free_regions(t={})", ty.repr()); + debug!("relate_free_regions(t={:?})", ty); let body_scope = CodeExtent::from_node_id(body_id); let body_scope = ty::ReScope(body_scope); let implications = implicator::implications(self.fcx.infcx(), self.fcx, body_id, @@ -364,7 +363,7 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { // that don't go into the free-region-map but which we use // here. for implication in implications { - debug!("implication: {}", implication.repr()); + debug!("implication: {:?}", implication); match implication { implicator::Implication::RegionSubRegion(_, ty::ReFree(free_a), @@ -372,8 +371,8 @@ impl<'a, 'tcx> Rcx<'a, 'tcx> { self.fcx.inh.infcx.add_given(free_a, vid_b); } implicator::Implication::RegionSubGeneric(_, r_a, ref generic_b) => { - debug!("RegionSubGeneric: {} <= {}", - r_a.repr(), generic_b.repr()); + debug!("RegionSubGeneric: {:?} <= {:?}", + r_a, generic_b); self.region_bound_pairs.push((r_a, generic_b.clone())); } @@ -464,7 +463,7 @@ fn visit_local(rcx: &mut Rcx, l: &ast::Local) { fn constrain_bindings_in_pat(pat: &ast::Pat, rcx: &mut Rcx) { let tcx = rcx.fcx.tcx(); - debug!("regionck::visit_pat(pat={})", pat.repr()); + debug!("regionck::visit_pat(pat={:?})", pat); pat_util::pat_bindings(&tcx.def_map, pat, |_, id, span, _| { // If we have a variable that contains region'd data, that // data will be accessible from anywhere that the variable is @@ -501,8 +500,8 @@ fn constrain_bindings_in_pat(pat: &ast::Pat, rcx: &mut Rcx) { } fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { - debug!("regionck::visit_expr(e={}, repeating_scope={})", - expr.repr(), rcx.repeating_scope); + debug!("regionck::visit_expr(e={:?}, repeating_scope={})", + expr, rcx.repeating_scope); // No matter what, the type of each expression must outlive the // scope of that expression. This also guarantees basic WF. @@ -744,9 +743,9 @@ fn constrain_cast(rcx: &mut Rcx, cast_expr: &ast::Expr, source_expr: &ast::Expr) { - debug!("constrain_cast(cast_expr={}, source_expr={})", - cast_expr.repr(), - source_expr.repr()); + debug!("constrain_cast(cast_expr={:?}, source_expr={:?})", + cast_expr, + source_expr); let source_ty = rcx.resolve_node_type(source_expr.id); let target_ty = rcx.resolve_node_type(cast_expr.id); @@ -757,9 +756,9 @@ fn constrain_cast(rcx: &mut Rcx, cast_expr: &ast::Expr, from_ty: Ty<'tcx>, to_ty: Ty<'tcx>) { - debug!("walk_cast(from_ty={}, to_ty={})", - from_ty.repr(), - to_ty.repr()); + debug!("walk_cast(from_ty={:?}, to_ty={:?})", + from_ty, + to_ty); match (&from_ty.sty, &to_ty.sty) { /*From:*/ (&ty::TyRef(from_r, ref from_mt), /*To: */ &ty::TyRef(to_r, ref to_mt)) => { @@ -807,7 +806,7 @@ fn constrain_callee(rcx: &mut Rcx, // // tcx.sess.span_bug( // callee_expr.span, - // format!("Calling non-function: {}", callee_ty.repr())); + // format!("Calling non-function: {}", callee_ty)); } } } @@ -822,11 +821,11 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, //! in the type of the function. Also constrains the regions that //! appear in the arguments appropriately. - debug!("constrain_call(call_expr={}, \ - receiver={}, \ + debug!("constrain_call(call_expr={:?}, \ + receiver={:?}, \ implicitly_ref_args={})", - call_expr.repr(), - receiver.repr(), + call_expr, + receiver, implicitly_ref_args); // `callee_region` is the scope representing the time in which the @@ -836,10 +835,10 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, let callee_scope = CodeExtent::from_node_id(call_expr.id); let callee_region = ty::ReScope(callee_scope); - debug!("callee_region={}", callee_region.repr()); + debug!("callee_region={:?}", callee_region); for arg_expr in arg_exprs { - debug!("Argument: {}", arg_expr.repr()); + debug!("Argument: {:?}", arg_expr); // ensure that any regions appearing in the argument type are // valid for at least the lifetime of the function: @@ -858,7 +857,7 @@ fn constrain_call<'a, I: Iterator>(rcx: &mut Rcx, // as loop above, but for receiver if let Some(r) = receiver { - debug!("receiver: {}", r.repr()); + debug!("receiver: {:?}", r); type_of_node_must_outlive( rcx, infer::CallRcvr(r.span), r.id, callee_region); @@ -875,10 +874,10 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, derefs: usize, mut derefd_ty: Ty<'tcx>) { - debug!("constrain_autoderefs(deref_expr={}, derefs={}, derefd_ty={})", - deref_expr.repr(), + debug!("constrain_autoderefs(deref_expr={:?}, derefs={}, derefd_ty={:?})", + deref_expr, derefs, - derefd_ty.repr()); + derefd_ty); let r_deref_expr = ty::ReScope(CodeExtent::from_node_id(deref_expr.id)); for i in 0..derefs { @@ -887,8 +886,8 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, derefd_ty = match rcx.fcx.inh.method_map.borrow().get(&method_call) { Some(method) => { - debug!("constrain_autoderefs: #{} is overloaded, method={}", - i, method.repr()); + debug!("constrain_autoderefs: #{} is overloaded, method={:?}", + i, method); // Treat overloaded autoderefs as if an AutoRef adjustment // was applied on the base type, as that is always the case. @@ -901,19 +900,19 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, _ => { rcx.tcx().sess.span_bug( deref_expr.span, - &format!("bad overloaded deref type {}", - method.ty.repr())) + &format!("bad overloaded deref type {:?}", + method.ty)) } }; debug!("constrain_autoderefs: receiver r={:?} m={:?}", - r.repr(), m); + r, m); { let mc = mc::MemCategorizationContext::new(rcx.fcx); let self_cmt = ignore_err!(mc.cat_expr_autoderefd(deref_expr, i)); debug!("constrain_autoderefs: self_cmt={:?}", - self_cmt.repr()); + self_cmt); link_region(rcx, deref_expr.span, r, ty::BorrowKind::from_mutbl(m), self_cmt); } @@ -974,8 +973,8 @@ fn check_safety_of_rvalue_destructor_if_necessary<'a, 'tcx>(rcx: &mut Rcx<'a, 't .sess .span_bug(span, &format!("unexpected rvalue region in rvalue \ - destructor safety checking: `{}`", - region.repr())); + destructor safety checking: `{:?}`", + region)); } } } @@ -1023,7 +1022,7 @@ fn type_of_node_must_outlive<'a, 'tcx>( |method_call| rcx.resolve_method_type(method_call)); debug!("constrain_regions_in_type_of_node(\ ty={}, ty0={}, id={}, minimum_lifetime={:?})", - ty.user_string(), ty0.user_string(), + ty, ty0, id, minimum_lifetime); type_must_outlive(rcx, origin, ty, minimum_lifetime); } @@ -1032,14 +1031,14 @@ fn type_of_node_must_outlive<'a, 'tcx>( /// resulting pointer is linked to the lifetime of its guarantor (if any). fn link_addr_of(rcx: &mut Rcx, expr: &ast::Expr, mutability: ast::Mutability, base: &ast::Expr) { - debug!("link_addr_of(expr={}, base={})", expr.repr(), base.repr()); + debug!("link_addr_of(expr={:?}, base={:?})", expr, base); let cmt = { let mc = mc::MemCategorizationContext::new(rcx.fcx); ignore_err!(mc.cat_expr(base)) }; - debug!("link_addr_of: cmt={}", cmt.repr()); + debug!("link_addr_of: cmt={:?}", cmt); link_region_from_node_type(rcx, expr.span, expr.id, mutability, cmt); } @@ -1065,7 +1064,7 @@ fn link_match(rcx: &Rcx, discr: &ast::Expr, arms: &[ast::Arm]) { debug!("regionck::for_match()"); let mc = mc::MemCategorizationContext::new(rcx.fcx); let discr_cmt = ignore_err!(mc.cat_expr(discr)); - debug!("discr_cmt={}", discr_cmt.repr()); + debug!("discr_cmt={:?}", discr_cmt); for arm in arms { for root_pat in &arm.pats { link_pattern(rcx, mc, discr_cmt.clone(), &**root_pat); @@ -1083,9 +1082,9 @@ fn link_fn_args(rcx: &Rcx, body_scope: CodeExtent, args: &[ast::Arg]) { let arg_ty = rcx.fcx.node_ty(arg.id); let re_scope = ty::ReScope(body_scope); let arg_cmt = mc.cat_rvalue(arg.id, arg.ty.span, re_scope, arg_ty); - debug!("arg_ty={} arg_cmt={}", - arg_ty.repr(), - arg_cmt.repr()); + debug!("arg_ty={:?} arg_cmt={:?}", + arg_ty, + arg_cmt); link_pattern(rcx, mc, arg_cmt, &*arg.pat); } } @@ -1096,9 +1095,9 @@ fn link_pattern<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, mc: mc::MemCategorizationContext>, discr_cmt: mc::cmt<'tcx>, root_pat: &ast::Pat) { - debug!("link_pattern(discr_cmt={}, root_pat={})", - discr_cmt.repr(), - root_pat.repr()); + debug!("link_pattern(discr_cmt={:?}, root_pat={:?})", + discr_cmt, + root_pat); let _ = mc.cat_pattern(discr_cmt, root_pat, |mc, sub_cmt, sub_pat| { match sub_pat.node { // `ref x` pattern @@ -1134,7 +1133,7 @@ fn link_autoref(rcx: &Rcx, debug!("link_autoref(autoref={:?})", autoref); let mc = mc::MemCategorizationContext::new(rcx.fcx); let expr_cmt = ignore_err!(mc.cat_expr_autoderefd(expr, autoderefs)); - debug!("expr_cmt={}", expr_cmt.repr()); + debug!("expr_cmt={:?}", expr_cmt); match *autoref { ty::AutoPtr(r, m) => { @@ -1154,8 +1153,8 @@ fn link_autoref(rcx: &Rcx, fn link_by_ref(rcx: &Rcx, expr: &ast::Expr, callee_scope: CodeExtent) { - debug!("link_by_ref(expr={}, callee_scope={:?})", - expr.repr(), callee_scope); + debug!("link_by_ref(expr={:?}, callee_scope={:?})", + expr, callee_scope); let mc = mc::MemCategorizationContext::new(rcx.fcx); let expr_cmt = ignore_err!(mc.cat_expr(expr)); let borrow_region = ty::ReScope(callee_scope); @@ -1169,13 +1168,13 @@ fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, id: ast::NodeId, mutbl: ast::Mutability, cmt_borrowed: mc::cmt<'tcx>) { - debug!("link_region_from_node_type(id={:?}, mutbl={:?}, cmt_borrowed={})", - id, mutbl, cmt_borrowed.repr()); + debug!("link_region_from_node_type(id={:?}, mutbl={:?}, cmt_borrowed={:?})", + id, mutbl, cmt_borrowed); let rptr_ty = rcx.resolve_node_type(id); if !ty::type_is_error(rptr_ty) { let tcx = rcx.fcx.ccx.tcx; - debug!("rptr_ty={}", rptr_ty.user_string()); + debug!("rptr_ty={}", rptr_ty); let r = ty::ty_region(tcx, span, rptr_ty); link_region(rcx, span, &r, ty::BorrowKind::from_mutbl(mutbl), cmt_borrowed); @@ -1194,10 +1193,10 @@ fn link_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, let mut borrow_kind = borrow_kind; loop { - debug!("link_region(borrow_region={}, borrow_kind={}, borrow_cmt={})", - borrow_region.repr(), - borrow_kind.repr(), - borrow_cmt.repr()); + debug!("link_region(borrow_region={:?}, borrow_kind={:?}, borrow_cmt={:?})", + borrow_region, + borrow_kind, + borrow_cmt); match borrow_cmt.cat.clone() { mc::cat_deref(ref_cmt, _, mc::Implicit(ref_kind, ref_region)) | @@ -1307,8 +1306,8 @@ fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, _ => { rcx.tcx().sess.span_bug( span, - &format!("Illegal upvar id: {}", - upvar_id.repr())); + &format!("Illegal upvar id: {:?}", + upvar_id)); } } } @@ -1323,9 +1322,9 @@ fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, } }; - debug!("link_reborrowed_region: {} <= {}", - borrow_region.repr(), - ref_region.repr()); + debug!("link_reborrowed_region: {:?} <= {:?}", + borrow_region, + ref_region); rcx.fcx.mk_subr(cause, *borrow_region, ref_region); // If we end up needing to recurse and establish a region link @@ -1398,14 +1397,14 @@ pub fn type_must_outlive<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, ty: Ty<'tcx>, region: ty::Region) { - debug!("type_must_outlive(ty={}, region={})", - ty.repr(), - region.repr()); + debug!("type_must_outlive(ty={:?}, region={:?})", + ty, + region); let implications = implicator::implications(rcx.fcx.infcx(), rcx.fcx, rcx.body_id, ty, region, origin.span()); for implication in implications { - debug!("implication: {}", implication.repr()); + debug!("implication: {:?}", implication); match implication { implicator::Implication::RegionSubRegion(None, r_a, r_b) => { rcx.fcx.mk_subr(origin.clone(), r_a, r_b); @@ -1440,8 +1439,8 @@ fn closure_must_outlive<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>, region: ty::Region, def_id: ast::DefId, substs: &'tcx Substs<'tcx>) { - debug!("closure_must_outlive(region={}, def_id={}, substs={})", - region.repr(), def_id.repr(), substs.repr()); + debug!("closure_must_outlive(region={:?}, def_id={:?}, substs={:?})", + region, def_id, substs); let upvars = rcx.fcx.closure_upvars(def_id, substs).unwrap(); for upvar in upvars { @@ -1458,9 +1457,9 @@ fn generic_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, generic: &GenericKind<'tcx>) { let param_env = &rcx.fcx.inh.param_env; - debug!("param_must_outlive(region={}, generic={})", - region.repr(), - generic.repr()); + debug!("param_must_outlive(region={:?}, generic={:?})", + region, + generic); // To start, collect bounds from user: let mut param_bounds = @@ -1493,9 +1492,9 @@ fn generic_must_outlive<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>, // well-formed, then, A must be lower-generic by `'a`, but we // don't know that this holds from first principles. for &(ref r, ref p) in &rcx.region_bound_pairs { - debug!("generic={} p={}", - generic.repr(), - p.repr()); + debug!("generic={:?} p={:?}", + generic, + p); if generic == p { param_bounds.push(*r); } @@ -1518,8 +1517,8 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, let tcx = fcx.tcx(); let infcx = fcx.infcx(); - debug!("projection_bounds(projection_ty={})", - projection_ty.repr()); + debug!("projection_bounds(projection_ty={:?})", + projection_ty); let ty = ty::mk_projection(tcx, projection_ty.trait_ref.clone(), projection_ty.item_name); @@ -1543,16 +1542,16 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, _ => { return None; } }; - debug!("projection_bounds: outlives={} (1)", - outlives.repr()); + debug!("projection_bounds: outlives={:?} (1)", + outlives); // apply the substitutions (and normalize any projected types) let outlives = fcx.instantiate_type_scheme(span, projection_ty.trait_ref.substs, &outlives); - debug!("projection_bounds: outlives={} (2)", - outlives.repr()); + debug!("projection_bounds: outlives={:?} (2)", + outlives); let region_result = infcx.commit_if_ok(|_| { let (outlives, _) = @@ -1561,8 +1560,8 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, infer::AssocTypeProjection(projection_ty.item_name), &outlives); - debug!("projection_bounds: outlives={} (3)", - outlives.repr()); + debug!("projection_bounds: outlives={:?} (3)", + outlives); // check whether this predicate applies to our current projection match infer::mk_eqty(infcx, false, infer::Misc(span), ty, outlives.0) { @@ -1571,8 +1570,8 @@ fn projection_bounds<'a,'tcx>(rcx: &Rcx<'a, 'tcx>, } }); - debug!("projection_bounds: region_result={}", - region_result.repr()); + debug!("projection_bounds: region_result={:?}", + region_result); region_result.ok() }) diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index a5668d8e86053..99e6309918c97 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -51,7 +51,6 @@ use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; use syntax::visit::{self, Visitor}; -use util::ppaux::Repr; /////////////////////////////////////////////////////////////////////////// // PUBLIC ENTRY POINTS @@ -133,8 +132,8 @@ impl<'a,'tcx> SeedBorrowKind<'a,'tcx> { if !self.fcx.inh.closure_kinds.borrow().contains_key(&closure_def_id) { self.closures_with_inferred_kinds.insert(expr.id); self.fcx.inh.closure_kinds.borrow_mut().insert(closure_def_id, ty::FnClosureKind); - debug!("check_closure: adding closure_id={} to closures_with_inferred_kinds", - closure_def_id.repr()); + debug!("check_closure: adding closure_id={:?} to closures_with_inferred_kinds", + closure_def_id); } ty::with_freevars(self.tcx(), expr.id, |freevars| { @@ -241,8 +240,8 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("adjust_upvar_borrow_kind_for_consume(cmt={}, mode={:?})", - cmt.repr(), mode); + debug!("adjust_upvar_borrow_kind_for_consume(cmt={:?}, mode={:?})", + cmt, mode); // we only care about moves match mode { @@ -254,8 +253,8 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { // for that to be legal, the upvar would have to be borrowed // by value instead let guarantor = cmt.guarantor(); - debug!("adjust_upvar_borrow_kind_for_consume: guarantor={}", - guarantor.repr()); + debug!("adjust_upvar_borrow_kind_for_consume: guarantor={:?}", + guarantor); match guarantor.cat { mc::cat_deref(_, _, mc::BorrowedPtr(..)) | mc::cat_deref(_, _, mc::Implicit(..)) => { @@ -292,8 +291,8 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { /// to). If cmt contains any by-ref upvars, this implies that /// those upvars must be borrowed using an `&mut` borrow. fn adjust_upvar_borrow_kind_for_mut(&mut self, cmt: mc::cmt<'tcx>) { - debug!("adjust_upvar_borrow_kind_for_mut(cmt={})", - cmt.repr()); + debug!("adjust_upvar_borrow_kind_for_mut(cmt={:?})", + cmt); match cmt.cat.clone() { mc::cat_deref(base, _, mc::Unique) | @@ -326,8 +325,8 @@ impl<'a,'tcx> AdjustBorrowKind<'a,'tcx> { } fn adjust_upvar_borrow_kind_for_unique(&self, cmt: mc::cmt<'tcx>) { - debug!("adjust_upvar_borrow_kind_for_unique(cmt={})", - cmt.repr()); + debug!("adjust_upvar_borrow_kind_for_unique(cmt={:?})", + cmt); match cmt.cat.clone() { mc::cat_deref(base, _, mc::Unique) | @@ -494,7 +493,7 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume(cmt={},mode={:?})", cmt.repr(), mode); + debug!("consume(cmt={:?},mode={:?})", cmt, mode); self.adjust_upvar_borrow_kind_for_consume(cmt, mode); } @@ -509,7 +508,7 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { cmt: mc::cmt<'tcx>, mode: euv::ConsumeMode) { - debug!("consume_pat(cmt={},mode={:?})", cmt.repr(), mode); + debug!("consume_pat(cmt={:?},mode={:?})", cmt, mode); self.adjust_upvar_borrow_kind_for_consume(cmt, mode); } @@ -521,8 +520,8 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { bk: ty::BorrowKind, _loan_cause: euv::LoanCause) { - debug!("borrow(borrow_id={}, cmt={}, bk={:?})", - borrow_id, cmt.repr(), bk); + debug!("borrow(borrow_id={}, cmt={:?}, bk={:?})", + borrow_id, cmt, bk); match bk { ty::ImmBorrow => { } @@ -546,8 +545,8 @@ impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> { assignee_cmt: mc::cmt<'tcx>, _mode: euv::MutateMode) { - debug!("mutate(assignee_cmt={})", - assignee_cmt.repr()); + debug!("mutate(assignee_cmt={:?})", + assignee_cmt); self.adjust_upvar_borrow_kind_for_mut(assignee_cmt); } diff --git a/src/librustc_typeck/check/wf.rs b/src/librustc_typeck/check/wf.rs index 7bcd3ddf59048..c048845892c4b 100644 --- a/src/librustc_typeck/check/wf.rs +++ b/src/librustc_typeck/check/wf.rs @@ -18,7 +18,6 @@ use middle::traits; use middle::ty::{self, Ty}; use middle::ty::liberate_late_bound_regions; use middle::ty_fold::{TypeFolder, TypeFoldable, super_fold_ty}; -use util::ppaux::{Repr, UserString}; use std::collections::HashSet; use syntax::ast; @@ -350,7 +349,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { param_name: ast::Name) { span_err!(self.tcx().sess, span, E0392, - "parameter `{}` is never used", param_name.user_string()); + "parameter `{}` is never used", param_name); let suggested_marker_id = self.tcx().lang_items.phantom_data(); match suggested_marker_id { @@ -358,7 +357,7 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> { self.tcx().sess.fileline_help( span, &format!("consider removing `{}` or using a marker such as `{}`", - param_name.user_string(), + param_name, ty::item_path_str(self.tcx(), def_id))); } None => { @@ -395,7 +394,7 @@ fn reject_non_type_param_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, "cannot bound type `{}`, where clause \ bounds may only be attached to types involving \ type parameters", - bounded_ty.repr()) + bounded_ty) } fn is_ty_param(ty: ty::Ty) -> bool { @@ -543,16 +542,16 @@ impl<'cx,'tcx> TypeFolder<'tcx> for BoundsChecker<'cx,'tcx> { self.fcx.tcx(), region::DestructionScopeData::new(self.scope), binder); - debug!("BoundsChecker::fold_binder: late-bound regions replaced: {} at scope: {:?}", - value.repr(), self.scope); + debug!("BoundsChecker::fold_binder: late-bound regions replaced: {:?} at scope: {:?}", + value, self.scope); let value = value.fold_with(self); self.binding_count -= 1; ty::Binder(value) } fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { - debug!("BoundsChecker t={}", - t.repr()); + debug!("BoundsChecker t={:?}", + t); match self.cache { Some(ref mut cache) => { diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 1be7e42b7170d..05cc3077fc9fb 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -21,7 +21,6 @@ use middle::ty_fold::{TypeFolder,TypeFoldable}; use middle::infer; use write_substs_to_tcx; use write_ty_to_tcx; -use util::ppaux::Repr; use std::cell::Cell; @@ -169,10 +168,10 @@ impl<'cx, 'tcx, 'v> Visitor<'v> for WritebackCx<'cx, 'tcx> { self.visit_node_id(ResolvingPattern(p.span), p.id); - debug!("Type for pattern binding {} (id {}) resolved to {}", + debug!("Type for pattern binding {} (id {}) resolved to {:?}", pat_to_string(p), p.id, - ty::node_id_to_type(self.tcx(), p.id).repr()); + ty::node_id_to_type(self.tcx(), p.id)); visit::walk_pat(self, p); } @@ -215,9 +214,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { ty::UpvarBorrow { kind: upvar_borrow.kind, region: r }) } }; - debug!("Upvar capture for {} resolved to {}", - upvar_id.repr(), - new_upvar_capture.repr()); + debug!("Upvar capture for {:?} resolved to {:?}", + upvar_id, + new_upvar_capture); self.fcx.tcx().upvar_capture_map.borrow_mut().insert(*upvar_id, new_upvar_capture); } } @@ -245,7 +244,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { let n_ty = self.fcx.node_ty(id); let n_ty = self.resolve(&n_ty, reason); write_ty_to_tcx(self.tcx(), id, n_ty); - debug!("Node {} has type {}", id, n_ty.repr()); + debug!("Node {} has type {:?}", id, n_ty); // Resolve any substitutions self.fcx.opt_node_ty_substs(id, |item_substs| { @@ -294,9 +293,9 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { // Resolve any method map entry match self.fcx.inh.method_map.borrow_mut().remove(&method_call) { Some(method) => { - debug!("writeback::resolve_method_map_entry(call={:?}, entry={})", + debug!("writeback::resolve_method_map_entry(call={:?}, entry={:?})", method_call, - method.repr()); + method); let new_method = MethodCallee { origin: self.resolve(&method.origin, reason), ty: self.resolve(&method.ty, reason), @@ -427,8 +426,8 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Resolver<'cx, 'tcx> { match self.infcx.fully_resolve(&t) { Ok(t) => t, Err(e) => { - debug!("Resolver::fold_ty: input type `{}` not fully resolvable", - t.repr()); + debug!("Resolver::fold_ty: input type `{:?}` not fully resolvable", + t); self.report_error(e); self.tcx().types.err } diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 59b57a4926491..b66c76048c639 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -44,7 +44,6 @@ use syntax::codemap::Span; use syntax::parse::token; use syntax::visit; use util::nodemap::{DefIdMap, FnvHashMap}; -use util::ppaux::Repr; mod orphan; mod overlap; @@ -82,7 +81,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>, inference_context.tcx.sess.span_bug( span, &format!("coherence encountered unexpected type searching for base type: {}", - ty.repr())); + ty)); } } } @@ -149,9 +148,9 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { if let Some(trait_ref) = ty::impl_trait_ref(self.crate_context.tcx, impl_did) { - debug!("(checking implementation) adding impl for trait '{}', item '{}'", - trait_ref.repr(), - token::get_ident(item.ident)); + debug!("(checking implementation) adding impl for trait '{:?}', item '{}'", + trait_ref, + item.ident); enforce_trait_manually_implementable(self.crate_context.tcx, item.span, @@ -179,8 +178,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { trait_ref: &ty::TraitRef<'tcx>, all_impl_items: &mut Vec) { let tcx = self.crate_context.tcx; - debug!("instantiate_default_methods(impl_id={:?}, trait_ref={})", - impl_id, trait_ref.repr()); + debug!("instantiate_default_methods(impl_id={:?}, trait_ref={:?})", + impl_id, trait_ref); let impl_type_scheme = ty::lookup_item_type(tcx, impl_id); @@ -190,7 +189,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let new_id = tcx.sess.next_node_id(); let new_did = local_def(new_id); - debug!("new_did={:?} trait_method={}", new_did, trait_method.repr()); + debug!("new_did={:?} trait_method={:?}", new_did, trait_method); // Create substitutions for the various trait parameters. let new_method_ty = @@ -203,7 +202,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { &**trait_method, Some(trait_method.def_id))); - debug!("new_method_ty={}", new_method_ty.repr()); + debug!("new_method_ty={:?}", new_method_ty); all_impl_items.push(MethodTraitItemId(new_did)); // construct the polytype for the method based on the @@ -214,7 +213,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { ty: ty::mk_bare_fn(tcx, Some(new_did), tcx.mk_bare_fn(new_method_ty.fty.clone())) }; - debug!("new_polytype={}", new_polytype.repr()); + debug!("new_polytype={:?}", new_polytype); tcx.tcache.borrow_mut().insert(new_did, new_polytype); tcx.predicates.borrow_mut().insert(new_did, new_method_ty.predicates.clone()); @@ -360,8 +359,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let copy_trait = ty::lookup_trait_def(tcx, copy_trait); copy_trait.for_each_impl(tcx, |impl_did| { - debug!("check_implementations_of_copy: impl_did={}", - impl_did.repr()); + debug!("check_implementations_of_copy: impl_did={:?}", + impl_did); if impl_did.krate != ast::LOCAL_CRATE { debug!("check_implementations_of_copy(): impl not in this \ @@ -370,16 +369,16 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { } let self_type = ty::lookup_item_type(tcx, impl_did); - debug!("check_implementations_of_copy: self_type={} (bound)", - self_type.repr()); + debug!("check_implementations_of_copy: self_type={:?} (bound)", + self_type); let span = tcx.map.span(impl_did.node); let param_env = ParameterEnvironment::for_item(tcx, impl_did.node); let self_type = self_type.ty.subst(tcx, ¶m_env.free_substs); assert!(!self_type.has_escaping_regions()); - debug!("check_implementations_of_copy: self_type={} (free)", - self_type.repr()); + debug!("check_implementations_of_copy: self_type={:?} (free)", + self_type); match ty::can_type_implement_copy(¶m_env, span, self_type) { Ok(()) => {} @@ -429,8 +428,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let trait_def = ty::lookup_trait_def(tcx, coerce_unsized_trait); trait_def.for_each_impl(tcx, |impl_did| { - debug!("check_implementations_of_coerce_unsized: impl_did={}", - impl_did.repr()); + debug!("check_implementations_of_coerce_unsized: impl_did={:?}", + impl_did); if impl_did.krate != ast::LOCAL_CRATE { debug!("check_implementations_of_coerce_unsized(): impl not \ @@ -442,8 +441,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let trait_ref = ty::impl_trait_ref(self.crate_context.tcx, impl_did).unwrap(); let target = *trait_ref.substs.types.get(subst::TypeSpace, 0); - debug!("check_implementations_of_coerce_unsized: {} -> {} (bound)", - source.repr(), target.repr()); + debug!("check_implementations_of_coerce_unsized: {:?} -> {:?} (bound)", + source, target); let span = tcx.map.span(impl_did.node); let param_env = ParameterEnvironment::for_item(tcx, impl_did.node); @@ -451,8 +450,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { let target = target.subst(tcx, ¶m_env.free_substs); assert!(!source.has_escaping_regions()); - debug!("check_implementations_of_coerce_unsized: {} -> {} (free)", - source.repr(), target.repr()); + debug!("check_implementations_of_coerce_unsized: {:?} -> {:?} (free)", + source, target); let infcx = new_infer_ctxt(tcx); @@ -518,10 +517,8 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { if name == token::special_names::unnamed_field { i.to_string() } else { - token::get_name(name).to_string() - }, - a.repr(), - b.repr()) + name.to_string() + }, a, b) }).collect::>().connect(", ")); return; } @@ -597,8 +594,8 @@ fn subst_receiver_types_in_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, { let combined_substs = ty::make_substs_for_receiver_types(tcx, trait_ref, method); - debug!("subst_receiver_types_in_method_ty: combined_substs={}", - combined_substs.repr()); + debug!("subst_receiver_types_in_method_ty: combined_substs={:?}", + combined_substs); let method_predicates = method.predicates.subst(tcx, &combined_substs); let mut method_generics = method.generics.subst(tcx, &combined_substs); @@ -614,13 +611,13 @@ fn subst_receiver_types_in_method_ty<'tcx>(tcx: &ty::ctxt<'tcx>, impl_type_scheme.generics.regions.get_slice(space).to_vec()); } - debug!("subst_receiver_types_in_method_ty: method_generics={}", - method_generics.repr()); + debug!("subst_receiver_types_in_method_ty: method_generics={:?}", + method_generics); let method_fty = method.fty.subst(tcx, &combined_substs); - debug!("subst_receiver_types_in_method_ty: method_ty={}", - method.fty.repr()); + debug!("subst_receiver_types_in_method_ty: method_ty={:?}", + method.fty); ty::Method::new( method.name, diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 3068bb9923dd0..8376b92da3dea 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -18,7 +18,6 @@ use syntax::ast; use syntax::ast_util; use syntax::codemap::Span; use syntax::visit; -use util::ppaux::{Repr, UserString}; pub fn check(tcx: &ty::ctxt) { let mut orphan = OrphanChecker { tcx: tcx }; @@ -229,7 +228,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { "type parameter `{}` must be used as the type parameter for \ some local type (e.g. `MyStruct`); only traits defined in \ the current crate can be implemented for a type parameter", - param_ty.user_string()); + param_ty); return; } } @@ -267,9 +266,9 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { // This final impl is legal according to the orpan // rules, but it invalidates the reasoning from // `two_foos` above. - debug!("trait_ref={} trait_def_id={} trait_has_default_impl={}", - trait_ref.repr(), - trait_def_id.repr(), + debug!("trait_ref={:?} trait_def_id={:?} trait_has_default_impl={}", + trait_ref, + trait_def_id, ty::trait_has_default_impl(self.tcx, trait_def_id)); if ty::trait_has_default_impl(self.tcx, trait_def_id) && @@ -307,7 +306,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> { can only be implemented for a struct/enum type, \ not `{}`", ty::item_path_str(self.tcx, trait_def_id), - self_ty.user_string())) + self_ty)) } }; diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 74ce9ed540ecb..0e8067e7181bd 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -21,7 +21,6 @@ use syntax::ast_util; use syntax::visit; use syntax::codemap::Span; use util::nodemap::DefIdMap; -use util::ppaux::{Repr, UserString}; pub fn check(tcx: &ty::ctxt) { let mut overlap = OverlapChecker { tcx: tcx, default_impls: DefIdMap() }; @@ -61,8 +60,8 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> { fn check_for_overlapping_impls_of_trait(&self, trait_def: &'tcx ty::TraitDef<'tcx>) { - debug!("check_for_overlapping_impls_of_trait(trait_def={})", - trait_def.repr()); + debug!("check_for_overlapping_impls_of_trait(trait_def={:?})", + trait_def); // We should already know all impls of this trait, so these // borrows are safe. @@ -131,10 +130,10 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> { if let Some((impl1_def_id, impl2_def_id)) = self.order_impls( impl1_def_id, impl2_def_id) { - debug!("check_if_impls_overlap({}, {}, {})", - trait_def_id.repr(), - impl1_def_id.repr(), - impl2_def_id.repr()); + debug!("check_if_impls_overlap({:?}, {:?}, {:?})", + trait_def_id, + impl1_def_id, + impl2_def_id); let infcx = infer::new_infer_ctxt(self.tcx); if traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id) { @@ -217,7 +216,7 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OverlapChecker<'cx, 'tcx> { span_err!(self.tcx.sess, item.span, E0371, "the object type `{}` automatically \ implements the trait `{}`", - trait_ref.self_ty().user_string(), + trait_ref.self_ty(), ty::item_path_str(self.tcx, trait_def_id)); } } diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index fe276b3d1bded..fa39e9d0491f9 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -16,7 +16,6 @@ use syntax::ast::{Item, ItemImpl}; use syntax::ast; use syntax::ast_util; use syntax::visit; -use util::ppaux::UserString; pub fn check(tcx: &ty::ctxt) { let mut orphan = UnsafetyChecker { tcx: tcx }; @@ -55,14 +54,14 @@ impl<'cx, 'tcx, 'v> UnsafetyChecker<'cx, 'tcx> { (ast::Unsafety::Normal, ast::Unsafety::Unsafe, _) => { span_err!(self.tcx.sess, item.span, E0199, "implementing the trait `{}` is not unsafe", - trait_ref.user_string()); + trait_ref); } (ast::Unsafety::Unsafe, ast::Unsafety::Normal, ast::ImplPolarity::Positive) => { span_err!(self.tcx.sess, item.span, E0200, "the trait `{}` requires an `unsafe impl` declaration", - trait_ref.user_string()); + trait_ref); } (ast::Unsafety::Unsafe, diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 9987b884cf282..13d2cf25e0665 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -80,7 +80,6 @@ use rscope::*; use rustc::ast_map; use util::common::{ErrorReported, memoized}; use util::nodemap::{FnvHashMap, FnvHashSet}; -use util::ppaux::{Repr, UserString}; use write_ty_to_tcx; use std::cell::{Cell, RefCell}; @@ -255,7 +254,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { tcx.sess.note( &format!("the cycle begins when computing the bounds \ for type parameter `{}`...", - def.name.user_string())); + def.name)); } } @@ -277,7 +276,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { tcx.sess.note( &format!("...which then requires computing the bounds \ for type parameter `{}`...", - def.name.user_string())); + def.name)); } } } @@ -300,7 +299,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { tcx.sess.note( &format!("...which then again requires computing the bounds \ for type parameter `{}`, completing the cycle.", - def.name.user_string())); + def.name)); } } } @@ -317,7 +316,7 @@ impl<'a,'tcx> CrateCtxt<'a,'tcx> { let item = match tcx.map.get(trait_id.node) { ast_map::NodeItem(item) => item, - _ => tcx.sess.bug(&format!("get_trait_def({}): not an item", trait_id.repr())) + _ => tcx.sess.bug(&format!("get_trait_def({:?}): not an item", trait_id)) }; trait_def_of_item(self, &*item) @@ -371,8 +370,8 @@ impl<'a, 'tcx> AstConv<'tcx> for ItemCtxt<'a, 'tcx> { trait_def_id: ast::DefId) -> Result<(), ErrorReported> { - debug!("ensure_super_predicates(trait_def_id={})", - trait_def_id.repr()); + debug!("ensure_super_predicates(trait_def_id={:?})", + trait_def_id); self.ccx.ensure_super_predicates(span, trait_def_id) } @@ -634,8 +633,8 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, let fty = ty::mk_bare_fn(ccx.tcx, Some(def_id), ccx.tcx.mk_bare_fn(ty_method.fty.clone())); - debug!("method {} (id {}) has type {}", - ident, id, fty.repr()); + debug!("method {} (id {}) has type {:?}", + ident, id, fty); ccx.tcx.tcache.borrow_mut().insert(def_id,TypeScheme { generics: ty_method.generics.clone(), ty: fty @@ -644,8 +643,8 @@ fn convert_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, write_ty_to_tcx(ccx.tcx, id, fty); - debug!("writing method type: def_id={:?} mty={}", - def_id, ty_method.repr()); + debug!("writing method type: def_id={:?} mty={:?}", + def_id, ty_method); ccx.tcx.impl_or_trait_items.borrow_mut().insert(def_id, ty::MethodTraitItem(Rc::new(ty_method))); @@ -742,10 +741,11 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CrateCtxt<'a, 'tcx>, rcvr_ty_predicates: &ty::GenericPredicates<'tcx>) where I: Iterator { - debug!("convert_methods(untransformed_rcvr_ty={}, rcvr_ty_generics={}, rcvr_ty_predicates={})", - untransformed_rcvr_ty.repr(), - rcvr_ty_generics.repr(), - rcvr_ty_predicates.repr()); + debug!("convert_methods(untransformed_rcvr_ty={:?}, rcvr_ty_generics={:?}, \ + rcvr_ty_predicates={:?})", + untransformed_rcvr_ty, + rcvr_ty_generics, + rcvr_ty_predicates); let tcx = ccx.tcx; let mut seen_methods = FnvHashSet(); @@ -1139,7 +1139,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, { let tcx = ccx.tcx; - debug!("ensure_super_predicates_step(trait_def_id={})", trait_def_id.repr()); + debug!("ensure_super_predicates_step(trait_def_id={:?})", trait_def_id); if trait_def_id.krate != ast::LOCAL_CRATE { // If this trait comes from an external crate, then all of the @@ -1191,9 +1191,9 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, let superpredicates = ty::GenericPredicates { predicates: VecPerParamSpace::new(superbounds, vec![], vec![]) }; - debug!("superpredicates for trait {} = {}", - local_def(item.id).repr(), - superpredicates.repr()); + debug!("superpredicates for trait {:?} = {:?}", + local_def(item.id), + superpredicates); tcx.super_predicates.borrow_mut().insert(trait_def_id, superpredicates.clone()); @@ -1206,7 +1206,7 @@ fn ensure_super_predicates_step(ccx: &CrateCtxt, .map(|tr| tr.def_id()) .collect(); - debug!("ensure_super_predicates_step: def_ids={}", def_ids.repr()); + debug!("ensure_super_predicates_step: def_ids={:?}", def_ids); def_ids } @@ -1532,9 +1532,8 @@ fn convert_typed_item<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, scheme.generics.types.iter() .map(|t| match t.object_lifetime_default { Some(ty::ObjectLifetimeDefault::Specific(r)) => - r.user_string(), - d => - d.repr(), + r.to_string(), + d => format!("{:?}", d), }) .collect::>() .connect(","); @@ -1620,8 +1619,8 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, ast_generics: &ast::Generics) -> ty::Generics<'tcx> { - debug!("ty_generics_for_trait(trait_id={}, substs={})", - local_def(trait_id).repr(), substs.repr()); + debug!("ty_generics_for_trait(trait_id={:?}, substs={:?})", + local_def(trait_id), substs); let mut generics = ty_generics_for_type_or_impl(ccx, ast_generics); @@ -2200,12 +2199,12 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( &ty::liberate_late_bound_regions( tcx, body_scope, &ty::Binder(base_type))); - debug!("required_type={} required_type_free={} \ - base_type={} base_type_free={}", - required_type.repr(), - required_type_free.repr(), - base_type.repr(), - base_type_free.repr()); + debug!("required_type={:?} required_type_free={:?} \ + base_type={:?} base_type_free={:?}", + required_type, + required_type_free, + base_type, + base_type_free); let infcx = infer::new_infer_ctxt(tcx); drop(::require_same_types(tcx, @@ -2216,7 +2215,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>( required_type_free, || { format!("mismatched self type: expected `{}`", - required_type.user_string()) + required_type) })); // We could conceviably add more free-region relations here, @@ -2286,7 +2285,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, idx: index as u32, name: ty_param.ident.name }; if !input_parameters.contains(&ctp::Parameter::Type(param_ty)) { - report_unused_parameter(tcx, ty_param.span, "type", ¶m_ty.user_string()); + report_unused_parameter(tcx, ty_param.span, "type", ¶m_ty.to_string()); } } @@ -2316,7 +2315,7 @@ fn enforce_impl_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>, !input_parameters.contains(&ctp::Parameter::Region(region)) { report_unused_parameter(tcx, lifetime_def.lifetime.span, - "lifetime", ®ion.name.user_string()); + "lifetime", ®ion.name.to_string()); } } diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index b56bb895b9ed6..8feecd1561311 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -109,7 +109,6 @@ use middle::ty::{self, Ty}; use rustc::ast_map; use session::config; use util::common::time; -use util::ppaux::{Repr, UserString}; use syntax::codemap::Span; use syntax::print::pprust::*; @@ -148,7 +147,7 @@ pub struct CrateCtxt<'a, 'tcx: 'a> { // Functions that write types into the node type table fn write_ty_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, node_id: ast::NodeId, ty: Ty<'tcx>) { - debug!("write_ty_to_tcx({}, {})", node_id, ty.repr()); + debug!("write_ty_to_tcx({}, {:?})", node_id, ty); assert!(!ty::type_needs_infer(ty)); tcx.node_type_insert(node_id, ty); } @@ -157,9 +156,9 @@ fn write_substs_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, node_id: ast::NodeId, item_substs: ty::ItemSubsts<'tcx>) { if !item_substs.is_noop() { - debug!("write_substs_to_tcx({}, {})", + debug!("write_substs_to_tcx({}, {:?})", node_id, - item_substs.repr()); + item_substs); assert!(item_substs.substs.types.all(|t| !ty::type_needs_infer(*t))); @@ -240,14 +239,13 @@ fn check_main_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, main_span, main_t, se_ty, || { format!("main function expects type: `{}`", - se_ty.user_string()) + se_ty) }); } _ => { tcx.sess.span_bug(main_span, - &format!("main has a non-function type: found \ - `{}`", - main_t.repr())); + &format!("main has a non-function type: found `{}`", + main_t)); } } } @@ -290,15 +288,14 @@ fn check_start_fn_ty(ccx: &CrateCtxt, require_same_types(tcx, None, false, start_span, start_t, se_ty, || { format!("start function expects type: `{}`", - se_ty.user_string()) + se_ty) }); } _ => { tcx.sess.span_bug(start_span, - &format!("start has a non-function type: found \ - `{}`", - start_t.repr())); + &format!("start has a non-function type: found `{}`", + start_t)); } } } diff --git a/src/librustc_typeck/variance.rs b/src/librustc_typeck/variance.rs index 91ec676c09521..1f4e134365121 100644 --- a/src/librustc_typeck/variance.rs +++ b/src/librustc_typeck/variance.rs @@ -278,7 +278,6 @@ use syntax::ast_util; use syntax::visit; use syntax::visit::Visitor; use util::nodemap::NodeMap; -use util::ppaux::Repr; pub fn infer_variance(tcx: &ty::ctxt) { let krate = tcx.map.krate(); @@ -845,8 +844,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { generics: &ty::Generics<'tcx>, trait_ref: ty::TraitRef<'tcx>, variance: VarianceTermPtr<'a>) { - debug!("add_constraints_from_trait_ref: trait_ref={} variance={:?}", - trait_ref.repr(), + debug!("add_constraints_from_trait_ref: trait_ref={:?} variance={:?}", + trait_ref, variance); let trait_def = ty::lookup_trait_def(self.tcx(), trait_ref.def_id); @@ -867,8 +866,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { generics: &ty::Generics<'tcx>, ty: Ty<'tcx>, variance: VarianceTermPtr<'a>) { - debug!("add_constraints_from_ty(ty={}, variance={:?})", - ty.repr(), + debug!("add_constraints_from_ty(ty={:?}, variance={:?})", + ty, variance); match ty.sty { @@ -981,8 +980,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { ty::TyInfer(..) => { self.tcx().sess.bug( &format!("unexpected type encountered in \ - variance inference: {}", - ty.repr())); + variance inference: {}", ty)); } } } @@ -997,9 +995,9 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { region_param_defs: &[ty::RegionParameterDef], substs: &subst::Substs<'tcx>, variance: VarianceTermPtr<'a>) { - debug!("add_constraints_from_substs(def_id={}, substs={}, variance={:?})", - def_id.repr(), - substs.repr(), + debug!("add_constraints_from_substs(def_id={:?}, substs={:?}, variance={:?})", + def_id, + substs, variance); for p in type_param_defs { @@ -1066,8 +1064,8 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { self.tcx() .sess .bug(&format!("unexpected region encountered in variance \ - inference: {}", - region.repr())); + inference: {:?}", + region)); } } } @@ -1194,17 +1192,16 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { types: types, regions: regions }; - debug!("item_id={} item_variances={}", + debug!("item_id={} item_variances={:?}", item_id, - item_variances.repr()); + item_variances); let item_def_id = ast_util::local_def(item_id); // For unit testing: check for a special "rustc_variance" // attribute and report an error with various results if found. if ty::has_attr(tcx, item_def_id, "rustc_variance") { - let found = item_variances.repr(); - span_err!(tcx.sess, tcx.map.span(item_id), E0208, "{}", &found[..]); + span_err!(tcx.sess, tcx.map.span(item_id), E0208, "{:?}", item_variances); } let newly_added = tcx.item_variance_map.borrow_mut() From d9148311451d38e831dcaa15548fb6ac6f6450b9 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Thu, 18 Jun 2015 20:57:24 +0300 Subject: [PATCH 47/48] rustc: add more doc comments to ty::Lift and ty::with_ctxt. --- src/librustc/middle/ty.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index e82754680a5e9..170b98b88310f 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -816,6 +816,12 @@ impl<'tcx> ctxt<'tcx> { /// provided ty::ctxt<'tcx>. /// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx> /// by looking them up in their respective interners. +/// None is returned if the value or one of the components is not part +/// of the provided context. +/// For Ty, None can be returned if either the type interner doesn't +/// contain the TypeVariants key or if the address of the interned +/// pointer differs. The latter case is possible if a primitive type, +/// e.g. `()` or `u8`, was interned in a different context. pub trait Lift<'tcx> { type Lifted; fn lift_to_tcx(&self, tcx: &ctxt<'tcx>) -> Option; @@ -3016,6 +3022,10 @@ impl<'tcx> CommonTypes<'tcx> { } } +/// Create a type context and call the closure with a `&ty::ctxt` reference +/// to the context. The closure enforces that the type context and any interned +/// value (types, substs, etc.) can only be used while `ty::tls` has a valid +/// reference to the context, to allow formatting values that need it. pub fn with_ctxt<'tcx, F, R>(s: Session, arenas: &'tcx CtxtArenas<'tcx>, def_map: DefMap, From 6eed1662af4b72a829b65d7227bdcbdff1220be9 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Fri, 19 Jun 2015 01:45:20 +0300 Subject: [PATCH 48/48] Remove extra fmt::Debug impl for VtableClosureData from #26147. --- src/librustc/middle/traits/util.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index 6fb085c8838d7..54bcd9d7e66ab 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -301,12 +301,6 @@ pub fn fresh_type_vars_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, infcx.fresh_substs_for_generics(span, &impl_generics) } -impl<'tcx, N> fmt::Debug for super::VtableClosureData<'tcx, N> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "VtableClosure({:?})", self.closure_def_id) - } -} - /// See `super::obligations_for_generics` pub fn predicates_for_generics<'tcx>(cause: ObligationCause<'tcx>, recursion_depth: usize,