Skip to content
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

NLL: diagnostics deviate from source line order for no obvious reason #51167

Closed
pnkfelix opened this issue May 29, 2018 · 7 comments
Closed

NLL: diagnostics deviate from source line order for no obvious reason #51167

pnkfelix opened this issue May 29, 2018 · 7 comments
Assignees
Labels
A-NLL Area: Non Lexical Lifetimes (NLL) NLL-diagnostics Working torwads the "diagnostic parity" goal
Milestone

Comments

@pnkfelix
Copy link
Member

pnkfelix commented May 29, 2018

Consider:

https://github.com/rust-lang/rust/blob/master/src/test/ui/span/send-is-not-static-ensures-scoping.nll.stderr

compare it to the AST borrowck output:

https://github.com/rust-lang/rust/blob/master/src/test/ui/span/send-is-not-static-ensures-scoping.stderr

  1. Why are we inverting the order in which we report these diagnostics?
  2. We may want to consider not doing that. Even if it means e.g. buffering the diangotics and sorting them before emitting them, or some similar hack. (I admit I am loathe to do this since I myself really like when I am able to correlate the RUST_LOG output with diagnostic output. But if necessary, we could add a -Z flag to turn off the buffer+sorting, in order to bring back such correlation. For end users, buffering+sorting is probably a net win.)

An important reason to prioritize this: Fixing this is likely going to make our internal process for comparing the diagnostic output more efficient.

@pnkfelix pnkfelix added WG-compiler-nll NLL-diagnostics Working torwads the "diagnostic parity" goal A-NLL Area: Non Lexical Lifetimes (NLL) labels May 29, 2018
@nikomatsakis nikomatsakis added this to the Rust 2018 Preview 2 milestone Jun 29, 2018
@nikomatsakis
Copy link
Contributor

Marking as Edition Preview 2 because .. maybe an easy fix.

@nikomatsakis
Copy link
Contributor

I think we should just try visiting the basic blocks in reverse-postfix order. The visit occurs here:

fn analyze_results(&mut self, flow_uninit: &mut Self::FlowState) {
let flow = flow_uninit;
for bb in self.mir().basic_blocks().indices() {
flow.reset_to_entry_of(bb);
self.process_basic_block(bb, flow);
}
}

and in particular the for loop here goes over the basic blocks in an arbitrary order

for bb in self.mir().basic_blocks().indices() {

What we want to do is to go over in reverse post-order, which basically maps to execution order as we would normally define it. There is a function reverse_postorder that already exists to compute this ordering -- it returns an Iterator<Item = BasicBlock> -- and you can see some other random code that uses it here:

let mut rpo = traversal::reverse_postorder(mir);

So we basically want to change that code to iterate over the result of reverse_postorder.

@nikomatsakis nikomatsakis added I-nominated E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. labels Jul 3, 2018
@nikomatsakis nikomatsakis removed E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. I-nominated labels Jul 6, 2018
@nikomatsakis
Copy link
Contributor

OK, @csmoe did the RPO trick -- it definitely helped, but it doesn't seem to have fixed @pnkfelix's example. Not sure @pnkfelix how many more such examples there are -- however, it occurs to me -- @spastorino is also adding some buffering that we might use to do sorting after the fact, as well.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 7, 2018
Visit the mir basic blocks in reverse-postfix order

cc rust-lang#51167
r? @nikomatsakis
@nikomatsakis
Copy link
Contributor

Assigning to @spastorino as this should get fixed as a side-effect of #46908

@spastorino
Copy link
Member

Assigning to @pnkfelix as he took over the migrate thing. I can help here if needed at some point.

@spastorino spastorino assigned pnkfelix and unassigned spastorino Jul 23, 2018
@pnkfelix
Copy link
Member Author

@nikomatsakis do you think this should remain on EP2, or should we move it to RC?

(I'm going to take a shot at resolving it today, or at least doing as much as I can via the buffering we added. But still, time is tight for EP2.)

@pnkfelix
Copy link
Member Author

moving this to RC as I think it is sufficiently low priority that it should not block EP2 nor NLL's release in EP2.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Aug 1, 2018
…r=petrochenkov

NLL: sort diagnostics by span

Sorting the output diagnostics by span is a long planned revision to the NLL diagnostics that we hope will yield a less surprising user experience in some case.

Once we got them buffered, it was trivial to implement. (The hard part is skimming the resulting changes to the diagnostics to make sure nothing broke... Note that I largely rubber-stamped the `#[rustc_regions]` output change.)

Fix rust-lang#51167
pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 1, 2018
…r=petrochenkov

NLL: sort diagnostics by span

Sorting the output diagnostics by span is a long planned revision to the NLL diagnostics that we hope will yield a less surprising user experience in some case.

Once we got them buffered, it was trivial to implement. (The hard part is skimming the resulting changes to the diagnostics to make sure nothing broke... Note that I largely rubber-stamped the `#[rustc_regions]` output change.)

Fix rust-lang#51167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non Lexical Lifetimes (NLL) NLL-diagnostics Working torwads the "diagnostic parity" goal
Projects
None yet
Development

No branches or pull requests

3 participants