summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/needless_match.txt
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/src/docs/needless_match.txt')
-rw-r--r--src/tools/clippy/src/docs/needless_match.txt36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/needless_match.txt b/src/tools/clippy/src/docs/needless_match.txt
new file mode 100644
index 000000000..92b40a5df
--- /dev/null
+++ b/src/tools/clippy/src/docs/needless_match.txt
@@ -0,0 +1,36 @@
+### What it does
+Checks for unnecessary `match` or match-like `if let` returns for `Option` and `Result`
+when function signatures are the same.
+
+### Why is this bad?
+This `match` block does nothing and might not be what the coder intended.
+
+### Example
+```
+fn foo() -> Result<(), i32> {
+ match result {
+ Ok(val) => Ok(val),
+ Err(err) => Err(err),
+ }
+}
+
+fn bar() -> Option<i32> {
+ if let Some(val) = option {
+ Some(val)
+ } else {
+ None
+ }
+}
+```
+
+Could be replaced as
+
+```
+fn foo() -> Result<(), i32> {
+ result
+}
+
+fn bar() -> Option<i32> {
+ option
+}
+``` \ No newline at end of file