diff options
Diffstat (limited to 'src/tools/clippy/tests/ui/unnecessary_to_owned.fixed')
-rw-r--r-- | src/tools/clippy/tests/ui/unnecessary_to_owned.fixed | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed b/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed index fe09aad06..ddeda795f 100644 --- a/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed +++ b/src/tools/clippy/tests/ui/unnecessary_to_owned.fixed @@ -2,7 +2,6 @@ #![allow(clippy::needless_borrow, clippy::ptr_arg)] #![warn(clippy::unnecessary_to_owned)] -#![feature(custom_inner_attributes)] use std::borrow::Cow; use std::ffi::{CStr, CString, OsStr, OsString}; @@ -215,14 +214,14 @@ fn get_file_path(_file_type: &FileType) -> Result<std::path::PathBuf, std::io::E fn require_string(_: &String) {} +#[clippy::msrv = "1.35"] fn _msrv_1_35() { - #![clippy::msrv = "1.35"] // `copied` was stabilized in 1.36, so clippy should use `cloned`. let _ = &["x"][..].iter().cloned(); } +#[clippy::msrv = "1.36"] fn _msrv_1_36() { - #![clippy::msrv = "1.36"] let _ = &["x"][..].iter().copied(); } @@ -426,3 +425,32 @@ mod issue_9504 { foo(std::path::PathBuf::new().to_string_lossy().to_string()).await; } } + +mod issue_9771a { + #![allow(dead_code)] + + use std::marker::PhantomData; + + pub struct Key<K: AsRef<[u8]>, V: ?Sized>(K, PhantomData<V>); + + impl<K: AsRef<[u8]>, V: ?Sized> Key<K, V> { + pub fn new(key: K) -> Key<K, V> { + Key(key, PhantomData) + } + } + + pub fn pkh(pkh: &[u8]) -> Key<Vec<u8>, String> { + Key::new([b"pkh-", pkh].concat().to_vec()) + } +} + +mod issue_9771b { + #![allow(dead_code)] + + pub struct Key<K: AsRef<[u8]>>(K); + + pub fn from(c: &[u8]) -> Key<Vec<u8>> { + let v = [c].concat(); + Key(v.to_vec()) + } +} |