-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix dbg_macro ICE when used iterated by for loop
#16011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
| 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)) | ||
| } |
There was a problem hiding this comment.
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!(` |
There was a problem hiding this comment.
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}?
|
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. |
Closes #16008
changelog: [
dbg_macro] fix ICE when used iterated by for loop