blob: b62e9107a561e2432b8e859501f410ab32e64b1b [file] [log] [blame]
#![warn(clippy::owned_cow)]
use std::borrow::Cow;
use std::ffi::{CString, OsString};
use std::path::PathBuf;
fn main() {
let x: Cow<'static, str> = Cow::Owned(String::from("Hi!"));
//~^ ERROR: needlessly owned Cow type
let y: Cow<'_, [u8]> = Cow::Owned(vec![]);
//~^ ERROR: needlessly owned Cow type
let z: Cow<'_, [_]> = Cow::Owned(vec![2_i32]);
//~^ ERROR: needlessly owned Cow type
let o: Cow<'_, std::ffi::OsStr> = Cow::Owned(OsString::new());
//~^ ERROR: needlessly owned Cow type
let c: Cow<'_, std::ffi::CStr> = Cow::Owned(CString::new("").unwrap());
//~^ ERROR: needlessly owned Cow type
let p: Cow<'_, std::path::Path> = Cow::Owned(PathBuf::new());
//~^ ERROR: needlessly owned Cow type
// false positive: borrowed type
let b: Cow<'_, str> = Cow::Borrowed("Hi!");
}