1
Fork 0

Update ui test crate

This commit is contained in:
Oli Scherer 2023-07-27 11:40:22 +00:00
parent 0afd38b093
commit 3d88fae050
1219 changed files with 6861 additions and 5821 deletions

View file

@ -1,7 +1,7 @@
[alias] [alias]
uitest = "test --test compile-test" uitest = "test --test compile-test -- --check"
uibless = "test --test compile-test -- -- --bless" uibless = "test --test compile-test"
bless = "test -- -- --bless" bless = "test"
dev = "run --package clippy_dev --bin clippy_dev --manifest-path clippy_dev/Cargo.toml --" 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 -- " lintcheck = "run --package lintcheck --bin lintcheck --manifest-path lintcheck/Cargo.toml -- "
collect-metadata = "test --test dogfood --features internal -- run_metadata_collection_lint --ignored" 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" termize = "0.1"
[dev-dependencies] [dev-dependencies]
ui_test = "0.11.5" ui_test = "0.12"
tester = "0.9" tester = "0.9"
regex = "1.5" regex = "1.5"
toml = "0.7.3" 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 ## Rustfix tests
If the lint you are working on is making use of structured suggestions, the test 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 will create a `.fixed` file by running [rustfix] for that test.
additionally run [rustfix] for that test. Rustfix will apply the suggestions Rustfix will apply the suggestions
from the lint to the code of the test file and compare that to the contents of a from the lint to the code of the test file and compare that to the contents of a
`.fixed` file. `.fixed` file.

View file

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

View file

