Skip to content

Commit 4ea0f72

Browse files
authored
Merge pull request #1471 from Manishearth/serde
remove rustc-serialize dependency and factor `util::cargo` out into a crate
2 parents c04eaf7 + 2c69e9c commit 4ea0f72

File tree

9 files changed

+27
-99
lines changed

9 files changed

+27
-99
lines changed

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ test = false
3232
# begin automatic update
3333
clippy_lints = { version = "0.0.111", path = "clippy_lints" }
3434
# end automatic update
35+
cargo_metadata = "0.1.1"
3536

3637
[dev-dependencies]
3738
compiletest_rs = "0.2.5"
3839
lazy_static = "0.1.15"
3940
regex = "0.2"
40-
rustc-serialize = "0.3"
41+
serde_derive = "0.9.1"
4142
clippy-mini-macro-test = { version = "0.1", path = "mini-macro" }
42-
serde = "0.7"
43+
serde = "0.9.1"
4344

4445
[features]
4546
debugging = []

clippy_lints/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ semver = "0.2.1"
2222
toml = "0.2"
2323
unicode-normalization = "0.1"
2424
quine-mc_cluskey = "0.2.2"
25-
rustc-serialize = "0.3"
2625

2726
[features]
2827
debugging = []

clippy_lints/src/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ extern crate regex_syntax;
3838
// for finding minimal boolean expressions
3939
extern crate quine_mc_cluskey;
4040

41-
extern crate rustc_serialize;
42-
4341
extern crate rustc_errors;
4442
extern crate rustc_plugin;
4543
extern crate rustc_const_eval;

clippy_lints/src/utils/cargo.rs

-77
This file was deleted.

clippy_lints/src/utils/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use syntax::errors::DiagnosticBuilder;
2121
use syntax::ptr::P;
2222
use syntax::symbol::keywords;
2323

24-
pub mod cargo;
2524
pub mod comparisons;
2625
pub mod conf;
2726
pub mod constants;

src/main.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use std::process::{self, Command};
2121
use syntax::ast;
2222
use std::io::{self, Write};
2323

24-
use clippy_lints::utils::cargo;
24+
extern crate cargo_metadata;
2525

2626
struct ClippyCompilerCalls {
2727
default: RustcDefaultCalls,
@@ -179,15 +179,14 @@ pub fn main() {
179179

180180
let manifest_path_arg = std::env::args().skip(2).find(|val| val.starts_with("--manifest-path="));
181181

182-
let mut metadata = if let Ok(metadata) = cargo::metadata(manifest_path_arg.as_ref().map(AsRef::as_ref)) {
182+
let mut metadata = if let Ok(metadata) = cargo_metadata::metadata(manifest_path_arg.as_ref()
183+
.map(AsRef::as_ref)) {
183184
metadata
184185
} else {
185186
let _ = io::stderr().write_fmt(format_args!("error: Could not obtain cargo metadata."));
186187
process::exit(101);
187188
};
188189

189-
assert_eq!(metadata.version, 1);
190-
191190
let manifest_path = manifest_path_arg.map(|arg| PathBuf::from(Path::new(&arg["--manifest-path=".len()..])));
192191

193192
let current_dir = std::env::current_dir();

tests/compile-fail/serde.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,19 @@ struct A;
99

1010
impl serde::de::Visitor for A {
1111
type Value = ();
12-
fn visit_str<E>(&mut self, _v: &str) -> Result<Self::Value, E>
13-
where E: serde::Error,
12+
13+
fn expecting(&self, _: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
14+
unimplemented!()
15+
}
16+
17+
fn visit_str<E>(self, _v: &str) -> Result<Self::Value, E>
18+
where E: serde::de::Error,
1419
{
1520
unimplemented!()
1621
}
1722

18-
fn visit_string<E>(&mut self, _v: String) -> Result<Self::Value, E>
19-
where E: serde::Error,
23+
fn visit_string<E>(self, _v: String) -> Result<Self::Value, E>
24+
where E: serde::de::Error,
2025
{
2126
unimplemented!()
2227
}
@@ -27,9 +32,13 @@ struct B;
2732
impl serde::de::Visitor for B {
2833
type Value = ();
2934

30-
fn visit_string<E>(&mut self, _v: String) -> Result<Self::Value, E>
35+
fn expecting(&self, _: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
36+
unimplemented!()
37+
}
38+
39+
fn visit_string<E>(self, _v: String) -> Result<Self::Value, E>
3140
//~^ ERROR you should not implement `visit_string` without also implementing `visit_str`
32-
where E: serde::Error,
41+
where E: serde::de::Error,
3342
{
3443
unimplemented!()
3544
}

tests/used_underscore_binding_macro.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#![feature(plugin)]
22
#![plugin(clippy)]
33

4-
extern crate rustc_serialize;
4+
#[macro_use]
5+
extern crate serde_derive;
56

67
/// Test that we do not lint for unused underscores in a `MacroAttribute` expansion
78
#[deny(used_underscore_binding)]
8-
#[derive(RustcEncodable)]
9+
#[derive(Deserialize)]
910
struct MacroAttributesTest {
1011
_foo: u32,
1112
}

tests/versioncheck.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
extern crate clippy_lints;
2-
use clippy_lints::utils::cargo;
1+
extern crate cargo_metadata;
32

43
#[test]
54
fn check_that_clippy_lints_has_the_same_version_as_clippy() {
6-
let clippy_meta = cargo::metadata(None).expect("could not obtain cargo metadata");
5+
let clippy_meta = cargo_metadata::metadata(None).expect("could not obtain cargo metadata");
76
std::env::set_current_dir(std::env::current_dir().unwrap().join("clippy_lints")).unwrap();
8-
let clippy_lints_meta = cargo::metadata(None).expect("could not obtain cargo metadata");
7+
let clippy_lints_meta = cargo_metadata::metadata(None).expect("could not obtain cargo metadata");
98
assert_eq!(clippy_lints_meta.packages[0].version, clippy_meta.packages[0].version);
109
for package in &clippy_meta.packages[0].dependencies {
1110
if package.name == "clippy_lints" {

0 commit comments

Comments
 (0)