Skip to content

Commit 63d6df2

Browse files
committed
Add a comment that explains about comparing snippet to raw text
1 parent f5c941a commit 63d6df2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

clippy_lints/src/methods.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,8 @@ fn lint_map_unwrap_or(cx: &LateContext, expr: &hir::Expr, map_args: &[hir::Expr]
11541154
let map_snippet = snippet(cx, map_args[1].span, "..");
11551155
let unwrap_snippet = snippet(cx, unwrap_args[1].span, "..");
11561156
// lint message
1157+
// comparing the snippet from source to raw text ("None") below is safe
1158+
// because we already have checked the type.
11571159
let arg = if unwrap_snippet == "None" { "None" } else { "a" };
11581160
let suggest = if unwrap_snippet == "None" { "and_then(f)" } else { "map_or(a, f)" };
11591161
let msg = &format!(

0 commit comments

Comments
 (0)