Skip to content

Commit

Permalink
Stabilize debug builders for 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sfackler committed May 20, 2015
1 parent 43cf733 commit e161d5c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 27 deletions.
1 change: 0 additions & 1 deletion src/libcollections/lib.rs
Expand Up @@ -39,7 +39,6 @@
#![feature(str_char)]
#![feature(str_words)]
#![feature(slice_patterns)]
#![feature(debug_builders)]
#![feature(utf8_error)]
#![cfg_attr(test, feature(rand, rustc_private, test, hash, collections,
collections_drain, collections_range))]
Expand Down
31 changes: 18 additions & 13 deletions src/libcore/fmt/builders.rs
Expand Up @@ -54,6 +54,7 @@ impl<'a, 'b: 'a> fmt::Write for PadAdapter<'a, 'b> {
///
/// Constructed by the `Formatter::debug_struct` method.
#[must_use]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub struct DebugStruct<'a, 'b: 'a> {
fmt: &'a mut fmt::Formatter<'b>,
result: fmt::Result,
Expand All @@ -72,7 +73,7 @@ pub fn debug_struct_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str)

impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
/// Adds a new field to the generated struct output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn field(&mut self, name: &str, value: &fmt::Debug) -> &mut DebugStruct<'a, 'b> {
self.result = self.result.and_then(|_| {
let prefix = if self.has_fields {
Expand All @@ -94,7 +95,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
}

/// Finishes output and returns any error encountered.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result {
if self.has_fields {
self.result = self.result.and_then(|_| {
Expand All @@ -117,6 +118,7 @@ impl<'a, 'b: 'a> DebugStruct<'a, 'b> {
///
/// Constructed by the `Formatter::debug_tuple` method.
#[must_use]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub struct DebugTuple<'a, 'b: 'a> {
fmt: &'a mut fmt::Formatter<'b>,
result: fmt::Result,
Expand All @@ -134,7 +136,7 @@ pub fn debug_tuple_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>, name: &str) -> D

impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
/// Adds a new field to the generated tuple struct output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn field(&mut self, value: &fmt::Debug) -> &mut DebugTuple<'a, 'b> {
self.result = self.result.and_then(|_| {
let (prefix, space) = if self.has_fields {
Expand All @@ -156,7 +158,7 @@ impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
}

/// Finishes output and returns any error encountered.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result {
if self.has_fields {
self.result = self.result.and_then(|_| {
Expand Down Expand Up @@ -211,6 +213,7 @@ impl<'a, 'b: 'a> DebugInner<'a, 'b> {
///
/// Constructed by the `Formatter::debug_set` method.
#[must_use]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub struct DebugSet<'a, 'b: 'a> {
inner: DebugInner<'a, 'b>,
}
Expand All @@ -228,14 +231,14 @@ pub fn debug_set_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugSet<'a, 'b

impl<'a, 'b: 'a> DebugSet<'a, 'b> {
/// Adds a new entry to the set output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugSet<'a, 'b> {
self.inner.entry(entry);
self
}

/// Adds the contents of an iterator of entries to the set output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugSet<'a, 'b>
where D: fmt::Debug, I: IntoIterator<Item=D> {
for entry in entries {
Expand All @@ -245,7 +248,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
}

/// Finishes output and returns any error encountered.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result {
self.inner.finish();
self.inner.result.and_then(|_| self.inner.fmt.write_str("}"))
Expand All @@ -256,6 +259,7 @@ impl<'a, 'b: 'a> DebugSet<'a, 'b> {
///
/// Constructed by the `Formatter::debug_list` method.
#[must_use]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub struct DebugList<'a, 'b: 'a> {
inner: DebugInner<'a, 'b>,
}
Expand All @@ -273,14 +277,14 @@ pub fn debug_list_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugList<'a,

impl<'a, 'b: 'a> DebugList<'a, 'b> {
/// Adds a new entry to the list output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entry(&mut self, entry: &fmt::Debug) -> &mut DebugList<'a, 'b> {
self.inner.entry(entry);
self
}

/// Adds the contents of an iterator of entries to the list output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entries<D, I>(&mut self, entries: I) -> &mut DebugList<'a, 'b>
where D: fmt::Debug, I: IntoIterator<Item=D> {
for entry in entries {
Expand All @@ -290,7 +294,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
}

/// Finishes output and returns any error encountered.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result {
self.inner.finish();
self.inner.result.and_then(|_| self.inner.fmt.write_str("]"))
Expand All @@ -301,6 +305,7 @@ impl<'a, 'b: 'a> DebugList<'a, 'b> {
///
/// Constructed by the `Formatter::debug_map` method.
#[must_use]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub struct DebugMap<'a, 'b: 'a> {
fmt: &'a mut fmt::Formatter<'b>,
result: fmt::Result,
Expand All @@ -318,7 +323,7 @@ pub fn debug_map_new<'a, 'b>(fmt: &'a mut fmt::Formatter<'b>) -> DebugMap<'a, 'b

impl<'a, 'b: 'a> DebugMap<'a, 'b> {
/// Adds a new entry to the map output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entry(&mut self, key: &fmt::Debug, value: &fmt::Debug) -> &mut DebugMap<'a, 'b> {
self.result = self.result.and_then(|_| {
if self.is_pretty() {
Expand All @@ -336,7 +341,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
}

/// Adds the contents of an iterator of entries to the map output.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn entries<K, V, I>(&mut self, entries: I) -> &mut DebugMap<'a, 'b>
where K: fmt::Debug, V: fmt::Debug, I: IntoIterator<Item=(K, V)> {
for (k, v) in entries {
Expand All @@ -346,7 +351,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
}

/// Finishes output and returns any error encountered.
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
pub fn finish(&mut self) -> fmt::Result {
let prefix = if self.is_pretty() && self.has_fields { "\n" } else { "" };
self.result.and_then(|_| write!(self.fmt, "{}}}", prefix))
Expand Down
15 changes: 5 additions & 10 deletions src/libcore/fmt/mod.rs
Expand Up @@ -719,7 +719,6 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo {
Expand All @@ -739,7 +738,7 @@ impl<'a> Formatter<'a> {
/// // prints "Foo { bar: 10, baz: "Hello World" }"
/// println!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() });
/// ```
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
pub fn debug_struct<'b>(&'b mut self, name: &str) -> DebugStruct<'b, 'a> {
builders::debug_struct_new(self, name)
Expand All @@ -751,7 +750,6 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo(i32, String);
Expand All @@ -768,7 +766,7 @@ impl<'a> Formatter<'a> {
/// // prints "Foo(10, "Hello World")"
/// println!("{:?}", Foo(10, "Hello World".to_string()));
/// ```
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
pub fn debug_tuple<'b>(&'b mut self, name: &str) -> DebugTuple<'b, 'a> {
builders::debug_tuple_new(self, name)
Expand All @@ -780,7 +778,6 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo(Vec<i32>);
Expand All @@ -794,7 +791,7 @@ impl<'a> Formatter<'a> {
/// // prints "[10, 11]"
/// println!("{:?}", Foo(vec![10, 11]));
/// ```
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
pub fn debug_list<'b>(&'b mut self) -> DebugList<'b, 'a> {
builders::debug_list_new(self)
Expand All @@ -806,7 +803,6 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo(Vec<i32>);
Expand All @@ -820,7 +816,7 @@ impl<'a> Formatter<'a> {
/// // prints "{10, 11}"
/// println!("{:?}", Foo(vec![10, 11]));
/// ```
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
pub fn debug_set<'b>(&'b mut self) -> DebugSet<'b, 'a> {
builders::debug_set_new(self)
Expand All @@ -832,7 +828,6 @@ impl<'a> Formatter<'a> {
/// # Examples
///
/// ```rust
/// # #![feature(debug_builders, core)]
/// use std::fmt;
///
/// struct Foo(Vec<(String, i32)>);
Expand All @@ -846,7 +841,7 @@ impl<'a> Formatter<'a> {
/// // prints "{"A": 10, "B": 11}"
/// println!("{:?}", Foo(vec![("A".to_string(), 10), ("B".to_string(), 11)]));
/// ```
#[unstable(feature = "debug_builders", reason = "method was just created")]
#[stable(feature = "debug_builders", since = "1.2.0")]
#[inline]
pub fn debug_map<'b>(&'b mut self) -> DebugMap<'b, 'a> {
builders::debug_map_new(self)
Expand Down
1 change: 0 additions & 1 deletion src/libcoretest/lib.rs
Expand Up @@ -20,7 +20,6 @@
#![feature(std_misc)]
#![feature(libc)]
#![feature(hash)]
#![feature(debug_builders)]
#![feature(unique)]
#![feature(step_by)]
#![feature(slice_patterns)]
Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Expand Up @@ -109,7 +109,6 @@
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
#![feature(debug_builders)]
#![feature(into_cow)]
#![feature(lang_items)]
#![feature(libc)]
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/deriving-associated-types.rs
Expand Up @@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![feature(core, debug_builders)]
#![feature(core)]

pub trait DeclaredTrait {
type Type;
Expand Down

0 comments on commit e161d5c

Please sign in to comment.