Skip to content

Implement "Use last" lint#3832

Merged
bors merged 2 commits intorust-lang:masterfrom
HarrisonMc555:use_last
May 27, 2019
Merged

Implement "Use last" lint#3832
bors merged 2 commits intorust-lang:masterfrom
HarrisonMc555:use_last

Conversation

@HarrisonMc555
Copy link
Contributor

@HarrisonMc555 HarrisonMc555 commented Feb 28, 2019

Closes #3673

This lint checks the use of x.get(x.len() - 1) and suggests x.last() (where x is a Vec).

There's at least one more thing that needs to happen here. I believe I am correctly checking most of the scenarios and avoiding false positives. However, if different Vecs are used for the x.get and y.len, then it will emit a false positive. In other words, I need to check to make sure the Vecs are the same.

Also, a lot of these commits were temporary and not helpful to the project history...am I supposed to squash on merge? If so, how do I do that?

changelog: New lint: get_last_with_len

Loading
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.

New lint: replace x.get(x.len()-1) with x.last()

7 participants