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

Fix or_fun_call for index operator #6267

Merged
merged 2 commits into from
Nov 8, 2020
Merged

Conversation

camsteffen
Copy link
Contributor

changelog: Fix or_fun_call for index operator

Fixes #6266

@rust-highfive
Copy link

r? @flip1995

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Oct 29, 2020
@camsteffen
Copy link
Contributor Author

camsteffen commented Oct 29, 2020

Oops. The fix for references (e.g. opt.map_or(&foo())) doesn't work due to lifetimes. I'll remove that part for this PR.

@camsteffen
Copy link
Contributor Author

Need to resolve the question of including slices at #6267.

Also, I think I should amend this to not include opt.map_or(array[const_expr])?

@flip1995
Copy link
Member

flip1995 commented Nov 8, 2020

Need to resolve the question of including slices at #6267.

I don't think we should lint on indexing slices, arrays or vecs, since those operations are O(1), even with bounds checks, while indexing into hashmaps can be way more involved.

@camsteffen
Copy link
Contributor Author

Okay, now it will only lint when indexing HashMap or BTreeMap.

@flip1995
Copy link
Member

flip1995 commented Nov 8, 2020

@bors r+

Thanks!

@bors
Copy link
Collaborator

bors commented Nov 8, 2020

📌 Commit 9cab084 has been approved by flip1995

@bors
Copy link
Collaborator

bors commented Nov 8, 2020

⌛ Testing commit 9cab084 with merge 2067a01...

@bors
Copy link
Collaborator

bors commented Nov 8, 2020

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: flip1995
Pushing 2067a01 to master...

@bors bors merged commit 2067a01 into rust-lang:master Nov 8, 2020
@camsteffen camsteffen deleted the or-fun-idx branch July 8, 2021 22:01
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.

or_fun_call lint shouldn't ignore indexing to HashMap types
4 participants