Skip to content

Commit

Permalink
Add a comment that explains about comparing snippet to raw text
Browse files Browse the repository at this point in the history
  • Loading branch information
topecongiro committed Oct 6, 2017
1 parent f5c941a commit 63d6df2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clippy_lints/src/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,8 @@ fn lint_map_unwrap_or(cx: &LateContext, expr: &hir::Expr, map_args: &[hir::Expr]
let map_snippet = snippet(cx, map_args[1].span, "..");
let unwrap_snippet = snippet(cx, unwrap_args[1].span, "..");
// lint message
// comparing the snippet from source to raw text ("None") below is safe
// because we already have checked the type.
let arg = if unwrap_snippet == "None" { "None" } else { "a" };
let suggest = if unwrap_snippet == "None" { "and_then(f)" } else { "map_or(a, f)" };
let msg = &format!(
Expand Down

0 comments on commit 63d6df2

Please sign in to comment.