mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
Merge pull request #2065 from rust-lang-nursery/cargo_clippy
Cargo clippy refactoring
This commit is contained in:
commit
6f36f214a5
313 changed files with 647 additions and 1099 deletions
|
@ -28,6 +28,7 @@ script:
|
|||
- cargo test --features debugging
|
||||
- mkdir -p ~/rust/cargo/bin
|
||||
- cp target/debug/cargo-clippy ~/rust/cargo/bin/cargo-clippy
|
||||
- cp target/debug/clippy-driver ~/rust/cargo/bin/clippy-driver
|
||||
- PATH=$PATH:~/rust/cargo/bin cargo clippy --all -- -D clippy
|
||||
- cd clippy_workspace_tests && PATH=$PATH:~/rust/cargo/bin cargo clippy -- -D clippy && cd ..
|
||||
- cd clippy_workspace_tests/src && PATH=$PATH:~/rust/cargo/bin cargo clippy -- -D clippy && cd ../..
|
||||
|
|
|
@ -14,6 +14,7 @@ readme = "README.md"
|
|||
license = "MPL-2.0"
|
||||
keywords = ["clippy", "lint", "plugin"]
|
||||
categories = ["development-tools", "development-tools::cargo-plugins"]
|
||||
build = "build.rs"
|
||||
|
||||
[badges]
|
||||
travis-ci = { repository = "rust-lang-nursery/rust-clippy" }
|
||||
|
@ -29,6 +30,11 @@ name = "cargo-clippy"
|
|||
test = false
|
||||
path = "src/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "clippy-driver"
|
||||
test = false
|
||||
path = "src/driver.rs"
|
||||
|
||||
[dependencies]
|
||||
# begin automatic update
|
||||
clippy_lints = { version = "0.0.165", path = "clippy_lints" }
|
||||
|
|
8
build.rs
Normal file
8
build.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
use std::env;
|
||||
|
||||
fn main() {
|
||||
// Forward the profile to the main compilation
|
||||
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
|
||||
// Don't rebuild even if nothing changed
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
}
|
198
src/driver.rs
Normal file
198
src/driver.rs
Normal file
|
@ -0,0 +1,198 @@
|
|||
// error-pattern:yummy
|
||||
#![feature(box_syntax)]
|
||||
#![feature(rustc_private)]
|
||||
#![allow(unknown_lints, missing_docs_in_private_items)]
|
||||
|
||||
extern crate clippy_lints;
|
||||
extern crate getopts;
|
||||
extern crate rustc;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_errors;
|
||||
extern crate rustc_plugin;
|
||||
extern crate syntax;
|
||||
|
||||
use rustc_driver::{driver, Compilation, CompilerCalls, RustcDefaultCalls};
|
||||
use rustc::session::{config, CompileIncomplete, Session};
|
||||
use rustc::session::config::{ErrorOutputType, Input};
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use syntax::ast;
|
||||
|
||||
struct ClippyCompilerCalls {
|
||||
default: RustcDefaultCalls,
|
||||
run_lints: bool,
|
||||
}
|
||||
|
||||
impl ClippyCompilerCalls {
|
||||
fn new(run_lints: bool) -> Self {
|
||||
Self {
|
||||
default: RustcDefaultCalls,
|
||||
run_lints: run_lints,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
|
||||
fn early_callback(
|
||||
&mut self,
|
||||
matches: &getopts::Matches,
|
||||
sopts: &config::Options,
|
||||
cfg: &ast::CrateConfig,
|
||||
descriptions: &rustc_errors::registry::Registry,
|
||||
output: ErrorOutputType,
|
||||
) -> Compilation {
|
||||
self.default
|
||||
.early_callback(matches, sopts, cfg, descriptions, output)
|
||||
}
|
||||
fn no_input(
|
||||
&mut self,
|
||||
matches: &getopts::Matches,
|
||||
sopts: &config::Options,
|
||||
cfg: &ast::CrateConfig,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
descriptions: &rustc_errors::registry::Registry,
|
||||
) -> Option<(Input, Option<PathBuf>)> {
|
||||
self.default
|
||||
.no_input(matches, sopts, cfg, odir, ofile, descriptions)
|
||||
}
|
||||
fn late_callback(
|
||||
&mut self,
|
||||
matches: &getopts::Matches,
|
||||
sess: &Session,
|
||||
crate_stores: &rustc::middle::cstore::CrateStore,
|
||||
input: &Input,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
) -> Compilation {
|
||||
self.default
|
||||
.late_callback(matches, sess, crate_stores, input, odir, ofile)
|
||||
}
|
||||
fn build_controller(&mut self, sess: &Session, matches: &getopts::Matches) -> driver::CompileController<'a> {
|
||||
let mut control = self.default.build_controller(sess, matches);
|
||||
|
||||
if self.run_lints {
|
||||
let old = std::mem::replace(&mut control.after_parse.callback, box |_| {});
|
||||
control.after_parse.callback = Box::new(move |state| {
|
||||
{
|
||||
let mut registry = rustc_plugin::registry::Registry::new(
|
||||
state.session,
|
||||
state
|
||||
.krate
|
||||
.as_ref()
|
||||
.expect(
|
||||
"at this compilation stage \
|
||||
the krate must be parsed",
|
||||
)
|
||||
.span,
|
||||
);
|
||||
registry.args_hidden = Some(Vec::new());
|
||||
clippy_lints::register_plugins(&mut registry);
|
||||
|
||||
let rustc_plugin::registry::Registry {
|
||||
early_lint_passes,
|
||||
late_lint_passes,
|
||||
lint_groups,
|
||||
llvm_passes,
|
||||
attributes,
|
||||
..
|
||||
} = registry;
|
||||
let sess = &state.session;
|
||||
let mut ls = sess.lint_store.borrow_mut();
|
||||
for pass in early_lint_passes {
|
||||
ls.register_early_pass(Some(sess), true, pass);
|
||||
}
|
||||
for pass in late_lint_passes {
|
||||
ls.register_late_pass(Some(sess), true, pass);
|
||||
}
|
||||
|
||||
for (name, to) in lint_groups {
|
||||
ls.register_group(Some(sess), true, name, to);
|
||||
}
|
||||
|
||||
sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes);
|
||||
sess.plugin_attributes.borrow_mut().extend(attributes);
|
||||
}
|
||||
old(state);
|
||||
});
|
||||
}
|
||||
|
||||
control
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(print_stdout)]
|
||||
fn show_version() {
|
||||
println!("{}", env!("CARGO_PKG_VERSION"));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
use std::env;
|
||||
|
||||
if env::var("CLIPPY_DOGFOOD").map(|_| true).unwrap_or(false) {
|
||||
panic!("yummy");
|
||||
}
|
||||
|
||||
if std::env::args().any(|a| a == "--version" || a == "-V") {
|
||||
show_version();
|
||||
return;
|
||||
}
|
||||
|
||||
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
|
||||
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
|
||||
let sys_root = if let (Some(home), Some(toolchain)) = (home, toolchain) {
|
||||
format!("{}/toolchains/{}", home, toolchain)
|
||||
} else {
|
||||
option_env!("SYSROOT")
|
||||
.map(|s| s.to_owned())
|
||||
.or_else(|| {
|
||||
Command::new("rustc")
|
||||
.arg("--print")
|
||||
.arg("sysroot")
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|out| String::from_utf8(out.stdout).ok())
|
||||
.map(|s| s.trim().to_owned())
|
||||
})
|
||||
.expect(
|
||||
"need to specify SYSROOT env var during clippy compilation, or use rustup or multirust",
|
||||
)
|
||||
};
|
||||
|
||||
rustc_driver::in_rustc_thread(|| {
|
||||
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
|
||||
// We're invoking the compiler programatically, so we ignore this/
|
||||
let mut orig_args: Vec<String> = env::args().collect();
|
||||
if orig_args[1] == "rustc" {
|
||||
// we still want to be able to invoke it normally though
|
||||
orig_args.remove(1);
|
||||
}
|
||||
// this conditional check for the --sysroot flag is there so users can call
|
||||
// `clippy_driver` directly
|
||||
// without having to pass --sysroot or anything
|
||||
let mut args: Vec<String> = if orig_args.iter().any(|s| s == "--sysroot") {
|
||||
orig_args.clone()
|
||||
} else {
|
||||
orig_args.clone().into_iter()
|
||||
.chain(Some("--sysroot".to_owned()))
|
||||
.chain(Some(sys_root))
|
||||
.collect()
|
||||
};
|
||||
|
||||
// this check ensures that dependencies are built but not linted and the final
|
||||
// crate is
|
||||
// linted but not built
|
||||
let clippy_enabled = env::var("CLIPPY_TESTS").ok().map_or(false, |val| val == "true") ||
|
||||
orig_args.iter().any(|s| s == "--emit=metadata");
|
||||
|
||||
if clippy_enabled {
|
||||
args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]);
|
||||
}
|
||||
|
||||
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);
|
||||
let (result, _) = rustc_driver::run_compiler(&args, &mut ccc, None, None);
|
||||
if let Err(CompileIncomplete::Errored(_)) = result {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}).expect("rustc_thread failed");
|
||||
}
|
349
src/main.rs
349
src/main.rs
|
@ -3,128 +3,12 @@
|
|||
#![feature(rustc_private)]
|
||||
#![allow(unknown_lints, missing_docs_in_private_items)]
|
||||
|
||||
extern crate clippy_lints;
|
||||
extern crate getopts;
|
||||
extern crate rustc;
|
||||
extern crate rustc_driver;
|
||||
extern crate rustc_errors;
|
||||
extern crate rustc_plugin;
|
||||
extern crate syntax;
|
||||
|
||||
use rustc_driver::{driver, Compilation, CompilerCalls, RustcDefaultCalls};
|
||||
use rustc::session::{config, CompileIncomplete, Session};
|
||||
use rustc::session::config::{ErrorOutputType, Input};
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{self, Command};
|
||||
use syntax::ast;
|
||||
use std::process;
|
||||
use std::io::{self, Write};
|
||||
|
||||
extern crate cargo_metadata;
|
||||
|
||||
struct ClippyCompilerCalls {
|
||||
default: RustcDefaultCalls,
|
||||
run_lints: bool,
|
||||
}
|
||||
|
||||
impl ClippyCompilerCalls {
|
||||
fn new(run_lints: bool) -> Self {
|
||||
Self {
|
||||
default: RustcDefaultCalls,
|
||||
run_lints: run_lints,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> CompilerCalls<'a> for ClippyCompilerCalls {
|
||||
fn early_callback(
|
||||
&mut self,
|
||||
matches: &getopts::Matches,
|
||||
sopts: &config::Options,
|
||||
cfg: &ast::CrateConfig,
|
||||
descriptions: &rustc_errors::registry::Registry,
|
||||
output: ErrorOutputType,
|
||||
) -> Compilation {
|
||||
self.default
|
||||
.early_callback(matches, sopts, cfg, descriptions, output)
|
||||
}
|
||||
fn no_input(
|
||||
&mut self,
|
||||
matches: &getopts::Matches,
|
||||
sopts: &config::Options,
|
||||
cfg: &ast::CrateConfig,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
descriptions: &rustc_errors::registry::Registry,
|
||||
) -> Option<(Input, Option<PathBuf>)> {
|
||||
self.default
|
||||
.no_input(matches, sopts, cfg, odir, ofile, descriptions)
|
||||
}
|
||||
fn late_callback(
|
||||
&mut self,
|
||||
matches: &getopts::Matches,
|
||||
sess: &Session,
|
||||
crate_stores: &rustc::middle::cstore::CrateStore,
|
||||
input: &Input,
|
||||
odir: &Option<PathBuf>,
|
||||
ofile: &Option<PathBuf>,
|
||||
) -> Compilation {
|
||||
self.default
|
||||
.late_callback(matches, sess, crate_stores, input, odir, ofile)
|
||||
}
|
||||
fn build_controller(&mut self, sess: &Session, matches: &getopts::Matches) -> driver::CompileController<'a> {
|
||||
let mut control = self.default.build_controller(sess, matches);
|
||||
|
||||
if self.run_lints {
|
||||
let old = std::mem::replace(&mut control.after_parse.callback, box |_| {});
|
||||
control.after_parse.callback = Box::new(move |state| {
|
||||
{
|
||||
let mut registry = rustc_plugin::registry::Registry::new(
|
||||
state.session,
|
||||
state
|
||||
.krate
|
||||
.as_ref()
|
||||
.expect(
|
||||
"at this compilation stage \
|
||||
the krate must be parsed",
|
||||
)
|
||||
.span,
|
||||
);
|
||||
registry.args_hidden = Some(Vec::new());
|
||||
clippy_lints::register_plugins(&mut registry);
|
||||
|
||||
let rustc_plugin::registry::Registry {
|
||||
early_lint_passes,
|
||||
late_lint_passes,
|
||||
lint_groups,
|
||||
llvm_passes,
|
||||
attributes,
|
||||
..
|
||||
} = registry;
|
||||
let sess = &state.session;
|
||||
let mut ls = sess.lint_store.borrow_mut();
|
||||
for pass in early_lint_passes {
|
||||
ls.register_early_pass(Some(sess), true, pass);
|
||||
}
|
||||
for pass in late_lint_passes {
|
||||
ls.register_late_pass(Some(sess), true, pass);
|
||||
}
|
||||
|
||||
for (name, to) in lint_groups {
|
||||
ls.register_group(Some(sess), true, name, to);
|
||||
}
|
||||
|
||||
sess.plugin_llvm_passes.borrow_mut().extend(llvm_passes);
|
||||
sess.plugin_attributes.borrow_mut().extend(attributes);
|
||||
}
|
||||
old(state);
|
||||
});
|
||||
}
|
||||
|
||||
control
|
||||
}
|
||||
}
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
const CARGO_CLIPPY_HELP: &str = r#"Checks a package to catch common mistakes and improve your Rust code.
|
||||
|
@ -181,166 +65,105 @@ pub fn main() {
|
|||
return;
|
||||
}
|
||||
|
||||
if "clippy" == std::env::args().nth(1).as_ref().expect("cargo-clippy should be called with at least one argument!") {
|
||||
// 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 manifest_path_arg = std::env::args()
|
||||
.skip(2)
|
||||
.find(|val| val.starts_with("--manifest-path="));
|
||||
let mut metadata = if let Ok(metadata) = cargo_metadata::metadata(manifest_path_arg.as_ref().map(AsRef::as_ref))
|
||||
{
|
||||
metadata
|
||||
} else {
|
||||
let _ = io::stderr().write_fmt(format_args!("error: Could not obtain cargo metadata.\n"));
|
||||
process::exit(101);
|
||||
};
|
||||
|
||||
let mut metadata = if let Ok(metadata) = cargo_metadata::metadata(manifest_path_arg.as_ref().map(AsRef::as_ref))
|
||||
{
|
||||
metadata
|
||||
} else {
|
||||
let _ = io::stderr().write_fmt(format_args!("error: Could not obtain cargo metadata.\n"));
|
||||
process::exit(101);
|
||||
};
|
||||
let manifest_path = manifest_path_arg.map(|arg| {
|
||||
Path::new(&arg["--manifest-path=".len()..])
|
||||
.canonicalize()
|
||||
.expect("manifest path could not be canonicalized")
|
||||
});
|
||||
|
||||
let manifest_path = manifest_path_arg.map(|arg| {
|
||||
Path::new(&arg["--manifest-path=".len()..])
|
||||
.canonicalize()
|
||||
.expect("manifest path could not be canonicalized")
|
||||
});
|
||||
|
||||
let packages = if std::env::args().any(|a| a == "--all") {
|
||||
metadata.packages
|
||||
} else {
|
||||
let package_index = {
|
||||
if let Some(manifest_path) = manifest_path {
|
||||
metadata.packages.iter().position(|package| {
|
||||
let package_manifest_path = Path::new(&package.manifest_path)
|
||||
.canonicalize()
|
||||
.expect("package manifest path could not be canonicalized");
|
||||
package_manifest_path == manifest_path
|
||||
})
|
||||
} else {
|
||||
let package_manifest_paths: HashMap<_, _> = metadata
|
||||
.packages
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, package)| {
|
||||
let package_manifest_path = Path::new(&package.manifest_path)
|
||||
.parent()
|
||||
.expect("could not find parent directory of package manifest")
|
||||
.canonicalize()
|
||||
.expect("package directory cannot be canonicalized");
|
||||
(package_manifest_path, i)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let current_dir = std::env::current_dir()
|
||||
.expect("could not read current directory")
|
||||
let packages = if std::env::args().any(|a| a == "--all") {
|
||||
metadata.packages
|
||||
} else {
|
||||
let package_index = {
|
||||
if let Some(manifest_path) = manifest_path {
|
||||
metadata.packages.iter().position(|package| {
|
||||
let package_manifest_path = Path::new(&package.manifest_path)
|
||||
.canonicalize()
|
||||
.expect("current directory cannot be canonicalized");
|
||||
.expect("package manifest path could not be canonicalized");
|
||||
package_manifest_path == manifest_path
|
||||
})
|
||||
} else {
|
||||
let package_manifest_paths: HashMap<_, _> = metadata
|
||||
.packages
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, package)| {
|
||||
let package_manifest_path = Path::new(&package.manifest_path)
|
||||
.parent()
|
||||
.expect("could not find parent directory of package manifest")
|
||||
.canonicalize()
|
||||
.expect("package directory cannot be canonicalized");
|
||||
(package_manifest_path, i)
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut current_path: &Path = ¤t_dir;
|
||||
let current_dir = std::env::current_dir()
|
||||
.expect("could not read current directory")
|
||||
.canonicalize()
|
||||
.expect("current directory cannot be canonicalized");
|
||||
|
||||
// This gets the most-recent parent (the one that takes the fewest `cd ..`s to
|
||||
// reach).
|
||||
loop {
|
||||
if let Some(&package_index) = package_manifest_paths.get(current_path) {
|
||||
break Some(package_index);
|
||||
} else {
|
||||
// We'll never reach the filesystem root, because to get to this point in the
|
||||
// code
|
||||
// the call to `cargo_metadata::metadata` must have succeeded. So it's okay to
|
||||
// unwrap the current path's parent.
|
||||
current_path = current_path
|
||||
.parent()
|
||||
.unwrap_or_else(|| panic!("could not find parent of path {}", current_path.display()));
|
||||
}
|
||||
let mut current_path: &Path = ¤t_dir;
|
||||
|
||||
// This gets the most-recent parent (the one that takes the fewest `cd ..`s to
|
||||
// reach).
|
||||
loop {
|
||||
if let Some(&package_index) = package_manifest_paths.get(current_path) {
|
||||
break Some(package_index);
|
||||
} else {
|
||||
// We'll never reach the filesystem root, because to get to this point in the
|
||||
// code
|
||||
// the call to `cargo_metadata::metadata` must have succeeded. So it's okay to
|
||||
// unwrap the current path's parent.
|
||||
current_path = current_path
|
||||
.parent()
|
||||
.unwrap_or_else(|| panic!("could not find parent of path {}", current_path.display()));
|
||||
}
|
||||
}
|
||||
}.expect("could not find matching package");
|
||||
}
|
||||
}.expect("could not find matching package");
|
||||
|
||||
vec![metadata.packages.remove(package_index)]
|
||||
};
|
||||
vec![metadata.packages.remove(package_index)]
|
||||
};
|
||||
|
||||
for package in packages {
|
||||
let manifest_path = package.manifest_path;
|
||||
for package in packages {
|
||||
let manifest_path = package.manifest_path;
|
||||
|
||||
for target in package.targets {
|
||||
let args = std::env::args()
|
||||
.skip(2)
|
||||
.filter(|a| a != "--all" && !a.starts_with("--manifest-path="));
|
||||
for target in package.targets {
|
||||
let args = std::env::args()
|
||||
.skip(2)
|
||||
.filter(|a| a != "--all" && !a.starts_with("--manifest-path="));
|
||||
|
||||
let args = std::iter::once(format!("--manifest-path={}", manifest_path)).chain(args);
|
||||
if let Some(first) = target.kind.get(0) {
|
||||
if target.kind.len() > 1 || first.ends_with("lib") {
|
||||
if let Err(code) = process(std::iter::once("--lib".to_owned()).chain(args)) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
} else if ["bin", "example", "test", "bench"].contains(&&**first) {
|
||||
if let Err(code) = process(
|
||||
vec![format!("--{}", first), target.name]
|
||||
.into_iter()
|
||||
.chain(args),
|
||||
) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
let args = std::iter::once(format!("--manifest-path={}", manifest_path)).chain(args);
|
||||
if let Some(first) = target.kind.get(0) {
|
||||
if target.kind.len() > 1 || first.ends_with("lib") {
|
||||
if let Err(code) = process(std::iter::once("--lib".to_owned()).chain(args)) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
} else if ["bin", "example", "test", "bench"].contains(&&**first) {
|
||||
if let Err(code) = process(
|
||||
vec![format!("--{}", first), target.name]
|
||||
.into_iter()
|
||||
.chain(args),
|
||||
) {
|
||||
std::process::exit(code);
|
||||
}
|
||||
} else {
|
||||
panic!("badly formatted cargo metadata: target::kind is an empty array");
|
||||
}
|
||||
} else {
|
||||
panic!("badly formatted cargo metadata: target::kind is an empty array");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// this arm is executed when cargo-clippy runs `cargo rustc` with the `RUSTC_WRAPPER`
|
||||
// env var set to itself
|
||||
|
||||
let home = option_env!("RUSTUP_HOME").or(option_env!("MULTIRUST_HOME"));
|
||||
let toolchain = option_env!("RUSTUP_TOOLCHAIN").or(option_env!("MULTIRUST_TOOLCHAIN"));
|
||||
let sys_root = if let (Some(home), Some(toolchain)) = (home, toolchain) {
|
||||
format!("{}/toolchains/{}", home, toolchain)
|
||||
} else {
|
||||
option_env!("SYSROOT")
|
||||
.map(|s| s.to_owned())
|
||||
.or_else(|| {
|
||||
Command::new("rustc")
|
||||
.arg("--print")
|
||||
.arg("sysroot")
|
||||
.output()
|
||||
.ok()
|
||||
.and_then(|out| String::from_utf8(out.stdout).ok())
|
||||
.map(|s| s.trim().to_owned())
|
||||
})
|
||||
.expect(
|
||||
"need to specify SYSROOT env var during clippy compilation, or use rustup or multirust",
|
||||
)
|
||||
};
|
||||
|
||||
rustc_driver::in_rustc_thread(|| {
|
||||
// Setting RUSTC_WRAPPER causes Cargo to pass 'rustc' as the first argument.
|
||||
// We're invoking the compiler programatically, so we ignore this/
|
||||
let orig_args: Vec<String> = env::args().skip(1).collect();
|
||||
|
||||
// this conditional check for the --sysroot flag is there so users can call
|
||||
// `cargo-clippy` directly
|
||||
// without having to pass --sysroot or anything
|
||||
let mut args: Vec<String> = if orig_args.iter().any(|s| s == "--sysroot") {
|
||||
orig_args.clone()
|
||||
} else {
|
||||
orig_args.clone().into_iter()
|
||||
.chain(Some("--sysroot".to_owned()))
|
||||
.chain(Some(sys_root))
|
||||
.collect()
|
||||
};
|
||||
|
||||
// this check ensures that dependencies are built but not linted and the final
|
||||
// crate is
|
||||
// linted but not built
|
||||
let clippy_enabled = orig_args.iter().any(|s| s == "--emit=metadata");
|
||||
|
||||
if clippy_enabled {
|
||||
args.extend_from_slice(&["--cfg".to_owned(), r#"feature="cargo-clippy""#.to_owned()]);
|
||||
}
|
||||
|
||||
let mut ccc = ClippyCompilerCalls::new(clippy_enabled);
|
||||
let (result, _) = rustc_driver::run_compiler(&args, &mut ccc, None, None);
|
||||
if let Err(CompileIncomplete::Errored(_)) = result {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}).expect("rustc_thread failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,7 +185,9 @@ where
|
|||
args.push("--cfg".to_owned());
|
||||
args.push(r#"feature="cargo-clippy""#.to_owned());
|
||||
|
||||
let path = std::env::current_exe().expect("current executable path invalid");
|
||||
let path = std::env::current_exe()
|
||||
.expect("current executable path invalid")
|
||||
.with_file_name("clippy-driver");
|
||||
let exit_status = std::process::Command::new("cargo")
|
||||
.args(&args)
|
||||
.env("RUSTC_WRAPPER", path)
|
||||
|
|
|
@ -3,6 +3,14 @@ extern crate compiletest_rs as compiletest;
|
|||
use std::path::PathBuf;
|
||||
use std::env::{set_var, var};
|
||||
|
||||
fn clippy_driver_path() -> PathBuf {
|
||||
if let Some(path) = option_env!("CLIPPY_DRIVER_PATH") {
|
||||
PathBuf::from(path)
|
||||
} else {
|
||||
PathBuf::from(concat!("target/", env!("PROFILE"), "/clippy-driver"))
|
||||
}
|
||||
}
|
||||
|
||||
fn run_mode(dir: &'static str, mode: &'static str) {
|
||||
let mut config = compiletest::Config::default();
|
||||
|
||||
|
@ -16,12 +24,15 @@ fn run_mode(dir: &'static str, mode: &'static str) {
|
|||
config.mode = cfg_mode;
|
||||
config.build_base = PathBuf::from("target/debug/test_build_base");
|
||||
config.src_base = PathBuf::from(format!("tests/{}", dir));
|
||||
config.rustc_path = clippy_driver_path();
|
||||
|
||||
compiletest::run_tests(&config);
|
||||
}
|
||||
|
||||
fn prepare_env() {
|
||||
set_var("CLIPPY_DISABLE_DOCS_LINKS", "true");
|
||||
set_var("CLIPPY_TESTS", "true");
|
||||
set_var("RUST_BACKTRACE", "0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -29,8 +40,4 @@ fn compile_test() {
|
|||
prepare_env();
|
||||
run_mode("run-pass", "run-pass");
|
||||
run_mode("ui", "ui");
|
||||
#[cfg(target_os = "windows")]
|
||||
run_mode("ui-windows", "ui");
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
run_mode("ui-posix", "ui");
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy(conf_file="./tests/auxiliary/conf_whitelisted.toml"))]
|
||||
|
||||
fn main() {}
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
pub trait Trait {
|
||||
const CONSTANT: u8;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![deny(clippy)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![allow(clippy)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![allow(clippy)]
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![deny(clippy)]
|
||||
|
||||
fn core() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![deny(mut_mut, zero_ptr, cmp_nan)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![feature(conservative_impl_trait)]
|
||||
#![deny(needless_lifetimes)]
|
||||
#![allow(dead_code)]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy, clippy_mini_macro_test)]
|
||||
#![plugin(clippy_mini_macro_test)]
|
||||
|
||||
#[deny(warnings)]
|
||||
fn main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![allow(blacklisted_name)]
|
||||
|
||||
pub fn foo(bar: *const u8) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![warn(single_match_else)]
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
// error-pattern: error reading Clippy's configuration file
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy(conf_file="./tests/auxiliary/non_existant_conf.toml"))]
|
||||
|
||||
fn main() {}
|
|
@ -1,4 +0,0 @@
|
|||
error: error reading Clippy's configuration file: No such file or directory (os error 2)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
# A script to update the references for all tests. The idea is that
|
||||
# you do a run, which will generate files in the build directory
|
||||
# containing the (normalized) actual output of the compiler. You then
|
||||
# run this script, which will copy those files over. If you find
|
||||
# yourself manually editing a foo.stderr file, you're doing it wrong.
|
||||
#
|
||||
# See all `update-references.sh`, if you just want to update a single test.
|
||||
|
||||
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" ]]; then
|
||||
echo "usage: $0"
|
||||
fi
|
||||
|
||||
BUILD_DIR=$PWD/target/debug/test_build_base
|
||||
MY_DIR=$(dirname $0)
|
||||
cd $MY_DIR
|
||||
find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR
|
|
@ -1,50 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
# A script to update the references for particular tests. The idea is
|
||||
# that you do a run, which will generate files in the build directory
|
||||
# containing the (normalized) actual output of the compiler. This
|
||||
# script will then copy that output and replace the "expected output"
|
||||
# files. You can then commit the changes.
|
||||
#
|
||||
# If you find yourself manually editing a foo.stderr file, you're
|
||||
# doing it wrong.
|
||||
|
||||
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
|
||||
echo "usage: $0 <build-directory> <relative-path-to-rs-files>"
|
||||
echo ""
|
||||
echo "For example:"
|
||||
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
|
||||
fi
|
||||
|
||||
MYDIR=$(dirname $0)
|
||||
|
||||
BUILD_DIR="$1"
|
||||
shift
|
||||
|
||||
while [[ "$1" != "" ]]; do
|
||||
STDERR_NAME="${1/%.rs/.stderr}"
|
||||
STDOUT_NAME="${1/%.rs/.stdout}"
|
||||
shift
|
||||
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
|
||||
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
|
||||
echo updating $MYDIR/$STDOUT_NAME
|
||||
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
|
||||
fi
|
||||
if [ -f $BUILD_DIR/$STDERR_NAME ] && \
|
||||
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
|
||||
echo updating $MYDIR/$STDERR_NAME
|
||||
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
// error-pattern: error reading Clippy's configuration file
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy(conf_file="./tests/auxiliary/non_existant_conf.toml"))]
|
||||
|
||||
fn main() {}
|
|
@ -1,4 +0,0 @@
|
|||
error: error reading Clippy's configuration file: The system cannot find the file specified. (os error 2)
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
# A script to update the references for all tests. The idea is that
|
||||
# you do a run, which will generate files in the build directory
|
||||
# containing the (normalized) actual output of the compiler. You then
|
||||
# run this script, which will copy those files over. If you find
|
||||
# yourself manually editing a foo.stderr file, you're doing it wrong.
|
||||
#
|
||||
# See all `update-references.sh`, if you just want to update a single test.
|
||||
|
||||
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" ]]; then
|
||||
echo "usage: $0"
|
||||
fi
|
||||
|
||||
BUILD_DIR=$PWD/target/debug/test_build_base
|
||||
MY_DIR=$(dirname $0)
|
||||
cd $MY_DIR
|
||||
find . -name '*.rs' | xargs ./update-references.sh $BUILD_DIR
|
|
@ -1,50 +0,0 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
# file at the top-level directory of this distribution and at
|
||||
# http://rust-lang.org/COPYRIGHT.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
# option. This file may not be copied, modified, or distributed
|
||||
# except according to those terms.
|
||||
|
||||
# A script to update the references for particular tests. The idea is
|
||||
# that you do a run, which will generate files in the build directory
|
||||
# containing the (normalized) actual output of the compiler. This
|
||||
# script will then copy that output and replace the "expected output"
|
||||
# files. You can then commit the changes.
|
||||
#
|
||||
# If you find yourself manually editing a foo.stderr file, you're
|
||||
# doing it wrong.
|
||||
|
||||
if [[ "$1" == "--help" || "$1" == "-h" || "$1" == "" || "$2" == "" ]]; then
|
||||
echo "usage: $0 <build-directory> <relative-path-to-rs-files>"
|
||||
echo ""
|
||||
echo "For example:"
|
||||
echo " $0 ../../../build/x86_64-apple-darwin/test/ui *.rs */*.rs"
|
||||
fi
|
||||
|
||||
MYDIR=$(dirname $0)
|
||||
|
||||
BUILD_DIR="$1"
|
||||
shift
|
||||
|
||||
while [[ "$1" != "" ]]; do
|
||||
STDERR_NAME="${1/%.rs/.stderr}"
|
||||
STDOUT_NAME="${1/%.rs/.stdout}"
|
||||
shift
|
||||
if [ -f $BUILD_DIR/$STDOUT_NAME ] && \
|
||||
! (diff $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME >& /dev/null); then
|
||||
echo updating $MYDIR/$STDOUT_NAME
|
||||
cp $BUILD_DIR/$STDOUT_NAME $MYDIR/$STDOUT_NAME
|
||||
fi
|
||||
if [ -f $BUILD_DIR/$STDERR_NAME ] && \
|
||||
! (diff $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME >& /dev/null); then
|
||||
echo updating $MYDIR/$STDERR_NAME
|
||||
cp $BUILD_DIR/$STDERR_NAME $MYDIR/$STDERR_NAME
|
||||
fi
|
||||
done
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![warn(absurd_extreme_comparisons)]
|
||||
#![allow(unused, eq_op, no_effect, unnecessary_operation, needless_pass_by_value)]
|
||||
|
|
|
@ -143,5 +143,3 @@ error: <-comparison of unit values detected. This will always be false
|
|||
|
|
||||
= note: `-D unit-cmp` implied by `-D warnings`
|
||||
|
||||
error: aborting due to 18 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(approx_constant)]
|
||||
#[allow(unused, shadow_unrelated, similar_names)]
|
||||
|
|
|
@ -114,5 +114,3 @@ error: approximate value of `f{32, 64}::consts::SQRT_2` found. Consider using it
|
|||
55 | let my_sq2 = 1.4142;
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![warn(integer_arithmetic, float_arithmetic)]
|
||||
#![allow(unused, shadow_reuse, shadow_unrelated, no_effect, unnecessary_operation)]
|
||||
|
|
|
@ -69,5 +69,3 @@ error: floating-point arithmetic detected
|
|||
29 | -f;
|
||||
| ^^
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(inclusive_range_syntax, plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![warn(indexing_slicing)]
|
||||
#![warn(out_of_bounds_indexing)]
|
||||
|
|
|
@ -116,5 +116,3 @@ error: range is out of bounds
|
|||
44 | &empty[..4];
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 19 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(assign_ops)]
|
||||
#[allow(unused_assignments)]
|
||||
|
|
|
@ -134,5 +134,3 @@ error: manual implementation of an assign operation
|
|||
40 | s = s + "bla";
|
||||
| ^^^^^^^^^^^^^ help: replace it with: `s += "bla"`
|
||||
|
||||
error: aborting due to 22 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[allow(unused_assignments)]
|
||||
#[warn(misrefactored_assign_op)]
|
||||
|
|
|
@ -48,5 +48,3 @@ error: variable appears on both sides of an assignment operation
|
|||
15 | a &= a & 1;
|
||||
| ^^^^^^^^^^ help: replace it with: `a &= 1`
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![warn(inline_always, deprecated_semver)]
|
||||
|
||||
|
|
|
@ -20,5 +20,3 @@ error: the since field must contain a semver-compliant version
|
|||
30 | #[deprecated(since = "1")]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
const THREE_BITS : i64 = 7;
|
||||
const EVEN_MORE_REDIRECTION : i64 = THREE_BITS;
|
||||
|
|
|
@ -92,5 +92,3 @@ error: ineffective bit mask: `x | 1` compared to `8`, is the same as x compared
|
|||
55 | x | 1 >= 8;
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![allow(dead_code, similar_names, single_match, toplevel_ref_arg, unused_mut, unused_variables)]
|
||||
#![warn(blacklisted_name)]
|
||||
|
|
|
@ -84,5 +84,3 @@ error: use of a blacklisted/placeholder name `baz`
|
|||
35 | if let Some(ref mut baz) = Some(42) {}
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![warn(block_in_if_condition_expr)]
|
||||
#![warn(block_in_if_condition_stmt)]
|
||||
|
|
|
@ -50,5 +50,3 @@ error: this boolean expression can be simplified
|
|||
|
|
||||
= note: `-D nonminimal-bool` implied by `-D warnings`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(bool_comparison)]
|
||||
fn main() {
|
||||
|
|
|
@ -24,5 +24,3 @@ error: equality checks against false can be replaced by a negation
|
|||
10 | if false == x { "yes" } else { "no" };
|
||||
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![warn(nonminimal_bool, logic_bug)]
|
||||
|
||||
#[allow(unused, many_single_char_names)]
|
||||
|
|
|
@ -130,5 +130,3 @@ help: try
|
|||
39 | let _ = !(a == b && c == d);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![deny(borrowed_box)]
|
||||
#![allow(blacklisted_name)]
|
||||
|
|
|
@ -28,5 +28,3 @@ error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
|
|||
22 | fn test4(a: &Box<bool>);
|
||||
| ^^^^^^^^^^ help: try: `&bool`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![warn(clippy)]
|
||||
#![allow(boxed_local, needless_pass_by_value)]
|
||||
|
|
|
@ -7,5 +7,3 @@ error: you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`
|
|||
= note: `-D box-vec` implied by `-D warnings`
|
||||
= help: `Vec<T>` is already on the heap, `Box<Vec<T>>` makes an extra allocation.
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![warn(builtin_type_shadow)]
|
||||
|
||||
fn foo<u32>(a: u32) -> u32 {
|
||||
|
|
|
@ -17,5 +17,3 @@ error[E0308]: mismatched types
|
|||
= note: expected type `u32`
|
||||
found type `{integer}`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[deny(naive_bytecount)]
|
||||
fn main() {
|
||||
|
|
|
@ -22,5 +22,3 @@ error: You appear to be counting bytes the naive way
|
|||
22 | let _ = x.iter().filter(|a| b + 1 == **a).count(); // naive byte count
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: Consider using the bytecount crate: `bytecount::count(x, b + 1)`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap, cast_lossless)]
|
||||
#[allow(no_effect, unnecessary_operation)]
|
||||
|
|
|
@ -460,5 +460,3 @@ error: casting to the same type is unnecessary (`bool` -> `bool`)
|
|||
88 | false as bool;
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 75 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![warn(char_lit_as_u8)]
|
||||
#![allow(unused_variables)]
|
||||
|
|
|
@ -8,5 +8,3 @@ error: casting character literal to u8. `char`s are 4 bytes wide in rust, so cas
|
|||
= help: Consider using a byte literal instead:
|
||||
b'a'
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(cmp_nan)]
|
||||
#[allow(float_cmp, no_effect, unnecessary_operation)]
|
||||
|
|
|
@ -72,5 +72,3 @@ error: doomed comparison with NAN, use `std::{f32,f64}::is_nan()` instead
|
|||
21 | y >= std::f64::NAN;
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![warn(cmp_null)]
|
||||
#![allow(unused_mut)]
|
||||
|
||||
|
|
|
@ -12,5 +12,3 @@ error: Comparing with null is better expressed by the .is_null() method
|
|||
16 | if m == ptr::null_mut() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(cmp_owned)]
|
||||
#[allow(unnecessary_operation)]
|
||||
|
|
|
@ -36,5 +36,3 @@ error: this creates an owned instance just for comparison
|
|||
30 | self.to_owned() == *other
|
||||
| ^^^^^^^^^^^^^^^ try calling implementing the comparison without allocating
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(collapsible_if)]
|
||||
fn main() {
|
||||
|
|
|
@ -252,5 +252,3 @@ help: try
|
|||
112 | }
|
||||
|
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![warn(clippy)]
|
||||
#![allow(unused, needless_pass_by_value)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
|
|
@ -90,5 +90,3 @@ error: very complex type used. Consider factoring parts into `type` definitions
|
|||
40 | let _y: Vec<Vec<Box<(u32, u32, u32, u32)>>> = vec![];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// error-pattern: `conf_file` must be a named value
|
||||
|
||||
#![feature(plugin)]
|
||||
|
||||
#![plugin(clippy(conf_file))]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
error: `conf_file` must be a named value
|
||||
--> $DIR/conf_bad_arg.rs:4:18
|
||||
error: compiler plugins are experimental and possibly buggy (see issue #29597)
|
||||
--> $DIR/conf_bad_arg.rs:4:1
|
||||
|
|
||||
4 | #![plugin(clippy(conf_file))]
|
||||
| ^^^^^^^^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: Clippy will use default configuration
|
||||
--> $DIR/conf_bad_arg.rs:4:18
|
||||
|
|
||||
4 | #![plugin(clippy(conf_file))]
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
= help: add #![feature(plugin)] to the crate attributes to enable
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// error-pattern: error reading Clippy's configuration file
|
||||
|
||||
#![feature(plugin)]
|
||||
|
||||
#![plugin(clippy(conf_file="./tests/ui/conf_bad_toml.toml"))]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
error: error reading Clippy's configuration file: expected an equals, found an identifier at line 1
|
||||
|
||||
error: aborting due to previous error
|
||||
error: compiler plugins are experimental and possibly buggy (see issue #29597)
|
||||
--> $DIR/conf_bad_toml.rs:4:1
|
||||
|
|
||||
4 | #![plugin(clippy(conf_file="./$DIR/conf_bad_toml.toml"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(plugin)] to the crate attributes to enable
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a `Vec < String >` but is a `integer`
|
||||
|
||||
#![feature(plugin)]
|
||||
|
||||
#![plugin(clippy(conf_file="./tests/ui/conf_bad_type.toml"))]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
error: error reading Clippy's configuration file: invalid type: integer `42`, expected a sequence
|
||||
|
||||
error: aborting due to previous error
|
||||
error: compiler plugins are experimental and possibly buggy (see issue #29597)
|
||||
--> $DIR/conf_bad_type.rs:4:1
|
||||
|
|
||||
4 | #![plugin(clippy(conf_file="./$DIR/conf_bad_type.toml"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(plugin)] to the crate attributes to enable
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(plugin)]
|
||||
|
||||
#![plugin(clippy(conf_file="./tests/auxiliary/conf_french_blacklisted_name.toml"))]
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
|
|
@ -1,46 +1,8 @@
|
|||
error: use of a blacklisted/placeholder name `toto`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:9:9
|
||||
error: compiler plugins are experimental and possibly buggy (see issue #29597)
|
||||
--> $DIR/conf_french_blacklisted_name.rs:2:1
|
||||
|
|
||||
9 | fn test(toto: ()) {}
|
||||
| ^^^^
|
||||
2 | #![plugin(clippy(conf_file="./tests/auxiliary/conf_french_blacklisted_name.toml"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D blacklisted-name` implied by `-D warnings`
|
||||
|
||||
error: use of a blacklisted/placeholder name `toto`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:12:9
|
||||
|
|
||||
12 | let toto = 42;
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `tata`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:13:9
|
||||
|
|
||||
13 | let tata = 42;
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `titi`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:14:9
|
||||
|
|
||||
14 | let titi = 42;
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `toto`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:20:10
|
||||
|
|
||||
20 | (toto, Some(tata), titi @ Some(_)) => (),
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `tata`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:20:21
|
||||
|
|
||||
20 | (toto, Some(tata), titi @ Some(_)) => (),
|
||||
| ^^^^
|
||||
|
||||
error: use of a blacklisted/placeholder name `titi`
|
||||
--> $DIR/conf_french_blacklisted_name.rs:20:28
|
||||
|
|
||||
20 | (toto, Some(tata), titi @ Some(_)) => (),
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
= help: add #![feature(plugin)] to the crate attributes to enable
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(attr_literals)]
|
||||
#![feature(plugin)]
|
||||
|
||||
#![plugin(clippy(conf_file=42))]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
error: `conf_file` value must be a string
|
||||
--> $DIR/conf_path_non_string.rs:3:28
|
||||
error: compiler plugins are experimental and possibly buggy (see issue #29597)
|
||||
--> $DIR/conf_path_non_string.rs:3:1
|
||||
|
|
||||
3 | #![plugin(clippy(conf_file=42))]
|
||||
| ^^
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: Clippy will use default configuration
|
||||
--> $DIR/conf_path_non_string.rs:3:28
|
||||
|
|
||||
3 | #![plugin(clippy(conf_file=42))]
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
= help: add #![feature(plugin)] to the crate attributes to enable
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// error-pattern: error reading Clippy's configuration file: unknown key `foobar`
|
||||
|
||||
#![feature(plugin)]
|
||||
|
||||
#![plugin(clippy(conf_file="./tests/auxiliary/conf_unknown_key.toml"))]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
error: error reading Clippy's configuration file: unknown field `foobar`, expected one of `blacklisted-names`, `cyclomatic-complexity-threshold`, `doc-valid-idents`, `too-many-arguments-threshold`, `type-complexity-threshold`, `single-char-binding-names-threshold`, `too-large-for-stack`, `enum-variant-name-threshold`, `enum-variant-size-threshold`, `verbose-bit-mask-threshold`, `third-party`
|
||||
|
||||
error: aborting due to previous error
|
||||
error: compiler plugins are experimental and possibly buggy (see issue #29597)
|
||||
--> $DIR/conf_unknown_key.rs:4:1
|
||||
|
|
||||
4 | #![plugin(clippy(conf_file="./tests/auxiliary/conf_unknown_key.toml"))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add #![feature(plugin)] to the crate attributes to enable
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#![feature(plugin, dotdoteq_in_patterns, inclusive_range_syntax)]
|
||||
#![plugin(clippy)]
|
||||
#![feature(dotdoteq_in_patterns, inclusive_range_syntax)]
|
||||
|
||||
#![allow(dead_code, no_effect, unnecessary_operation)]
|
||||
#![allow(let_and_return)]
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error: This else block is redundant.
|
||||
|
||||
--> $DIR/copies.rs:121:20
|
||||
--> $DIR/copies.rs:120:20
|
||||
|
|
||||
121 | } else {
|
||||
120 | } else {
|
||||
| ____________________^
|
||||
122 | | continue;
|
||||
123 | | }
|
||||
121 | | continue;
|
||||
122 | | }
|
||||
| |_____________^
|
||||
|
|
||||
= note: `-D needless-continue` implied by `-D warnings`
|
||||
|
@ -18,12 +18,12 @@ error: This else block is redundant.
|
|||
|
||||
error: This else block is redundant.
|
||||
|
||||
--> $DIR/copies.rs:131:20
|
||||
--> $DIR/copies.rs:130:20
|
||||
|
|
||||
131 | } else {
|
||||
130 | } else {
|
||||
| ____________________^
|
||||
132 | | continue;
|
||||
133 | | }
|
||||
131 | | continue;
|
||||
132 | | }
|
||||
| |_____________^
|
||||
|
|
||||
= help: Consider dropping the else clause and merging the code that follows (in the loop) with the if block, like so:
|
||||
|
@ -33,5 +33,3 @@ error: This else block is redundant.
|
|||
}
|
||||
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin, custom_attribute)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
#![allow(clippy)]
|
||||
#![warn(cyclomatic_complexity)]
|
||||
#![allow(unused)]
|
||||
|
|
|
@ -269,5 +269,3 @@ error: the function has a cyclomatic complexity of 8
|
|||
|
|
||||
= help: you could split it up into multiple smaller functions
|
||||
|
||||
error: aborting due to 20 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin, custom_attribute)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
#![warn(cyclomatic_complexity)]
|
||||
#![warn(unused)]
|
||||
|
||||
|
|
|
@ -13,5 +13,3 @@ error: the function has a cyclomatic complexity of 3
|
|||
= note: `-D cyclomatic-complexity` implied by `-D warnings`
|
||||
= help: you could split it up into multiple smaller functions
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(str_to_string)]
|
||||
|
||||
|
|
|
@ -24,5 +24,3 @@ error: lint unstable_as_mut_slice has been removed: `Vec::as_mut_slice` has been
|
|||
10 | #[warn(unstable_as_mut_slice)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#![feature(untagged_unions)]
|
||||
|
||||
|
|
|
@ -106,5 +106,3 @@ note: consider deriving `Clone` or removing `Copy`
|
|||
87 | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin, never_type)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
#![warn(diverging_sub_expression)]
|
||||
#![allow(match_same_arms, logic_bug)]
|
||||
|
||||
|
|
|
@ -36,5 +36,3 @@ error: sub-expression diverges
|
|||
37 | _ => true || break,
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#![feature(plugin, alloc)]
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
#![plugin(clippy)]
|
||||
|
||||
#![warn(clippy)]
|
||||
#![allow(dead_code, needless_pass_by_value)]
|
||||
|
||||
|
|
|
@ -47,5 +47,3 @@ error: I see you're using a LinkedList! Perhaps you meant some other data struct
|
|||
|
|
||||
= help: a VecDeque might work
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! This file tests for the DOC_MARKDOWN lint
|
||||
|
||||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![warn(doc_markdown)]
|
||||
|
||||
|
|
|
@ -180,5 +180,3 @@ error: you should put bare URLs between `<`/`>` or make a proper Markdown link
|
|||
168 | /// Not ok: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 30 previous errors
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
|
||||
|
||||
|
||||
#[warn(double_neg)]
|
||||
fn main() {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue