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

manual_slice_fill: do not initialize from the iterator #14191

Merged
merged 2 commits into from
Feb 22, 2025

Conversation

samueltardieu
Copy link
Contributor

@samueltardieu samueltardieu commented Feb 10, 2025

let mut tmp = vec![1, 2, 3];
for b in &mut tmp {
    *b = !*b;
}

must not suggest the invalid tmp.fill(!*b).

In addition, there is another commit which cleans up two function calls with no effect.

Fix #14189

changelog: [manual_slice_fill]: ensure that the initialization expression doesn't reference the iterator

@rustbot
Copy link
Collaborator

rustbot commented Feb 10, 2025

r? @Manishearth

rustbot has assigned @Manishearth.
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 Feb 10, 2025
@samueltardieu
Copy link
Contributor Author

r? clippy

@samueltardieu
Copy link
Contributor Author

samueltardieu commented Feb 10, 2025

(ping @lapla-cogito who is the author of this new lint)

@Manishearth
Copy link
Member

r? clippy

Still traveling

@rustbot rustbot assigned dswij and unassigned Centri3 Feb 10, 2025
@samueltardieu
Copy link
Contributor Author

Rebased

In both instances, `!assign_val.span.from_expansion()` – which is more
restrictive than `span_is_local(assign_val.span)` – has been required
already.
```rust
let mut tmp = vec![1, 2, 3];
for b in &mut tmp {
    *b = !*b;
}
```

must not suggest the invalid `tmp.fill(!*b)`.
Copy link
Member

@dswij dswij left a comment

Choose a reason for hiding this comment

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

Thanks!

@dswij dswij added this pull request to the merge queue Feb 22, 2025
Merged via the queue into rust-lang:master with commit d92da0f Feb 22, 2025
11 checks passed
@samueltardieu samueltardieu deleted the push-nwommozmsnos branch February 23, 2025 10:05
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.

manual_slice_fill shouldn't apply when the fill is variable
6 participants