about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHMPerson1 <hmperson1@gmail.com>2019-10-17 12:41:45 -0400
committerHMPerson1 <hmperson1@gmail.com>2019-10-17 12:41:45 -0400
commitffb53e74571f4b179f265b846cfa443e527621fb (patch)
tree82f644bd58eb078eb6cfc6ba35f0009c007e400d
parent106a72592c024f0e03500cb17fd1fd28566866b0 (diff)
downloadrust-ffb53e74571f4b179f265b846cfa443e527621fb.tar.gz
rust-ffb53e74571f4b179f265b846cfa443e527621fb.zip
Add `run-rustfix` to `inefficient_to_string`
-rw-r--r--tests/ui/inefficient_to_string.fixed32
-rw-r--r--tests/ui/inefficient_to_string.rs1
-rw-r--r--tests/ui/inefficient_to_string.stderr14
3 files changed, 40 insertions, 7 deletions
diff --git a/tests/ui/inefficient_to_string.fixed b/tests/ui/inefficient_to_string.fixed
new file mode 100644
index 00000000000..32bc7574a52
--- /dev/null
+++ b/tests/ui/inefficient_to_string.fixed
@@ -0,0 +1,32 @@
+// run-rustfix
+#![deny(clippy::inefficient_to_string)]
+
+use std::borrow::Cow;
+use std::string::ToString;
+
+fn main() {
+    let rstr: &str = "hello";
+    let rrstr: &&str = &rstr;
+    let rrrstr: &&&str = &rrstr;
+    let _: String = rstr.to_string();
+    let _: String = (*rrstr).to_string();
+    let _: String = (**rrrstr).to_string();
+
+    let string: String = String::from("hello");
+    let rstring: &String = &string;
+    let rrstring: &&String = &rstring;
+    let rrrstring: &&&String = &rrstring;
+    let _: String = string.to_string();
+    let _: String = rstring.to_string();
+    let _: String = (*rrstring).to_string();
+    let _: String = (**rrrstring).to_string();
+
+    let cow: Cow<'_, str> = Cow::Borrowed("hello");
+    let rcow: &Cow<'_, str> = &cow;
+    let rrcow: &&Cow<'_, str> = &rcow;
+    let rrrcow: &&&Cow<'_, str> = &rrcow;
+    let _: String = cow.to_string();
+    let _: String = rcow.to_string();
+    let _: String = (*rrcow).to_string();
+    let _: String = (**rrrcow).to_string();
+}
diff --git a/tests/ui/inefficient_to_string.rs b/tests/ui/inefficient_to_string.rs
index a9f8f244c19..2741565e50d 100644
--- a/tests/ui/inefficient_to_string.rs
+++ b/tests/ui/inefficient_to_string.rs
@@ -1,3 +1,4 @@
+// run-rustfix
 #![deny(clippy::inefficient_to_string)]
 
 use std::borrow::Cow;
diff --git a/tests/ui/inefficient_to_string.stderr b/tests/ui/inefficient_to_string.stderr
index 70e3c1e82c7..3c2f64c805f 100644
--- a/tests/ui/inefficient_to_string.stderr
+++ b/tests/ui/inefficient_to_string.stderr
@@ -1,18 +1,18 @@
 error: calling `to_string` on `&&str`
-  --> $DIR/inefficient_to_string.rs:11:21
+  --> $DIR/inefficient_to_string.rs:12:21
    |
 LL |     let _: String = rrstr.to_string();
    |                     ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrstr).to_string()`
    |
 note: lint level defined here
-  --> $DIR/inefficient_to_string.rs:1:9
+  --> $DIR/inefficient_to_string.rs:2:9
    |
 LL | #![deny(clippy::inefficient_to_string)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: `&str` implements `ToString` through the blanket impl, but `str` specializes `ToString` directly
 
 error: calling `to_string` on `&&&str`
-  --> $DIR/inefficient_to_string.rs:12:21
+  --> $DIR/inefficient_to_string.rs:13:21
    |
 LL |     let _: String = rrrstr.to_string();
    |                     ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstr).to_string()`
@@ -20,7 +20,7 @@ LL |     let _: String = rrrstr.to_string();
    = help: `&&str` implements `ToString` through the blanket impl, but `str` specializes `ToString` directly
 
 error: calling `to_string` on `&&std::string::String`
-  --> $DIR/inefficient_to_string.rs:20:21
+  --> $DIR/inefficient_to_string.rs:21:21
    |
 LL |     let _: String = rrstring.to_string();
    |                     ^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrstring).to_string()`
@@ -28,7 +28,7 @@ LL |     let _: String = rrstring.to_string();
    = help: `&std::string::String` implements `ToString` through the blanket impl, but `std::string::String` specializes `ToString` directly
 
 error: calling `to_string` on `&&&std::string::String`
-  --> $DIR/inefficient_to_string.rs:21:21
+  --> $DIR/inefficient_to_string.rs:22:21
    |
 LL |     let _: String = rrrstring.to_string();
    |                     ^^^^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrstring).to_string()`
@@ -36,7 +36,7 @@ LL |     let _: String = rrrstring.to_string();
    = help: `&&std::string::String` implements `ToString` through the blanket impl, but `std::string::String` specializes `ToString` directly
 
 error: calling `to_string` on `&&std::borrow::Cow<'_, str>`
-  --> $DIR/inefficient_to_string.rs:29:21
+  --> $DIR/inefficient_to_string.rs:30:21
    |
 LL |     let _: String = rrcow.to_string();
    |                     ^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(*rrcow).to_string()`
@@ -44,7 +44,7 @@ LL |     let _: String = rrcow.to_string();
    = help: `&std::borrow::Cow<'_, str>` implements `ToString` through the blanket impl, but `std::borrow::Cow<'_, str>` specializes `ToString` directly
 
 error: calling `to_string` on `&&&std::borrow::Cow<'_, str>`
-  --> $DIR/inefficient_to_string.rs:30:21
+  --> $DIR/inefficient_to_string.rs:31:21
    |
 LL |     let _: String = rrrcow.to_string();
    |                     ^^^^^^^^^^^^^^^^^^ help: try dereferencing the receiver: `(**rrrcow).to_string()`