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

rustc: Start moving toward "try_get is a bug" for incremental #44071

Merged
merged 6 commits into from
Aug 26, 2017

Conversation

alexcrichton
Copy link
Member

This PR is an effort to burn down some of the work items on #42633. The basic change here was to leave the try_get function exposed but have it return a DiagnosticBuilder instead of a CycleError. This means that it should be a compiler bug to not handle the error as dropping a diagnostic should result in a complier panic.

After that change it was then necessary to update the compiler's callsites of try_get to handle the error coming out. These were handled as:

  • The sized_constraint and needs_drop_raw checks take the diagnostic and defer it as a compiler bug. This was a new piece of functionality added to the error handling infrastructure, and the idea is that for both these checks a "real" compiler error should be emitted elsewhere, so it's only a bug if we don't actually emit the complier error elsewhere.
  • MIR inlining was updated to just ignore the diagnostic. This is being tracked by change how MIR inlining handles cycles #43542 which sounded like it either already had some work underway or was planning to change regardless.
  • The final case, item_path, is still sort of up for debate. At the time of this writing this PR simply removes the invocations of try_get there, assuming that the query will always succeed. This turns out to be true for the test suite anyway! It sounds like, though, that this logic was intended to assist in "weird" situations like RUST_LOG where debug implementations can trigger at any time. This PR would therefore, however, break those implementations.

I'm unfortunately sort of out of ideas on how to handle item_path, but other thoughts would be welcome!

Closes #42633

@rust-highfive
Copy link
Collaborator

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member Author

r? @nikomatsakis

@alexcrichton alexcrichton force-pushed the no-cycles branch 2 times, most recently from d2a5977 to b704502 Compare August 24, 2017 14:41
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 24, 2017

📌 Commit b704502 has been approved by nikomatsakis

@eddyb
Copy link
Member

eddyb commented Aug 24, 2017

The sized_constraint and needs_drop_raw checks take the diagnostic and defer it as a compiler bug

Hadn't considered this, very nice solution! As for everything else, I'm fine with non-user regressions.

@@ -205,7 +206,9 @@ pub struct CycleError<'a, 'tcx: 'a> {
}

impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
pub fn report_cycle(self, CycleError { span, cycle }: CycleError) {
pub fn report_cycle(self, CycleError { span, cycle }: CycleError)
Copy link
Member

Choose a reason for hiding this comment

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

Wait, can this and CycleError be private? The only reason they're public is for try_get, I think?
Also, CycleError can probably be decomposed into its fields now? Not sure though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure yeah, I'll try to do this.

@alexcrichton
Copy link
Member Author

@bors: r=nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 24, 2017

📌 Commit b26eb6c has been approved by nikomatsakis

@shepmaster shepmaster added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 25, 2017
@bors
Copy link
Contributor

bors commented Aug 25, 2017

☔ The latest upstream changes (presumably #44046) made this pull request unmergeable. Please resolve the merge conflicts.

This adds a function to `DiagnosticBuilder` to delay the entire diagnostic as a
bug to be emitted at a later time. This'll end up getting used in the compiler
in the subsequent commits...
This alters the return value of the `try_get` function so the error contains a
diagnostic rather than a `CycleError`. This way consumers are forced to take
*some* action (else they get a bug to an un-emitted diagnostic). This action
could be to emit the error itself, or in some cases delay the diagnostic as a
bug and continue.
The `sized_constraint` and `needs_drop_raw` queries both use `try_get` to detect
cycles, but in both of these cases the cycle indicates an error has happened
elsewhere in compilation. In these cases we can just delay the diagnostic to get
emitted as a bug later if we ended up forgetting to emit the error diagnostic.
It sounds like this is being handled elsewhere, so for now just preserve the
existing behavior of ignoring th error.
This seems like it may be likely to cause bugs with `RUST_LOG` and other
"interesting" scenarios, but it removes the usage of `try_get` for now!
@alexcrichton
Copy link
Member Author

@bors: r=nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 25, 2017

📌 Commit 11b9170 has been approved by nikomatsakis

@aidanhs
Copy link
Member

aidanhs commented Aug 26, 2017

@bors r-

[00:06:44] error[E0252]: the name `DiagnosticBuilder` is defined multiple times
[00:06:44]   --> /checkout/src/librustc/ty/maps.rs:13:26
[00:06:44]    |
[00:06:44] 11 | use errors::DiagnosticBuilder;
[00:06:44]    |     ------------------------- previous import of the type `DiagnosticBuilder` here
[00:06:44] 12 | use dep_graph::{DepConstructor, DepNode, DepNodeIndex};
[00:06:44] 13 | use errors::{Diagnostic, DiagnosticBuilder};
[00:06:44]    |                          ^^^^^^^^^^^^^^^^^ `DiagnosticBuilder` reimported here

@alexcrichton
Copy link
Member Author

@bors: r=nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 26, 2017

📌 Commit c766aa4 has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Aug 26, 2017

⌛ Testing commit c766aa4 with merge e7070dd...

bors added a commit that referenced this pull request Aug 26, 2017
rustc: Start moving toward "try_get is a bug" for incremental

This PR is an effort to burn down some of the work items on #42633. The basic change here was to leave the `try_get` function exposed but have it return a `DiagnosticBuilder` instead of a `CycleError`. This means that it should be a compiler bug to *not* handle the error as dropping a diagnostic should result in a complier panic.

After that change it was then necessary to update the compiler's callsites of `try_get` to handle the error coming out. These were handled as:

* The `sized_constraint` and `needs_drop_raw` checks take the diagnostic and defer it as a compiler bug. This was a new piece of functionality added to the error handling infrastructure, and the idea is that for both these checks a "real" compiler error should be emitted elsewhere, so it's only a bug if we don't actually emit the complier error elsewhere.
* MIR inlining was updated to just ignore the diagnostic. This is being tracked by #43542 which sounded like it either already had some work underway or was planning to change regardless.
* The final case, `item_path`, is still sort of up for debate. At the time of this writing this PR simply removes the invocations of `try_get` there, assuming that the query will always succeed. This turns out to be true for the test suite anyway! It sounds like, though, that this logic was intended to assist in "weird" situations like `RUST_LOG` where debug implementations can trigger at any time. This PR would therefore, however, break those implementations.

I'm unfortunately sort of out of ideas on how to handle `item_path`, but other thoughts would be welcome!

Closes #42633
@bors
Copy link
Contributor

bors commented Aug 26, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing e7070dd to master...

@bors bors merged commit c766aa4 into rust-lang:master Aug 26, 2017
@alexcrichton alexcrichton deleted the no-cycles branch August 27, 2017 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants