-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Fix debug ICE when previous arg span during extra comma removal comes from macro context #112447
Conversation
r? @oli-obk (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
… construction comes from macro context
// NOTE(#112437): we *manually* calculate the previous comma span here | ||
// because `Span::to` returns incomplete span when `prev` or `span` | ||
// involves macro contexts. | ||
span = Span::new(prev.hi(), span.hi(), span.ctxt(), span.parent()); |
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.
This fix looks incorrect if the argument comes from a macro variable, for example for the following the span will now start after 1 and go all the way to 2:
fn foo(_: i32) {}
macro_rules! m {
($e:expr) => {
foo(1, $e)
}
}
fn main() {
m!(2)
}
I think you can swap the arguments to get a better span: span.to(prev.shrink_to_hi())
.
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.
Unfortunately that isn't correct either: Span::to
will also return incomplete span when the "current" argument span (span
) is from a macro context...
e.g.
f(1, panic!());
I will have to think about how to correctly fix this span if either comes from macro contexts...
Unfortunately I do not know how to properly fix this issue, closing for now. |
Manually calculate
prev.shrink_to_hi().to(span)
to avoid empty span whenprev
comes from a macro context, such as in the code below:Fixes #112437.