Skip to content

Commit b936ee1

Browse files
committed
Revise diagnostic message
1 parent 671f4c9 commit b936ee1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

clippy_lints/src/default_box_assignments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl LateLintPass<'_> for DefaultBoxAssignments {
5151
cx,
5252
DEFAULT_BOX_ASSIGNMENTS,
5353
expr.span,
54-
"assigning `Default::default()` to `Box<T>`",
54+
"creating a new box with default content",
5555
|diag| {
5656
let mut app = Applicability::MachineApplicable;
5757
let suggestion = format!(
@@ -61,7 +61,7 @@ impl LateLintPass<'_> for DefaultBoxAssignments {
6161

6262
diag.note("this creates a needless allocation").span_suggestion(
6363
expr.span,
64-
"assign to the inner value",
64+
"replace existing content with default instead",
6565
suggestion,
6666
app,
6767
);

tests/ui/default_box_assignments.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
error: assigning `Default::default()` to `Box<T>`
1+
error: creating a new box with default content
22
--> tests/ui/default_box_assignments.rs:11:5
33
|
44
LL | b = Default::default();
5-
| ^^^^^^^^^^^^^^^^^^^^^^ help: assign to the inner value: `*b = Default::default()`
5+
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace existing content with default instead: `*b = Default::default()`
66
|
77
= note: this creates a needless allocation
88
= note: `-D clippy::default-box-assignments` implied by `-D warnings`
99
= help: to override `-D warnings` add `#[allow(clippy::default_box_assignments)]`
1010

11-
error: assigning `Default::default()` to `Box<T>`
11+
error: creating a new box with default content
1212
--> tests/ui/default_box_assignments.rs:13:5
1313
|
1414
LL | b = Box::default();
15-
| ^^^^^^^^^^^^^^^^^^ help: assign to the inner value: `*b = Default::default()`
15+
| ^^^^^^^^^^^^^^^^^^ help: replace existing content with default instead: `*b = Default::default()`
1616
|
1717
= note: this creates a needless allocation
1818

0 commit comments

Comments
 (0)