-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add assert message to suggestion in lint assertions_on_constants #4635
Conversation
Currently I just reused the help message. I'm not 100% sure if this should be a suggestion. |
You created the |
Also you should be able to reuse this code from here to the end of the file: rust-clippy/clippy_lints/src/format.rs Line 73 in 54bf4ff
|
Yes I created it originally from the code expanded by I will change the names and try to simplify a bit. I'm not 100% sure what can be simplified and what's important but I guess the risk of someone accidentally writing the same code the macro generates are very slim (or maybe impossible because of the Should I for example keep things like |
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've gone over the if_chain
and left you some comments on things, that I think can be removed or should be renamed.
Since the match is pretty specific for this expansion if you only match on the "happy path", that leads to the begin_panic
call, I don't think that you also have to match the unrelated expanded parts. Also DropTemps
is only possible in expanded code and not in hand written code (IIUC), so we should be good here.
Yes, that would be great! While your at it, can you also remove this function: rust-clippy/clippy_lints/src/utils/mod.rs Lines 362 to 364 in 737f0a6
and use On the other hand, I think this refactor should be done in another PR. So
I think this is too big of a change for this unrelated PR. |
I'd suggest to do the refactor from my comment above and
in another PR. If you want to, you can do
in this PR or also in another PR, as off your choosing. |
dba6723
to
d66acc2
Compare
I think I will do the following in this PR:
And then split the rest into other PRs:
|
Thanks! @bors r+ |
📋 Looks like this PR is still in progress, ignoring approval. Hint: Remove WIP from this PR's title when it is ready for review. |
ping @Lythenas IIUC this PR is finished. Since this is still marked as WIP, are there still open points you want to address? |
Sorry forgot to remove the WIP. I'm all done here. |
Thanks! @bors r+ |
📌 Commit 6ee8d75 has been approved by |
Add assert message to suggestion in lint assertions_on_constants <!-- Thank you for making Clippy better! We're collecting our changelog from pull request descriptions. If your PR only updates to the latest nightly, you can leave the `changelog` entry as `none`. Otherwise, please write a short comment explaining your change. If your PR fixes an issue, you can add "fixes #issue_number" into this PR description. This way the issue will be automatically closed when your PR is merged. If you added a new lint, here's a checklist for things that will be checked during review or continuous integration. - [x] Followed [lint naming conventions][lint_naming] - [x] Added passing UI tests (including committed `.stderr` file) - [ ] `cargo test` passes locally - [x] Executed `./util/dev update_lints` - [ ] Added lint documentation - [ ] Run `./util/dev fmt` [lint_naming]: https://rust-lang.github.io/rfcs/0344-conventions-galore.html#lints Note that you can skip the above if you are just opening a WIP PR in order to get feedback. Delete this line and everything above before opening your PR --> - [x] suggest replacing `assert!(false, "msg")` with `panic!("msg")` - [x] extend to allow ~~variables~~ any expression for `"msg"` - ~~suggest replacing `assert!(false, "msg {}", "arg")` with `panic!("msg {}", "arg")`~~ changelog: add assert message to suggestion in lint assertions_on_constants Work towards fixing: #3575
☀️ Test successful - checks-travis, status-appveyor |
Use match_function_call wherever possible Move `match_function_call` to `utils` and use it wherever possible as discussed in #4635. changelog: none
Use match_function_call wherever possible Move `match_function_call` to `utils` and use it wherever possible as discussed in #4635. changelog: none
assert!(false, "msg")
withpanic!("msg")
variablesany expression for"msg"
suggest replacingassert!(false, "msg {}", "arg")
withpanic!("msg {}", "arg")
changelog: add assert message to suggestion in lint assertions_on_constants
Work towards fixing: #3575