diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:18:32 +0000 |
commit | 4547b622d8d29df964fa2914213088b148c498fc (patch) | |
tree | 9fc6b25f3c3add6b745be9a2400a6e96140046e9 /src/tools/clippy/tests/ui/unnecessary_to_owned.rs | |
parent | Releasing progress-linux version 1.66.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-4547b622d8d29df964fa2914213088b148c498fc.tar.xz rustc-4547b622d8d29df964fa2914213088b148c498fc.zip |
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/unnecessary_to_owned.rs')
-rw-r--r-- | src/tools/clippy/tests/ui/unnecessary_to_owned.rs | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/tools/clippy/tests/ui/unnecessary_to_owned.rs b/src/tools/clippy/tests/ui/unnecessary_to_owned.rs index 3de6d0903..95d257673 100644 --- a/src/tools/clippy/tests/ui/unnecessary_to_owned.rs +++ b/src/tools/clippy/tests/ui/unnecessary_to_owned.rs @@ -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"][..].to_vec().into_iter(); } +#[clippy::msrv = "1.36"] fn _msrv_1_36() { - #![clippy::msrv = "1.36"] let _ = &["x"][..].to_vec().into_iter(); } @@ -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()) + } +} |