-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Give me a way to emit all the delayed bugs as errors (add -Zeagerly-emit-delayed-bugs
)
#119872
Give me a way to emit all the delayed bugs as errors (add -Zeagerly-emit-delayed-bugs
)
#119872
Conversation
There are two places that handle normal delayed bugs. This commit factors out some repeated code. Also, we can use `std::mem::take` instead of `std::mem::replace`.
LL | trait Foo {} | ||
| ^^^^^^^^^ | ||
|
||
error: expected fulfillment errors |
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.
It's very strange that compiletest doesn't make you //~ expected fulfillment errors
, though I consider that bug to be orthogonal to this PR.
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.
It's not a bug, //~
only checks diagnostics that have a (non-dummy) span.
You should be able to do // error-pattern: expected fulfillment errors
at the top of the file (while keeping the other //~
s).
Just last week I removed
I think this new option should handle good path delayed bugs. Currently I also wonder if And that makes me wonder if the two options could be combined. Could we drop this PR and just change |
I'm happy to implement this. I can see why emitting good-path bugs as errors should happen if we're emitting delayed bugs.
I don't care about naming really. As long as this helps make sure we preserve the functionality that's being lost in #119871.
I have a hunch that it would be unnecessarily noisy to emit all bugs on |
Can you give an example of how you would use this new flag? I'm not doubting that you would, I just want to understand how it would get used, in case that gives me ideas for alternatives. |
I can't give a hard example of a specific ICE I've fixed where I've needed to use Before this PR, I would have acquire such a stack trace by starting at With this PR, I would simply add Footnotes
|
Thanks for the info. I think the updated |
04532e9
to
7df43d3
Compare
I'm not certain that we landed on an obvious correct name for the flag, so I didn't change that yet, but I did cherry-pick 3330940 to consolidate good path bugs into the regular error reporting pathway. Now |
|
||
Level::ForceWarning(_) | ||
| Level::Warning | ||
| Level::DelayedBug(DelayedBugKind::GoodPath) |
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.
This seems wrong. Good path delayed bugs, when emitted, are errors just as much as normal delayed bugs.
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.
No. Good path bugs are not errors, since they are defused by emitting warnings or error diagnostics.
Returning an ErrorGuaranteed here would be promising that compilation fails.
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.
I think you're looking at the wrong end. If you fail to emit a warning or an error, the the good path delayed bug is emitted as a bug. It has "bug" in the name!
let diagnostic = Diagnostic::new(DelayedBug, msg); | ||
let backtrace = std::backtrace::Backtrace::capture(); | ||
inner.good_path_delayed_bugs.push(DelayedDiagnostic::with_backtrace(diagnostic, backtrace)); | ||
DiagnosticBuilder::<()>::new(self, DelayedBug(DelayedBugKind::GoodPath), msg).emit() |
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.
Should be ErrorGuaranteed
instead of ()
, and also this method can return ErrorGuaranteed
just like span_delayed_bug
.
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.
It is not correct to return ErrorGuaranteed
from good_path_bug
.
If I delayed a good path bug, emitted a warning-level diagnostic to suppress the good path bugs from causing an ICE, then constructed a Ty::new_error
from that ErrorGuranteed
, I could end up with a TyKind::Error
in codegen. That's not sound.
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.
Hmm, ok, I see what you're saying. I hate good path delayed bugs! I'd love to get rid of them, I think the one in TypeErrCtxt::drop
is bogus and should be something else (though I haven't worked out what, yet) and the other one in trimmed_def_paths
I wonder if it's even worth having.
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.
Ok, but for now, I'd rather keep what I have so we don't accidentally expose new ways for people to make ErrorGuaranteed
s out of nothing. Creating an ErrorGuaranteed
when you shouldn't have one could lead to really bad bugs that can go unnoticed and it's not worth a minor cleanup imo.
It's possible we could construct the diagnostic as a DiagnosticBuilder<ErrorGuranteed>
, but the emit
call still should return None
for clarity, and the fn good_path_bug
user-facing API still needs to return ()
for correctness, so I don't see the harm in just making it act function as a DiagnosticBuilder<()>
always.
self.good_path_delayed_bugs | ||
.push(DelayedDiagnostic::with_backtrace(diagnostic.clone(), backtrace)); | ||
|
||
return None; |
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.
And here, can return an ErrorGuaranteed
. So there's scope for more code sharing between these two match arms.
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.
See above
/// Its `EmissionGuarantee` is `ErrorGuaranteed`. | ||
DelayedBug, | ||
/// Its `EmissionGuarantee` is `ErrorGuaranteed` for `Normal` delayed bugs, and `()` for | ||
/// `GoodPath` delayed bugs. |
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.
Again, good path delayed bugs are also ErrorGuaranteed
.
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.
See above, this is not true
I'm content with the name Overall it LGTM, though my distaste for good path delayed bugs has risen a notch. I figure it's worth @oli-obk reviewing it as well, given my confusion above. |
oh yea, they are the worst 😆 @bors r=oli-obk,nnethercote |
…llaumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#119817 (Remove special-casing around `AliasKind::Opaque` when structurally resolving in new solver) - rust-lang#119819 (Check rust lints when an unknown lint is detected) - rust-lang#119872 (Give me a way to emit all the delayed bugs as errors (add `-Zeagerly-emit-delayed-bugs`)) - rust-lang#119877 (Add more information to `visit_projection_elem`) - rust-lang#119884 (Rename `--env` option flag to `--env-set`) - rust-lang#119885 (Revert rust-lang#113923) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#119872 - compiler-errors:eagerly-emit-delayed-bugs, r=oli-obk,nnethercote Give me a way to emit all the delayed bugs as errors (add `-Zeagerly-emit-delayed-bugs`) This is probably a *better* way to inspect all the delayed bugs in a program that what exists currently (and therefore makes it very easy to choose the right number `N` with `-Zemit-err-as-bug=N`, though I guess the naming is a bit ironic when you pair both of the flags together, but that feels like naming bikeshed more than anything). This pacifies my only concern with rust-lang#119871 (comment), because (afaict?) that PR doesn't allow you to intercept a delayed bug's stack trace anymore, which as someone who debugs the compiler a lot, is something that I can *promise* that I do. r? `@nnethercote` or `@oli-obk`
This is probably a better way to inspect all the delayed bugs in a program that what exists currently (and therefore makes it very easy to choose the right number
N
with-Zemit-err-as-bug=N
, though I guess the naming is a bit ironic when you pair both of the flags together, but that feels like naming bikeshed more than anything).This pacifies my only concern with #119871 (comment), because (afaict?) that PR doesn't allow you to intercept a delayed bug's stack trace anymore, which as someone who debugs the compiler a lot, is something that I can promise that I do.
r? @nnethercote or @oli-obk