]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/tests/ui/unnecessary_to_owned.rs
Auto merge of #100869 - nnethercote:replace-ThinVec, r=spastorino
[rust.git] / src / tools / clippy / tests / ui / unnecessary_to_owned.rs
index fe09a489ab0a67b81cf5280f3dc8b9c1140aa061..7f62ba3ab5d559ea0d8a60da23f977389044f054 100644 (file)
@@ -329,3 +329,31 @@ fn main() {
         rw.set_view(&rw.default_view().to_owned());
     }
 }
+
+mod issue_9317 {
+    #![allow(dead_code)]
+
+    struct Bytes {}
+
+    impl ToString for Bytes {
+        fn to_string(&self) -> String {
+            "123".to_string()
+        }
+    }
+
+    impl AsRef<[u8]> for Bytes {
+        fn as_ref(&self) -> &[u8] {
+            &[1, 2, 3]
+        }
+    }
+
+    fn consume<C: AsRef<[u8]>>(c: C) {
+        let _ = c;
+    }
+
+    pub fn main() {
+        let b = Bytes {};
+        // Should not lint.
+        consume(b.to_string());
+    }
+}