Skip to content

Commit 83875ea

Browse files
committed
Prep for upgrade to cargo_metadata 0.14.0
1 parent c5cbf78 commit 83875ea

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/tools/clippy/clippy_lints/src/cargo_common_metadata.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! lint on missing cargo common metadata
22
3-
use std::path::PathBuf;
4-
53
use clippy_utils::{diagnostics::span_lint, is_lint_allowed};
64
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
75
use rustc_lint::{LateContext, LateLintPass};
@@ -69,12 +67,8 @@ fn missing_warning(cx: &LateContext<'_>, package: &cargo_metadata::Package, fiel
6967
span_lint(cx, CARGO_COMMON_METADATA, DUMMY_SP, &message);
7068
}
7169

72-
fn is_empty_str(value: &Option<String>) -> bool {
73-
value.as_ref().map_or(true, String::is_empty)
74-
}
75-
76-
fn is_empty_path(value: &Option<PathBuf>) -> bool {
77-
value.as_ref().and_then(|x| x.to_str()).map_or(true, str::is_empty)
70+
fn is_empty_str<T: AsRef<std::ffi::OsStr>>(value: &Option<T>) -> bool {
71+
value.as_ref().map_or(true, |s| s.as_ref().is_empty())
7872
}
7973

8074
fn is_empty_vec(value: &[String]) -> bool {
@@ -98,15 +92,15 @@ impl LateLintPass<'_> for CargoCommonMetadata {
9892
missing_warning(cx, &package, "package.description");
9993
}
10094

101-
if is_empty_str(&package.license) && is_empty_path(&package.license_file) {
95+
if is_empty_str(&package.license) && is_empty_str(&package.license_file) {
10296
missing_warning(cx, &package, "either package.license or package.license_file");
10397
}
10498

10599
if is_empty_str(&package.repository) {
106100
missing_warning(cx, &package, "package.repository");
107101
}
108102

109-
if is_empty_path(&package.readme) {
103+
if is_empty_str(&package.readme) {
110104
missing_warning(cx, &package, "package.readme");
111105
}
112106

0 commit comments

Comments
 (0)