about summary refs log tree commit diff
path: root/src/test/rustdoc-ui/coverage/json.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-07-06 15:56:52 +0000
committerbors <bors@rust-lang.org>2020-07-06 15:56:52 +0000
commitac856922f80e9ef8cd95c3004699e4bc8fa0c978 (patch)
tree49cbbe0c038ae067a7c256f94c876b4dc04985a6 /src/test/rustdoc-ui/coverage/json.rs
parent57cdf2dc16e1833008ae5b120cb2c045d267dda8 (diff)
parentc8f700ea697f74ef8f86891b050c859cf457e3ab (diff)
downloadrust-ac856922f80e9ef8cd95c3004699e4bc8fa0c978.tar.gz
rust-ac856922f80e9ef8cd95c3004699e4bc8fa0c978.zip
Auto merge of #5301 - JarredAllen:option_if_let_else, r=flip1995
Suggest `Option::map_or`(_else) for `if let Some { y } else { x }`

Fixes #5203

There are two issues with this code that I have noticed:

- Use of `Option::map_or` causes it to always evaluate the code in the else block. If that block is computationally expensive or if it updates some state (such as getting the next value from an iterator), then this change would cause the code to behave differently. In either of those circumstances, it should suggest Option::map_or_else, which takes both cases as a closure and runs one. However, I don't know how to check if the expression would change some state, so I left the lint's applicability as MaybeIncorrect.

- There are lints which can trigger on specific sub-cases of this lint (`if_let_some_result`, `question_mark`, and `while_let_loop`) and suggest different changes (usually better ones because they're more specific). Is this acceptable for clippy to give multiple suggestions, or should I have the code check if those other lints trigger and then not trigger this lint if they do?

changelog: Add lint [`option_if_let_else`]
Diffstat (limited to 'src/test/rustdoc-ui/coverage/json.rs')
0 files changed, 0 insertions, 0 deletions