Skip to content

Commit 2106a23

Browse files
Update help text in inefficient_to_string
Co-Authored-By: Manish Goregaokar <[email protected]>
1 parent ffb53e7 commit 2106a23

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clippy_lints/src/methods/inefficient_to_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn lint<'tcx>(cx: &LateContext<'_, 'tcx>, expr: &hir::Expr, arg: &hir::Expr,
2424
&format!("calling `to_string` on `{}`", arg_ty),
2525
|db| {
2626
db.help(&format!(
27-
"`{}` implements `ToString` through the blanket impl, but `{}` specializes `ToString` directly",
27+
"`{}` implements `ToString` through a slower blanket impl, but `{}` has a fast specialization of `ToString`",
2828
self_ty, deref_self_ty
2929
));
3030
let mut applicability = Applicability::MachineApplicable;

tests/ui/inefficient_to_string.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,47 @@ note: lint level defined here
99
|
1010
LL | #![deny(clippy::inefficient_to_string)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12-
= help: `&str` implements `ToString` through the blanket impl, but `str` specializes `ToString` directly
12+
= help: `&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString`
1313

1414
error: calling `to_string` on `&&&str`
1515
--> $DIR/inefficient_to_string.rs:13:21
1616
|
1717
LL | let _: String = rrrstr.to_string();
1818
| ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstr).to_string()`
1919
|
20-
= help: `&&str` implements `ToString` through the blanket impl, but `str` specializes `ToString` directly
20+
= help: `&&str` implements `ToString` through a slower blanket impl, but `str` has a fast specialization of `ToString`
2121

2222
error: calling `to_string` on `&&std::string::String`
2323
--> $DIR/inefficient_to_string.rs:21:21
2424
|
2525
LL | let _: String = rrstring.to_string();
2626
| ^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrstring).to_string()`
2727
|
28-
= help: `&std::string::String` implements `ToString` through the blanket impl, but `std::string::String` specializes `ToString` directly
28+
= help: `&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString`
2929

3030
error: calling `to_string` on `&&&std::string::String`
3131
--> $DIR/inefficient_to_string.rs:22:21
3232
|
3333
LL | let _: String = rrrstring.to_string();
3434
| ^^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstring).to_string()`
3535
|
36-
= help: `&&std::string::String` implements `ToString` through the blanket impl, but `std::string::String` specializes `ToString` directly
36+
= help: `&&std::string::String` implements `ToString` through a slower blanket impl, but `std::string::String` has a fast specialization of `ToString`
3737

3838
error: calling `to_string` on `&&std::borrow::Cow<'_, str>`
3939
--> $DIR/inefficient_to_string.rs:30:21
4040
|
4141
LL | let _: String = rrcow.to_string();
4242
| ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrcow).to_string()`
4343
|
44-
= help: `&std::borrow::Cow<'_, str>` implements `ToString` through the blanket impl, but `std::borrow::Cow<'_, str>` specializes `ToString` directly
44+
= help: `&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString`
4545

4646
error: calling `to_string` on `&&&std::borrow::Cow<'_, str>`
4747
--> $DIR/inefficient_to_string.rs:31:21
4848
|
4949
LL | let _: String = rrrcow.to_string();
5050
| ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrcow).to_string()`
5151
|
52-
= help: `&&std::borrow::Cow<'_, str>` implements `ToString` through the blanket impl, but `std::borrow::Cow<'_, str>` specializes `ToString` directly
52+
= help: `&&std::borrow::Cow<'_, str>` implements `ToString` through a slower blanket impl, but `std::borrow::Cow<'_, str>` has a fast specialization of `ToString`
5353

5454
error: aborting due to 6 previous errors
5555

0 commit comments

Comments
 (0)