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

Review iterations on 0..xyz.len() -1 #8905

Open
dvermd opened this issue Oct 28, 2020 · 0 comments
Open

Review iterations on 0..xyz.len() -1 #8905

dvermd opened this issue Oct 28, 2020 · 0 comments
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@dvermd
Copy link
Contributor

dvermd commented Oct 28, 2020

Development Task

While working on clippy lints #8336, I encountered a bug where a loop goes iterates on 0..xyz.len() -1 to use copy() on a element and treat the last element xyz[xyz.len() - 1] after the loop without the copy().
This seems like an optimization.

But in the case of this loop

for i in 0..downstreams.len() - 1 {
there is a test missing on the last element.

Confirmed that this is a bug, thank you!
Originally posted by @andylokandy in #8890 (comment)

There are several other places that uses this optimization in the code. They may need inspection to prevent similar bugs.

Note: this particular bug is fixed in #8890

@dvermd dvermd added the type/enhancement The issue or PR belongs to an enhancement. label Oct 28, 2020
@dvermd dvermd mentioned this issue Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant