-
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
improve span of erroneous empty macro invocation #27584
Conversation
The ideas is to use the span of the complete macro invocation if the span of a macro error is `DUMMY_SP`. fixes rust-lang#7970
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Don't know how this got closed, but it shouldn't be. |
@@ -249,22 +249,6 @@ pub enum ParseResult<T> { | |||
pub type NamedParseResult = ParseResult<HashMap<Ident, Rc<NamedMatch>>>; | |||
pub type PositionalParseResult = ParseResult<Vec<Rc<NamedMatch>>>; | |||
|
|||
pub fn parse_or_else(sess: &ParseSess, |
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.
Maybe this function could be changed to take in a substitute_span: Span
and have the DUMMY_SP
comparison internally?
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.
Sure, I choose to remove it because
- It was only called in one place
- It only forwarded it's arguments to
parse
and panicked on failure
Taking this into account I don't think the existence of this function is really justified, especially since I would have had to add another parameter to it.
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.
Your reasoning sounds good to me.
I wonder if fn substitute_dummy(self, other: Span) -> Span {
if *self == DUMMY_SP { other } else { *self }
} Which can be used like: Error(err_sp, ref msg) => panic!(cx.span_fatal(err_sp.substitute_dummy(sp), msg)) |
Thanks for tackling this, it's definitely annoying. |
Regarding
which again does not seem to justify adding such a method to me. |
Your choice, but I do think abstracting out this pattern is a good way to encourage avoiding printing DUMMY_SP even if it isn't used that much right now (even 3 uses seems like enough to justify it for me). |
Alright, should I add the method and change the other usages in this pull request or does that require another? |
I think doing it in this PR is fine. |
I added the suggested method and have to admit that the code looks cleaner that way :) |
@bors r+ Thanks! |
📌 Commit d46e840 has been approved by |
The ideas is to use the span of the complete macro invocation if the span of a macro error is `DUMMY_SP`. fixes rust-lang#7970
The ideas is to use the span of the complete macro invocation if the span of a macro error is `DUMMY_SP`. fixes #7970
💔 Test failed - auto-linux-32-opt |
@bors: retry On Tue, Aug 11, 2015 at 5:39 PM, bors notifications@github.com wrote:
|
⚡ Previous build results for auto-linux-64-nopt-t, auto-linux-64-opt, auto-mac-32-opt, auto-mac-64-nopt-t, auto-mac-64-opt, auto-win-gnu-32-opt, auto-win-msvc-32-opt, auto-win-msvc-64-opt are reusable. Rebuilding only auto-linux-32-nopt-t, auto-linux-32-opt, auto-linux-64-x-android-t, auto-win-gnu-32-nopt-t, auto-win-gnu-64-nopt-t, auto-win-gnu-64-opt... |
The ideas is to use the span of the complete macro invocation if the span of a macro error is
DUMMY_SP
.fixes #7970