Skip to content

Commit c603122

Browse files
committed
panic at map_unit_fn.rs:202 for map() without args
1 parent 80c07d4 commit c603122

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clippy_lints/src/map_unit_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ fn suggestion_msg(function_type: &str, map_type: &str) -> String {
199199

200200
fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr, map_args: &[hir::Expr]) {
201201
let var_arg = &map_args[0];
202-
let fn_arg = &map_args[1];
203202

204203
let (map_type, variant, lint) = if match_type(cx, cx.tables.expr_ty(var_arg), &paths::OPTION) {
205204
("Option", "Some", OPTION_MAP_UNIT_FN)
@@ -208,6 +207,7 @@ fn lint_map_unit_fn(cx: &LateContext<'_, '_>, stmt: &hir::Stmt, expr: &hir::Expr
208207
} else {
209208
return;
210209
};
210+
let fn_arg = &map_args[1];
211211

212212
if is_unit_function(cx, fn_arg) {
213213
let msg = suggestion_msg("function", map_type);

0 commit comments

Comments
 (0)