Skip to content

Commit e57deaa

Browse files
committed
Auto merge of rust-lang#10659 - timvisee:fix-size-of-val, r=Manishearth
Suggest `std::mem::size_of_val` instead of `std::mem::size_of_value` This fixes the incorrect suggestion to use `std::mem::size_of_value`. It should be [`std::mem::size_of_val`](https://doc.rust-lang.org/std/mem/fn.size_of_val.html). changelog: [`manual_slice_size_calculation`]: suggest `std::mem::size_of_val` rather than `std::mem::size_of_value`
2 parents 90cb0fa + 4fb38cf commit e57deaa

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

clippy_lints/src/manual_slice_size_calculation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare_lint_pass!(ManualSliceSizeCalculation => [MANUAL_SLICE_SIZE_CALCULATION]
3838

3939
impl<'tcx> LateLintPass<'tcx> for ManualSliceSizeCalculation {
4040
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
41-
// Does not apply inside const because size_of_value is not cost in stable.
41+
// Does not apply inside const because size_of_val is not cost in stable.
4242
if !in_constant(cx, expr.hir_id)
4343
&& let ExprKind::Binary(ref op, left, right) = expr.kind
4444
&& BinOpKind::Mul == op.node
@@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualSliceSizeCalculation {
5050
expr.span,
5151
"manual slice size calculation",
5252
None,
53-
"consider using std::mem::size_of_value instead");
53+
"consider using std::mem::size_of_val instead");
5454
}
5555
}
5656
}

tests/ui/manual_slice_size_calculation.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: manual slice size calculation
44
LL | let _ = s_i32.len() * size_of::<i32>(); // WARNING
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: consider using std::mem::size_of_value instead
7+
= help: consider using std::mem::size_of_val instead
88
= note: `-D clippy::manual-slice-size-calculation` implied by `-D warnings`
99

1010
error: manual slice size calculation
@@ -13,39 +13,39 @@ error: manual slice size calculation
1313
LL | let _ = size_of::<i32>() * s_i32.len(); // WARNING
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
|
16-
= help: consider using std::mem::size_of_value instead
16+
= help: consider using std::mem::size_of_val instead
1717

1818
error: manual slice size calculation
1919
--> $DIR/manual_slice_size_calculation.rs:13:13
2020
|
2121
LL | let _ = size_of::<i32>() * s_i32.len() * 5; // WARNING
2222
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2323
|
24-
= help: consider using std::mem::size_of_value instead
24+
= help: consider using std::mem::size_of_val instead
2525

2626
error: manual slice size calculation
2727
--> $DIR/manual_slice_size_calculation.rs:17:13
2828
|
2929
LL | let _ = len * size_of::<i32>(); // WARNING
3030
| ^^^^^^^^^^^^^^^^^^^^^^
3131
|
32-
= help: consider using std::mem::size_of_value instead
32+
= help: consider using std::mem::size_of_val instead
3333

3434
error: manual slice size calculation
3535
--> $DIR/manual_slice_size_calculation.rs:18:13
3636
|
3737
LL | let _ = s_i32.len() * size; // WARNING
3838
| ^^^^^^^^^^^^^^^^^^
3939
|
40-
= help: consider using std::mem::size_of_value instead
40+
= help: consider using std::mem::size_of_val instead
4141

4242
error: manual slice size calculation
4343
--> $DIR/manual_slice_size_calculation.rs:19:13
4444
|
4545
LL | let _ = len * size; // WARNING
4646
| ^^^^^^^^^^
4747
|
48-
= help: consider using std::mem::size_of_value instead
48+
= help: consider using std::mem::size_of_val instead
4949

5050
error: aborting due to 6 previous errors
5151

0 commit comments

Comments
 (0)