if !(type_permits_lack_of_use || fn_warned || op_warned) {
cx.struct_span_lint(UNUSED_RESULTS, s.span, |lint| {
- lint.build(&format!("unused result of type `{}`", ty)).emit()
+ lint.build(&format!("unused result of type `{}`", ty)).emit();
});
}
let descr_pre = &format!("{}boxed ", descr_pre);
check_must_use_ty(cx, boxed_ty, expr, span, descr_pre, descr_post, plural_len)
}
- ty::Adt(def, _) => check_must_use_def(cx, def.did, span, descr_pre, descr_post),
+ ty::Adt(def, _) => check_must_use_def(cx, def.did(), span, descr_pre, descr_post),
ty::Opaque(def, _) => {
let mut has_emitted = false;
for &(predicate, _) in cx.tcx.explicit_item_bounds(def) {
}
ty::Tuple(ref tys) => {
let mut has_emitted = false;
- let spans = if let hir::ExprKind::Tup(comps) = &expr.kind {
+ let comps = if let hir::ExprKind::Tup(comps) = expr.kind {
debug_assert_eq!(comps.len(), tys.len());
- comps.iter().map(|e| e.span).collect()
+ comps
} else {
- vec![]
+ &[]
};
- for (i, ty) in tys.iter().map(|k| k.expect_ty()).enumerate() {
+ for (i, ty) in tys.iter().enumerate() {
let descr_post = &format!(" in tuple element {}", i);
- let span = *spans.get(i).unwrap_or(&span);
- if check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, plural_len)
- {
+ let e = comps.get(i).unwrap_or(expr);
+ let span = e.span;
+ if check_must_use_ty(cx, ty, e, span, descr_pre, descr_post, plural_len) {
has_emitted = true;
}
}
} else {
lint.span_help(s.span, "use `drop` to clarify the intent");
}
- lint.emit()
+ lint.emit();
} else {
- lint.build("path statement with no effect").emit()
+ lint.build("path statement with no effect").emit();
}
});
}
};
cx.struct_span_lint(UNUSED_IMPORT_BRACES, item.span, |lint| {
- lint.build(&format!("braces around {} is unnecessary", node_name)).emit()
+ lint.build(&format!("braces around {} is unnecessary", node_name)).emit();
});
}
}
"unnecessary allocation, use `&mut` instead"
}
};
- lint.build(msg).emit()
+ lint.build(msg).emit();
});
}
}