From c6031221e034ea3c41ffd129798c305cea439c01 Mon Sep 17 00:00:00 2001 From: Mark Nieweglowski Date: Sat, 22 Dec 2018 00:58:07 -0500 Subject: [PATCH] panic at map_unit_fn.rs:202 for map() without args --- clippy_lints/src/map_unit_fn.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clippy_lints/src/map_unit_fn.rs b/clippy_lints/src/map_unit_fn.rs index 39450deb84c..e5c17beb404 100644 --- a/clippy_lints/src/map_unit_fn.rs +++ b/clippy_lints/src/map_unit_fn.rs @@ -199,7 +199,6 @@ fn suggestion_msg(function_type: &str, map_type: &str) -> String { fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr, map_args: &[hir::Expr]) { let var_arg = &map_args[0]; - let fn_arg = &map_args[1]; let (map_type, variant, lint) = if match_type(cx, cx.tables.expr_ty(var_arg), &paths::OPTION) { ("Option", "Some", OPTION_MAP_UNIT_FN) @@ -208,6 +207,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr } else { return; }; + let fn_arg = &map_args[1]; if is_unit_function(cx, fn_arg) { let msg = suggestion_msg("function", map_type);