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

Move emit_stashed_diagnostic call in rustfmt. #121615

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

nnethercote
Copy link
Contributor

This call was added to parse_crate_mod in #121487, to fix a case where a stashed diagnostic wasn't emitted. But there is another path where a stashed diagnostic might fail to be emitted if there's a parse error, if the build call in parse_crate_inner fails before parse_crate_mod is reached.

So this commit moves the emit_stashed_diagnostic call outwards, from parse_crate_mod to format_project, just after the Parser::parse_crate call. This should be far out enough to catch any parsing errors.

Fixes #121517.

r? @oli-obk
cc @ytmimi

This call was added to `parse_crate_mod` in rust-lang#121487, to fix a case where
a stashed diagnostic wasn't emitted. But there is another path where a
stashed diagnostic might fail to be emitted if there's a parse error, if
the `build` call in `parse_crate_inner` fails before `parse_crate_mod`
is reached.

So this commit moves the `emit_stashed_diagnostic` call outwards, from
`parse_crate_mod` to `format_project`, just after the
`Parser::parse_crate` call. This should be far out enough to catch any
parsing errors.

Fixes rust-lang#121517.
@rustbot
Copy link
Collaborator

rustbot commented Feb 25, 2024

Some changes occurred in src/tools/rustfmt

cc @rust-lang/rustfmt

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 25, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Feb 26, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 26, 2024

📌 Commit bf7d1b5 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 26, 2024
@ytmimi
Copy link
Contributor

ytmimi commented Feb 26, 2024

@nnethercote your explanation makes sense to me. Thank you for working on this fix!

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#121389 (llvm-wrapper: fix few warnings)
 - rust-lang#121493 (By changing some attributes to only_local, reducing encoding attributes in the crate metadate.)
 - rust-lang#121615 (Move `emit_stashed_diagnostic` call in rustfmt.)
 - rust-lang#121617 (Actually use the right closure kind when checking async Fn goals)
 - rust-lang#121628 (Do not const prop unions)
 - rust-lang#121629 (fix some references to no-longer-existing ReprOptions.layout_seed)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9d5ab73 into rust-lang:master Feb 26, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 26, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 26, 2024
Rollup merge of rust-lang#121615 - nnethercote:fix-121517, r=oli-obk

Move `emit_stashed_diagnostic` call in rustfmt.

This call was added to `parse_crate_mod` in rust-lang#121487, to fix a case where a stashed diagnostic wasn't emitted. But there is another path where a stashed diagnostic might fail to be emitted if there's a parse error, if the `build` call in `parse_crate_inner` fails before `parse_crate_mod` is reached.

So this commit moves the `emit_stashed_diagnostic` call outwards, from `parse_crate_mod` to `format_project`, just after the `Parser::parse_crate` call. This should be far out enough to catch any parsing errors.

Fixes rust-lang#121517.

r? `@oli-obk`
cc `@ytmimi`
@nnethercote nnethercote deleted the fix-121517 branch February 26, 2024 21:15
nnethercote added a commit to nnethercote/rust that referenced this pull request Feb 28, 2024
I removed it in rust-lang#121206 because I thought thought it wasn't necessary.
But then I had to add an `emit_stashed_diagnostics` call elsewhere in
rustfmt to avoid the assertion failure (which took two attempts to get
right, rust-lang#121487 and rust-lang#121615), and now there's an assertion failure in
clippy as well (rust-lang/rust-clippy#12364).

So this commit just reinstates the call in `DiagCtxtInner::drop`. It
also reverts the rustfmt changes from rust-lang#121487 and rust-lang#121615, though it
keeps the tests added for those PRs.
nnethercote added a commit to nnethercote/rust that referenced this pull request Feb 29, 2024
I removed it in rust-lang#121206 because I thought thought it wasn't necessary.
But then I had to add an `emit_stashed_diagnostics` call elsewhere in
rustfmt to avoid the assertion failure (which took two attempts to get
right, rust-lang#121487 and rust-lang#121615), and now there's an assertion failure in
clippy as well (rust-lang/rust-clippy#12364).

So this commit just reinstates the call in `DiagCtxtInner::drop`. It
also reverts the rustfmt changes from rust-lang#121487 and rust-lang#121615, though it
keeps the tests added for those PRs.
nnethercote added a commit to nnethercote/rust that referenced this pull request Mar 1, 2024
I removed it in rust-lang#121206 because I thought thought it wasn't necessary.
But then I had to add an `emit_stashed_diagnostics` call elsewhere in
rustfmt to avoid the assertion failure (which took two attempts to get
right, rust-lang#121487 and rust-lang#121615), and now there's an assertion failure in
clippy as well (rust-lang/rust-clippy#12364).

So this commit just reinstates the call in `DiagCtxtInner::drop`. It
also reverts the rustfmt changes from rust-lang#121487 and rust-lang#121615, though it
keeps the tests added for those PRs.
calebcartwright pushed a commit to calebcartwright/rust that referenced this pull request Jun 22, 2024
Move `emit_stashed_diagnostic` call in rustfmt.

This call was added to `parse_crate_mod` in rust-lang#121487, to fix a case where a stashed diagnostic wasn't emitted. But there is another path where a stashed diagnostic might fail to be emitted if there's a parse error, if the `build` call in `parse_crate_inner` fails before `parse_crate_mod` is reached.

So this commit moves the `emit_stashed_diagnostic` call outwards, from `parse_crate_mod` to `format_project`, just after the `Parser::parse_crate` call. This should be far out enough to catch any parsing errors.

Fixes rust-lang#121517.

r? `@oli-obk`
cc `@ytmimi`
calebcartwright pushed a commit to calebcartwright/rust that referenced this pull request Jun 22, 2024
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#121389 (llvm-wrapper: fix few warnings)
 - rust-lang#121493 (By changing some attributes to only_local, reducing encoding attributes in the crate metadate.)
 - rust-lang#121615 (Move `emit_stashed_diagnostic` call in rustfmt.)
 - rust-lang#121617 (Actually use the right closure kind when checking async Fn goals)
 - rust-lang#121628 (Do not const prop unions)
 - rust-lang#121629 (fix some references to no-longer-existing ReprOptions.layout_seed)

r? `@ghost`
`@rustbot` modify labels: rollup
calebcartwright pushed a commit to calebcartwright/rust that referenced this pull request Jun 22, 2024
I removed it in rust-lang#121206 because I thought thought it wasn't necessary.
But then I had to add an `emit_stashed_diagnostics` call elsewhere in
rustfmt to avoid the assertion failure (which took two attempts to get
right, rust-lang#121487 and rust-lang#121615), and now there's an assertion failure in
clippy as well (rust-lang/rust-clippy#12364).

So this commit just reinstates the call in `DiagCtxtInner::drop`. It
also reverts the rustfmt changes from rust-lang#121487 and rust-lang#121615, though it
keeps the tests added for those PRs.
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.

rustfmt: self.stashed_diagnostics.is_empty()
5 participants