From f4cde5bc4e17198670d49c21aa8ce4c199c5489c Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 1 Dec 2018 02:54:09 +0100 Subject: [PATCH] stabilize std::dbg!(...) --- src/libstd/macros.rs | 12 ++---------- .../dbg-macro-expected-behavior.rs | 18 ++++++++---------- .../dbg-macro-feature-gate.rs | 5 ----- .../dbg-macro-feature-gate.stderr | 11 ----------- .../dbg-macro-move-semantics.nll.stderr | 2 +- .../dbg-macro-move-semantics.rs | 2 -- .../dbg-macro-move-semantics.stderr | 4 ++-- .../dbg-macro-requires-debug.rs | 2 -- .../dbg-macro-requires-debug.stderr | 2 +- 9 files changed, 14 insertions(+), 44 deletions(-) delete mode 100644 src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs delete mode 100644 src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 0995ab3c373ca..94827d2a0355f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -224,11 +224,9 @@ macro_rules! eprintln { /// the value of a given expression. An example: /// /// ```rust -/// #![feature(dbg_macro)] -/// /// let a = 2; /// let b = dbg!(a * 2) + 1; -/// // ^-- prints: [src/main.rs:4] a * 2 = 4 +/// // ^-- prints: [src/main.rs:2] a * 2 = 4 /// assert_eq!(b, 5); /// ``` /// @@ -262,8 +260,6 @@ macro_rules! eprintln { /// With a method call: /// /// ```rust -/// #![feature(dbg_macro)] -/// /// fn foo(n: usize) { /// if let Some(_) = dbg!(n.checked_sub(4)) { /// // ... @@ -282,8 +278,6 @@ macro_rules! eprintln { /// Naive factorial implementation: /// /// ```rust -/// #![feature(dbg_macro)] -/// /// fn factorial(n: u32) -> u32 { /// if dbg!(n <= 1) { /// dbg!(1) @@ -312,8 +306,6 @@ macro_rules! eprintln { /// The `dbg!(..)` macro moves the input: /// /// ```compile_fail -/// #![feature(dbg_macro)] -/// /// /// A wrapper around `usize` which importantly is not Copyable. /// #[derive(Debug)] /// struct NoCopy(usize); @@ -325,7 +317,7 @@ macro_rules! eprintln { /// /// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr) #[macro_export] -#[unstable(feature = "dbg_macro", issue = "54306")] +#[stable(feature = "dbg_macro", since = "1.32.0")] macro_rules! dbg { ($val:expr) => { // Use of `match` here is intentional because it affects the lifetimes diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs index f7216c57e42b8..3d24f49ad7509 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs @@ -5,8 +5,6 @@ // Tests ensuring that `dbg!(expr)` has the expected run-time behavior. // as well as some compile time properties we expect. -#![feature(dbg_macro)] - #[derive(Copy, Clone, Debug)] struct Unit; @@ -57,31 +55,31 @@ fn test() { fn validate_stderr(stderr: Vec) { assert_eq!(stderr, &[ - ":23] Unit = Unit", + ":21] Unit = Unit", - ":24] a = Unit", + ":22] a = Unit", - ":30] Point{x: 42, y: 24,} = Point {", + ":28] Point{x: 42, y: 24,} = Point {", " x: 42,", " y: 24", "}", - ":31] b = Point {", + ":29] b = Point {", " x: 42,", " y: 24", "}", - ":40] &a = NoCopy(", + ":38] &a = NoCopy(", " 1337", ")", - ":40] dbg!(& a) = NoCopy(", + ":38] dbg!(& a) = NoCopy(", " 1337", ")", - ":45] f(&42) = 42", + ":43] f(&42) = 42", "before", - ":50] { foo += 1; eprintln!(\"before\"); 7331 } = 7331", + ":48] { foo += 1; eprintln!(\"before\"); 7331 } = 7331", ]); } diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs deleted file mode 100644 index b237c6f147bf7..0000000000000 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Feature gate test for `dbg!(..)`. - -fn main() { - dbg!(1); -} diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr deleted file mode 100644 index 64df1e196d285..0000000000000 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0658]: macro dbg! is unstable (see issue #54306) - --> $DIR/dbg-macro-feature-gate.rs:4:5 - | -LL | dbg!(1); - | ^^^^^^^^ - | - = help: add #![feature(dbg_macro)] to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr index bf99fef3bbd2f..218a1d5b5fd12 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:11:18 + --> $DIR/dbg-macro-move-semantics.rs:9:18 | LL | let _ = dbg!(a); | ------- value moved here diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs index bcf508d9af5d7..06a23ea1767b0 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs @@ -1,7 +1,5 @@ // Test ensuring that `dbg!(expr)` will take ownership of the argument. -#![feature(dbg_macro)] - #[derive(Debug)] struct NoCopy(usize); diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr index 1064317438515..cfc318c1cd0f3 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:11:18 + --> $DIR/dbg-macro-move-semantics.rs:9:18 | LL | let _ = dbg!(a); | ------- value moved here @@ -10,7 +10,7 @@ LL | let _ = dbg!(a); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error[E0382]: use of moved value: `a` - --> $DIR/dbg-macro-move-semantics.rs:11:13 + --> $DIR/dbg-macro-move-semantics.rs:9:13 | LL | let _ = dbg!(a); | ------- value moved here diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs index 8e6f3b226fc1e..365e62c808673 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs @@ -1,7 +1,5 @@ // Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`. -#![feature(dbg_macro)] - struct NotDebug; fn main() { diff --git a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index a3b6a1761b991..ecab673953d6d 100644 --- a/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -1,5 +1,5 @@ error[E0277]: `NotDebug` doesn't implement `std::fmt::Debug` - --> $DIR/dbg-macro-requires-debug.rs:8:23 + --> $DIR/dbg-macro-requires-debug.rs:6:23 | LL | let _: NotDebug = dbg!(NotDebug); | ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}`