@ -5,7 +5,7 @@
#![warn(rust_2018_idioms, unused_lifetimes)] #![warn(rust_2018_idioms, unused_lifetimes)]
#![allow(unused_extern_crates)] #![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 as compiletest;
use ui_test::Mode as TestMode; use ui_test::Mode as TestMode;
@ -110,13 +110,14 @@ mod test_utils;
// whether to run internal tests or not // whether to run internal tests or not
const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal"); const RUN_INTERNAL_TESTS: bool = cfg!(feature = "internal");
fn base_config(test_dir: &str) -> compiletest::Config { fn base_config(test_dir: &str) -> (compiletest::Config, Args) {
let args = Args::test();
let mut config = compiletest::Config { let mut config = compiletest::Config {
mode: TestMode::Yolo, mode: TestMode::Yolo,
stderr_filters: vec![], stderr_filters: vec![],
stdout_filters: vec![], stdout_filters: vec![],
output_conflict_handling: if var_os("RUSTC_BLESS").is_some_and(|v| v != "0") output_conflict_handling: if var_os("GITHUB_ACTION").is_none()
|| env::args().any(|arg| arg == "--bless") && (var_os("RUSTC_BLESS").is_some_and(|v| v != "0") || !args.check)
{ {
OutputConflictHandling::Bless OutputConflictHandling::Bless
} else { } else {
@ -158,7 +159,7 @@ fn base_config(test_dir: &str) -> compiletest::Config {
} else { } else {
"clippy-driver" "clippy-driver"
}); });
config (config, args)
} }
fn test_filter() -> Box<dyn Sync + Fn(&Path) -> bool> { fn test_filter() -> Box<dyn Sync + Fn(&Path) -> bool> {
@ -171,7 +172,7 @@ fn test_filter() -> Box<dyn Sync + Fn(&Path) -> bool> {
} }
fn run_ui() { fn run_ui() {
let config = base_config("ui"); let (config, args) = base_config("ui");
//config.rustfix_coverage = true; //config.rustfix_coverage = true;
// use tests/clippy.toml // use tests/clippy.toml
let _g = VarGuard::set("CARGO_MANIFEST_DIR", fs::canonicalize("tests").unwrap()); let _g = VarGuard::set("CARGO_MANIFEST_DIR", fs::canonicalize("tests").unwrap());
@ -189,12 +190,12 @@ fn run_ui() {
compiletest::run_tests_generic( compiletest::run_tests_generic(
config, config,
move |path| compiletest::default_file_filter(path) && test_filter(path), args,
move |path, args| compiletest::default_file_filter(path, args) && test_filter(path),
compiletest::default_per_file_config, compiletest::default_per_file_config,
status_emitter::Text, status_emitter::Text::verbose(),
) )
.unwrap(); .unwrap();
check_rustfix_coverage();
} }
fn run_internal_tests() { fn run_internal_tests() {
@ -202,23 +203,24 @@ fn run_internal_tests() {
if !RUN_INTERNAL_TESTS { if !RUN_INTERNAL_TESTS {
return; 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 { 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 test_filter = test_filter();
compiletest::run_tests_generic( compiletest::run_tests_generic(
config, config,
move |path| compiletest::default_file_filter(path) && test_filter(path), args,
move |path, args| compiletest::default_file_filter(path, args) && test_filter(path),
compiletest::default_per_file_config, compiletest::default_per_file_config,
status_emitter::Text, status_emitter::Text::verbose(),
) )
.unwrap(); .unwrap();
} }
fn run_ui_toml() { fn run_ui_toml() {
let mut config = base_config("ui-toml"); let (mut config, args) = base_config("ui-toml");
config.stderr_filter( config.stderr_filter(
&regex::escape( &regex::escape(
@ -237,7 +239,8 @@ fn run_ui_toml() {
ui_test::run_tests_generic( ui_test::run_tests_generic(
config, config,
|path| compiletest::default_file_filter(path) && test_filter(path), args,
|path, args| compiletest::default_file_filter(path, args) && test_filter(path),
|config, path| { |config, path| {
let mut config = config.clone(); let mut config = config.clone();
config config
@ -246,7 +249,7 @@ fn run_ui_toml() {
.push(("CLIPPY_CONF_DIR".into(), Some(path.parent().unwrap().into()))); .push(("CLIPPY_CONF_DIR".into(), Some(path.parent().unwrap().into())));
Some(config) Some(config)
}, },
status_emitter::Text, status_emitter::Text::verbose(),
) )
.unwrap(); .unwrap();
} }
@ -256,7 +259,7 @@ fn run_ui_cargo() {
return; 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.input_file_flag = CommandBuilder::cargo().input_file_flag;
config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag; config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag;
config.program.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()]; config.program.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()];
@ -291,13 +294,14 @@ fn run_ui_cargo() {
ui_test::run_tests_generic( ui_test::run_tests_generic(
config, config,
|path| test_filter(path) && path.ends_with("Cargo.toml"), args,
|path, _args| test_filter(path) && path.ends_with("Cargo.toml"),
|config, path| { |config, path| {
let mut config = config.clone(); let mut config = config.clone();
config.out_dir = PathBuf::from("target/ui_test_cargo/").join(path.parent().unwrap()); config.out_dir = PathBuf::from("target/ui_test_cargo/").join(path.parent().unwrap());
Some(config) Some(config)
}, },
status_emitter::Text, status_emitter::Text::verbose(),
) )
.unwrap(); .unwrap();
} }
@ -322,7 +326,6 @@ fn main() {
"cargo" => run_ui_cargo as fn(), "cargo" => run_ui_cargo as fn(),
"toml" => run_ui_toml as fn(), "toml" => run_ui_toml as fn(),
"internal" => run_internal_tests 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(), "ui-cargo-toml-metadata" => ui_cargo_toml_metadata as fn(),
_ => panic!("unknown speedtest: {speedtest} || accepted speedtests are: [ui, cargo, toml, internal]"), _ => panic!("unknown speedtest: {speedtest} || accepted speedtests are: [ui, cargo, toml, internal]"),
@ -349,89 +352,10 @@ fn main() {
run_ui_toml(); run_ui_toml();
run_ui_cargo(); run_ui_cargo();
run_internal_tests(); run_internal_tests();
rustfix_coverage_known_exceptions_accuracy();
ui_cargo_toml_metadata(); 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() { fn ui_cargo_toml_metadata() {
let ui_cargo_path = Path::new("tests/ui-cargo"); let ui_cargo_path = Path::new("tests/ui-cargo");
let cargo_common_metadata_path = ui_cargo_path.join("cargo_common_metadata"); let cargo_common_metadata_path = ui_cargo_path.join("cargo_common_metadata");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: variables can be used directly in the `format!` string 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); LL | println!("val='{}'", local_i32);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL + println!("val='{local_i32}'");
| |
error: variables can be used directly in the `format!` string 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); 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 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); 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 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); 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 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); 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 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()); LL | println!("{}, {}", local_i32, local_opt.unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

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

View file

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

@ -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 //@aux-build:proc_macro_derive.rs:proc-macro
//@run-rustfix
#![warn(clippy::nonstandard_macro_braces)] #![warn(clippy::nonstandard_macro_braces)]

View file

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

View file

@ -1,5 +1,5 @@
error: use of irregular braces for `vec!` macro 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}; LL | let _ = vec! {1, 2, 3};
| ^^^^^^^^^^^^^^ help: consider writing: `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` = note: `-D clippy::nonstandard-macro-braces` implied by `-D warnings`
error: use of irregular braces for `format!` macro 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"]; LL | let _ = format!["ugh {} stop being such a good compiler", "hello"];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `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 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!{{}, ()}; LL | let _ = matches!{{}, ()};
| ^^^^^^^^^^^^^^^^ help: consider writing: `matches!({}, ())` | ^^^^^^^^^^^^^^^^ help: consider writing: `matches!({}, ())`
error: use of irregular braces for `quote!` macro 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;); LL | let _ = quote!(let x = 1;);
| ^^^^^^^^^^^^^^^^^^ help: consider writing: `quote!{let x = 1;}` | ^^^^^^^^^^^^^^^^^^ help: consider writing: `quote!{let x = 1;}`
error: use of irregular braces for `quote::quote!` macro 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); LL | let _ = quote::quote!(match match match);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `quote::quote!{match match match}` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `quote::quote!{match match match}`
error: use of irregular braces for `vec!` macro 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} LL | vec!{0, 0, 0}
| ^^^^^^^^^^^^^ help: consider writing: `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) = 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 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![]; LL | let _: type_pos!(usize) = vec![];
| ^^^^^^^^^^^^^^^^ help: consider writing: `type_pos![usize]` | ^^^^^^^^^^^^^^^^ help: consider writing: `type_pos![usize]`
error: use of irregular braces for `eprint!` macro 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"); LL | eprint!("test if user config overrides defaults");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `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( #![allow(
unused, unused,
clippy::unused_unit, clippy::unused_unit,

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: consider moving the `;` inside the block for consistent formatting 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 | / {
LL | | unit_fn_block(); LL | | unit_fn_block();

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: consider moving the `;` outside the block for consistent formatting 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(); } LL | { unit_fn_block(); }
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL + { unit_fn_block() };
| |
error: consider moving the `;` outside the block for consistent formatting 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(); } LL | unsafe { unit_fn_block(); }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL + unsafe { unit_fn_block() };
| |
error: consider moving the `;` outside the block for consistent formatting 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!(()); } LL | { m!(()); }
| ^^^^^^^^^^^ | ^^^^^^^^^^^

View file

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

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,4 +1,3 @@
//@run-rustfix
//@aux-build:proc_macros.rs:proc-macro //@aux-build:proc_macros.rs:proc-macro
#![allow(unused)] #![allow(unused)]
#![warn(clippy::allow_attributes)] #![warn(clippy::allow_attributes)]

View file

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

View file

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

View file

@ -1,4 +1,3 @@
//@run-rustfix
//@edition:2018 //@edition:2018
//@aux-build:proc_macros.rs:proc-macro //@aux-build:proc_macros.rs:proc-macro

View file

@ -1,4 +1,3 @@
//@run-rustfix
//@edition:2018 //@edition:2018
//@aux-build:proc_macros.rs:proc-macro //@aux-build:proc_macros.rs:proc-macro

View file

@ -1,5 +1,5 @@
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:19:17 --> $DIR/almost_complete_range.rs:18:17
| |
LL | let _ = ('a') ..'z'; LL | let _ = ('a') ..'z';
| ^^^^^^--^^^ | ^^^^^^--^^^
@ -9,7 +9,7 @@ LL | let _ = ('a') ..'z';
= note: `-D clippy::almost-complete-range` implied by `-D warnings` = note: `-D clippy::almost-complete-range` implied by `-D warnings`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:20:17 --> $DIR/almost_complete_range.rs:19:17
| |
LL | let _ = 'A' .. ('Z'); LL | let _ = 'A' .. ('Z');
| ^^^^--^^^^^^ | ^^^^--^^^^^^
@ -17,7 +17,7 @@ LL | let _ = 'A' .. ('Z');
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:21:17 --> $DIR/almost_complete_range.rs:20:17
| |
LL | let _ = ((('0'))) .. ('9'); LL | let _ = ((('0'))) .. ('9');
| ^^^^^^^^^^--^^^^^^ | ^^^^^^^^^^--^^^^^^
@ -25,7 +25,7 @@ LL | let _ = ((('0'))) .. ('9');
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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'); LL | let _ = (b'a')..(b'z');
| ^^^^^^--^^^^^^ | ^^^^^^--^^^^^^
@ -33,7 +33,7 @@ LL | let _ = (b'a')..(b'z');
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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'; LL | let _ = b'A'..b'Z';
| ^^^^--^^^^ | ^^^^--^^^^
@ -41,7 +41,7 @@ LL | let _ = b'A'..b'Z';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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'; LL | let _ = b'0'..b'9';
| ^^^^--^^^^ | ^^^^--^^^^
@ -49,7 +49,7 @@ LL | let _ = b'0'..b'9';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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'; LL | let _ = inline!('a')..'z';
| ^^^^^^^^^^^^--^^^ | ^^^^^^^^^^^^--^^^
@ -57,7 +57,7 @@ LL | let _ = inline!('a')..'z';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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'; LL | let _ = inline!('A')..'Z';
| ^^^^^^^^^^^^--^^^ | ^^^^^^^^^^^^--^^^
@ -65,7 +65,7 @@ LL | let _ = inline!('A')..'Z';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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'; LL | let _ = inline!('0')..'9';
| ^^^^^^^^^^^^--^^^ | ^^^^^^^^^^^^--^^^
@ -73,7 +73,7 @@ LL | let _ = inline!('0')..'9';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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, 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: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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, 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: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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, 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: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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, LL | 'a'..'z' if true => 1,
| ^^^--^^^ | ^^^--^^^
@ -105,7 +105,7 @@ LL | 'a'..'z' if true => 1,
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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, LL | 'A'..'Z' if true => 2,
| ^^^--^^^ | ^^^--^^^
@ -113,7 +113,7 @@ LL | 'A'..'Z' if true => 2,
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii 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, LL | '0'..'9' if true => 3,
| ^^^--^^^ | ^^^--^^^
@ -121,7 +121,7 @@ LL | '0'..'9' if true => 3,
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:66:17 --> $DIR/almost_complete_range.rs:65:17
| |
LL | let _ = 'a'..'z'; 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) = 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 error: almost complete ascii range
--> $DIR/almost_complete_range.rs:67:17 --> $DIR/almost_complete_range.rs:66:17
| |
LL | let _ = 'A'..'Z'; 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) = 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 error: almost complete ascii range
--> $DIR/almost_complete_range.rs:68:17 --> $DIR/almost_complete_range.rs:67:17
| |
LL | let _ = '0'..'9'; 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) = 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 error: almost complete ascii range
--> $DIR/almost_complete_range.rs:75:9 --> $DIR/almost_complete_range.rs:74:9
| |
LL | 'a'..'z' => 1, LL | 'a'..'z' => 1,
| ^^^--^^^ | ^^^--^^^
@ -159,7 +159,7 @@ LL | 'a'..'z' => 1,
| help: use an inclusive range: `...` | help: use an inclusive range: `...`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:76:9 --> $DIR/almost_complete_range.rs:75:9
| |
LL | 'A'..'Z' => 2, LL | 'A'..'Z' => 2,
| ^^^--^^^ | ^^^--^^^
@ -167,7 +167,7 @@ LL | 'A'..'Z' => 2,
| help: use an inclusive range: `...` | help: use an inclusive range: `...`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:77:9 --> $DIR/almost_complete_range.rs:76:9
| |
LL | '0'..'9' => 3, LL | '0'..'9' => 3,
| ^^^--^^^ | ^^^--^^^
@ -175,7 +175,7 @@ LL | '0'..'9' => 3,
| help: use an inclusive range: `...` | help: use an inclusive range: `...`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:84:13 --> $DIR/almost_complete_range.rs:83:13
| |
LL | let _ = 'a'..'z'; LL | let _ = 'a'..'z';
| ^^^--^^^ | ^^^--^^^
@ -183,7 +183,7 @@ LL | let _ = 'a'..'z';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:85:13 --> $DIR/almost_complete_range.rs:84:13
| |
LL | let _ = 'A'..'Z'; LL | let _ = 'A'..'Z';
| ^^^--^^^ | ^^^--^^^
@ -191,7 +191,7 @@ LL | let _ = 'A'..'Z';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:86:13 --> $DIR/almost_complete_range.rs:85:13
| |
LL | let _ = '0'..'9'; LL | let _ = '0'..'9';
| ^^^--^^^ | ^^^--^^^
@ -199,7 +199,7 @@ LL | let _ = '0'..'9';
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:88:9 --> $DIR/almost_complete_range.rs:87:9
| |
LL | 'a'..'z' => 1, LL | 'a'..'z' => 1,
| ^^^--^^^ | ^^^--^^^
@ -207,7 +207,7 @@ LL | 'a'..'z' => 1,
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:89:9 --> $DIR/almost_complete_range.rs:88:9
| |
LL | 'A'..'Z' => 1, LL | 'A'..'Z' => 1,
| ^^^--^^^ | ^^^--^^^
@ -215,7 +215,7 @@ LL | 'A'..'Z' => 1,
| help: use an inclusive range: `..=` | help: use an inclusive range: `..=`
error: almost complete ascii range error: almost complete ascii range
--> $DIR/almost_complete_range.rs:90:9 --> $DIR/almost_complete_range.rs:89:9
| |
LL | '0'..'9' => 3, LL | '0'..'9' => 3,
| ^^^--^^^ | ^^^--^^^

View file

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

View file

@ -1,5 +1,5 @@
error: casting the result of `as_ptr` to *mut u8 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; LL | let _ = string.as_ptr() as *mut u8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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` = note: `-D clippy::as-ptr-cast-mut` implied by `-D warnings`
error: casting the result of `as_ptr` to *mut i8 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 _; LL | let _: *mut i8 = string.as_ptr() as *mut _;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `string.as_mut_ptr()`

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: called `assert!` with `Result::is_ok` 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()); LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` | ^^^^^^^^^^^^^^^^^^ 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` = note: `-D clippy::assertions-on-result-states` implied by `-D warnings`
error: called `assert!` with `Result::is_ok` 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()); LL | assert!(get_ok().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok().unwrap()`
error: called `assert!` with `Result::is_ok` 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()); LL | assert!(get_ok_macro!().is_ok());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with: `get_ok_macro!().unwrap()`
error: called `assert!` with `Result::is_ok` 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()); LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
error: called `assert!` with `Result::is_ok` 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()); LL | assert!(r.is_ok());
| ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()` | ^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap()`
error: called `assert!` with `Result::is_err` 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()); LL | assert!(r.is_err());
| ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()` | ^^^^^^^^^^^^^^^^^^^ help: replace with: `r.unwrap_err()`
error: called `assert!` with `Result::is_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()) LL | assert!(res.is_err())
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();` | ^^^^^^^^^^^^^^^^^^^^^ help: replace with: `res.unwrap_err();`

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: an async construct yields a type which is itself awaitable 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 { LL | let _h = async {
| _____________________- | _____________________-
@ -19,7 +19,7 @@ LL + }.await
| |
error: an async construct yields a type which is itself awaitable 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 { LL | let _i = async {
| ____________________- | ____________________-
@ -32,7 +32,7 @@ LL | | };
| |_____- outer async construct | |_____- outer async construct
error: an async construct yields a type which is itself awaitable 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 || { LL | let _j = async || {
| ________________________- | ________________________-
@ -51,7 +51,7 @@ LL + }.await
| |
error: an async construct yields a type which is itself awaitable 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 || { LL | let _k = async || {
| _______________________- | _______________________-
@ -64,7 +64,7 @@ LL | | };
| |_____- outer async construct | |_____- outer async construct
error: an async construct yields a type which is itself awaitable 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; LL | let _l = async || CustomFutureType;
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^
@ -74,7 +74,7 @@ LL | let _l = async || CustomFutureType;
| help: consider awaiting this value: `CustomFutureType.await` | help: consider awaiting this value: `CustomFutureType.await`
error: an async construct yields a type which is itself awaitable 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 || { LL | let _m = async || {
| _______________________- | _______________________-

View file

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

View file

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

View file

@ -1,23 +1,23 @@
error: using `Option.and_then(Some)`, which is a no-op 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); LL | let _ = x.and_then(Some);
| ^^^^^^^^^^^^^^^^ help: use the expression directly: `x` | ^^^^^^^^^^^^^^^^ help: use the expression directly: `x`
| |
note: the lint level is defined here 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)] LL | #![deny(clippy::bind_instead_of_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: using `Option.and_then(|x| Some(y))`, which is more succinctly expressed as `map(|x| y)` 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)); LL | let _ = x.and_then(|o| Some(o + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.map(|o| o + 1)`
error: using `Result.and_then(Ok)`, which is a no-op 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); LL | let _ = x.and_then(Ok);
| ^^^^^^^^^^^^^^ help: use the expression directly: `x` | ^^^^^^^^^^^^^^ help: use the expression directly: `x`

