Auto merge of #11239 - oli-obk:ui_test, r=Alexendoo,flip1995

Update ui test crate

This update also removes the `//`@run-rustfix`` flag, and just runs rustfix on all tests. This means I had to opt out of running rustfix on ~100 tests, but it also allowed me to remove the rustfix coverage check entirely, as it is now effectively builtin.

changelog: update ui-test crate to 0.13 (automatically runs rustfix on all tests)
This commit is contained in:
bors 2023-08-11 15:14:09 +00:00
commit 739faf3641
1264 changed files with 7093 additions and 6151 deletions

View file

@ -1,7 +1,7 @@
[alias]
uitest = "test --test compile-test"
uibless = "test --test compile-test -- -- --bless"
bless = "test -- -- --bless"
uitest = "test --test compile-test -- --check"
uibless = "test --test compile-test"
bless = "test"
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --"
lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
collect-metadata = "test --test dogfood --features internal -- run_metadata_collection_lint --ignored"

View file

@ -27,7 +27,7 @@ tempfile = { version = "3.2", optional = true }
termize = "0.1"
[dev-dependencies]
ui_test = "0.11.5"
ui_test = "0.17.0"
tester = "0.9"
regex = "1.5"
toml = "0.7.3"

View file

@ -161,8 +161,8 @@ The process of generating the `.stderr` file is the same, and prepending the
## Rustfix tests
If the lint you are working on is making use of structured suggestions, the test
file should include a `//@run-rustfix` comment at the top. This will
additionally run [rustfix] for that test. Rustfix will apply the suggestions
will create a `.fixed` file by running [rustfix] for that test.
Rustfix will apply the suggestions
from the lint to the code of the test file and compare that to the contents of a
`.fixed` file.

View file

@ -690,7 +690,6 @@ fn gen_deprecated_lints_test(lints: &[DeprecatedLint]) -> String {
fn gen_renamed_lints_test(lints: &[RenamedLint]) -> String {
let mut seen_lints = HashSet::new();
let mut res: String = GENERATED_FILE_COMMENT.into();
res.push_str("//@run-rustfix\n\n");
for lint in lints {
if seen_lints.insert(&lint.new_name) {
writeln!(res, "#![allow({})]", lint.new_name).unwrap();

View file

@ -5,7 +5,7 @@
#![warn(rust_2018_idioms, unused_lifetimes)]
#![allow(unused_extern_crates)]
use compiletest::{status_emitter, CommandBuilder, OutputConflictHandling};
use compiletest::{status_emitter, Args, CommandBuilder, OutputConflictHandling};
use ui_test as compiletest;
use ui_test::Mode as TestMode;
@ -110,28 +110,33 @@ mod test_utils;
// whether to run internal tests or not
const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
fn base_config(test_dir: &str) -> compiletest::Config {
fn canonicalize(path: impl AsRef<Path>) -> PathBuf {
let path = path.as_ref();
fs::create_dir_all(path).unwrap();
fs::canonicalize(path).unwrap_or_else(|err| panic!("{} cannot be canonicalized: {err}", path.display()))
}
fn base_config(test_dir: &str) -> (compiletest::Config, Args) {
let args = Args::test().unwrap();
let mut config = compiletest::Config {
mode: TestMode::Yolo,
mode: TestMode::Yolo { rustfix: true },
stderr_filters: vec![],
stdout_filters: vec![],
output_conflict_handling: if var_os("RUSTC_BLESS").is_some_and(|v| v != "0")
|| env::args().any(|arg| arg == "--bless")
output_conflict_handling: if var_os("GITHUB_ACTION").is_none()
&& (var_os("RUSTC_BLESS").is_some_and(|v| v != "0") || !args.check)
{
OutputConflictHandling::Bless
} else {
OutputConflictHandling::Error("cargo uibless".into())
},
target: None,
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap_or("target".into())).join("ui_test"),
out_dir: canonicalize(
std::env::var_os("CARGO_TARGET_DIR")
.map_or_else(|| std::env::current_dir().unwrap().join("target"), PathBuf::from),
)
.join("ui_test"),
..compiletest::Config::rustc(Path::new("tests").join(test_dir))
};
if let Some(_path) = option_env!("RUSTC_LIB_PATH") {
//let path = PathBuf::from(path);
//config.run_lib_path = path.clone();
//config.compile_lib_path = path;
}
let current_exe_path = env::current_exe().unwrap();
let deps_path = current_exe_path.parent().unwrap();
let profile_path = deps_path.parent().unwrap();
@ -164,7 +169,7 @@ fn base_config(test_dir: &str) -> compiletest::Config {
} else {
"clippy-driver"
});
config
(config, args)
}
fn test_filter() -> Box<dyn Sync + Fn(&Path) -> bool> {
@ -177,10 +182,10 @@ fn test_filter() -> Box<dyn Sync + Fn(&Path) -> bool> {
}
fn run_ui() {
let config = base_config("ui");
let (config, args) = base_config("ui");
//config.rustfix_coverage = true;
// use tests/clippy.toml
let _g = VarGuard::set("CARGO_MANIFEST_DIR", fs::canonicalize("tests").unwrap());
let _g = VarGuard::set("CARGO_MANIFEST_DIR", canonicalize("tests"));
let _threads = VarGuard::set(
"RUST_TEST_THREADS",
// if RUST_TEST_THREADS is set, adhere to it, otherwise override it
@ -193,14 +198,20 @@ fn run_ui() {
let test_filter = test_filter();
let quiet = args.quiet;
compiletest::run_tests_generic(
config,
move |path| compiletest::default_file_filter(path) && test_filter(path),
vec![config],
args,
move |path, args, config| compiletest::default_file_filter(path, args, config) && test_filter(path),
compiletest::default_per_file_config,
status_emitter::Text,
if quiet {
status_emitter::Text::quiet()
} else {
status_emitter::Text::verbose()
},
)
.unwrap();
check_rustfix_coverage();
}
fn run_internal_tests() {
@ -208,28 +219,33 @@ fn run_internal_tests() {
if !RUN_INTERNAL_TESTS {
return;
}
let mut config = base_config("ui-internal");
let (mut config, args) = base_config("ui-internal");
if let OutputConflictHandling::Error(err) = &mut config.output_conflict_handling {
*err = "cargo uitest --features internal -- -- --bless".into();
*err = "cargo uitest --features internal".into();
}
let test_filter = test_filter();
let quiet = args.quiet;
compiletest::run_tests_generic(
config,
move |path| compiletest::default_file_filter(path) && test_filter(path),
vec![config],
args,
move |path, args, config| compiletest::default_file_filter(path, args, config) && test_filter(path),
compiletest::default_per_file_config,
status_emitter::Text,
if quiet {
status_emitter::Text::quiet()
} else {
status_emitter::Text::verbose()
},
)
.unwrap();
}
fn run_ui_toml() {
let mut config = base_config("ui-toml");
let (mut config, args) = base_config("ui-toml");
config.stderr_filter(
&regex::escape(
&fs::canonicalize("tests")
.unwrap()
&canonicalize("tests")
.parent()
.unwrap()
.display()
@ -240,19 +256,23 @@ fn run_ui_toml() {
);
let test_filter = test_filter();
let quiet = args.quiet;
ui_test::run_tests_generic(
config,
|path| compiletest::default_file_filter(path) && test_filter(path),
|config, path| {
let mut config = config.clone();
vec![config],
args,
|path, args, config| compiletest::default_file_filter(path, args, config) && test_filter(path),
|config, path, _file_contents| {
config
.program
.envs
.push(("CLIPPY_CONF_DIR".into(), Some(path.parent().unwrap().into())));
Some(config)
},
status_emitter::Text,
if quiet {
status_emitter::Text::quiet()
} else {
status_emitter::Text::verbose()
},
)
.unwrap();
}
@ -262,7 +282,7 @@ fn run_ui_cargo() {
return;
}
let mut config = base_config("ui-cargo");
let (mut config, args) = base_config("ui-cargo");
config.program.input_file_flag = CommandBuilder::cargo().input_file_flag;
config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag;
config.program.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()];
@ -282,8 +302,7 @@ fn run_ui_cargo() {
config.stderr_filter(
&regex::escape(
&fs::canonicalize("tests")
.unwrap()
&canonicalize("tests")
.parent()
.unwrap()
.display()
@ -294,16 +313,26 @@ fn run_ui_cargo() {
);
let test_filter = test_filter();
let quiet = args.quiet;
ui_test::run_tests_generic(
config,
|path| test_filter(path) && path.ends_with("Cargo.toml"),
|config, path| {
let mut config = config.clone();
config.out_dir = PathBuf::from("target/ui_test_cargo/").join(path.parent().unwrap());
Some(config)
vec![config],
args,
|path, _args, _config| test_filter(path) && path.ends_with("Cargo.toml"),
|config, path, _file_contents| {
config.out_dir = canonicalize(
std::env::current_dir()
.unwrap()
.join("target")
.join("ui_test_cargo/")
.join(path.parent().unwrap()),
);
},
if quiet {
status_emitter::Text::quiet()
} else {
status_emitter::Text::verbose()
},
status_emitter::Text,
)
.unwrap();
}
@ -328,7 +357,6 @@ fn main() {
"cargo" => run_ui_cargo as fn(),
"toml" => run_ui_toml as fn(),
"internal" => run_internal_tests as fn(),
"rustfix-coverage-known-exceptions-accuracy" => rustfix_coverage_known_exceptions_accuracy as fn(),
"ui-cargo-toml-metadata" => ui_cargo_toml_metadata as fn(),
_ => panic!("unknown speedtest: {speedtest} || accepted speedtests are: [ui, cargo, toml, internal]"),
@ -355,89 +383,10 @@ fn main() {
run_ui_toml();
run_ui_cargo();
run_internal_tests();
rustfix_coverage_known_exceptions_accuracy();
ui_cargo_toml_metadata();
}
}
const RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS: &[&str] = &[
"assign_ops2.rs",
"borrow_deref_ref_unfixable.rs",
"cast_size_32bit.rs",
"char_lit_as_u8.rs",
"cmp_owned/without_suggestion.rs",
"dbg_macro.rs",
"deref_addrof_double_trigger.rs",
"doc/unbalanced_ticks.rs",
"eprint_with_newline.rs",
"explicit_counter_loop.rs",
"iter_skip_next_unfixable.rs",
"let_and_return.rs",
"literals.rs",
"map_flatten.rs",
"map_unwrap_or.rs",
"match_bool.rs",
"mem_replace_macro.rs",
"needless_arbitrary_self_type_unfixable.rs",
"needless_borrow_pat.rs",
"needless_for_each_unfixable.rs",
"nonminimal_bool.rs",
"print_literal.rs",
"redundant_static_lifetimes_multiple.rs",
"ref_binding_to_reference.rs",
"repl_uninit.rs",
"result_map_unit_fn_unfixable.rs",
"search_is_some.rs",
"single_component_path_imports_nested_first.rs",
"string_add.rs",
"suspicious_to_owned.rs",
"toplevel_ref_arg_non_rustfix.rs",
"unit_arg.rs",
"unnecessary_clone.rs",
"unnecessary_lazy_eval_unfixable.rs",
"write_literal.rs",
"write_literal_2.rs",
];
fn check_rustfix_coverage() {
let missing_coverage_path = Path::new("debug/test/ui/rustfix_missing_coverage.txt");
let missing_coverage_path = if let Ok(target_dir) = std::env::var("CARGO_TARGET_DIR") {
PathBuf::from(target_dir).join(missing_coverage_path)
} else {
missing_coverage_path.to_path_buf()
};
if let Ok(missing_coverage_contents) = std::fs::read_to_string(missing_coverage_path) {
assert!(RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS.iter().is_sorted_by_key(Path::new));
for rs_file in missing_coverage_contents.lines() {
let rs_path = Path::new(rs_file);
if rs_path.starts_with("tests/ui/crashes") {
continue;
}
assert!(rs_path.starts_with("tests/ui/"), "{rs_file:?}");
let filename = rs_path.strip_prefix("tests/ui/").unwrap();
assert!(
RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS
.binary_search_by_key(&filename, Path::new)
.is_ok(),
"`{rs_file}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \
Please either add `//@run-rustfix` at the top of the file or add the file to \
`RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS` in `tests/compile-test.rs`.",
);
}
}
}
fn rustfix_coverage_known_exceptions_accuracy() {
for filename in RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS {
let rs_path = Path::new("tests/ui").join(filename);
assert!(rs_path.exists(), "`{}` does not exist", rs_path.display());
let fixed_path = rs_path.with_extension("fixed");
assert!(!fixed_path.exists(), "`{}` exists", fixed_path.display());
}
}
fn ui_cargo_toml_metadata() {
let ui_cargo_path = Path::new("tests/ui-cargo");
let cargo_common_metadata_path = ui_cargo_path.join("cargo_common_metadata");

View file

@ -16,7 +16,7 @@ fn old_test_headers() {
continue;
}
let file = fs::read_to_string(entry.path()).unwrap();
let file = fs::read_to_string(entry.path()).unwrap_or_else(|err| panic!("{}: {err}", entry.path().display()));
if let Some(header) = old_headers.find(&file) {
println!("Found header `{}` in {}", header.as_str(), entry.path().display());

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,5 +1,5 @@
error: this call is collapsible
--> $DIR/collapsible_span_lint_calls.rs:36:9
--> $DIR/collapsible_span_lint_calls.rs:35:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | | db.span_suggestion(expr.span, help_msg, sugg.to_string(), Applicability::MachineApplicable);
@ -7,14 +7,14 @@ LL | | });
| |__________^ help: collapse into: `span_lint_and_sugg(cx, TEST_LINT, expr.span, lint_msg, help_msg, sugg.to_string(), Applicability::MachineApplicable)`
|
note: the lint level is defined here
--> $DIR/collapsible_span_lint_calls.rs:2:9
--> $DIR/collapsible_span_lint_calls.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::collapsible_span_lint_calls)]` implied by `#[deny(clippy::internal)]`
error: this call is collapsible
--> $DIR/collapsible_span_lint_calls.rs:39:9
--> $DIR/collapsible_span_lint_calls.rs:38:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | | db.span_help(expr.span, help_msg);
@ -22,7 +22,7 @@ LL | | });
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), help_msg)`
error: this call is collapsible
--> $DIR/collapsible_span_lint_calls.rs:42:9
--> $DIR/collapsible_span_lint_calls.rs:41:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | | db.help(help_msg);
@ -30,7 +30,7 @@ LL | | });
| |__________^ help: collapse into: `span_lint_and_help(cx, TEST_LINT, expr.span, lint_msg, None, help_msg)`
error: this call is collapsible
--> $DIR/collapsible_span_lint_calls.rs:45:9
--> $DIR/collapsible_span_lint_calls.rs:44:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | | db.span_note(expr.span, note_msg);
@ -38,7 +38,7 @@ LL | | });
| |__________^ help: collapse into: `span_lint_and_note(cx, TEST_LINT, expr.span, lint_msg, Some(expr.span), note_msg)`
error: this call is collapsible
--> $DIR/collapsible_span_lint_calls.rs:48:9
--> $DIR/collapsible_span_lint_calls.rs:47:9
|
LL | / span_lint_and_then(cx, TEST_LINT, expr.span, lint_msg, |db| {
LL | | db.note(note_msg);

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
#![feature(rustc_private)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
#![feature(rustc_private)]

View file

@ -1,30 +1,30 @@
error: interning a defined symbol
--> $DIR/interning_defined_symbol.rs:18:13
--> $DIR/interning_defined_symbol.rs:17:13
|
LL | let _ = Symbol::intern("f32");
| ^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::f32`
|
note: the lint level is defined here
--> $DIR/interning_defined_symbol.rs:2:9
--> $DIR/interning_defined_symbol.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::interning_defined_symbol)]` implied by `#[deny(clippy::internal)]`
error: interning a defined symbol
--> $DIR/interning_defined_symbol.rs:21:13
--> $DIR/interning_defined_symbol.rs:20:13
|
LL | let _ = sym!(f32);
| ^^^^^^^^^ help: try: `rustc_span::sym::f32`
error: interning a defined symbol
--> $DIR/interning_defined_symbol.rs:24:13
--> $DIR/interning_defined_symbol.rs:23:13
|
LL | let _ = Symbol::intern("proc-macro");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::proc_dash_macro`
error: interning a defined symbol
--> $DIR/interning_defined_symbol.rs:27:13
--> $DIR/interning_defined_symbol.rs:26:13
|
LL | let _ = Symbol::intern("self");
| ^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::symbol::kw::SelfLower`

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,11 +1,11 @@
error: `extract_msrv_attr!` macro missing from `LateLintPass` implementation
--> $DIR/invalid_msrv_attr_impl.rs:30:1
--> $DIR/invalid_msrv_attr_impl.rs:28:1
|
LL | impl LateLintPass<'_> for Pass {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/invalid_msrv_attr_impl.rs:3:9
--> $DIR/invalid_msrv_attr_impl.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
@ -17,7 +17,7 @@ LL + extract_msrv_attr!(LateContext);
|
error: `extract_msrv_attr!` macro missing from `EarlyLintPass` implementation
--> $DIR/invalid_msrv_attr_impl.rs:34:1
--> $DIR/invalid_msrv_attr_impl.rs:32:1
|
LL | impl EarlyLintPass for Pass {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![deny(clippy::internal)]
#![allow(clippy::missing_clippy_version_attribute)]
#![feature(rustc_private)]

View file

@ -1,11 +1,11 @@
error: usage of `outer_expn().expn_data()`
--> $DIR/outer_expn_data.rs:25:34
--> $DIR/outer_expn_data.rs:23:34
|
LL | let _ = expr.span.ctxt().outer_expn().expn_data();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `outer_expn_data()`
|
note: the lint level is defined here
--> $DIR/outer_expn_data.rs:3:9
--> $DIR/outer_expn_data.rs:1:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,3 @@
//@run-rustfix
//@aux-build:paths.rs
#![deny(clippy::internal)]
#![feature(rustc_private)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
//@aux-build:paths.rs
#![deny(clippy::internal)]
#![feature(rustc_private)]

View file

@ -1,72 +1,72 @@
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:37:13
--> $DIR/unnecessary_def_path.rs:36:13
|
LL | let _ = match_type(cx, ty, &OPTION);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)`
|
note: the lint level is defined here
--> $DIR/unnecessary_def_path.rs:3:9
--> $DIR/unnecessary_def_path.rs:2:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::unnecessary_def_path)]` implied by `#[deny(clippy::internal)]`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:38:13
--> $DIR/unnecessary_def_path.rs:37:13
|
LL | let _ = match_type(cx, ty, RESULT);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:39:13
--> $DIR/unnecessary_def_path.rs:38:13
|
LL | let _ = match_type(cx, ty, &["core", "result", "Result"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:43:13
--> $DIR/unnecessary_def_path.rs:42:13
|
LL | let _ = clippy_utils::ty::match_type(cx, ty, rc_path);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Rc)`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:45:13
--> $DIR/unnecessary_def_path.rs:44:13
|
LL | let _ = match_type(cx, ty, &paths::OPTION);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Option)`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:46:13
--> $DIR/unnecessary_def_path.rs:45:13
|
LL | let _ = match_type(cx, ty, paths::RESULT);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::Result)`
error: use of a def path to a `LangItem`
--> $DIR/unnecessary_def_path.rs:48:13
--> $DIR/unnecessary_def_path.rs:47:13
|
LL | let _ = match_type(cx, ty, &["alloc", "boxed", "Box"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_lang_item(cx, ty, LangItem::OwnedBox)`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:49:13
--> $DIR/unnecessary_def_path.rs:48:13
|
LL | let _ = match_type(cx, ty, &["core", "mem", "maybe_uninit", "MaybeUninit", "uninit"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_type_diagnostic_item(cx, ty, sym::maybe_uninit_uninit)`
error: use of a def path to a `LangItem`
--> $DIR/unnecessary_def_path.rs:51:13
--> $DIR/unnecessary_def_path.rs:50:13
|
LL | let _ = match_def_path(cx, did, &["alloc", "boxed", "Box"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OwnedBox) == Some(did)`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:52:13
--> $DIR/unnecessary_def_path.rs:51:13
|
LL | let _ = match_def_path(cx, did, &["core", "option", "Option"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.is_diagnostic_item(sym::Option, did)`
error: use of a def path to a `LangItem`
--> $DIR/unnecessary_def_path.rs:53:13
--> $DIR/unnecessary_def_path.rs:52:13
|
LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cx.tcx.lang_items().get(LangItem::OptionSome) == Some(did)`
@ -74,25 +74,25 @@ LL | let _ = match_def_path(cx, did, &["core", "option", "Option", "Some"]);
= help: if this `DefId` came from a constructor expression or pattern then the parent `DefId` should be used instead
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:55:13
--> $DIR/unnecessary_def_path.rs:54:13
|
LL | let _ = match_trait_method(cx, expr, &["core", "convert", "AsRef"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_trait_method(cx, expr, sym::AsRef)`
error: use of a def path to a diagnostic item
--> $DIR/unnecessary_def_path.rs:57:13
--> $DIR/unnecessary_def_path.rs:56:13
|
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_path_diagnostic_item(cx, expr, sym::Option)`
error: use of a def path to a `LangItem`
--> $DIR/unnecessary_def_path.rs:58:13
--> $DIR/unnecessary_def_path.rs:57:13
|
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "iter", "traits", "Iterator", "next"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `path_res(cx, expr).opt_def_id().map_or(false, |id| cx.tcx.lang_items().get(LangItem::IteratorNext) == Some(id))`
error: use of a def path to a `LangItem`
--> $DIR/unnecessary_def_path.rs:59:13
--> $DIR/unnecessary_def_path.rs:58:13
|
LL | let _ = is_expr_path_def_path(cx, expr, &["core", "option", "Option", "Some"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `is_res_lang_ctor(cx, path_res(cx, expr), LangItem::OptionSome)`

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![feature(rustc_private)]
#![deny(clippy::internal)]
#![allow(

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![feature(rustc_private)]
#![deny(clippy::internal)]
#![allow(

View file

@ -1,36 +1,36 @@
error: unnecessary `Symbol` to string conversion
--> $DIR/unnecessary_symbol_str.rs:16:5
--> $DIR/unnecessary_symbol_str.rs:15:5
|
LL | Symbol::intern("foo").as_str() == "clippy";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::sym::clippy`
|
note: the lint level is defined here
--> $DIR/unnecessary_symbol_str.rs:3:9
--> $DIR/unnecessary_symbol_str.rs:2:9
|
LL | #![deny(clippy::internal)]
| ^^^^^^^^^^^^^^^^
= note: `#[deny(clippy::unnecessary_symbol_str)]` implied by `#[deny(clippy::internal)]`
error: unnecessary `Symbol` to string conversion
--> $DIR/unnecessary_symbol_str.rs:17:5
--> $DIR/unnecessary_symbol_str.rs:16:5
|
LL | Symbol::intern("foo").to_string() == "self";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") == rustc_span::symbol::kw::SelfLower`
error: unnecessary `Symbol` to string conversion
--> $DIR/unnecessary_symbol_str.rs:18:5
--> $DIR/unnecessary_symbol_str.rs:17:5
|
LL | Symbol::intern("foo").to_ident_string() != "Self";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Symbol::intern("foo") != rustc_span::symbol::kw::SelfUpper`
error: unnecessary `Symbol` to string conversion
--> $DIR/unnecessary_symbol_str.rs:19:5
--> $DIR/unnecessary_symbol_str.rs:18:5
|
LL | &*Ident::empty().as_str() == "clippy";
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Ident::empty().name == rustc_span::sym::clippy`
error: unnecessary `Symbol` to string conversion
--> $DIR/unnecessary_symbol_str.rs:20:5
--> $DIR/unnecessary_symbol_str.rs:19:5
|
LL | "clippy" == Ident::empty().to_string();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `rustc_span::sym::clippy == Ident::empty().name`

View file

@ -1,4 +1,4 @@
//@aux-build:../../ui/auxiliary/proc_macros.rs:proc-macro
//@aux-build:../../ui/auxiliary/proc_macros.rs
//@aux-build:helper.rs
//@revisions: allow_crates disallow_crates
//@[allow_crates] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/absolute_paths/allow_crates

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::uninlined_format_args)]
#![allow(clippy::unnecessary_literal_unwrap)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::uninlined_format_args)]
#![allow(clippy::unnecessary_literal_unwrap)]

View file

@ -1,5 +1,5 @@
error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:10:5
--> $DIR/uninlined_format_args.rs:9:5
|
LL | println!("val='{}'", local_i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL + println!("val='{local_i32}'");
|
error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:11:5
--> $DIR/uninlined_format_args.rs:10:5
|
LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL + println!("Hello {} is {local_f64:.local_i32$}", "x");
|
error: literal with an empty format string
--> $DIR/uninlined_format_args.rs:11:35
--> $DIR/uninlined_format_args.rs:10:35
|
LL | println!("Hello {} is {:.*}", "x", local_i32, local_f64);
| ^^^
@ -37,7 +37,7 @@ LL + println!("Hello x is {:.*}", local_i32, local_f64);
|
error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:12:5
--> $DIR/uninlined_format_args.rs:11:5
|
LL | println!("Hello {} is {:.*}", local_i32, 5, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -49,7 +49,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
|
error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:13:5
--> $DIR/uninlined_format_args.rs:12:5
|
LL | println!("Hello {} is {2:.*}", local_i32, 5, local_f64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -61,7 +61,7 @@ LL + println!("Hello {local_i32} is {local_f64:.*}", 5);
|
error: variables can be used directly in the `format!` string
--> $DIR/uninlined_format_args.rs:14:5
--> $DIR/uninlined_format_args.rs:13:5
|
LL | println!("{}, {}", local_i32, local_opt.unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,6 @@
#![allow(unused)]
#![warn(clippy::large_const_arrays, clippy::large_stack_arrays)]
//@no-rustfix
const ABOVE: [u8; 11] = [0; 11];
const BELOW: [u8; 10] = [0; 10];

View file

@ -1,6 +1,6 @@
//@compile-flags: --test
#![warn(clippy::dbg_macro)]
//@no-rustfix
fn foo(n: u32) -> u32 {
if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
}

View file

@ -0,0 +1,12 @@
#![warn(clippy::doc_markdown)]
/// This is a special interface for ClipPy which doesn't require backticks
fn allowed_name() {}
/// OAuth and LaTeX are inside Clippy's default list.
fn default_name() {}
/// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
fn unknown_name() {}
fn main() {}

View file

@ -0,0 +1,12 @@
#![warn(clippy::doc_markdown)]
/// This is a special interface for ClipPy which doesn't require backticks
fn allowed_name() {}
/// `OAuth` and `LaTeX` are inside Clippy's default list.
fn default_name() {}
/// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
fn unknown_name() {}
fn main() {}

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![rustfmt::skip]
#![feature(custom_inner_attributes)]
#![allow(unused)]

View file

@ -0,0 +1,27 @@
#![warn(clippy::large_futures)]
fn main() {}
pub async fn should_warn() {
let x = [0u8; 1024];
async {}.await;
dbg!(x);
}
pub async fn should_not_warn() {
let x = [0u8; 1020];
async {}.await;
dbg!(x);
}
pub async fn bar() {
Box::pin(should_warn()).await;
async {
let x = [0u8; 1024];
dbg!(x);
}
.await;
should_not_warn().await;
}

View file

@ -0,0 +1,23 @@
#![allow(clippy::excessive_precision)]
#![warn(clippy::unreadable_literal)]
fn allow_inconsistent_digit_grouping() {
#![allow(clippy::inconsistent_digit_grouping)]
let _pass1 = 100_200_300.123456789;
}
fn main() {
allow_inconsistent_digit_grouping();
let _pass1 = 100_200_300.100_200_300;
let _pass2 = 1.123456789;
let _pass3 = 1.0;
let _pass4 = 10000.00001;
let _pass5 = 1.123456789e1;
// due to clippy::inconsistent-digit-grouping
let _fail1 = 100_200_300.123_456_789;
// fail due to the integer part
let _fail2 = 100_200_300.300_200_100;
}

View file

@ -0,0 +1,24 @@
#![deny(clippy::index_refutable_slice)]
fn below_limit() {
let slice: Option<&[u32]> = Some(&[1, 2, 3]);
if let Some([_, _, _, _, _, _, _, slice_7, ..]) = slice {
//~^ ERROR: binding can be a slice pattern
// This would usually not be linted but is included now due to the
// index limit in the config file
println!("{}", slice_7);
}
}
fn above_limit() {
let slice: Option<&[u32]> = Some(&[1, 2, 3]);
if let Some(slice) = slice {
// This will not be linted as 8 is above the limit
println!("{}", slice[8]);
}
}
fn main() {
below_limit();
above_limit();
}

View file

@ -0,0 +1,98 @@
#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
use std::mem::{size_of, size_of_val};
use std::ops::Deref;
mod enums {
enum E {
A,
B,
#[doc(hidden)]
_C,
}
// user forgot to remove the marker
#[non_exhaustive]
enum Ep {
A,
B,
#[doc(hidden)]
_C,
}
}
fn option_as_ref_deref() {
let mut opt = Some(String::from("123"));
let _ = opt.as_ref().map(String::as_str);
let _ = opt.as_ref().map(|x| x.as_str());
let _ = opt.as_mut().map(String::as_mut_str);
let _ = opt.as_mut().map(|x| x.as_mut_str());
}
fn match_like_matches() {
let _y = match Some(5) {
Some(0) => true,
_ => false,
};
}
fn match_same_arms() {
match (1, 2, 3) {
(1, .., 3) => 42,
(.., 3) => 42,
_ => 0,
};
}
fn match_same_arms2() {
let _ = match Some(42) {
Some(_) => 24,
None => 24,
};
}
fn manual_strip_msrv() {
let s = "hello, world!";
if s.starts_with("hello, ") {
assert_eq!(s["hello, ".len()..].to_uppercase(), "WORLD!");
}
}
fn check_index_refutable_slice() {
// This shouldn't trigger `clippy::index_refutable_slice` as the suggestion
// would only be valid from 1.42.0 onward
let slice: Option<&[u32]> = Some(&[1]);
if let Some(slice) = slice {
println!("{}", slice[0]);
}
}
fn map_clone_suggest_copied() {
// This should still trigger the lint but suggest `cloned()` instead of `copied()`
let _: Option<u64> = Some(&16).cloned();
}
fn borrow_as_ptr() {
let val = 1;
let _p = &val as *const i32;
let mut val_mut = 1;
let _p_mut = &mut val_mut as *mut i32;
}
fn manual_bits() {
size_of::<i8>() * 8;
size_of_val(&0u32) * 8;
}
fn main() {
option_as_ref_deref();
match_like_matches();
match_same_arms();
match_same_arms2();
manual_strip_msrv();
check_index_refutable_slice();
borrow_as_ptr();
}

View file

@ -0,0 +1,16 @@
#![warn(clippy::missing_enforced_import_renames)]
use std::alloc as colla;
use std::option::Option as Maybe;
use std::process::{exit as goodbye, Child as Kid};
use std::thread::sleep as thread_sleep;
#[rustfmt::skip]
use std::{
any::{type_name as ident, Any},
clone as foo,
sync :: Mutex as StdMutie,
};
fn main() {
use std::collections::BTreeMap as Map;
}

View file

@ -1,5 +1,4 @@
//@aux-build:proc_macro_derive.rs:proc-macro
//@run-rustfix
//@aux-build:proc_macro_derive.rs
#![warn(clippy::nonstandard_macro_braces)]

View file

@ -1,5 +1,4 @@
//@aux-build:proc_macro_derive.rs:proc-macro
//@run-rustfix
//@aux-build:proc_macro_derive.rs
#![warn(clippy::nonstandard_macro_braces)]

View file

@ -1,5 +1,5 @@
error: use of irregular braces for `vec!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:44:13
--> $DIR/conf_nonstandard_macro_braces.rs:43:13
|
LL | let _ = vec! {1, 2, 3};
| ^^^^^^^^^^^^^^ help: consider writing: `vec![1, 2, 3]`
@ -7,31 +7,31 @@ LL | let _ = vec! {1, 2, 3};
= note: `-D clippy::nonstandard-macro-braces` implied by `-D warnings`
error: use of irregular braces for `format!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:45:13
--> $DIR/conf_nonstandard_macro_braces.rs:44:13
|
LL | let _ = format!["ugh {} stop being such a good compiler", "hello"];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `format!("ugh {} stop being such a good compiler", "hello")`
error: use of irregular braces for `matches!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
--> $DIR/conf_nonstandard_macro_braces.rs:45:13
|
LL | let _ = matches!{{}, ()};
| ^^^^^^^^^^^^^^^^ help: consider writing: `matches!({}, ())`
error: use of irregular braces for `quote!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:47:13
--> $DIR/conf_nonstandard_macro_braces.rs:46:13
|
LL | let _ = quote!(let x = 1;);
| ^^^^^^^^^^^^^^^^^^ help: consider writing: `quote!{let x = 1;}`
error: use of irregular braces for `quote::quote!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:48:13
--> $DIR/conf_nonstandard_macro_braces.rs:47:13
|
LL | let _ = quote::quote!(match match match);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `quote::quote!{match match match}`
error: use of irregular braces for `vec!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:19:9
--> $DIR/conf_nonstandard_macro_braces.rs:18:9
|
LL | vec!{0, 0, 0}
| ^^^^^^^^^^^^^ help: consider writing: `vec![0, 0, 0]`
@ -42,13 +42,13 @@ LL | let _ = test!(); // trigger when macro def is inside our own crate
= note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
error: use of irregular braces for `type_pos!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:57:12
--> $DIR/conf_nonstandard_macro_braces.rs:56:12
|
LL | let _: type_pos!(usize) = vec![];
| ^^^^^^^^^^^^^^^^ help: consider writing: `type_pos![usize]`
error: use of irregular braces for `eprint!` macro
--> $DIR/conf_nonstandard_macro_braces.rs:59:5
--> $DIR/conf_nonstandard_macro_braces.rs:58:5
|
LL | eprint!("test if user config overrides defaults");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `eprint!["test if user config overrides defaults"]`

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![allow(
unused,
clippy::unused_unit,

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![allow(
unused,
clippy::unused_unit,

View file

@ -1,5 +1,5 @@
error: consider moving the `;` outside the block for consistent formatting
--> $DIR/both.rs:43:5
--> $DIR/both.rs:42:5
|
LL | { unit_fn_block(); }
| ^^^^^^^^^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL + { unit_fn_block() };
|
error: consider moving the `;` outside the block for consistent formatting
--> $DIR/both.rs:44:5
--> $DIR/both.rs:43:5
|
LL | unsafe { unit_fn_block(); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL + unsafe { unit_fn_block() };
|
error: consider moving the `;` inside the block for consistent formatting
--> $DIR/both.rs:49:5
--> $DIR/both.rs:48:5
|
LL | / {
LL | | unit_fn_block();
@ -40,7 +40,7 @@ LL ~ }
|
error: consider moving the `;` outside the block for consistent formatting
--> $DIR/both.rs:63:5
--> $DIR/both.rs:62:5
|
LL | { m!(()); }
| ^^^^^^^^^^^

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![allow(
unused,
clippy::unused_unit,

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![allow(
unused,
clippy::unused_unit,

View file

@ -1,5 +1,5 @@
error: consider moving the `;` inside the block for consistent formatting
--> $DIR/semicolon_inside_block.rs:48:5
--> $DIR/semicolon_inside_block.rs:47:5
|
LL | / {
LL | | unit_fn_block();

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![allow(
unused,
clippy::unused_unit,

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![allow(
unused,
clippy::unused_unit,

View file

@ -1,5 +1,5 @@
error: consider moving the `;` outside the block for consistent formatting
--> $DIR/semicolon_outside_block.rs:42:5
--> $DIR/semicolon_outside_block.rs:41:5
|
LL | { unit_fn_block(); }
| ^^^^^^^^^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL + { unit_fn_block() };
|
error: consider moving the `;` outside the block for consistent formatting
--> $DIR/semicolon_outside_block.rs:43:5
--> $DIR/semicolon_outside_block.rs:42:5
|
LL | unsafe { unit_fn_block(); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL + unsafe { unit_fn_block() };
|
error: consider moving the `;` outside the block for consistent formatting
--> $DIR/semicolon_outside_block.rs:62:5
--> $DIR/semicolon_outside_block.rs:61:5
|
LL | { m!(()); }
| ^^^^^^^^^^^

View file

@ -1,6 +1,6 @@
//@normalize-stderr-test: "\(\d+ byte\)" -> "(N byte)"
//@normalize-stderr-test: "\(limit: \d+ byte\)" -> "(limit: N byte)"
//@no-rustfix
#![warn(clippy::trivially_copy_pass_by_ref)]
#![allow(clippy::needless_pass_by_ref_mut)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macro_unsafe.rs:proc-macro
//@aux-build:proc_macro_unsafe.rs
#![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)]
#![allow(deref_nullptr, clippy::let_unit_value, clippy::missing_safety_doc)]

View file

@ -0,0 +1,95 @@
//@compile-flags: --test
#![allow(
unused_mut,
clippy::get_first,
clippy::from_iter_instead_of_collect,
clippy::useless_vec
)]
#![warn(clippy::unwrap_used)]
#![warn(clippy::get_unwrap)]
use std::collections::{BTreeMap, HashMap, VecDeque};
struct GetFalsePositive {
arr: [u32; 3],
}
impl GetFalsePositive {
fn get(&self, pos: usize) -> Option<&u32> {
self.arr.get(pos)
}
fn get_mut(&mut self, pos: usize) -> Option<&mut u32> {
self.arr.get_mut(pos)
}
}
fn main() {
let mut boxed_slice: Box<[u8]> = Box::new([0, 1, 2, 3]);
let mut some_slice = &mut [0, 1, 2, 3];
let mut some_vec = vec![0, 1, 2, 3];
let mut some_vecdeque: VecDeque<_> = some_vec.iter().cloned().collect();
let mut some_hashmap: HashMap<u8, char> = HashMap::from_iter(vec![(1, 'a'), (2, 'b')]);
let mut some_btreemap: BTreeMap<u8, char> = BTreeMap::from_iter(vec![(1, 'a'), (2, 'b')]);
let mut false_positive = GetFalsePositive { arr: [0, 1, 2] };
{
// Test `get().unwrap()`
let _ = &boxed_slice[1];
let _ = &some_slice[0];
let _ = &some_vec[0];
let _ = &some_vecdeque[0];
let _ = &some_hashmap[&1];
let _ = &some_btreemap[&1];
#[allow(clippy::unwrap_used)]
let _ = false_positive.get(0).unwrap();
// Test with deref
let _: u8 = boxed_slice[1];
}
{
// Test `get_mut().unwrap()`
boxed_slice[0] = 1;
some_slice[0] = 1;
some_vec[0] = 1;
some_vecdeque[0] = 1;
// Check false positives
#[allow(clippy::unwrap_used)]
{
*some_hashmap.get_mut(&1).unwrap() = 'b';
*some_btreemap.get_mut(&1).unwrap() = 'b';
*false_positive.get_mut(0).unwrap() = 1;
}
}
{
// Test `get().unwrap().foo()` and `get_mut().unwrap().bar()`
let _ = some_vec[0..1].to_vec();
let _ = some_vec[0..1].to_vec();
}
}
#[test]
fn test() {
let boxed_slice: Box<[u8]> = Box::new([0, 1, 2, 3]);
let _ = &boxed_slice[1];
}
#[cfg(test)]
mod issue9612 {
// should not lint in `#[cfg(test)]` modules
#[test]
fn test_fn() {
let _a: u8 = 2.try_into().unwrap();
let _a: u8 = 3.try_into().expect("");
util();
}
fn util() {
let _a: u8 = 4.try_into().unwrap();
let _a: u8 = 5.try_into().expect("");
// should still warn
let _ = &Box::new([0])[1];
}
}

View file

@ -0,0 +1,44 @@
#![warn(clippy::upper_case_acronyms)]
struct HttpResponse; // not linted by default, but with cfg option
struct CString; // not linted
enum Flags {
Ns, // not linted
Cwr,
Ece,
Urg,
Ack,
Psh,
Rst,
Syn,
Fin,
}
// linted with cfg option, beware that lint suggests `GccllvmSomething` instead of
// `GccLlvmSomething`
struct GccllvmSomething;
// don't warn on public items
pub struct MIXEDCapital;
pub struct FULLCAPITAL;
// enum variants should not be linted if the num is pub
pub enum ParseError<T> {
FULLCAPITAL(u8),
MIXEDCapital(String),
Utf8(std::string::FromUtf8Error),
Parse(T, String),
}
// private, do lint here
enum ParseErrorPrivate<T> {
Wasd(u8),
WasdMixed(String),
Utf8(std::string::FromUtf8Error),
Parse(T, String),
}
fn main() {}

View file

@ -0,0 +1,16 @@
struct S {
x: u64,
}
struct C {
y: u16,
}
struct Foo(Vec<u8>);
struct Bar(Vec<u16>);
struct Quux(Vec<Box<u32>>);
struct Baz(Vec<Box<(u16, u16)>>);
struct BarBaz(Vec<Box<S>>);
struct FooBarBaz(Vec<C>);
fn main() {}

View file

@ -1,5 +1,4 @@
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![allow(unused)]
#![warn(clippy::allow_attributes)]
#![feature(lint_reasons)]

View file

@ -1,5 +1,4 @@
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![allow(unused)]
#![warn(clippy::allow_attributes)]
#![feature(lint_reasons)]

View file

@ -1,5 +1,5 @@
error: #[allow] attribute found
--> $DIR/allow_attributes.rs:14:3
--> $DIR/allow_attributes.rs:13:3
|
LL | #[allow(dead_code)]
| ^^^^^ help: replace it with: `expect`
@ -7,7 +7,7 @@ LL | #[allow(dead_code)]
= note: `-D clippy::allow-attributes` implied by `-D warnings`
error: #[allow] attribute found
--> $DIR/allow_attributes.rs:23:30
--> $DIR/allow_attributes.rs:22:30
|
LL | #[cfg_attr(panic = "unwind", allow(dead_code))]
| ^^^^^ help: replace it with: `expect`

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![feature(lint_reasons)]
#![deny(clippy::allow_attributes_without_reason)]
#![allow(unfulfilled_lint_expectations)]

View file

@ -1,6 +1,5 @@
//@run-rustfix
//@edition:2018
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![feature(exclusive_range_pattern)]
#![feature(stmt_expr_attributes)]

View file

@ -1,6 +1,5 @@
//@run-rustfix
//@edition:2018
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![feature(exclusive_range_pattern)]
#![feature(stmt_expr_attributes)]

View file

@ -1,5 +1,5 @@
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:19:17
--> $DIR/almost_complete_range.rs:18:17
|
LL | let _ = ('a') ..'z';
| ^^^^^^--^^^
@ -9,7 +9,7 @@ LL | let _ = ('a') ..'z';
= note: `-D clippy::almost-complete-range` implied by `-D warnings`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:20:17
--> $DIR/almost_complete_range.rs:19:17
|
LL | let _ = 'A' .. ('Z');
| ^^^^--^^^^^^
@ -17,7 +17,7 @@ LL | let _ = 'A' .. ('Z');
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:21:17
--> $DIR/almost_complete_range.rs:20:17
|
LL | let _ = ((('0'))) .. ('9');
| ^^^^^^^^^^--^^^^^^
@ -25,7 +25,7 @@ LL | let _ = ((('0'))) .. ('9');
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:28:13
--> $DIR/almost_complete_range.rs:27:13
|
LL | let _ = (b'a')..(b'z');
| ^^^^^^--^^^^^^
@ -33,7 +33,7 @@ LL | let _ = (b'a')..(b'z');
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:29:13
--> $DIR/almost_complete_range.rs:28:13
|
LL | let _ = b'A'..b'Z';
| ^^^^--^^^^
@ -41,7 +41,7 @@ LL | let _ = b'A'..b'Z';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:30:13
--> $DIR/almost_complete_range.rs:29:13
|
LL | let _ = b'0'..b'9';
| ^^^^--^^^^
@ -49,7 +49,7 @@ LL | let _ = b'0'..b'9';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:36:13
--> $DIR/almost_complete_range.rs:35:13
|
LL | let _ = inline!('a')..'z';
| ^^^^^^^^^^^^--^^^
@ -57,7 +57,7 @@ LL | let _ = inline!('a')..'z';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:37:13
--> $DIR/almost_complete_range.rs:36:13
|
LL | let _ = inline!('A')..'Z';
| ^^^^^^^^^^^^--^^^
@ -65,7 +65,7 @@ LL | let _ = inline!('A')..'Z';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:38:13
--> $DIR/almost_complete_range.rs:37:13
|
LL | let _ = inline!('0')..'9';
| ^^^^^^^^^^^^--^^^
@ -73,7 +73,7 @@ LL | let _ = inline!('0')..'9';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:41:9
--> $DIR/almost_complete_range.rs:40:9
|
LL | b'a'..b'z' if true => 1,
| ^^^^--^^^^
@ -81,7 +81,7 @@ LL | b'a'..b'z' if true => 1,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:42:9
--> $DIR/almost_complete_range.rs:41:9
|
LL | b'A'..b'Z' if true => 2,
| ^^^^--^^^^
@ -89,7 +89,7 @@ LL | b'A'..b'Z' if true => 2,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:43:9
--> $DIR/almost_complete_range.rs:42:9
|
LL | b'0'..b'9' if true => 3,
| ^^^^--^^^^
@ -97,7 +97,7 @@ LL | b'0'..b'9' if true => 3,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:51:9
--> $DIR/almost_complete_range.rs:50:9
|
LL | 'a'..'z' if true => 1,
| ^^^--^^^
@ -105,7 +105,7 @@ LL | 'a'..'z' if true => 1,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:52:9
--> $DIR/almost_complete_range.rs:51:9
|
LL | 'A'..'Z' if true => 2,
| ^^^--^^^
@ -113,7 +113,7 @@ LL | 'A'..'Z' if true => 2,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:53:9
--> $DIR/almost_complete_range.rs:52:9
|
LL | '0'..'9' if true => 3,
| ^^^--^^^
@ -121,7 +121,7 @@ LL | '0'..'9' if true => 3,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:66:17
--> $DIR/almost_complete_range.rs:65:17
|
LL | let _ = 'a'..'z';
| ^^^--^^^
@ -131,7 +131,7 @@ LL | let _ = 'a'..'z';
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:67:17
--> $DIR/almost_complete_range.rs:66:17
|
LL | let _ = 'A'..'Z';
| ^^^--^^^
@ -141,7 +141,7 @@ LL | let _ = 'A'..'Z';
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:68:17
--> $DIR/almost_complete_range.rs:67:17
|
LL | let _ = '0'..'9';
| ^^^--^^^
@ -151,7 +151,7 @@ LL | let _ = '0'..'9';
= note: this error originates in the macro `__inline_mac_fn_main` (in Nightly builds, run with -Z macro-backtrace for more info)
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:75:9
--> $DIR/almost_complete_range.rs:74:9
|
LL | 'a'..'z' => 1,
| ^^^--^^^
@ -159,7 +159,7 @@ LL | 'a'..'z' => 1,
| help: use an inclusive range: `...`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:76:9
--> $DIR/almost_complete_range.rs:75:9
|
LL | 'A'..'Z' => 2,
| ^^^--^^^
@ -167,7 +167,7 @@ LL | 'A'..'Z' => 2,
| help: use an inclusive range: `...`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:77:9
--> $DIR/almost_complete_range.rs:76:9
|
LL | '0'..'9' => 3,
| ^^^--^^^
@ -175,7 +175,7 @@ LL | '0'..'9' => 3,
| help: use an inclusive range: `...`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:84:13
--> $DIR/almost_complete_range.rs:83:13
|
LL | let _ = 'a'..'z';
| ^^^--^^^
@ -183,7 +183,7 @@ LL | let _ = 'a'..'z';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:85:13
--> $DIR/almost_complete_range.rs:84:13
|
LL | let _ = 'A'..'Z';
| ^^^--^^^
@ -191,7 +191,7 @@ LL | let _ = 'A'..'Z';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:86:13
--> $DIR/almost_complete_range.rs:85:13
|
LL | let _ = '0'..'9';
| ^^^--^^^
@ -199,7 +199,7 @@ LL | let _ = '0'..'9';
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:88:9
--> $DIR/almost_complete_range.rs:87:9
|
LL | 'a'..'z' => 1,
| ^^^--^^^
@ -207,7 +207,7 @@ LL | 'a'..'z' => 1,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:89:9
--> $DIR/almost_complete_range.rs:88:9
|
LL | 'A'..'Z' => 1,
| ^^^--^^^
@ -215,7 +215,7 @@ LL | 'A'..'Z' => 1,
| help: use an inclusive range: `..=`
error: almost complete ascii range
--> $DIR/almost_complete_range.rs:90:9
--> $DIR/almost_complete_range.rs:89:9
|
LL | '0'..'9' => 3,
| ^^^--^^^

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![warn(clippy::arc_with_non_send_sync)]
#![allow(unused_variables)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macro_derive.rs:proc-macro
//@aux-build:proc_macro_derive.rs
#![allow(
clippy::assign_op_pattern,

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs:proc-macro
//@aux-build:proc_macros.rs
#![warn(clippy::as_conversions)]
#![allow(clippy::borrow_as_ptr, unused)]

View file

@ -1,6 +1,7 @@
#![allow(unused)]
#![warn(clippy::as_ptr_cast_mut)]
#![allow(clippy::wrong_self_convention, clippy::unnecessary_cast)]
//@no-rustfix
struct MutPtrWrapper(Vec<u8>);
impl MutPtrWrapper {

View file

@ -1,5 +1,5 @@
error: casting the result of `as_ptr` to *mut u8
--> $DIR/as_ptr_cast_mut.rs:21:13
--> $DIR/as_ptr_cast_mut.rs:22:13
|
LL | let _ = string.as_ptr() as *mut u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()`
@ -7,7 +7,7 @@ LL | let _ = string.as_ptr() as *mut u8;
= note: `-D clippy::as-ptr-cast-mut` implied by `-D warnings`
error: casting the result of `as_ptr` to *mut i8
--> $DIR/as_ptr_cast_mut.rs:22:22
--> $DIR/as_ptr_cast_mut.rs:23:22
|
LL | let _: *mut i8 = string.as_ptr() as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()`

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![warn(clippy::as_underscore)]
fn foo(_n: usize) {}

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![warn(clippy::as_underscore)]
fn foo(_n: usize) {}

View file

@ -1,5 +1,5 @@
error: using `as _` conversion
--> $DIR/as_underscore.rs:9:9
--> $DIR/as_underscore.rs:7:9
|
LL | foo(n as _);
| ^^^^^-
@ -9,7 +9,7 @@ LL | foo(n as _);
= note: `-D clippy::as-underscore` implied by `-D warnings`
error: using `as _` conversion
--> $DIR/as_underscore.rs:12:18
--> $DIR/as_underscore.rs:10:18
|
LL | let _n: u8 = n as _;
| ^^^^^-

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::assertions_on_result_states)]
#![allow(clippy::unnecessary_literal_unwrap)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::assertions_on_result_states)]
#![allow(clippy::unnecessary_literal_unwrap)]

View file

@ -1,5 +1,5 @@
error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:25:5
--> $DIR/assertions_on_result_states.rs:24:5
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
@ -7,37 +7,37 @@ LL | assert!(r.is_ok());
= note: `-D clippy::assertions-on-result-states` implied by `-D warnings`
error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:43:5
--> $DIR/assertions_on_result_states.rs:42:5
|
LL | assert!(get_ok().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()`
error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:46:5
--> $DIR/assertions_on_result_states.rs:45:5
|
LL | assert!(get_ok_macro!().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()`
error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:59:5
--> $DIR/assertions_on_result_states.rs:58:5
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
error: called `assert!` with `Result::is_ok`
--> $DIR/assertions_on_result_states.rs:65:9
--> $DIR/assertions_on_result_states.rs:64:9
|
LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:73:5
--> $DIR/assertions_on_result_states.rs:72:5
|
LL | assert!(r.is_err());
| ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`
error: called `assert!` with `Result::is_err`
--> $DIR/assertions_on_result_states.rs:83:5
--> $DIR/assertions_on_result_states.rs:82:5
|
LL | assert!(res.is_err())
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`

View file

@ -1,5 +1,3 @@
//@run-rustfix
use core::num::Wrapping;
#[allow(dead_code, unused_assignments, clippy::useless_vec)]

View file

@ -1,5 +1,3 @@
//@run-rustfix
use core::num::Wrapping;
#[allow(dead_code, unused_assignments, clippy::useless_vec)]

View file

@ -1,5 +1,5 @@
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:9:5
--> $DIR/assign_ops.rs:7:5
|
LL | a = a + 1;
| ^^^^^^^^^ help: replace it with: `a += 1`
@ -7,61 +7,61 @@ LL | a = a + 1;
= note: `-D clippy::assign-op-pattern` implied by `-D warnings`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:10:5
--> $DIR/assign_ops.rs:8:5
|
LL | a = 1 + a;
| ^^^^^^^^^ help: replace it with: `a += 1`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:11:5
--> $DIR/assign_ops.rs:9:5
|
LL | a = a - 1;
| ^^^^^^^^^ help: replace it with: `a -= 1`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:12:5
--> $DIR/assign_ops.rs:10:5
|
LL | a = a * 99;
| ^^^^^^^^^^ help: replace it with: `a *= 99`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:13:5
--> $DIR/assign_ops.rs:11:5
|
LL | a = 42 * a;
| ^^^^^^^^^^ help: replace it with: `a *= 42`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:14:5
--> $DIR/assign_ops.rs:12:5
|
LL | a = a / 2;
| ^^^^^^^^^ help: replace it with: `a /= 2`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:15:5
--> $DIR/assign_ops.rs:13:5
|
LL | a = a % 5;
| ^^^^^^^^^ help: replace it with: `a %= 5`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:16:5
--> $DIR/assign_ops.rs:14:5
|
LL | a = a & 1;
| ^^^^^^^^^ help: replace it with: `a &= 1`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:22:5
--> $DIR/assign_ops.rs:20:5
|
LL | s = s + "bla";
| ^^^^^^^^^^^^^ help: replace it with: `s += "bla"`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:26:5
--> $DIR/assign_ops.rs:24:5
|
LL | a = a + Wrapping(1u32);
| ^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a += Wrapping(1u32)`
error: manual implementation of an assign operation
--> $DIR/assign_ops.rs:28:5
--> $DIR/assign_ops.rs:26:5
|
LL | v[0] = v[0] + v[1];
| ^^^^^^^^^^^^^^^^^^ help: replace it with: `v[0] += v[1]`

View file

@ -1,3 +1,4 @@
//@no-rustfix: overlapping suggestions
#![allow(clippy::uninlined_format_args)]
#[allow(unused_assignments)]

View file

@ -1,5 +1,5 @@
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:7:5
--> $DIR/assign_ops2.rs:8:5
|
LL | a += a + 1;
| ^^^^^^^^^^
@ -15,7 +15,7 @@ LL | a = a + a + 1;
| ~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:8:5
--> $DIR/assign_ops2.rs:9:5
|
LL | a += 1 + a;
| ^^^^^^^^^^
@ -30,7 +30,7 @@ LL | a = a + 1 + a;
| ~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:9:5
--> $DIR/assign_ops2.rs:10:5
|
LL | a -= a - 1;
| ^^^^^^^^^^
@ -45,7 +45,7 @@ LL | a = a - (a - 1);
| ~~~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:10:5
--> $DIR/assign_ops2.rs:11:5
|
LL | a *= a * 99;
| ^^^^^^^^^^^
@ -60,7 +60,7 @@ LL | a = a * a * 99;
| ~~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:11:5
--> $DIR/assign_ops2.rs:12:5
|
LL | a *= 42 * a;
| ^^^^^^^^^^^
@ -75,7 +75,7 @@ LL | a = a * 42 * a;
| ~~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:12:5
--> $DIR/assign_ops2.rs:13:5
|
LL | a /= a / 2;
| ^^^^^^^^^^
@ -90,7 +90,7 @@ LL | a = a / (a / 2);
| ~~~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:13:5
--> $DIR/assign_ops2.rs:14:5
|
LL | a %= a % 5;
| ^^^^^^^^^^
@ -105,7 +105,7 @@ LL | a = a % (a % 5);
| ~~~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:14:5
--> $DIR/assign_ops2.rs:15:5
|
LL | a &= a & 1;
| ^^^^^^^^^^
@ -120,7 +120,7 @@ LL | a = a & a & 1;
| ~~~~~~~~~~~~~
error: variable appears on both sides of an assignment operation
--> $DIR/assign_ops2.rs:15:5
--> $DIR/assign_ops2.rs:16:5
|
LL | a *= a * a;
| ^^^^^^^^^^
@ -135,7 +135,7 @@ LL | a = a * a * a;
| ~~~~~~~~~~~~~
error: manual implementation of an assign operation
--> $DIR/assign_ops2.rs:52:5
--> $DIR/assign_ops2.rs:53:5
|
LL | buf = buf + cows.clone();
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `buf += cows.clone()`

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![feature(lint_reasons)]
#![feature(async_closure)]
#![warn(clippy::async_yields_async)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![feature(lint_reasons)]
#![feature(async_closure)]
#![warn(clippy::async_yields_async)]

View file

@ -1,5 +1,5 @@
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:40:9
--> $DIR/async_yields_async.rs:39:9
|
LL | let _h = async {
| _____________________-
@ -19,7 +19,7 @@ LL + }.await
|
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:45:9
--> $DIR/async_yields_async.rs:44:9
|
LL | let _i = async {
| ____________________-
@ -32,7 +32,7 @@ LL | | };
| |_____- outer async construct
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:51:9
--> $DIR/async_yields_async.rs:50:9
|
LL | let _j = async || {
| ________________________-
@ -51,7 +51,7 @@ LL + }.await
|
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:56:9
--> $DIR/async_yields_async.rs:55:9
|
LL | let _k = async || {
| _______________________-
@ -64,7 +64,7 @@ LL | | };
| |_____- outer async construct
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:58:23
--> $DIR/async_yields_async.rs:57:23
|
LL | let _l = async || CustomFutureType;
| ^^^^^^^^^^^^^^^^
@ -74,7 +74,7 @@ LL | let _l = async || CustomFutureType;
| help: consider awaiting this value: `CustomFutureType.await`
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:64:9
--> $DIR/async_yields_async.rs:63:9
|
LL | let _m = async || {
| _______________________-

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::bind_instead_of_map)]
#![allow(clippy::uninlined_format_args)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::bind_instead_of_map)]
#![allow(clippy::uninlined_format_args)]

View file

@ -1,23 +1,23 @@
error: using `Option.and_then(Some)`, which is a no-op
--> $DIR/bind_instead_of_map.rs:9:13
--> $DIR/bind_instead_of_map.rs:8:13
|
LL | let _ = x.and_then(Some);
| ^^^^^^^^^^^^^^^^ help: use the expression directly: `x`
|
note: the lint level is defined here
--> $DIR/bind_instead_of_map.rs:2:9
--> $DIR/bind_instead_of_map.rs:1:9
|
LL | #![deny(clippy::bind_instead_of_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> $DIR/bind_instead_of_map.rs:10:13
--> $DIR/bind_instead_of_map.rs:9:13
|
LL | let _ = x.and_then(|o| Some(o + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)`
error: using `Result.and_then(Ok)`, which is a no-op
--> $DIR/bind_instead_of_map.rs:16:13
--> $DIR/bind_instead_of_map.rs:15:13
|
LL | let _ = x.and_then(Ok);
| ^^^^^^^^^^^^^^ help: use the expression directly: `x`

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::bind_instead_of_map)]
#![allow(clippy::blocks_in_if_conditions)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::bind_instead_of_map)]
#![allow(clippy::blocks_in_if_conditions)]

View file

@ -1,11 +1,11 @@
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> $DIR/bind_instead_of_map_multipart.rs:6:13
--> $DIR/bind_instead_of_map_multipart.rs:5:13
|
LL | let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: the lint level is defined here
--> $DIR/bind_instead_of_map_multipart.rs:2:9
--> $DIR/bind_instead_of_map_multipart.rs:1:9
|
LL | #![deny(clippy::bind_instead_of_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -15,7 +15,7 @@ LL | let _ = Some("42").map(|s| if s.len() < 42 { 0 } else { s.len() });
| ~~~ ~ ~~~~~~~
error: using `Result.and_then(|x| Ok(y))`, which is more succinctly expressed as `map(|x| y)`
--> $DIR/bind_instead_of_map_multipart.rs:9:13
--> $DIR/bind_instead_of_map_multipart.rs:8:13
|
LL | let _ = Ok::<_, ()>("42").and_then(|s| if s.len() < 42 { Ok(0) } else { Ok(s.len()) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -26,7 +26,7 @@ LL | let _ = Ok::<_, ()>("42").map(|s| if s.len() < 42 { 0 } else { s.len()
| ~~~ ~ ~~~~~~~
error: using `Result.or_else(|x| Err(y))`, which is more succinctly expressed as `map_err(|x| y)`
--> $DIR/bind_instead_of_map_multipart.rs:12:13
--> $DIR/bind_instead_of_map_multipart.rs:11:13
|
LL | let _ = Err::<(), _>("42").or_else(|s| if s.len() < 42 { Err(s.len() + 20) } else { Err(s.len()) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -37,7 +37,7 @@ LL | let _ = Err::<(), _>("42").map_err(|s| if s.len() < 42 { s.len() + 20 }
| ~~~~~~~ ~~~~~~~~~~~~ ~~~~~~~
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> $DIR/bind_instead_of_map_multipart.rs:20:5
--> $DIR/bind_instead_of_map_multipart.rs:19:5
|
LL | / Some("42").and_then(|s| {
LL | | if {
@ -77,7 +77,7 @@ LL ~ _ => 1,
|
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)`
--> $DIR/bind_instead_of_map_multipart.rs:61:13
--> $DIR/bind_instead_of_map_multipart.rs:60:13
|
LL | let _ = Some("").and_then(|s| if s.len() == 20 { Some(m!()) } else { Some(Some(20)) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::blocks_in_if_conditions)]
#![allow(unused, clippy::let_and_return, clippy::needless_if)]
#![warn(clippy::nonminimal_bool)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::blocks_in_if_conditions)]
#![allow(unused, clippy::let_and_return, clippy::needless_if)]
#![warn(clippy::nonminimal_bool)]

View file

@ -1,5 +1,5 @@
error: in an `if` condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let`
--> $DIR/blocks_in_if_conditions.rs:24:5
--> $DIR/blocks_in_if_conditions.rs:23:5
|
LL | / if {
LL | | let x = 3;
@ -17,13 +17,13 @@ LL ~ }; if res {
|
error: omit braces around single expression condition
--> $DIR/blocks_in_if_conditions.rs:35:8
--> $DIR/blocks_in_if_conditions.rs:34:8
|
LL | if { true } { 6 } else { 10 }
| ^^^^^^^^ help: try: `true`
error: this boolean expression can be simplified
--> $DIR/blocks_in_if_conditions.rs:40:8
--> $DIR/blocks_in_if_conditions.rs:39:8
|
LL | if true && x == 3 { 6 } else { 10 }
| ^^^^^^^^^^^^^^ help: try: `x == 3`

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![allow(unused, clippy::assertions_on_constants)]
#![warn(clippy::bool_assert_comparison)]

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![allow(unused, clippy::assertions_on_constants)]
#![warn(clippy::bool_assert_comparison)]

View file

@ -1,5 +1,5 @@
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:89:5
--> $DIR/bool_assert_comparison.rs:87:5
|
LL | assert_eq!("a".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL + assert!(!"a".is_empty());
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:90:5
--> $DIR/bool_assert_comparison.rs:88:5
|
LL | assert_eq!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL + assert!("".is_empty());
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:91:5
--> $DIR/bool_assert_comparison.rs:89:5
|
LL | assert_eq!(true, "".is_empty());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -36,7 +36,7 @@ LL + assert!("".is_empty());
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:96:5
--> $DIR/bool_assert_comparison.rs:94:5
|
LL | assert_eq!(b, true);
| ^^^^^^^^^^^^^^^^^^^
@ -48,7 +48,7 @@ LL + assert!(b);
|
error: used `assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:99:5
--> $DIR/bool_assert_comparison.rs:97:5
|
LL | assert_ne!("a".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -60,7 +60,7 @@ LL + assert!("a".is_empty());
|
error: used `assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:100:5
--> $DIR/bool_assert_comparison.rs:98:5
|
LL | assert_ne!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL + assert!(!"".is_empty());
|
error: used `assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:101:5
--> $DIR/bool_assert_comparison.rs:99:5
|
LL | assert_ne!(true, "".is_empty());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -84,7 +84,7 @@ LL + assert!(!"".is_empty());
|
error: used `assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:106:5
--> $DIR/bool_assert_comparison.rs:104:5
|
LL | assert_ne!(b, true);
| ^^^^^^^^^^^^^^^^^^^
@ -96,7 +96,7 @@ LL + assert!(!b);
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:109:5
--> $DIR/bool_assert_comparison.rs:107:5
|
LL | debug_assert_eq!("a".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -108,7 +108,7 @@ LL + debug_assert!(!"a".is_empty());
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:110:5
--> $DIR/bool_assert_comparison.rs:108:5
|
LL | debug_assert_eq!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -120,7 +120,7 @@ LL + debug_assert!("".is_empty());
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:111:5
--> $DIR/bool_assert_comparison.rs:109:5
|
LL | debug_assert_eq!(true, "".is_empty());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -132,7 +132,7 @@ LL + debug_assert!("".is_empty());
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:116:5
--> $DIR/bool_assert_comparison.rs:114:5
|
LL | debug_assert_eq!(b, true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -144,7 +144,7 @@ LL + debug_assert!(b);
|
error: used `debug_assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:119:5
--> $DIR/bool_assert_comparison.rs:117:5
|
LL | debug_assert_ne!("a".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -156,7 +156,7 @@ LL + debug_assert!("a".is_empty());
|
error: used `debug_assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:120:5
--> $DIR/bool_assert_comparison.rs:118:5
|
LL | debug_assert_ne!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -168,7 +168,7 @@ LL + debug_assert!(!"".is_empty());
|
error: used `debug_assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:121:5
--> $DIR/bool_assert_comparison.rs:119:5
|
LL | debug_assert_ne!(true, "".is_empty());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -180,7 +180,7 @@ LL + debug_assert!(!"".is_empty());
|
error: used `debug_assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:126:5
--> $DIR/bool_assert_comparison.rs:124:5
|
LL | debug_assert_ne!(b, true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -192,7 +192,7 @@ LL + debug_assert!(!b);
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:131:5
--> $DIR/bool_assert_comparison.rs:129:5
|
LL | assert_eq!("a".is_empty(), false, "tadam {}", 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -204,7 +204,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", 1);
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:132:5
--> $DIR/bool_assert_comparison.rs:130:5
|
LL | assert_eq!("a".is_empty(), false, "tadam {}", true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -216,7 +216,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", true);
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:133:5
--> $DIR/bool_assert_comparison.rs:131:5
|
LL | assert_eq!(false, "a".is_empty(), "tadam {}", true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -228,7 +228,7 @@ LL + assert!(!"a".is_empty(), "tadam {}", true);
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:138:5
--> $DIR/bool_assert_comparison.rs:136:5
|
LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", 1);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -240,7 +240,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", 1);
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:139:5
--> $DIR/bool_assert_comparison.rs:137:5
|
LL | debug_assert_eq!("a".is_empty(), false, "tadam {}", true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -252,7 +252,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", true);
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:140:5
--> $DIR/bool_assert_comparison.rs:138:5
|
LL | debug_assert_eq!(false, "a".is_empty(), "tadam {}", true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -264,7 +264,7 @@ LL + debug_assert!(!"a".is_empty(), "tadam {}", true);
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:143:5
--> $DIR/bool_assert_comparison.rs:141:5
|
LL | assert_eq!(a!(), true);
| ^^^^^^^^^^^^^^^^^^^^^^
@ -276,7 +276,7 @@ LL + assert!(a!());
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:144:5
--> $DIR/bool_assert_comparison.rs:142:5
|
LL | assert_eq!(true, b!());
| ^^^^^^^^^^^^^^^^^^^^^^
@ -288,7 +288,7 @@ LL + assert!(b!());
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:148:5
--> $DIR/bool_assert_comparison.rs:146:5
|
LL | renamed!(b, true);
| ^^^^^^^^^^^^^^^^^
@ -300,7 +300,7 @@ LL + debug_assert!(b);
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:162:5
--> $DIR/bool_assert_comparison.rs:160:5
|
LL | assert_eq!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -312,7 +312,7 @@ LL + assert!("".is_empty());
|
error: used `assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:163:5
--> $DIR/bool_assert_comparison.rs:161:5
|
LL | assert_ne!("".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -324,7 +324,7 @@ LL + assert!("".is_empty());
|
error: used `assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:164:5
--> $DIR/bool_assert_comparison.rs:162:5
|
LL | assert_ne!("requires negation".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -336,7 +336,7 @@ LL + assert!(!"requires negation".is_empty());
|
error: used `assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:165:5
--> $DIR/bool_assert_comparison.rs:163:5
|
LL | assert_eq!("requires negation".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -348,7 +348,7 @@ LL + assert!(!"requires negation".is_empty());
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:167:5
--> $DIR/bool_assert_comparison.rs:165:5
|
LL | debug_assert_eq!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -360,7 +360,7 @@ LL + debug_assert!("".is_empty());
|
error: used `debug_assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:168:5
--> $DIR/bool_assert_comparison.rs:166:5
|
LL | debug_assert_ne!("".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -372,7 +372,7 @@ LL + debug_assert!("".is_empty());
|
error: used `debug_assert_ne!` with a literal bool
--> $DIR/bool_assert_comparison.rs:169:5
--> $DIR/bool_assert_comparison.rs:167:5
|
LL | debug_assert_ne!("requires negation".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -384,7 +384,7 @@ LL + debug_assert!(!"requires negation".is_empty());
|
error: used `debug_assert_eq!` with a literal bool
--> $DIR/bool_assert_comparison.rs:170:5
--> $DIR/bool_assert_comparison.rs:168:5
|
LL | debug_assert_eq!("requires negation".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![allow(clippy::needless_if)]
#![warn(clippy::bool_comparison)]
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![allow(clippy::needless_if)]
#![warn(clippy::bool_comparison)]
#![allow(clippy::incorrect_partial_ord_impl_on_ord_type)]

View file

@ -1,5 +1,5 @@
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:9:8
--> $DIR/bool_comparison.rs:7:8
|
LL | if x == true {
| ^^^^^^^^^ help: try simplifying it as shown: `x`
@ -7,127 +7,127 @@ LL | if x == true {
= note: `-D clippy::bool-comparison` implied by `-D warnings`
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:14:8
--> $DIR/bool_comparison.rs:12:8
|
LL | if x == false {
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:19:8
--> $DIR/bool_comparison.rs:17:8
|
LL | if true == x {
| ^^^^^^^^^ help: try simplifying it as shown: `x`
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:24:8
--> $DIR/bool_comparison.rs:22:8
|
LL | if false == x {
| ^^^^^^^^^^ help: try simplifying it as shown: `!x`
error: inequality checks against true can be replaced by a negation
--> $DIR/bool_comparison.rs:29:8
--> $DIR/bool_comparison.rs:27:8
|
LL | if x != true {
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
error: inequality checks against false are unnecessary
--> $DIR/bool_comparison.rs:34:8
--> $DIR/bool_comparison.rs:32:8
|
LL | if x != false {
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
error: inequality checks against true can be replaced by a negation
--> $DIR/bool_comparison.rs:39:8
--> $DIR/bool_comparison.rs:37:8
|
LL | if true != x {
| ^^^^^^^^^ help: try simplifying it as shown: `!x`
error: inequality checks against false are unnecessary
--> $DIR/bool_comparison.rs:44:8
--> $DIR/bool_comparison.rs:42:8
|
LL | if false != x {
| ^^^^^^^^^^ help: try simplifying it as shown: `x`
error: less than comparison against true can be replaced by a negation
--> $DIR/bool_comparison.rs:49:8
--> $DIR/bool_comparison.rs:47:8
|
LL | if x < true {
| ^^^^^^^^ help: try simplifying it as shown: `!x`
error: greater than checks against false are unnecessary
--> $DIR/bool_comparison.rs:54:8
--> $DIR/bool_comparison.rs:52:8
|
LL | if false < x {
| ^^^^^^^^^ help: try simplifying it as shown: `x`
error: greater than checks against false are unnecessary
--> $DIR/bool_comparison.rs:59:8
--> $DIR/bool_comparison.rs:57:8
|
LL | if x > false {
| ^^^^^^^^^ help: try simplifying it as shown: `x`
error: less than comparison against true can be replaced by a negation
--> $DIR/bool_comparison.rs:64:8
--> $DIR/bool_comparison.rs:62:8
|
LL | if true > x {
| ^^^^^^^^ help: try simplifying it as shown: `!x`
error: order comparisons between booleans can be simplified
--> $DIR/bool_comparison.rs:70:8
--> $DIR/bool_comparison.rs:68:8
|
LL | if x < y {
| ^^^^^ help: try simplifying it as shown: `!x & y`
error: order comparisons between booleans can be simplified
--> $DIR/bool_comparison.rs:75:8
--> $DIR/bool_comparison.rs:73:8
|
LL | if x > y {
| ^^^^^ help: try simplifying it as shown: `x & !y`
error: this comparison might be written more concisely
--> $DIR/bool_comparison.rs:123:8
--> $DIR/bool_comparison.rs:121:8
|
LL | if a == !b {};
| ^^^^^^^ help: try simplifying it as shown: `a != b`
error: this comparison might be written more concisely
--> $DIR/bool_comparison.rs:124:8
--> $DIR/bool_comparison.rs:122:8
|
LL | if !a == b {};
| ^^^^^^^ help: try simplifying it as shown: `a != b`
error: this comparison might be written more concisely
--> $DIR/bool_comparison.rs:128:8
--> $DIR/bool_comparison.rs:126:8
|
LL | if b == !a {};
| ^^^^^^^ help: try simplifying it as shown: `b != a`
error: this comparison might be written more concisely
--> $DIR/bool_comparison.rs:129:8
--> $DIR/bool_comparison.rs:127:8
|
LL | if !b == a {};
| ^^^^^^^ help: try simplifying it as shown: `b != a`
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:153:8
--> $DIR/bool_comparison.rs:151:8
|
LL | if false == m!(func) {}
| ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)`
error: equality checks against false can be replaced by a negation
--> $DIR/bool_comparison.rs:154:8
--> $DIR/bool_comparison.rs:152:8
|
LL | if m!(func) == false {}
| ^^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `!m!(func)`
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:155:8
--> $DIR/bool_comparison.rs:153:8
|
LL | if true == m!(func) {}
| ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)`
error: equality checks against true are unnecessary
--> $DIR/bool_comparison.rs:156:8
--> $DIR/bool_comparison.rs:154:8
|
LL | if m!(func) == true {}
| ^^^^^^^^^^^^^^^^ help: try simplifying it as shown: `m!(func)`

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![feature(let_chains, inline_const)]
#![warn(clippy::bool_to_int_with_if)]
#![allow(unused, dead_code, clippy::unnecessary_operation, clippy::no_effect)]

View file

@ -1,5 +1,3 @@
//@run-rustfix
#![feature(let_chains, inline_const)]
#![warn(clippy::bool_to_int_with_if)]
#![allow(unused, dead_code, clippy::unnecessary_operation, clippy::no_effect)]

View file

@ -1,5 +1,5 @@
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:16:5
--> $DIR/bool_to_int_with_if.rs:14:5
|
LL | / if a {
LL | | 1
@ -12,7 +12,7 @@ LL | | };
= note: `-D clippy::bool-to-int-with-if` implied by `-D warnings`
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:21:5
--> $DIR/bool_to_int_with_if.rs:19:5
|
LL | / if a {
LL | | 0
@ -24,7 +24,7 @@ LL | | };
= note: `!a as i32` or `(!a).into()` can also be valid options
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:26:5
--> $DIR/bool_to_int_with_if.rs:24:5
|
LL | / if !a {
LL | | 1
@ -36,7 +36,7 @@ LL | | };
= note: `!a as i32` or `(!a).into()` can also be valid options
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:31:5
--> $DIR/bool_to_int_with_if.rs:29:5
|
LL | / if a || b {
LL | | 1
@ -48,7 +48,7 @@ LL | | };
= note: `(a || b) as i32` or `(a || b).into()` can also be valid options
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:36:5
--> $DIR/bool_to_int_with_if.rs:34:5
|
LL | / if cond(a, b) {
LL | | 1
@ -60,7 +60,7 @@ LL | | };
= note: `cond(a, b) as i32` or `cond(a, b).into()` can also be valid options
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:41:5
--> $DIR/bool_to_int_with_if.rs:39:5
|
LL | / if x + y < 4 {
LL | | 1
@ -72,7 +72,7 @@ LL | | };
= note: `(x + y < 4) as i32` or `(x + y < 4).into()` can also be valid options
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:50:12
--> $DIR/bool_to_int_with_if.rs:48:12
|
LL | } else if b {
| ____________^
@ -85,7 +85,7 @@ LL | | };
= note: `b as i32` or `b.into()` can also be valid options
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:59:12
--> $DIR/bool_to_int_with_if.rs:57:12
|
LL | } else if b {
| ____________^
@ -98,7 +98,7 @@ LL | | };
= note: `!b as i32` or `(!b).into()` can also be valid options
error: boolean to int conversion using if
--> $DIR/bool_to_int_with_if.rs:126:5
--> $DIR/bool_to_int_with_if.rs:124:5
|
LL | if a { 1 } else { 0 }
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(a)`

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::borrow_as_ptr)]
#![allow(clippy::useless_vec)]

Some files were not shown because too many files have changed in this diff Show more