Skip to content

Commit aa92cc9

Browse files
authored
Rollup merge of rust-lang#56395 - Centril:stabilize-dbg-macro, r=SimonSapin
Stabilize dbg!(...) Per FCP in rust-lang#54306 (which is ~1 day from completion). r? @SimonSapin The PR is fairly isolated so a rollup should probably work.
2 parents 4e94bec + f4cde5b commit aa92cc9

9 files changed

+14
-44
lines changed

src/libstd/macros.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,9 @@ macro_rules! eprintln {
224224
/// the value of a given expression. An example:
225225
///
226226
/// ```rust
227-
/// #![feature(dbg_macro)]
228-
///
229227
/// let a = 2;
230228
/// let b = dbg!(a * 2) + 1;
231-
/// // ^-- prints: [src/main.rs:4] a * 2 = 4
229+
/// // ^-- prints: [src/main.rs:2] a * 2 = 4
232230
/// assert_eq!(b, 5);
233231
/// ```
234232
///
@@ -262,8 +260,6 @@ macro_rules! eprintln {
262260
/// With a method call:
263261
///
264262
/// ```rust
265-
/// #![feature(dbg_macro)]
266-
///
267263
/// fn foo(n: usize) {
268264
/// if let Some(_) = dbg!(n.checked_sub(4)) {
269265
/// // ...
@@ -282,8 +278,6 @@ macro_rules! eprintln {
282278
/// Naive factorial implementation:
283279
///
284280
/// ```rust
285-
/// #![feature(dbg_macro)]
286-
///
287281
/// fn factorial(n: u32) -> u32 {
288282
/// if dbg!(n <= 1) {
289283
/// dbg!(1)
@@ -312,8 +306,6 @@ macro_rules! eprintln {
312306
/// The `dbg!(..)` macro moves the input:
313307
///
314308
/// ```compile_fail
315-
/// #![feature(dbg_macro)]
316-
///
317309
/// /// A wrapper around `usize` which importantly is not Copyable.
318310
/// #[derive(Debug)]
319311
/// struct NoCopy(usize);
@@ -325,7 +317,7 @@ macro_rules! eprintln {
325317
///
326318
/// [stderr]: https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)
327319
#[macro_export]
328-
#[unstable(feature = "dbg_macro", issue = "54306")]
320+
#[stable(feature = "dbg_macro", since = "1.32.0")]
329321
macro_rules! dbg {
330322
($val:expr) => {
331323
// Use of `match` here is intentional because it affects the lifetimes

src/test/ui/rfc-2361-dbg-macro/dbg-macro-expected-behavior.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// Tests ensuring that `dbg!(expr)` has the expected run-time behavior.
66
// as well as some compile time properties we expect.
77

8-
#![feature(dbg_macro)]
9-
108
#[derive(Copy, Clone, Debug)]
119
struct Unit;
1210

@@ -57,31 +55,31 @@ fn test() {
5755

5856
fn validate_stderr(stderr: Vec<String>) {
5957
assert_eq!(stderr, &[
60-
":23] Unit = Unit",
58+
":21] Unit = Unit",
6159

62-
":24] a = Unit",
60+
":22] a = Unit",
6361

64-
":30] Point{x: 42, y: 24,} = Point {",
62+
":28] Point{x: 42, y: 24,} = Point {",
6563
" x: 42,",
6664
" y: 24",
6765
"}",
6866

69-
":31] b = Point {",
67+
":29] b = Point {",
7068
" x: 42,",
7169
" y: 24",
7270
"}",
7371

74-
":40] &a = NoCopy(",
72+
":38] &a = NoCopy(",
7573
" 1337",
7674
")",
7775

78-
":40] dbg!(& a) = NoCopy(",
76+
":38] dbg!(& a) = NoCopy(",
7977
" 1337",
8078
")",
81-
":45] f(&42) = 42",
79+
":43] f(&42) = 42",
8280

8381
"before",
84-
":50] { foo += 1; eprintln!(\"before\"); 7331 } = 7331",
82+
":48] { foo += 1; eprintln!(\"before\"); 7331 } = 7331",
8583
]);
8684
}
8785

src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.rs

-5
This file was deleted.

src/test/ui/rfc-2361-dbg-macro/dbg-macro-feature-gate.stderr

-11
This file was deleted.

src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.nll.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0382]: use of moved value: `a`
2-
--> $DIR/dbg-macro-move-semantics.rs:11:18
2+
--> $DIR/dbg-macro-move-semantics.rs:9:18
33
|
44
LL | let _ = dbg!(a);
55
| ------- value moved here

src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Test ensuring that `dbg!(expr)` will take ownership of the argument.
22

3-
#![feature(dbg_macro)]
4-
53
#[derive(Debug)]
64
struct NoCopy(usize);
75

src/test/ui/rfc-2361-dbg-macro/dbg-macro-move-semantics.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0382]: use of moved value: `a`
2-
--> $DIR/dbg-macro-move-semantics.rs:11:18
2+
--> $DIR/dbg-macro-move-semantics.rs:9:18
33
|
44
LL | let _ = dbg!(a);
55
| ------- value moved here
@@ -10,7 +10,7 @@ LL | let _ = dbg!(a);
1010
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
1111

1212
error[E0382]: use of moved value: `a`
13-
--> $DIR/dbg-macro-move-semantics.rs:11:13
13+
--> $DIR/dbg-macro-move-semantics.rs:9:13
1414
|
1515
LL | let _ = dbg!(a);
1616
| ------- value moved here

src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`.
22

3-
#![feature(dbg_macro)]
4-
53
struct NotDebug;
64

75
fn main() {

src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: `NotDebug` doesn't implement `std::fmt::Debug`
2-
--> $DIR/dbg-macro-requires-debug.rs:8:23
2+
--> $DIR/dbg-macro-requires-debug.rs:6:23
33
|
44
LL | let _: NotDebug = dbg!(NotDebug);
55
| ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}`

0 commit comments

Comments
 (0)