-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add the ability to merge spans to codemap #36585
Conversation
if let Some(_) = cm.merge_spans(span1, span2) { | ||
assert!(false); | ||
} | ||
else { |
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.
nit: no new line here
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.
In fact you don't need the else branch at all, and you can use panic!()
instead of assert!(false)
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.
or assert!(cm.merge_spans(span1, span2).is_none())
/// For this to work, the spans have to be: | ||
/// * the expn_id of both spans much match | ||
/// * the lhs span needs to end on the same line the rhs span begins | ||
/// * the lhs span must start at or before the rhs span |
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.
Do you expect spans to overlap sometimes? The only time I would expect that is if one is strictly larger than the other, in which case maybe this method shouldn't be used. If you agree, you could be stricter and require the sp.lhs.hi < sp.rhs.lo
, rather than comparing both lo
s
@nrc - comments addressed. I check for overlap now. Simplified the negative unit test also. |
@bors r=nrc |
📌 Commit e4b1842 has been approved by |
…, r=nrc Add the ability to merge spans to codemap This PR adds the ability to merge Spans. To do so, it builds on the Codemap's ability to verify the locations of spans, namely that following can be verified: * the expn_id of both spans much match * the lhs span needs to end on the same line the rhs span begins * the lhs span must start at or before the rhs span If all of these are met, a new span is returned that is min(lo), max(hi) of the two spans. This PR also removes an older Span merge, as this new functionality subsumes it. r? @nrc
…, r=nrc Add the ability to merge spans to codemap This PR adds the ability to merge Spans. To do so, it builds on the Codemap's ability to verify the locations of spans, namely that following can be verified: * the expn_id of both spans much match * the lhs span needs to end on the same line the rhs span begins * the lhs span must start at or before the rhs span If all of these are met, a new span is returned that is min(lo), max(hi) of the two spans. This PR also removes an older Span merge, as this new functionality subsumes it. r? @nrc
Add the ability to merge spans to codemap This PR adds the ability to merge Spans. To do so, it builds on the Codemap's ability to verify the locations of spans, namely that following can be verified: * the expn_id of both spans much match * the lhs span needs to end on the same line the rhs span begins * the lhs span must start at or before the rhs span If all of these are met, a new span is returned that is min(lo), max(hi) of the two spans. This PR also removes an older Span merge, as this new functionality subsumes it. r? @nrc
This PR adds the ability to merge Spans. To do so, it builds on the Codemap's ability to verify the locations of spans, namely that following can be verified:
If all of these are met, a new span is returned that is min(lo), max(hi) of the two spans.
This PR also removes an older Span merge, as this new functionality subsumes it.
r? @nrc