diff options
| author | Samuel E. Moelius III <sam@moeli.us> | 2021-09-01 18:31:42 -0400 |
|---|---|---|
| committer | Samuel E. Moelius III <sam@moeli.us> | 2021-09-09 04:59:06 -0400 |
| commit | ccc087ed629db0489f4cecfeaaa69f6c0f9f6fe5 (patch) | |
| tree | d67df76de8dbde71c3b208a6d534f09aa147c9e6 | |
| parent | 261e34d5348218cbea3cd9a589c49aba92c322d4 (diff) | |
| download | rust-ccc087ed629db0489f4cecfeaaa69f6c0f9f6fe5.tar.gz rust-ccc087ed629db0489f4cecfeaaa69f6c0f9f6fe5.zip | |
Prep for upgrade to cargo_metadata 0.14.0
| -rw-r--r-- | clippy_lints/src/cargo_common_metadata.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/clippy_lints/src/cargo_common_metadata.rs b/clippy_lints/src/cargo_common_metadata.rs index bd5426ba707..162911b77d6 100644 --- a/clippy_lints/src/cargo_common_metadata.rs +++ b/clippy_lints/src/cargo_common_metadata.rs @@ -1,7 +1,5 @@ //! lint on missing cargo common metadata -use std::path::PathBuf; - use clippy_utils::{diagnostics::span_lint, is_lint_allowed}; use rustc_hir::{hir_id::CRATE_HIR_ID, Crate}; use rustc_lint::{LateContext, LateLintPass}; @@ -69,12 +67,8 @@ fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, fiel span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, &message); } -fn is_empty_str(value: &Option<String>) -> bool { - value.as_ref().map_or(true, String::is_empty) -} - -fn is_empty_path(value: &Option<PathBuf>) -> bool { - value.as_ref().and_then(|x| x.to_str()).map_or(true, str::is_empty) +fn is_empty_str<T: AsRef<std::ffi::OsStr>>(value: &Option<T>) -> bool { + value.as_ref().map_or(true, |s| s.as_ref().is_empty()) } fn is_empty_vec(value: &[String]) -> bool { @@ -98,7 +92,7 @@ impl LateLintPass<'_> for CargoCommonMetadata { missing_warning(cx, &package, "package.description"); } - if is_empty_str(&package.license) && is_empty_path(&package.license_file) { + if is_empty_str(&package.license) && is_empty_str(&package.license_file) { missing_warning(cx, &package, "either package.license or package.license_file"); } @@ -106,7 +100,7 @@ impl LateLintPass<'_> for CargoCommonMetadata { missing_warning(cx, &package, "package.repository"); } - if is_empty_path(&package.readme) { + if is_empty_str(&package.readme) { missing_warning(cx, &package, "package.readme"); } |
