Skip to content

relax needless_range_loop so that it reports only direct indexing #2118

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

Merged
merged 2 commits into from
Oct 10, 2017

Conversation

chyvonomys
Copy link
Contributor

This change relaxes needless_range_loop so that it doesn't report cases when variable is indexed with some complex expression. Currently changes suggested by lint are not correct, and in some cases not desired. This "aggressive" check was there since PR #2021.
Fixes #2106 #2036
Test code and linter outputs here:
https://gist.github.com/chyvonomys/fcdc306d38c0de7cb40764fa697be593

@oli-obk
Copy link
Contributor

oli-obk commented Oct 8, 2017

Can you add your tests to our test suite?

@chyvonomys
Copy link
Contributor Author

I think I can. That's basically another pair of files under tests/ui, right?
Is there way to run only specific test? I get lots of fails on latest code..

@chyvonomys
Copy link
Contributor Author

OK, figured it out.
I added 5 cases, only one of which should be linted. (I omitted manual_memcpy case which already has test in for_loop.*).

@oli-obk oli-obk merged commit 28c401f into rust-lang:master Oct 10, 2017
@oli-obk
Copy link
Contributor

oli-obk commented Oct 10, 2017

Thanks! Regression tests help a lot in preventing this issue from occurring again

@chyvonomys chyvonomys deleted the relax-needless-loop branch October 10, 2017 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants