Skip to content

Expanded span printing #29995

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

Merged
merged 1 commit into from
Dec 8, 2015
Merged

Conversation

DanielJCampbell
Copy link
Contributor

r? @nrc

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (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. Due to 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.

cm.span_to_string(sp));
assert_eq!(sstr, res_str);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: reinstate the newline at the end of the file

@nrc
Copy link
Member

nrc commented Nov 23, 2015

This looks good. I would perhaps try a recursive approach rather than iterative - since we expect traces to be fairly short and acyclic, and there is no pressure to be ultra-fast.

while cur_span.expn_id != NO_EXPANSION && cur_span.expn_id != COMMAND_LINE_EXPN {
let old_span = cur_span;
let new_span = self.with_expn_info(old_span.expn_id,
|ei| ei.map(|ei| ei.call_site));
Copy link
Member

Choose a reason for hiding this comment

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

You expand iteratively down the call_site branch, but only one step down the callee branch (below), it seems to me you should be iterating to the end of both branches (which would be easier if you were being recursive). At that point you probably need to think about indentation or something to distinguish the structure.

@DanielJCampbell
Copy link
Contributor Author

Refactored to recurse down callee and call-site spans

/// CALLEE:
/// Callee span, or 'None'
/// CALLSITE:
/// Callsite span, or 'None'
Copy link
Member

Choose a reason for hiding this comment

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

Formatting of the output:

  • I would not use caps for callee/callsite - no need to draw attention to the headings
  • I would truncate the snippet to the smaller of 50 chars/one line + ...
  • rather than printing None, how about not printing anything at all (i.e., no heading or span)

@nrc
Copy link
Member

nrc commented Dec 7, 2015

I like this approach much better! Thanks for making the changes. I think all these comments are fairly minor.

@DanielJCampbell
Copy link
Contributor Author

Committed the suggested changes.

|ei| ei.map(|ei| ei.call_site.clone()));

indent.push_str(" ");
let mut flag = true;
Copy link
Member

Choose a reason for hiding this comment

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

could you give flag a more descriptive name please?

first line.
Callsite:
blork.rs:1:1: 1:12
first line.
Copy link
Member

Choose a reason for hiding this comment

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

Could you wrap he snippets in back ticks please - it'll make it easier to distinguish the code snippets from the rest

@nrc
Copy link
Member

nrc commented Dec 7, 2015

Last two comments! r+ with those addressed.

@DanielJCampbell DanielJCampbell force-pushed the Expanded-Span-Printing branch 2 times, most recently from b0606e5 to 5ab470b Compare December 8, 2015 00:09
@nrc
Copy link
Member

nrc commented Dec 8, 2015

@bors: r+

@bors
Copy link
Collaborator

bors commented Dec 8, 2015

📌 Commit 5ab470b has been approved by nrc

@nrc
Copy link
Member

nrc commented Dec 8, 2015

@bors: r+

@bors
Copy link
Collaborator

bors commented Dec 8, 2015

📌 Commit 6b6fb7b has been approved by nrc

@bors
Copy link
Collaborator

bors commented Dec 8, 2015

⌛ Testing commit 6b6fb7b with merge 6941b25...

@bors bors merged commit 6b6fb7b into rust-lang:master Dec 8, 2015
@DanielJCampbell DanielJCampbell deleted the Expanded-Span-Printing branch December 9, 2015 23:35
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.

5 participants