Skip to content

Conversation

@andjsrk
Copy link

@andjsrk andjsrk commented Dec 26, 2025

AFAIK [0; 3] is basically a syntax sugar for [0, 0, 0] so it should return whether the repeat's element can have side effects, like what it does on arrays.
And it seems that the rule for unary operators and indexings can be applied to binary operators as well.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 26, 2025

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rust-log-analyzer

This comment has been minimized.

@Kivooeo
Copy link
Member

Kivooeo commented Dec 26, 2025

Would you like to add a test for this, to reflect new behaviour you changed here

Because on a first glance it's not obvious (at least to me)

@andjsrk
Copy link
Author

andjsrk commented Dec 27, 2025

I'm not sure where should I add a test:

  • tests/ui/expr.rs - Expr::can_have_side_effects is used in a few minor(in my opinion) places and is used widely in Clippy rather than rustc. If I decide to add a test in there, I guess testing code would look pretty unintuitive (could be improved by comments though).
  • compiler/rustc_hir/src/hir/tests.rs - maybe I should add tests here, but I guess runtime test is needed (not just checking successful compilation) and I have no idea about how to create an Expr...

@jdonszelmann
Copy link
Contributor

I agree with @Kivooeo here: something has to be tested. A ui test will show a piece of rust code now compiling (or warning) differently. I think this is supposed to change something about the diagnostics of binop expressions and array expressions. So ideally, I'd see a uitest showing a diagnostic that is different. In fact, I see some tests that failed in CI, likely because of this diagnostics change. If you run x test tests/ui/<specific-test> --bless it will update the expected output, which you can commit, to show what diagnostics changed from this change. Maybe you want to also add a specific test for the exact changed diagnostics behavior after this PR. Let me know if that makes sense!

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 6, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 6, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot
Copy link
Collaborator

rustbot commented Jan 6, 2026

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Jan 6, 2026
@andjsrk
Copy link
Author

andjsrk commented Jan 6, 2026

Maybe you want to also add a specific test for the exact changed diagnostics behavior after this PR.

@jdonszelmann I'm going to add a test for repeats([x; N]) as it seems no test checks Expr::can_have_side_effects on repeats, but as I asked above I have no idea about where should I add a test, could you let me know?

@Kivooeo
Copy link
Member

Kivooeo commented Jan 6, 2026

Add please this test to tests/ui/repeat-expr/

And I'm not sure why this changes to clippy were made?

@andjsrk
Copy link
Author

andjsrk commented Jan 6, 2026

  • clippy::needless_match relies on Expr::can_have_side_effects and it warns some code in the UI test for clippy::manual_clamp.
  • clippy::needless_bitwise_bool has test cases that require improvement of Expr::can_have_side_effects and some of them are resolved now.

These are the cause of test failures in CI and so I fixed them, did I something wrong?

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@andjsrk
Copy link
Author

andjsrk commented Jan 6, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 6, 2026
@samueltardieu
Copy link
Member

The Clippy part looks ok.

@jdonszelmann
Copy link
Contributor

yea, I think this looks reasonable. @bors r=jdonszelmann,samueltardieu rollup

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 8, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 8, 2026

📌 Commit d848437 has been approved by jdonszelmann,samueltardieu

It is now in the queue for this repository.

@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 8, 2026
@jdonszelmann
Copy link
Contributor

actually, stop, @bors r-

@rust-bors rust-bors bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 8, 2026
@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 8, 2026

Commit d848437 has been unapproved.

@rust-bors rust-bors bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 8, 2026
@jdonszelmann
Copy link
Contributor

I realised that I would also quite like to see a test for the binary operator change here. After that r=me

@jdonszelmann
Copy link
Contributor

@rustbot author

@andjsrk
Copy link
Author

andjsrk commented Jan 9, 2026

@bors r=jdonszelmann

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 9, 2026

@andjsrk: 🔑 Insufficient privileges: not in review users

@andjsrk
Copy link
Author

andjsrk commented Jan 9, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 9, 2026
@andjsrk
Copy link
Author

andjsrk commented Jan 9, 2026

@jdonszelmann I have no permission, please take action on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants