Skip to content

Commit

Permalink
Merge branch 'master' into unneeded_wildcard_pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wright committed Sep 23, 2019
2 parents be4e415 + 157edad commit ca6d36b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions clippy_lints/src/cargo_common_metadata.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -47,6 +49,10 @@ 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_vec(value: &[String]) -> bool {
// This works because empty iterators return true
value.iter().all(std::string::String::is_empty)
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/builtin-type-shadow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ca6d36b

Please sign in to comment.