Skip to content

Commit 942dc28

Browse files
committed
Auto merge of rust-lang#156589 - cuviper:revert-dbg-tearing, r=the8472
Revert tearing changes to `dbg!` Since the primary change to `dbg!` in rust-lang#149869, we've been chasing a few regressions: * rust-lang#153850, fixed by rust-lang#154074 * rust-lang#154988, fixed by rust-lang#154994 * rust-lang#155902, proposed fix in rust-lang#155915 We already reverted this once, on beta only to prevent these regressions from shipping in 1.95. In that most recent PR, we decided that it would be better to revert `dbg!` to its original state everywhere (`main` and 1.96-`beta`), and then we can consider it from scratch later. So here I've reverted the change and its fixes, but kept the regression tests, including the pending one. cc @joboet @dianne @rust-lang/libs @rustbot label beta-nominated
2 parents 5f750de + 7aced89 commit 942dc28

2 files changed

Lines changed: 26 additions & 18 deletions

File tree

clippy_lints/src/dbg_macro.rs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,33 @@ impl LateLintPass<'_> for DbgMacro {
9292
(macro_call.span, String::from("()"))
9393
}
9494
},
95-
ExprKind::Match(args, _, _) => {
96-
let suggestion = match args.kind {
97-
// dbg!(1) => 1
98-
ExprKind::Tup([val]) => {
99-
snippet_with_applicability(cx, val.span.source_callsite(), "..", &mut applicability)
100-
.to_string()
95+
// dbg!(1)
96+
ExprKind::Match(val, ..) => (
97+
macro_call.span,
98+
snippet_with_applicability(cx, val.span.source_callsite(), "..", &mut applicability)
99+
.to_string(),
100+
),
101+
// dbg!(2, 3)
102+
ExprKind::Tup(
103+
[
104+
Expr {
105+
kind: ExprKind::Match(first, ..),
106+
..
101107
},
102-
// dbg!(2, 3) => (2, 3)
103-
ExprKind::Tup([first, .., last]) => {
104-
let snippet = snippet_with_applicability(
105-
cx,
106-
first.span.source_callsite().to(last.span.source_callsite()),
107-
"..",
108-
&mut applicability,
109-
);
110-
format!("({snippet})")
108+
..,
109+
Expr {
110+
kind: ExprKind::Match(last, ..),
111+
..
111112
},
112-
_ => unreachable!(),
113-
};
114-
(macro_call.span, suggestion)
113+
],
114+
) => {
115+
let snippet = snippet_with_applicability(
116+
cx,
117+
first.span.source_callsite().to(last.span.source_callsite()),
118+
"..",
119+
&mut applicability,
120+
);
121+
(macro_call.span, format!("({snippet})"))
115122
},
116123
_ => unreachable!(),
117124
};

clippy_utils/src/sym.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ generate! {
202202
cx,
203203
cycle,
204204
cyclomatic_complexity,
205+
dbg_macro,
205206
de,
206207
debug_struct,
207208
deprecated_in_future,

0 commit comments

Comments
 (0)