Skip to content

Conversation

@profetia
Copy link
Contributor

@profetia profetia commented Nov 2, 2025

Closes #16008

changelog: [dbg_macro] fix ICE when used iterated by for loop

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 2, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 2, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Comment on lines 190 to 192
fn first_dbg_macro_in_expansion(cx: &LateContext<'_>, span: Span) -> Option<MacroCall> {
macro_backtrace(span).find(|mc| cx.tcx.is_diagnostic_item(sym::dbg_macro, mc.def_id))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it looks like the issue is that it's picking up the desugared into_iter call, we could change this to something like expn_backtrace(span).take_while(|(_, data)| !matches!(data.kind, ExpnKind::Desugaring(_))).find(...)

macro_call
.span
.source_callsite()
.with_lo(macro_call.span.lo() + BytePos(5)) // after `dbg!(`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if the expression is poorly formatted, something like dbg ! { 0}?

@Jarcho
Copy link
Contributor

Jarcho commented Nov 4, 2025

Opened a PR on the rust side to fix the spans there (rust-lang/rust#148465). I'll hold off on any changes here until that's dealt with.

@Jarcho
Copy link
Contributor

Jarcho commented Nov 13, 2025

The ICE has been fixed upstream. The unreachable should still be replaced with a debug_assert.

@profetia
Copy link
Contributor Author

Closed as fixed by upstream

@profetia profetia closed this Nov 13, 2025
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE dbg_macro

5 participants