View file

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

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![deny(clippy::bind_instead_of_map)] #![deny(clippy::bind_instead_of_map)]
#![allow(clippy::blocks_in_if_conditions)] #![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)` 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()) }); LL | let _ = Some("42").and_then(|s| if s.len() < 42 { Some(0) } else { Some(s.len()) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
note: the lint level is defined here 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)] 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)` 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()) }); 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)` 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()) }); 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)` 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 | / Some("42").and_then(|s| {
LL | | if { 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)` 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)) }); 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)] #![warn(clippy::blocks_in_if_conditions)]
#![allow(unused, clippy::let_and_return, clippy::needless_if)] #![allow(unused, clippy::let_and_return, clippy::needless_if)]
#![warn(clippy::nonminimal_bool)] #![warn(clippy::nonminimal_bool)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::blocks_in_if_conditions)] #![warn(clippy::blocks_in_if_conditions)]
#![allow(unused, clippy::let_and_return, clippy::needless_if)] #![allow(unused, clippy::let_and_return, clippy::needless_if)]
#![warn(clippy::nonminimal_bool)] #![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` 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 | / if {
LL | | let x = 3; LL | | let x = 3;
@ -17,13 +17,13 @@ LL ~ }; if res {
| |
error: omit braces around single expression condition 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 } LL | if { true } { 6 } else { 10 }
| ^^^^^^^^ help: try: `true` | ^^^^^^^^ help: try: `true`
error: this boolean expression can be simplified 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 } LL | if true && x == 3 { 6 } else { 10 }
| ^^^^^^^^^^^^^^ help: try: `x == 3` | ^^^^^^^^^^^^^^ help: try: `x == 3`

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: used `assert_eq!` with a literal bool 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); LL | assert_eq!("a".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -12,7 +12,7 @@ LL + assert!(!"a".is_empty());
| |
error: used `assert_eq!` with a literal bool 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); LL | assert_eq!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -24,7 +24,7 @@ LL + assert!("".is_empty());
| |
error: used `assert_eq!` with a literal bool 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()); LL | assert_eq!(true, "".is_empty());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -36,7 +36,7 @@ LL + assert!("".is_empty());
| |
error: used `assert_eq!` with a literal bool 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); LL | assert_eq!(b, true);
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -48,7 +48,7 @@ LL + assert!(b);
| |
error: used `assert_ne!` with a literal bool 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); LL | assert_ne!("a".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -60,7 +60,7 @@ LL + assert!("a".is_empty());
| |
error: used `assert_ne!` with a literal bool 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); LL | assert_ne!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -72,7 +72,7 @@ LL + assert!(!"".is_empty());
| |
error: used `assert_ne!` with a literal bool 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()); LL | assert_ne!(true, "".is_empty());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -84,7 +84,7 @@ LL + assert!(!"".is_empty());
| |
error: used `assert_ne!` with a literal bool 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); LL | assert_ne!(b, true);
| ^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^
@ -96,7 +96,7 @@ LL + assert!(!b);
| |
error: used `debug_assert_eq!` with a literal bool 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); 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 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); 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 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()); 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 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); LL | debug_assert_eq!(b, true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -144,7 +144,7 @@ LL + debug_assert!(b);
| |
error: used `debug_assert_ne!` with a literal bool 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); 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 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); 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 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()); 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 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); LL | debug_assert_ne!(b, true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -192,7 +192,7 @@ LL + debug_assert!(!b);
| |
error: used `assert_eq!` with a literal bool 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); 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 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); 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 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); 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 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); 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 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); 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 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); 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 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); LL | assert_eq!(a!(), true);
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
@ -276,7 +276,7 @@ LL + assert!(a!());
| |
error: used `assert_eq!` with a literal bool 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!()); LL | assert_eq!(true, b!());
| ^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
@ -288,7 +288,7 @@ LL + assert!(b!());
| |
error: used `debug_assert_eq!` with a literal bool 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); LL | renamed!(b, true);
| ^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^
@ -300,7 +300,7 @@ LL + debug_assert!(b);
| |
error: used `assert_eq!` with a literal bool 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); LL | assert_eq!("".is_empty(), true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -312,7 +312,7 @@ LL + assert!("".is_empty());
| |
error: used `assert_ne!` with a literal bool 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); LL | assert_ne!("".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -324,7 +324,7 @@ LL + assert!("".is_empty());
| |
error: used `assert_ne!` with a literal bool 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); 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 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); 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 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); 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 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); 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 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); 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 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); LL | debug_assert_eq!("requires negation".is_empty(), false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: boolean to int conversion using if 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 | / if a {
LL | | 1 LL | | 1
@ -12,7 +12,7 @@ LL | | };
= note: `-D clippy::bool-to-int-with-if` implied by `-D warnings` = note: `-D clippy::bool-to-int-with-if` implied by `-D warnings`
error: boolean to int conversion using if 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 | / if a {
LL | | 0 LL | | 0
@ -24,7 +24,7 @@ LL | | };
= note: `!a as i32` or `(!a).into()` can also be valid options = note: `!a as i32` or `(!a).into()` can also be valid options
error: boolean to int conversion using if 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 | / if !a {
LL | | 1 LL | | 1
@ -36,7 +36,7 @@ LL | | };
= note: `!a as i32` or `(!a).into()` can also be valid options = note: `!a as i32` or `(!a).into()` can also be valid options
error: boolean to int conversion using if 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 | / if a || b {
LL | | 1 LL | | 1
@ -48,7 +48,7 @@ LL | | };
= note: `(a || b) as i32` or `(a || b).into()` can also be valid options = note: `(a || b) as i32` or `(a || b).into()` can also be valid options
error: boolean to int conversion using if 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 | / if cond(a, b) {
LL | | 1 LL | | 1
@ -60,7 +60,7 @@ LL | | };
= note: `cond(a, b) as i32` or `cond(a, b).into()` can also be valid options = note: `cond(a, b) as i32` or `cond(a, b).into()` can also be valid options
error: boolean to int conversion using if 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 | / if x + y < 4 {
LL | | 1 LL | | 1
@ -72,7 +72,7 @@ LL | | };
= note: `(x + y < 4) as i32` or `(x + y < 4).into()` can also be valid options = note: `(x + y < 4) as i32` or `(x + y < 4).into()` can also be valid options
error: boolean to int conversion using if 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 { LL | } else if b {
| ____________^ | ____________^
@ -85,7 +85,7 @@ LL | | };
= note: `b as i32` or `b.into()` can also be valid options = note: `b as i32` or `b.into()` can also be valid options
error: boolean to int conversion using if 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 { LL | } else if b {
| ____________^ | ____________^
@ -98,7 +98,7 @@ LL | | };
= note: `!b as i32` or `(!b).into()` can also be valid options = note: `!b as i32` or `(!b).into()` can also be valid options
error: boolean to int conversion using if 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 } LL | if a { 1 } else { 0 }
| ^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(a)` | ^^^^^^^^^^^^^^^^^^^^^ help: replace with from: `u8::from(a)`

View file

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

View file

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

View file

@ -1,5 +1,5 @@
error: borrow as raw pointer error: borrow as raw pointer
--> $DIR/borrow_as_ptr.rs:11:14 --> $DIR/borrow_as_ptr.rs:10:14
| |
LL | let _p = &val as *const i32; LL | let _p = &val as *const i32;
| ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(val)` | ^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of!(val)`
@ -7,7 +7,7 @@ LL | let _p = &val as *const i32;
= note: `-D clippy::borrow-as-ptr` implied by `-D warnings` = note: `-D clippy::borrow-as-ptr` implied by `-D warnings`
error: borrow as raw pointer error: borrow as raw pointer
--> $DIR/borrow_as_ptr.rs:18:18 --> $DIR/borrow_as_ptr.rs:17:18
| |
LL | let _p_mut = &mut val_mut as *mut i32; LL | let _p_mut = &mut val_mut as *mut i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(val_mut)` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::ptr::addr_of_mut!(val_mut)`

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::borrow_as_ptr)] #![warn(clippy::borrow_as_ptr)]
#![feature(lang_items, start, libc)] #![feature(lang_items, start, libc)]
#![no_std] #![no_std]

View file

@ -1,4 +1,3 @@
//@run-rustfix
#![warn(clippy::borrow_as_ptr)] #![warn(clippy::borrow_as_ptr)]
#![feature(lang_items, start, libc)] #![feature(lang_items, start, libc)]
#![no_std] #![no_std]

View file

@ -1,5 +1,5 @@
error: borrow as raw pointer error: borrow as raw pointer
--> $DIR/borrow_as_ptr_no_std.rs:9:14 --> $DIR/borrow_as_ptr_no_std.rs:8:14
| |
LL | let _p = &val as *const i32; LL | let _p = &val as *const i32;
| ^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of!(val)` | ^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of!(val)`
@ -7,7 +7,7 @@ LL | let _p = &val as *const i32;
= note: `-D clippy::borrow-as-ptr` implied by `-D warnings` = note: `-D clippy::borrow-as-ptr` implied by `-D warnings`
error: borrow as raw pointer error: borrow as raw pointer
--> $DIR/borrow_as_ptr_no_std.rs:12:18 --> $DIR/borrow_as_ptr_no_std.rs:11:18
| |
LL | let _p_mut = &mut val_mut as *mut i32; LL | let _p_mut = &mut val_mut as *mut i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of_mut!(val_mut)` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `core::ptr::addr_of_mut!(val_mut)`

