Skip to content

Commit 0b59468

Browse files
committed
fixup! redundant_box lint
1 parent f6eaa9b commit 0b59468

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

clippy_lints/src/redundant_box.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl LateLintPass<'_> for RedundantBox {
3838
&& let TyKind::Path(path) = hir_ty.kind
3939
&& let Some(boxed_ty) = qpath_generic_tys(&path).next()
4040
{
41-
span_lint_and_sugg_(cx, hir_ty.span, boxed_ty.span);
41+
emit_lint(cx, hir_ty.span, boxed_ty.span);
4242
}
4343
}
4444

@@ -48,22 +48,19 @@ impl LateLintPass<'_> for RedundantBox {
4848
&& is_thin_type(cx, boxed_ty)
4949
&& let ExprKind::Call(_, &[Expr { span, .. }]) = expr.kind
5050
{
51-
span_lint_and_sugg_(cx, expr.span, span);
51+
emit_lint(cx, expr.span, span);
5252
}
5353
}
5454
}
5555

5656
fn is_thin_type<'tcx>(cx: &LateContext<'tcx>, ty: rustc_middle::ty::Ty<'tcx>) -> bool {
57-
//TODO: usize's width will be the host's so lints may be misleading when the intended
58-
// target is a different architecture. Can/should we do someting about it? Maybe make it
59-
// configurable?
6057
ty.is_sized(cx.tcx, cx.typing_env()) && {
6158
let size = 8 * approx_ty_size(cx, ty);
6259
0 < size && size <= cx.sess().target.pointer_width as u64
6360
}
6461
}
6562

66-
fn span_lint_and_sugg_(cx: &LateContext<'_>, from_span: rustc_span::Span, to_span: rustc_span::Span) {
63+
fn emit_lint(cx: &LateContext<'_>, from_span: rustc_span::Span, to_span: rustc_span::Span) {
6764
span_lint_and_sugg(
6865
cx,
6966
REDUNDANT_BOX,

0 commit comments

Comments
 (0)