From 4c881d108a6964030dacfa7de3ae6445ab790b49 Mon Sep 17 00:00:00 2001 From: Cyril Plisko Date: Sat, 7 Sep 2019 11:00:02 +0300 Subject: [PATCH 1/2] clippy::cargo_common_metadata: check for license-file When license property is missing in Cargo.toml check for license-file as it may be used instead of the former. The check implemented here is very naive as it only verifies that the field is present and is not empty. More scrutiny can be applied by verifying the file is actually present. Fixes #4517 --- clippy_lints/src/cargo_common_metadata.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/cargo_common_metadata.rs b/clippy_lints/src/cargo_common_metadata.rs index 115bb9ee8c8a..cfc70de8f21d 100644 --- a/clippy_lints/src/cargo_common_metadata.rs +++ b/clippy_lints/src/cargo_common_metadata.rs @@ -1,5 +1,7 @@ //! lint on missing cargo common metadata +use std::path::PathBuf; + use crate::utils::span_lint; use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass}; use rustc::{declare_lint_pass, declare_tool_lint}; @@ -47,6 +49,10 @@ fn is_empty_str(value: &Option) -> bool { value.as_ref().map_or(true, String::is_empty) } +fn is_empty_path(value: &Option) -> bool { + value.as_ref().and_then(|x| x.to_str()).map_or(true, str::is_empty) +} + fn is_empty_vec(value: &[String]) -> bool { // This works because empty iterators return true value.iter().all(std::string::String::is_empty) @@ -72,8 +78,8 @@ impl EarlyLintPass for CargoCommonMetadata { missing_warning(cx, &package, "package.description"); } - if is_empty_str(&package.license) { - missing_warning(cx, &package, "package.license"); + if is_empty_str(&package.license) && is_empty_path(&package.license_file) { + missing_warning(cx, &package, "either package.license or package.license_file"); } if is_empty_str(&package.repository) { From d7b3e237db66ae9af7cf5e989e9b0dc57a6fc151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 22 Sep 2019 12:35:20 +0200 Subject: [PATCH 2/2] rustup https://github.com/rust-lang/rust/pull/64666 --- tests/ui/builtin-type-shadow.stderr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ui/builtin-type-shadow.stderr b/tests/ui/builtin-type-shadow.stderr index 5714f2094daa..c19ea6114f85 100644 --- a/tests/ui/builtin-type-shadow.stderr +++ b/tests/ui/builtin-type-shadow.stderr @@ -16,6 +16,8 @@ LL | 42 | = note: expected type `u32` found type `{integer}` + = help: type parameters must be constrained to match other types + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters error: aborting due to 2 previous errors