Skip to content

Account for new assert! desugaring in !condition suggestion - #145273

Merged
bors merged 1 commit into
rust-lang:masterfrom
estebank:not-not
Aug 12, 2025
Merged

Account for new assert! desugaring in !condition suggestion#145273
bors merged 1 commit into
rust-lang:masterfrom
estebank:not-not

Conversation

@estebank

Copy link
Copy Markdown
Contributor

rustc in #122661 is going to change the desugaring of assert! to be

match condition {true => {}
_ => panic!(),}

which will make the edge-case of condition being impl Not<Output = bool> while not being bool itself no longer a straightforward suggestion, but !!condition will coerce the expression to be bool, so it can be machine applicable.

Transposing rust-lang/rust-clippy#15453 to the rustc repo.

r? @samueltardieu

`rustc` is going to change the desugaring of `assert!` to be
```rust
match condition {
true => {}
_ => panic!(),
}
```
which will make the edge-case of `condition` being `impl Not<Output = bool>`
while not being `bool` itself no longer a straightforward suggestion,
but `!!condition` will coerce the expression to be `bool`, so it can be
machine applicable.
@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. labels Aug 11, 2025
@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@samueltardieu

Copy link
Copy Markdown
Member

@bors r+ rollup=always

@bors

bors commented Aug 11, 2025

Copy link
Copy Markdown
Collaborator

📌 Commit 86853b3 has been approved by samueltardieu

It is now in the queue for this repository.

