mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Changed signature of cargo::metadata according to review comment.
This commit is contained in:
parent
ebbd00b1ab
commit
2315a817ce
3 changed files with 5 additions and 5 deletions
|
@ -65,10 +65,10 @@ impl From<json::DecoderError> for Error {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn metadata(manifest_path_arg: &Option<String>) -> Result<Metadata, Error> {
|
||||
pub fn metadata(manifest_path_arg: Option<&str>) -> Result<Metadata, Error> {
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.arg("metadata").arg("--no-deps");
|
||||
if let Some(ref mani) = *manifest_path_arg {
|
||||
if let Some(mani) = manifest_path_arg {
|
||||
cmd.arg(mani);
|
||||
}
|
||||
let output = cmd.output()?;
|
||||
|
|
|
@ -140,7 +140,7 @@ pub fn main() {
|
|||
// this arm is executed on the initial call to `cargo clippy`
|
||||
let manifest_path_arg = std::env::args().skip(2).find(|val| val.starts_with("--manifest-path="));
|
||||
|
||||
let mut metadata = cargo::metadata(&manifest_path_arg).expect("could not obtain cargo metadata");
|
||||
let mut metadata = cargo::metadata(manifest_path_arg.as_ref().map(AsRef::as_ref)).expect("could not obtain cargo metadata");
|
||||
assert_eq!(metadata.version, 1);
|
||||
|
||||
let manifest_path = manifest_path_arg.map(|arg| PathBuf::from(Path::new(&arg["--manifest-path=".len()..])));
|
||||
|
|
|
@ -3,9 +3,9 @@ use clippy_lints::utils::cargo;
|
|||
|
||||
#[test]
|
||||
fn check_that_clippy_lints_has_the_same_version_as_clippy() {
|
||||
let clippy_meta = cargo::metadata(&None).expect("could not obtain cargo metadata");
|
||||
let clippy_meta = cargo::metadata(None).expect("could not obtain cargo metadata");
|
||||
std::env::set_current_dir(std::env::current_dir().unwrap().join("clippy_lints")).unwrap();
|
||||
let clippy_lints_meta = cargo::metadata(&None).expect("could not obtain cargo metadata");
|
||||
let clippy_lints_meta = cargo::metadata(None).expect("could not obtain cargo metadata");
|
||||
assert_eq!(clippy_lints_meta.packages[0].version, clippy_meta.packages[0].version);
|
||||
for package in &clippy_meta.packages[0].dependencies {
|
||||
if package.name == "clippy_lints" {
|
||||
|
|
Loading…
Reference in a new issue