Skip to content

Commit ca6d36b

Browse files
author
Michael Wright
committed
Merge branch 'master' into unneeded_wildcard_pattern
2 parents be4e415 + 157edad commit ca6d36b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clippy_lints/src/cargo_common_metadata.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! lint on missing cargo common metadata
22
3+
use std::path::PathBuf;
4+
35
use crate::utils::span_lint;
46
use rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
57
use rustc::{declare_lint_pass, declare_tool_lint};
@@ -47,6 +49,10 @@ fn is_empty_str(value: &Option<String>) -> bool {
4749
value.as_ref().map_or(true, String::is_empty)
4850
}
4951

52+
fn is_empty_path(value: &Option<PathBuf>) -> bool {
53+
value.as_ref().and_then(|x| x.to_str()).map_or(true, str::is_empty)
54+
}
55+
5056
fn is_empty_vec(value: &[String]) -> bool {
5157
// This works because empty iterators return true
5258
value.iter().all(std::string::String::is_empty)
@@ -72,8 +78,8 @@ impl EarlyLintPass for CargoCommonMetadata {
7278
missing_warning(cx, &package, "package.description");
7379
}
7480

75-
if is_empty_str(&package.license) {
76-
missing_warning(cx, &package, "package.license");
81+
if is_empty_str(&package.license) && is_empty_path(&package.license_file) {
82+
missing_warning(cx, &package, "either package.license or package.license_file");
7783
}
7884

7985
if is_empty_str(&package.repository) {

tests/ui/builtin-type-shadow.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ LL | 42
1616
|
1717
= note: expected type `u32`
1818
found type `{integer}`
19+
= help: type parameters must be constrained to match other types
20+
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
1921

2022
error: aborting due to 2 previous errors
2123

0 commit comments

Comments
 (0)