@borsbors 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 Aug 11, 2025
fmease added a commit to fmease/rust that referenced this pull request Aug 12, 2025
Account for new `assert!` desugaring in `!condition` suggestion
`rustc` in rust-lang#122661 is going to change the desugaring of `assert!` to be
```rust
match condition {
true => {}
_ => panic!(),
}
```
which will make the edge-case of `condition` being `impl Not<Output = bool>` while not being `bool` itself no longer a straightforward suggestion, but `!!condition` will coerce the expression to be `bool`, so it can be machine applicable.
Transposing rust-lang/rust-clippy#15453 to the rustc repo.
r? ``@samueltardieu``
@fmeasefmease mentioned this pull request Aug 12, 2025
bors added a commit that referenced this pull request Aug 12, 2025
Rollup of 15 pull requests
Successful merges:
- #131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
- #139806 (std: sys: pal: uefi: Overhaul Time)
- #144386 (Extract TraitImplHeader in AST/HIR)
- #144542 (Stabilize `sse4a` and `tbm` target features)
- #144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
- #145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
- #145214 (fix: re-enable self-assignment)
- #145216 (rustdoc: correct negative-to-implicit discriminant display)
- #145238 (Tweak invalid builtin attribute output)
- #145249 (Rename entered trace span variables from `_span` to `_trace`)
- #145251 (Support using #[unstable_feature_bound] on trait)
- #145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
- #145260 (Make explicit guarantees about `Vec`’s allocator)
- #145263 (Update books)
- #145273 (Account for new `assert!` desugaring in `!condition` suggestion)
r? `@ghost`
`@rustbot` modify labels: rollup
fmease added a commit to fmease/rust that referenced this pull request Aug 12, 2025
Account for new `assert!` desugaring in `!condition` suggestion
`rustc` in rust-lang#122661 is going to change the desugaring of `assert!` to be
```rust
match condition {
true => {}
_ => panic!(),
}
```
which will make the edge-case of `condition` being `impl Not<Output = bool>` while not being `bool` itself no longer a straightforward suggestion, but `!!condition` will coerce the expression to be `bool`, so it can be machine applicable.
Transposing rust-lang/rust-clippy#15453 to the rustc repo.
r? ```@samueltardieu```
@fmeasefmease mentioned this pull request Aug 12, 2025
bors added a commit that referenced this pull request Aug 12, 2025
Rollup of 14 pull requests
Successful merges:
- #131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
- #139806 (std: sys: pal: uefi: Overhaul Time)
- #144210 (std: thread: Return error if setting thread stack size fails)
- #144386 (Extract TraitImplHeader in AST/HIR)
- #144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
- #145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
- #145214 (fix: re-enable self-assignment)
- #145216 (rustdoc: correct negative-to-implicit discriminant display)
- #145238 (Tweak invalid builtin attribute output)
- #145249 (Rename entered trace span variables from `_span` to `_trace`)
- #145251 (Support using #[unstable_feature_bound] on trait)
- #145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
- #145263 (Update books)
- #145273 (Account for new `assert!` desugaring in `!condition` suggestion)
r? `@ghost`
`@rustbot` modify labels: rollup
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 12, 2025
Account for new `assert!` desugaring in `!condition` suggestion
`rustc` in rust-lang#122661 is going to change the desugaring of `assert!` to be
```rust
match condition {
true => {}
_ => panic!(),
}
```
which will make the edge-case of `condition` being `impl Not<Output = bool>` while not being `bool` itself no longer a straightforward suggestion, but `!!condition` will coerce the expression to be `bool`, so it can be machine applicable.
Transposing rust-lang/rust-clippy#15453 to the rustc repo.
r? ````@samueltardieu````
@ZalatharZalathar mentioned this pull request Aug 12, 2025
bors added a commit that referenced this pull request Aug 12, 2025
Rollup of 17 pull requests
Successful merges:
- #131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
- #139806 (std: sys: pal: uefi: Overhaul Time)
- #144210 (std: thread: Return error if setting thread stack size fails)
- #144386 (Extract TraitImplHeader in AST/HIR)
- #144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
- #145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
- #145214 (fix: re-enable self-assignment)
- #145216 (rustdoc: correct negative-to-implicit discriminant display)
- #145238 (Tweak invalid builtin attribute output)
- #145249 (Rename entered trace span variables from `_span` to `_trace`)
- #145251 (Support using #[unstable_feature_bound] on trait)
- #145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
- #145260 (Make explicit guarantees about `Vec`’s allocator)
- #145263 (Update books)
- #145273 (Account for new `assert!` desugaring in `!condition` suggestion)
- #145283 (Make I-miscompile imply I-prioritize)
- #145291 (bootstrap: Only warn about `rust.debug-assertions` if downloading rustc)
r? `@ghost`
`@rustbot` modify labels: rollup
@ZalatharZalathar mentioned this pull request Aug 12, 2025
bors added a commit that referenced this pull request Aug 12, 2025
Rollup of 17 pull requests
Successful merges:
- #131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
- #139806 (std: sys: pal: uefi: Overhaul Time)
- #144386 (Extract TraitImplHeader in AST/HIR)
- #144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
- #145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
- #145214 (fix: re-enable self-assignment)
- #145216 (rustdoc: correct negative-to-implicit discriminant display)
- #145238 (Tweak invalid builtin attribute output)
- #145249 (Rename entered trace span variables from `_span` to `_trace`)
- #145251 (Support using #[unstable_feature_bound] on trait)
- #145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
- #145260 (Make explicit guarantees about `Vec`’s allocator)
- #145263 (Update books)
- #145273 (Account for new `assert!` desugaring in `!condition` suggestion)
- #145283 (Make I-miscompile imply I-prioritize)
- #145291 (bootstrap: Only warn about `rust.debug-assertions` if downloading rustc)
- #145292 (Fix a typo in range docs)
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 2102eeb into rust-lang:masterAug 12, 2025
10 checks passed
@rustbotrustbot added this to the 1.91.0 milestone Aug 12, 2025
rust-timer added a commit that referenced this pull request Aug 12, 2025
Rollup merge of #145273 - estebank:not-not, r=samueltardieu
Account for new `assert!` desugaring in `!condition` suggestion
`rustc` in #122661 is going to change the desugaring of `assert!` to be
```rust
match condition {
true => {}
_ => panic!(),
}
```
which will make the edge-case of `condition` being `impl Not<Output = bool>` while not being `bool` itself no longer a straightforward suggestion, but `!!condition` will coerce the expression to be `bool`, so it can be machine applicable.
Transposing rust-lang/rust-clippy#15453 to the rustc repo.
r? `````@samueltardieu`````
github-actionsBot pushed a commit to rust-lang/miri that referenced this pull request Aug 13, 2025
Rollup of 17 pull requests
Successful merges:
- rust-lang/rust#131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
- rust-lang/rust#139806 (std: sys: pal: uefi: Overhaul Time)
- rust-lang/rust#144386 (Extract TraitImplHeader in AST/HIR)
- rust-lang/rust#144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
- rust-lang/rust#145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
- rust-lang/rust#145214 (fix: re-enable self-assignment)
- rust-lang/rust#145216 (rustdoc: correct negative-to-implicit discriminant display)
- rust-lang/rust#145238 (Tweak invalid builtin attribute output)
- rust-lang/rust#145249 (Rename entered trace span variables from `_span` to `_trace`)
- rust-lang/rust#145251 (Support using #[unstable_feature_bound] on trait)
- rust-lang/rust#145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
- rust-lang/rust#145260 (Make explicit guarantees about `Vec`’s allocator)
- rust-lang/rust#145263 (Update books)
- rust-lang/rust#145273 (Account for new `assert!` desugaring in `!condition` suggestion)
- rust-lang/rust#145283 (Make I-miscompile imply I-prioritize)
- rust-lang/rust#145291 (bootstrap: Only warn about `rust.debug-assertions` if downloading rustc)
- rust-lang/rust#145292 (Fix a typo in range docs)
r? `@ghost`
`@rustbot` modify labels: rollup
github-actionsBot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Aug 18, 2025
Rollup of 17 pull requests
Successful merges:
- rust-lang/rust#131477 (Apple: Always pass SDK root when linking with `cc`, and pass it via `SDKROOT` env var)
- rust-lang/rust#139806 (std: sys: pal: uefi: Overhaul Time)
- rust-lang/rust#144386 (Extract TraitImplHeader in AST/HIR)
- rust-lang/rust#144921 (Don't emit `rustdoc::broken_intra_doc_links` for GitHub-flavored Markdown admonitions like `[!NOTE]`)
- rust-lang/rust#145155 (Port `#[allow_internal_unsafe]` to the new attribute system (attempt 2))
- rust-lang/rust#145214 (fix: re-enable self-assignment)
- rust-lang/rust#145216 (rustdoc: correct negative-to-implicit discriminant display)
- rust-lang/rust#145238 (Tweak invalid builtin attribute output)
- rust-lang/rust#145249 (Rename entered trace span variables from `_span` to `_trace`)
- rust-lang/rust#145251 (Support using #[unstable_feature_bound] on trait)
- rust-lang/rust#145253 (Document compiler and stdlib in stage1 in `pr-check-2` CI job)
- rust-lang/rust#145260 (Make explicit guarantees about `Vec`’s allocator)
- rust-lang/rust#145263 (Update books)
- rust-lang/rust#145273 (Account for new `assert!` desugaring in `!condition` suggestion)
- rust-lang/rust#145283 (Make I-miscompile imply I-prioritize)
- rust-lang/rust#145291 (bootstrap: Only warn about `rust.debug-assertions` if downloading rustc)
- rust-lang/rust#145292 (Fix a typo in range docs)
r? `@ghost`
`@rustbot` modify labels: rollup
flip1995 pushed a commit to flip1995/rust that referenced this pull request Aug 22, 2025
Account for new `assert!` desugaring in `!condition` suggestion
`rustc` in rust-lang#122661 is going to change the desugaring of `assert!` to be
```rust
match condition {
true => {}
_ => panic!(),
}
```
which will make the edge-case of `condition` being `impl Not<Output = bool>` while not being `bool` itself no longer a straightforward suggestion, but `!!condition` will coerce the expression to be `bool`, so it can be machine applicable.
Transposing rust-lang/rust-clippy#15453 to the rustc repo.
r? `````@samueltardieu`````
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 2, 2025
…r=petrochenkov
fix: Filter suggestion parts that match existing code
While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information.
Before rust-lang#145273 (`Diff` style)
![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46)
After rust-lang#145273 ("multi-line" style)
![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0)
The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be.
To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out.
tgross35 added a commit to tgross35/rust that referenced this pull request Sep 3, 2025
…r=petrochenkov
fix: Filter suggestion parts that match existing code
While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information.
Before rust-lang#145273 (`Diff` style)
![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46)
After rust-lang#145273 ("multi-line" style)
![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0)
The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be.
To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out.
tgross35 added a commit to tgross35/rust that referenced this pull request Sep 3, 2025
…r=petrochenkov
fix: Filter suggestion parts that match existing code
While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information.
Before rust-lang#145273 (`Diff` style)
![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46)
After rust-lang#145273 ("multi-line" style)
![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0)
The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be.
To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 5, 2025
…r=petrochenkov
fix: Filter suggestion parts that match existing code
While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information.
Before rust-lang#145273 (`Diff` style)
![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46)
After rust-lang#145273 ("multi-line" style)
![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0)
The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be.
To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out.
try-job: aarch64-apple
bors added a commit that referenced this pull request Sep 5, 2025
fix: Filter suggestion parts that match existing code
While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in #145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information.
Before #145273 (`Diff` style)
![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46)
After #145273 ("multi-line" style)
![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0)
The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be.
To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out.
try-job: aarch64-apple
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Sep 18, 2025
fix: Filter suggestion parts that match existing code
While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang/rust#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information.
Before rust-lang/rust#145273 (`Diff` style)
![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46)
After rust-lang/rust#145273 ("multi-line" style)
![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0)
The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be.
To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out.
try-job: aarch64-apple
Muscraft pushed a commit to Muscraft/rust that referenced this pull request Sep 24, 2025
…petrochenkov
fix: Filter suggestion parts that match existing code
While testing my changes to make `rustc` use `annotate-snippets`, I encountered a new `clippy` test failure stemming from [two](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R275-R278) [suggestion](https://github.com/rust-lang/rust/pull/145273/files#diff-6e8403e31463539666afbc00479cb416dc767a518f562b6e2960630953ee7da2R289-R292) output changes in rust-lang#145273. The new output in these two cases feels like a regression as it is not as clear as the old output, and adds unnecessary information.
Before rust-lang#145273 (`Diff` style)
![before](https://github.com/user-attachments/assets/36f33635-cbce-45f1-823d-0cbe6f0cfe46)
After rust-lang#145273 ("multi-line" style)
![after](https://github.com/user-attachments/assets/d4cb00b8-5a42-436e-9329-db84347138f0)
The reason for the change was that a new suggestion part (which matches existing code) was added on a different line than the existing parts, causing the suggestion style to change from `Diff` to "multi-line". Since this new part matches existing code, no code changes show up in the output for it, but it still makes the suggestion style "multi-line" when it doesn't need to be.
To get the old output back, I made it so that suggestion parts that perfectly match existing code get filtered out.
try-job: aarch64-apple
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-clippyRelevant to the Clippy team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@estebank@rustbot@samueltardieu@bors