View file

@ -5,6 +5,7 @@
clippy::disallowed_names, clippy::disallowed_names,
clippy::needless_pass_by_ref_mut clippy::needless_pass_by_ref_mut
)] )]
//@no-rustfix
use std::fmt::Display; use std::fmt::Display;

View file

@ -1,5 +1,5 @@
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:24:14 --> $DIR/borrow_box.rs:25:14
| |
LL | let foo: &Box<bool>; LL | let foo: &Box<bool>;
| ^^^^^^^^^^ help: try: `&bool` | ^^^^^^^^^^ help: try: `&bool`
@ -11,55 +11,55 @@ LL | #![deny(clippy::borrowed_box)]
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:28:10 --> $DIR/borrow_box.rs:29:10
| |
LL | foo: &'a Box<bool>, LL | foo: &'a Box<bool>,
| ^^^^^^^^^^^^^ help: try: `&'a bool` | ^^^^^^^^^^^^^ help: try: `&'a bool`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:32:17 --> $DIR/borrow_box.rs:33:17
| |
LL | fn test4(a: &Box<bool>); LL | fn test4(a: &Box<bool>);
| ^^^^^^^^^^ help: try: `&bool` | ^^^^^^^^^^ help: try: `&bool`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:98:25 --> $DIR/borrow_box.rs:99:25
| |
LL | pub fn test14(_display: &Box<dyn Display>) {} LL | pub fn test14(_display: &Box<dyn Display>) {}
| ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display` | ^^^^^^^^^^^^^^^^^ help: try: `&dyn Display`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:99:25 --> $DIR/borrow_box.rs:100:25
| |
LL | pub fn test15(_display: &Box<dyn Display + Send>) {} LL | pub fn test15(_display: &Box<dyn Display + Send>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:100:29 --> $DIR/borrow_box.rs:101:29
| |
LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {} LL | pub fn test16<'a>(_display: &'a Box<dyn Display + 'a>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (dyn Display + 'a)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:102:25 --> $DIR/borrow_box.rs:103:25
| |
LL | pub fn test17(_display: &Box<impl Display>) {} LL | pub fn test17(_display: &Box<impl Display>) {}
| ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display` | ^^^^^^^^^^^^^^^^^^ help: try: `&impl Display`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:103:25 --> $DIR/borrow_box.rs:104:25
| |
LL | pub fn test18(_display: &Box<impl Display + Send>) {} LL | pub fn test18(_display: &Box<impl Display + Send>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)` | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(impl Display + Send)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:104:29 --> $DIR/borrow_box.rs:105:29
| |
LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {} LL | pub fn test19<'a>(_display: &'a Box<impl Display + 'a>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&'a (impl Display + 'a)`
error: you seem to be trying to use `&Box<T>`. Consider using just `&T` error: you seem to be trying to use `&Box<T>`. Consider using just `&T`
--> $DIR/borrow_box.rs:109:25 --> $DIR/borrow_box.rs:110:25
| |
LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {} LL | pub fn test20(_display: &Box<(dyn Display + Send)>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)` | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&(dyn Display + Send)`

