Skip to content

Conversation

@rusty-satyam
Copy link

@rusty-satyam rusty-satyam commented Jun 9, 2025

fixes #14847
changelog: [useless_conversion]: improved adjustments function

@rustbot
Copy link
Collaborator

rustbot commented Jun 9, 2025

r? @Alexendoo

rustbot has assigned @Alexendoo.
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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 9, 2025
Copy link
Member

@samueltardieu samueltardieu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to add tests that shows how this PR changes the behavior of the lint. Don't hesitate to put exercise all the code paths to ensure that no edge case is being forgotten.

View changes since this review

Comment on lines +456 to +461
if !adjustments.is_empty() {
let mut target = adjustments[0].target;

for adj in adjustments {
target = adj.target;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks overly complicated, can't you use something like this?

Suggested change
if !adjustments.is_empty() {
let mut target = adjustments[0].target;
for adj in adjustments {
target = adj.target;
}
if let adjustments @ [.., Adjustment { target, .. }] = cx.typeck_results().expr_adjustments(expr) {

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggestion for useless_conversion with .into_iter() could be better

4 participants