View file

@ -1,4 +1,3 @@
//@run-rustfix
//@aux-build: proc_macros.rs:proc-macro //@aux-build: proc_macros.rs:proc-macro
#![allow(dead_code, unused_variables)] #![allow(dead_code, unused_variables)]

View file

@ -1,4 +1,3 @@
//@run-rustfix
//@aux-build: proc_macros.rs:proc-macro //@aux-build: proc_macros.rs:proc-macro
#![allow(dead_code, unused_variables)] #![allow(dead_code, unused_variables)]

View file

@ -1,5 +1,5 @@
error: deref on an immutable reference error: deref on an immutable reference
--> $DIR/borrow_deref_ref.rs:14:17 --> $DIR/borrow_deref_ref.rs:13:17
| |
LL | let b = &*a; LL | let b = &*a;
| ^^^ help: if you would like to reborrow, try removing `&*`: `a` | ^^^ help: if you would like to reborrow, try removing `&*`: `a`
@ -7,13 +7,13 @@ LL | let b = &*a;
= note: `-D clippy::borrow-deref-ref` implied by `-D warnings` = note: `-D clippy::borrow-deref-ref` implied by `-D warnings`
error: deref on an immutable reference error: deref on an immutable reference
--> $DIR/borrow_deref_ref.rs:16:22 --> $DIR/borrow_deref_ref.rs:15:22
| |
LL | let b = &mut &*bar(&12); LL | let b = &mut &*bar(&12);
| ^^^^^^^^^^ help: if you would like to reborrow, try removing `&*`: `bar(&12)` | ^^^^^^^^^^ help: if you would like to reborrow, try removing `&*`: `bar(&12)`
error: deref on an immutable reference error: deref on an immutable reference
--> $DIR/borrow_deref_ref.rs:70:23 --> $DIR/borrow_deref_ref.rs:69:23
| |
LL | let addr_y = &&*x as *const _ as usize; // assert ok LL | let addr_y = &&*x as *const _ as usize; // assert ok
| ^^^ help: if you would like to reborrow, try removing `&*`: `x` | ^^^ help: if you would like to reborrow, try removing `&*`: `x`

View file

@ -1,3 +1,4 @@
//@no-rustfix: overlapping suggestions
#![allow(dead_code, unused_variables)] #![allow(dead_code, unused_variables)]
fn main() {} fn main() {}

View file

@ -1,5 +1,5 @@
error: deref on an immutable reference error: deref on an immutable reference
--> $DIR/borrow_deref_ref_unfixable.rs:8:23 --> $DIR/borrow_deref_ref_unfixable.rs:9:23
| |
LL | let x: &str = &*s; LL | let x: &str = &*s;
| ^^^ | ^^^

View file

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

View file

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

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