Merge commit 'd7b5cbf065' into clippyup
This commit is contained in:
parent
bd071bf5b2
commit
f8f9d01c2a
199 changed files with 4158 additions and 1931 deletions
|
|
@ -21,7 +21,7 @@ fn dogfood_clippy() {
|
|||
|
||||
// "" is the root package
|
||||
for package in &["", "clippy_dev", "clippy_lints", "clippy_utils", "rustc_tools_util"] {
|
||||
run_clippy_for_package(package, &[]);
|
||||
run_clippy_for_package(package, &["-D", "clippy::all", "-D", "clippy::pedantic"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -77,8 +77,6 @@ fn run_clippy_for_package(project: &str, args: &[&str]) {
|
|||
.arg("--all-features")
|
||||
.arg("--")
|
||||
.args(args)
|
||||
.args(&["-D", "clippy::all"])
|
||||
.args(&["-D", "clippy::pedantic"])
|
||||
.arg("-Cdebuginfo=0"); // disable debuginfo to generate less data in the target dir
|
||||
|
||||
if cfg!(feature = "internal") {
|
||||
|
|
|
|||
|
|
@ -1,3 +1 @@
|
|||
// error-pattern: error reading Clippy's configuration file
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1 @@
|
|||
// error-pattern: error reading Clippy's configuration file: `blacklisted-names` is expected to be a
|
||||
// `Vec < String >` but is a `integer`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
10
tests/ui-toml/blacklisted_names_append/blacklisted_names.rs
Normal file
10
tests/ui-toml/blacklisted_names_append/blacklisted_names.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#[warn(clippy::blacklisted_name)]
|
||||
|
||||
fn main() {
|
||||
// `foo` is part of the default configuration
|
||||
let foo = "bar";
|
||||
// `ducks` was unrightfully blacklisted
|
||||
let ducks = ["quack", "quack"];
|
||||
// `fox` is okay
|
||||
let fox = ["what", "does", "the", "fox", "say", "?"];
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
error: use of a blacklisted/placeholder name `foo`
|
||||
--> $DIR/blacklisted_names.rs:5:9
|
||||
|
|
||||
LL | let foo = "bar";
|
||||
| ^^^
|
||||
|
|
||||
= note: `-D clippy::blacklisted-name` implied by `-D warnings`
|
||||
|
||||
error: use of a blacklisted/placeholder name `ducks`
|
||||
--> $DIR/blacklisted_names.rs:7:9
|
||||
|
|
||||
LL | let ducks = ["quack", "quack"];
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
1
tests/ui-toml/blacklisted_names_append/clippy.toml
Normal file
1
tests/ui-toml/blacklisted_names_append/clippy.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
blacklisted-names = ["ducks", ".."]
|
||||
10
tests/ui-toml/blacklisted_names_replace/blacklisted_names.rs
Normal file
10
tests/ui-toml/blacklisted_names_replace/blacklisted_names.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#[warn(clippy::blacklisted_name)]
|
||||
|
||||
fn main() {
|
||||
// `foo` is part of the default configuration
|
||||
let foo = "bar";
|
||||
// `ducks` was unrightfully blacklisted
|
||||
let ducks = ["quack", "quack"];
|
||||
// `fox` is okay
|
||||
let fox = ["what", "does", "the", "fox", "say", "?"];
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
error: use of a blacklisted/placeholder name `ducks`
|
||||
--> $DIR/blacklisted_names.rs:7:9
|
||||
|
|
||||
LL | let ducks = ["quack", "quack"];
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `-D clippy::blacklisted-name` implied by `-D warnings`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
1
tests/ui-toml/blacklisted_names_replace/clippy.toml
Normal file
1
tests/ui-toml/blacklisted_names_replace/clippy.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
blacklisted-names = ["ducks"]
|
||||
|
|
@ -1,4 +1 @@
|
|||
// error-pattern: error reading Clippy's configuration file: found deprecated field
|
||||
// `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead.
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
1
tests/ui-toml/doc_valid_idents_append/clippy.toml
Normal file
1
tests/ui-toml/doc_valid_idents_append/clippy.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
doc-valid-idents = ["ClipPy", ".."]
|
||||
12
tests/ui-toml/doc_valid_idents_append/doc_markdown.rs
Normal file
12
tests/ui-toml/doc_valid_idents_append/doc_markdown.rs
Normal 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() {}
|
||||
14
tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr
Normal file
14
tests/ui-toml/doc_valid_idents_append/doc_markdown.stderr
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
error: item in documentation is missing backticks
|
||||
--> $DIR/doc_markdown.rs:9:5
|
||||
|
|
||||
LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted.
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::doc-markdown` implied by `-D warnings`
|
||||
help: try
|
||||
|
|
||||
LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
1
tests/ui-toml/doc_valid_idents_replace/clippy.toml
Normal file
1
tests/ui-toml/doc_valid_idents_replace/clippy.toml
Normal file
|
|
@ -0,0 +1 @@
|
|||
doc-valid-idents = ["ClipPy"]
|
||||
12
tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs
Normal file
12
tests/ui-toml/doc_valid_idents_replace/doc_markdown.rs
Normal 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() {}
|
||||
36
tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr
Normal file
36
tests/ui-toml/doc_valid_idents_replace/doc_markdown.stderr
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
error: item in documentation is missing backticks
|
||||
--> $DIR/doc_markdown.rs:6:5
|
||||
|
|
||||
LL | /// OAuth and LaTeX are inside Clippy's default list.
|
||||
| ^^^^^
|
||||
|
|
||||
= note: `-D clippy::doc-markdown` implied by `-D warnings`
|
||||
help: try
|
||||
|
|
||||
LL | /// `OAuth` and LaTeX are inside Clippy's default list.
|
||||
| ~~~~~~~
|
||||
|
||||
error: item in documentation is missing backticks
|
||||
--> $DIR/doc_markdown.rs:6:15
|
||||
|
|
||||
LL | /// OAuth and LaTeX are inside Clippy's default list.
|
||||
| ^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | /// OAuth and `LaTeX` are inside Clippy's default list.
|
||||
| ~~~~~~~
|
||||
|
||||
error: item in documentation is missing backticks
|
||||
--> $DIR/doc_markdown.rs:9:5
|
||||
|
|
||||
LL | /// TestItemThingyOfCoolness might sound cool but is not on the list and should be linted.
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: try
|
||||
|
|
||||
LL | /// `TestItemThingyOfCoolness` might sound cool but is not on the list and should be linted.
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
@ -1,3 +1 @@
|
|||
// error-pattern: should give absolutely no error
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,3 +1 @@
|
|||
// error-pattern: error reading Clippy's configuration file: unknown key `foobar`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#![feature(stmt_expr_attributes)]
|
||||
#![warn(clippy::almost_complete_letter_range)]
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
#![allow(clippy::needless_parens_on_range_literals)]
|
||||
|
||||
macro_rules! a {
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#![feature(stmt_expr_attributes)]
|
||||
#![warn(clippy::almost_complete_letter_range)]
|
||||
#![allow(ellipsis_inclusive_range_patterns)]
|
||||
#![allow(clippy::needless_parens_on_range_literals)]
|
||||
|
||||
macro_rules! a {
|
||||
() => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:19:17
|
||||
--> $DIR/almost_complete_letter_range.rs:20:17
|
||||
|
|
||||
LL | let _ = ('a') ..'z';
|
||||
| ^^^^^^--^^^
|
||||
|
|
@ -9,7 +9,7 @@ LL | let _ = ('a') ..'z';
|
|||
= note: `-D clippy::almost-complete-letter-range` implied by `-D warnings`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:20:17
|
||||
--> $DIR/almost_complete_letter_range.rs:21:17
|
||||
|
|
||||
LL | let _ = 'A' .. ('Z');
|
||||
| ^^^^--^^^^^^
|
||||
|
|
@ -17,7 +17,7 @@ LL | let _ = 'A' .. ('Z');
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:26:13
|
||||
--> $DIR/almost_complete_letter_range.rs:27:13
|
||||
|
|
||||
LL | let _ = (b'a')..(b'z');
|
||||
| ^^^^^^--^^^^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL | let _ = (b'a')..(b'z');
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:27:13
|
||||
--> $DIR/almost_complete_letter_range.rs:28:13
|
||||
|
|
||||
LL | let _ = b'A'..b'Z';
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -33,7 +33,7 @@ LL | let _ = b'A'..b'Z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:32:13
|
||||
--> $DIR/almost_complete_letter_range.rs:33:13
|
||||
|
|
||||
LL | let _ = a!()..'z';
|
||||
| ^^^^--^^^
|
||||
|
|
@ -41,7 +41,7 @@ LL | let _ = a!()..'z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:35:9
|
||||
--> $DIR/almost_complete_letter_range.rs:36:9
|
||||
|
|
||||
LL | b'a'..b'z' if true => 1,
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -49,7 +49,7 @@ LL | b'a'..b'z' if true => 1,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:36:9
|
||||
--> $DIR/almost_complete_letter_range.rs:37:9
|
||||
|
|
||||
LL | b'A'..b'Z' if true => 2,
|
||||
| ^^^^--^^^^
|
||||
|
|
@ -57,7 +57,7 @@ LL | b'A'..b'Z' if true => 2,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:43:9
|
||||
--> $DIR/almost_complete_letter_range.rs:44:9
|
||||
|
|
||||
LL | 'a'..'z' if true => 1,
|
||||
| ^^^--^^^
|
||||
|
|
@ -65,7 +65,7 @@ LL | 'a'..'z' if true => 1,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:44:9
|
||||
--> $DIR/almost_complete_letter_range.rs:45:9
|
||||
|
|
||||
LL | 'A'..'Z' if true => 2,
|
||||
| ^^^--^^^
|
||||
|
|
@ -73,7 +73,7 @@ LL | 'A'..'Z' if true => 2,
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:54:9
|
||||
--> $DIR/almost_complete_letter_range.rs:55:9
|
||||
|
|
||||
LL | 'a'..'z' => 1,
|
||||
| ^^^--^^^
|
||||
|
|
@ -81,7 +81,7 @@ LL | 'a'..'z' => 1,
|
|||
| help: use an inclusive range: `...`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:61:13
|
||||
--> $DIR/almost_complete_letter_range.rs:62:13
|
||||
|
|
||||
LL | let _ = 'a'..'z';
|
||||
| ^^^--^^^
|
||||
|
|
@ -89,7 +89,7 @@ LL | let _ = 'a'..'z';
|
|||
| help: use an inclusive range: `..=`
|
||||
|
||||
error: almost complete ascii letter range
|
||||
--> $DIR/almost_complete_letter_range.rs:63:9
|
||||
--> $DIR/almost_complete_letter_range.rs:64:9
|
||||
|
|
||||
LL | 'a'..'z' => 1,
|
||||
| ^^^--^^^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
#![feature(async_closure)]
|
||||
#![warn(clippy::async_yields_async)]
|
||||
|
||||
|
|
@ -65,3 +65,14 @@ fn main() {
|
|||
let _n = async || custom_future_type_ctor();
|
||||
let _o = async || f();
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[allow(dead_code)]
|
||||
fn check_expect_suppression() {
|
||||
#[expect(clippy::async_yields_async)]
|
||||
let _j = async || {
|
||||
async {
|
||||
3
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
#![feature(async_closure)]
|
||||
#![warn(clippy::async_yields_async)]
|
||||
|
||||
|
|
@ -65,3 +65,14 @@ fn main() {
|
|||
let _n = async || custom_future_type_ctor();
|
||||
let _o = async || f();
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[allow(dead_code)]
|
||||
fn check_expect_suppression() {
|
||||
#[expect(clippy::async_yields_async)]
|
||||
let _j = async || {
|
||||
async {
|
||||
3
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,4 +25,17 @@ impl FooBar {
|
|||
fn baz(&mut self) {}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn foo(x: u32, y: u32) -> u32 {
|
||||
x / y
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = (1, 2);
|
||||
let _ = if true {
|
||||
let (x, y) = x;
|
||||
foo(x, y)
|
||||
} else {
|
||||
let (y, x) = x;
|
||||
foo(x, y)
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ note: the lint level is defined here
|
|||
|
|
||||
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: The end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving the end statements out like this
|
||||
= note: the end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + let result = false;
|
||||
|
|
@ -28,7 +28,7 @@ LL | / println!("Same end of block");
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + println!("Same end of block");
|
||||
|
|
@ -44,7 +44,7 @@ LL | | );
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + println!(
|
||||
|
|
@ -60,7 +60,7 @@ LL | / println!("Hello World");
|
|||
LL | | }
|
||||
| |_________^
|
||||
|
|
||||
help: consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + println!("Hello World");
|
||||
|
|
@ -75,8 +75,8 @@ LL | | // I'm expecting a note about this
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= warning: Some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving the end statements out like this
|
||||
= warning: some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + let later_used_value = "A string value";
|
||||
|
|
@ -91,8 +91,8 @@ LL | | println!("This is the new simple_example: {}", simple_examples);
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= warning: Some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving the end statements out like this
|
||||
= warning: some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + let simple_examples = "I now identify as a &str :)";
|
||||
|
|
@ -106,8 +106,8 @@ LL | / x << 2
|
|||
LL | | };
|
||||
| |_____^
|
||||
|
|
||||
= note: The end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving the end statements out like this
|
||||
= note: the end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL ~ x << 2;
|
||||
|
|
@ -120,8 +120,8 @@ LL | / x * 4
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: The end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving the end statements out like this
|
||||
= note: the end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + x * 4
|
||||
|
|
@ -133,7 +133,7 @@ error: all if blocks contain the same code at the end
|
|||
LL | if x == 17 { b = 1; a = 0x99; } else { a = 0x99; }
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
help: consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ if x == 17 { b = 1; a = 0x99; } else { }
|
||||
LL + a = 0x99;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ note: the lint level is defined here
|
|||
|
|
||||
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
help: consider moving the start statements out like this
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ println!("Hello World!");
|
||||
LL + if true {
|
||||
|
|
@ -25,8 +25,8 @@ LL | | println!("The value y was set to: `{}`", y);
|
|||
LL | | let _z = y;
|
||||
| |___________________^
|
||||
|
|
||||
= warning: Some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving the start statements out like this
|
||||
= warning: some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let y = 9;
|
||||
LL + println!("The value y was set to: `{}`", y);
|
||||
|
|
@ -41,7 +41,7 @@ LL | / let _ = if x == 7 {
|
|||
LL | | let y = 16;
|
||||
| |___________________^
|
||||
|
|
||||
help: consider moving the start statements out like this
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let y = 16;
|
||||
LL + let _ = if x == 7 {
|
||||
|
|
@ -55,8 +55,8 @@ LL | | let used_value_name = "Different type";
|
|||
LL | | println!("Str: {}", used_value_name);
|
||||
| |_____________________________________________^
|
||||
|
|
||||
= warning: Some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving the start statements out like this
|
||||
= warning: some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let used_value_name = "Different type";
|
||||
LL + println!("Str: {}", used_value_name);
|
||||
|
|
@ -71,8 +71,8 @@ LL | | let can_be_overridden = "Move me";
|
|||
LL | | println!("I'm also moveable");
|
||||
| |______________________________________^
|
||||
|
|
||||
= warning: Some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving the start statements out like this
|
||||
= warning: some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let can_be_overridden = "Move me";
|
||||
LL + println!("I'm also moveable");
|
||||
|
|
@ -87,7 +87,7 @@ LL | | println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint
|
|||
LL | | println!("Because `IF_SAME_THEN_ELSE` is allowed here");
|
||||
| |________________________________________________________________^
|
||||
|
|
||||
help: consider moving the start statements out like this
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint.");
|
||||
LL + println!("Because `IF_SAME_THEN_ELSE` is allowed here");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
error: all if blocks contain the same code at the start and the end. Here at the start
|
||||
error: all if blocks contain the same code at both the start and the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:16:5
|
||||
|
|
||||
LL | / if x == 7 {
|
||||
|
|
@ -12,26 +12,26 @@ note: the lint level is defined here
|
|||
|
|
||||
LL | #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: and here at the end
|
||||
note: this code is shared at the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:28:5
|
||||
|
|
||||
LL | / let _u = 9;
|
||||
LL | | }
|
||||
| |_____^
|
||||
help: consider moving the start statements out like this
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let t = 7;
|
||||
LL + let _overlap_start = t * 2;
|
||||
LL + let _overlap_end = 2 * t;
|
||||
LL + if x == 7 {
|
||||
|
|
||||
help: and consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + let _u = 9;
|
||||
|
|
||||
|
||||
error: all if blocks contain the same code at the start and the end. Here at the start
|
||||
error: all if blocks contain the same code at both the start and the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:32:5
|
||||
|
|
||||
LL | / if x == 99 {
|
||||
|
|
@ -40,29 +40,29 @@ LL | | let _overlap_start = r;
|
|||
LL | | let _overlap_middle = r * r;
|
||||
| |____________________________________^
|
||||
|
|
||||
note: and here at the end
|
||||
note: this code is shared at the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:43:5
|
||||
|
|
||||
LL | / let _overlap_end = r * r * r;
|
||||
LL | | let z = "end";
|
||||
LL | | }
|
||||
| |_____^
|
||||
= warning: Some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving the start statements out like this
|
||||
= warning: some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let r = 7;
|
||||
LL + let _overlap_start = r;
|
||||
LL + let _overlap_middle = r * r;
|
||||
LL + if x == 99 {
|
||||
|
|
||||
help: and consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + let _overlap_end = r * r * r;
|
||||
LL + let z = "end";
|
||||
|
|
||||
|
||||
error: all if blocks contain the same code at the start and the end. Here at the start
|
||||
error: all if blocks contain the same code at both the start and the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:61:5
|
||||
|
|
||||
LL | / if (x > 7 && y < 13) || (x + y) % 2 == 1 {
|
||||
|
|
@ -71,7 +71,7 @@ LL | | let b = 0xffff00ff;
|
|||
LL | | let e_id = gen_id(a, b);
|
||||
| |________________________________^
|
||||
|
|
||||
note: and here at the end
|
||||
note: this code is shared at the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:81:5
|
||||
|
|
||||
LL | / let pack = DataPack {
|
||||
|
|
@ -82,15 +82,15 @@ LL | | };
|
|||
LL | | process_data(pack);
|
||||
LL | | }
|
||||
| |_____^
|
||||
= warning: Some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving the start statements out like this
|
||||
= warning: some moved values might need to be renamed to avoid wrong references
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let a = 0xcafe;
|
||||
LL + let b = 0xffff00ff;
|
||||
LL + let e_id = gen_id(a, b);
|
||||
LL + if (x > 7 && y < 13) || (x + y) % 2 == 1 {
|
||||
|
|
||||
help: and consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + let pack = DataPack {
|
||||
|
|
@ -100,51 +100,51 @@ LL + some_data: vec![0x12, 0x34, 0x56, 0x78, 0x90],
|
|||
LL + };
|
||||
...
|
||||
|
||||
error: all if blocks contain the same code at the start and the end. Here at the start
|
||||
error: all if blocks contain the same code at both the start and the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:94:5
|
||||
|
|
||||
LL | / let _ = if x == 7 {
|
||||
LL | | let _ = 19;
|
||||
| |___________________^
|
||||
|
|
||||
note: and here at the end
|
||||
note: this code is shared at the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:103:5
|
||||
|
|
||||
LL | / x << 2
|
||||
LL | | };
|
||||
| |_____^
|
||||
= note: The end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving the start statements out like this
|
||||
= note: the end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let _ = 19;
|
||||
LL + let _ = if x == 7 {
|
||||
|
|
||||
help: and consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL ~ x << 2;
|
||||
|
|
||||
|
||||
error: all if blocks contain the same code at the start and the end. Here at the start
|
||||
error: all if blocks contain the same code at both the start and the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:106:5
|
||||
|
|
||||
LL | / if x == 9 {
|
||||
LL | | let _ = 17;
|
||||
| |___________________^
|
||||
|
|
||||
note: and here at the end
|
||||
note: this code is shared at the end
|
||||
--> $DIR/shared_at_top_and_bottom.rs:115:5
|
||||
|
|
||||
LL | / x * 4
|
||||
LL | | }
|
||||
| |_____^
|
||||
= note: The end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving the start statements out like this
|
||||
= note: the end suggestion probably needs some adjustments to use the expression result correctly
|
||||
help: consider moving these statements before the if
|
||||
|
|
||||
LL ~ let _ = 17;
|
||||
LL + if x == 9 {
|
||||
|
|
||||
help: and consider moving the end statements out like this
|
||||
help: consider moving these statements after the if
|
||||
|
|
||||
LL ~ }
|
||||
LL + x * 4
|
||||
|
|
|
|||
|
|
@ -71,4 +71,9 @@ pub fn i8_to_u8(value: i8) {
|
|||
let _ = value >= 0;
|
||||
}
|
||||
|
||||
// Do not lint
|
||||
pub const fn issue_8898(i: u32) -> bool {
|
||||
i <= i32::MAX as u32
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -71,4 +71,9 @@ pub fn i8_to_u8(value: i8) {
|
|||
let _ = value >= 0;
|
||||
}
|
||||
|
||||
// Do not lint
|
||||
pub const fn issue_8898(i: u32) -> bool {
|
||||
i <= i32::MAX as u32
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
#![warn(clippy::default_numeric_fallback)]
|
||||
#![allow(
|
||||
unused,
|
||||
|
|
@ -173,4 +174,9 @@ mod in_macro {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_expect_suppression() {
|
||||
#[expect(clippy::default_numeric_fallback)]
|
||||
let x = 21;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// run-rustfix
|
||||
// aux-build:macro_rules.rs
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
#![warn(clippy::default_numeric_fallback)]
|
||||
#![allow(
|
||||
unused,
|
||||
|
|
@ -173,4 +174,9 @@ mod in_macro {
|
|||
}
|
||||
}
|
||||
|
||||
fn check_expect_suppression() {
|
||||
#[expect(clippy::default_numeric_fallback)]
|
||||
let x = 21;
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:20:17
|
||||
--> $DIR/default_numeric_fallback_i32.rs:21:17
|
||||
|
|
||||
LL | let x = 22;
|
||||
| ^^ help: consider adding suffix: `22_i32`
|
||||
|
|
@ -7,145 +7,145 @@ LL | let x = 22;
|
|||
= note: `-D clippy::default-numeric-fallback` implied by `-D warnings`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:21:18
|
||||
--> $DIR/default_numeric_fallback_i32.rs:22:18
|
||||
|
|
||||
LL | let x = [1, 2, 3];
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:21:21
|
||||
--> $DIR/default_numeric_fallback_i32.rs:22:21
|
||||
|
|
||||
LL | let x = [1, 2, 3];
|
||||
| ^ help: consider adding suffix: `2_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:21:24
|
||||
--> $DIR/default_numeric_fallback_i32.rs:22:24
|
||||
|
|
||||
LL | let x = [1, 2, 3];
|
||||
| ^ help: consider adding suffix: `3_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:22:28
|
||||
--> $DIR/default_numeric_fallback_i32.rs:23:28
|
||||
|
|
||||
LL | let x = if true { (1, 2) } else { (3, 4) };
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:22:31
|
||||
--> $DIR/default_numeric_fallback_i32.rs:23:31
|
||||
|
|
||||
LL | let x = if true { (1, 2) } else { (3, 4) };
|
||||
| ^ help: consider adding suffix: `2_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:22:44
|
||||
--> $DIR/default_numeric_fallback_i32.rs:23:44
|
||||
|
|
||||
LL | let x = if true { (1, 2) } else { (3, 4) };
|
||||
| ^ help: consider adding suffix: `3_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:22:47
|
||||
--> $DIR/default_numeric_fallback_i32.rs:23:47
|
||||
|
|
||||
LL | let x = if true { (1, 2) } else { (3, 4) };
|
||||
| ^ help: consider adding suffix: `4_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:23:23
|
||||
--> $DIR/default_numeric_fallback_i32.rs:24:23
|
||||
|
|
||||
LL | let x = match 1 {
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:24:13
|
||||
--> $DIR/default_numeric_fallback_i32.rs:25:13
|
||||
|
|
||||
LL | 1 => 1,
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:24:18
|
||||
--> $DIR/default_numeric_fallback_i32.rs:25:18
|
||||
|
|
||||
LL | 1 => 1,
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:25:18
|
||||
--> $DIR/default_numeric_fallback_i32.rs:26:18
|
||||
|
|
||||
LL | _ => 2,
|
||||
| ^ help: consider adding suffix: `2_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:42:21
|
||||
--> $DIR/default_numeric_fallback_i32.rs:43:21
|
||||
|
|
||||
LL | let y = 1;
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:50:21
|
||||
--> $DIR/default_numeric_fallback_i32.rs:51:21
|
||||
|
|
||||
LL | let y = 1;
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:56:21
|
||||
--> $DIR/default_numeric_fallback_i32.rs:57:21
|
||||
|
|
||||
LL | let y = 1;
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:68:9
|
||||
--> $DIR/default_numeric_fallback_i32.rs:69:9
|
||||
|
|
||||
LL | 1
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:74:27
|
||||
--> $DIR/default_numeric_fallback_i32.rs:75:27
|
||||
|
|
||||
LL | let f = || -> _ { 1 };
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:78:29
|
||||
--> $DIR/default_numeric_fallback_i32.rs:79:29
|
||||
|
|
||||
LL | let f = || -> i32 { 1 };
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:92:21
|
||||
--> $DIR/default_numeric_fallback_i32.rs:93:21
|
||||
|
|
||||
LL | generic_arg(1);
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:95:32
|
||||
--> $DIR/default_numeric_fallback_i32.rs:96:32
|
||||
|
|
||||
LL | let x: _ = generic_arg(1);
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:113:28
|
||||
--> $DIR/default_numeric_fallback_i32.rs:114:28
|
||||
|
|
||||
LL | GenericStruct { x: 1 };
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:116:36
|
||||
--> $DIR/default_numeric_fallback_i32.rs:117:36
|
||||
|
|
||||
LL | let _ = GenericStruct { x: 1 };
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:134:24
|
||||
--> $DIR/default_numeric_fallback_i32.rs:135:24
|
||||
|
|
||||
LL | GenericEnum::X(1);
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:154:23
|
||||
--> $DIR/default_numeric_fallback_i32.rs:155:23
|
||||
|
|
||||
LL | s.generic_arg(1);
|
||||
| ^ help: consider adding suffix: `1_i32`
|
||||
|
||||
error: default numeric fallback might occur
|
||||
--> $DIR/default_numeric_fallback_i32.rs:161:21
|
||||
--> $DIR/default_numeric_fallback_i32.rs:162:21
|
||||
|
|
||||
LL | let x = 22;
|
||||
| ^^ help: consider adding suffix: `22_i32`
|
||||
|
|
|
|||
|
|
@ -4,28 +4,28 @@
|
|||
#![warn(clippy::derive_partial_eq_without_eq)]
|
||||
|
||||
// Don't warn on structs that aren't PartialEq
|
||||
struct NotPartialEq {
|
||||
pub struct NotPartialEq {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
||||
// Eq can be derived but is missing
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct MissingEq {
|
||||
pub struct MissingEq {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
||||
// Eq is derived
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct NotMissingEq {
|
||||
pub struct NotMissingEq {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
||||
// Eq is manually implemented
|
||||
#[derive(PartialEq)]
|
||||
struct ManualEqImpl {
|
||||
pub struct ManualEqImpl {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
|
@ -34,13 +34,13 @@ impl Eq for ManualEqImpl {}
|
|||
|
||||
// Cannot be Eq because f32 isn't Eq
|
||||
#[derive(PartialEq)]
|
||||
struct CannotBeEq {
|
||||
pub struct CannotBeEq {
|
||||
foo: u32,
|
||||
bar: f32,
|
||||
}
|
||||
|
||||
// Don't warn if PartialEq is manually implemented
|
||||
struct ManualPartialEqImpl {
|
||||
pub struct ManualPartialEqImpl {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
|
@ -52,53 +52,75 @@ impl PartialEq for ManualPartialEqImpl {
|
|||
}
|
||||
|
||||
// Generic fields should be properly checked for Eq-ness
|
||||
#[derive(PartialEq)]
|
||||
struct GenericNotEq<T: Eq, U: PartialEq> {
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct GenericNotEq<T: Eq, U: PartialEq> {
|
||||
foo: T,
|
||||
bar: U,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct GenericEq<T: Eq, U: Eq> {
|
||||
pub struct GenericEq<T: Eq, U: Eq> {
|
||||
foo: T,
|
||||
bar: U,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct TupleStruct(u32);
|
||||
pub struct TupleStruct(u32);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct GenericTupleStruct<T: Eq>(T);
|
||||
pub struct GenericTupleStruct<T: Eq>(T);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct TupleStructNotEq(f32);
|
||||
pub struct TupleStructNotEq(f32);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
enum Enum {
|
||||
pub enum Enum {
|
||||
Foo(u32),
|
||||
Bar { a: String, b: () },
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
enum GenericEnum<T: Eq, U: Eq, V: Eq> {
|
||||
pub enum GenericEnum<T: Eq, U: Eq, V: Eq> {
|
||||
Foo(T),
|
||||
Bar { a: U, b: V },
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum EnumNotEq {
|
||||
pub enum EnumNotEq {
|
||||
Foo(u32),
|
||||
Bar { a: String, b: f32 },
|
||||
}
|
||||
|
||||
// Ensure that rustfix works properly when `PartialEq` has other derives on either side
|
||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
||||
struct RustFixWithOtherDerives;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Generic<T>(T);
|
||||
pub struct RustFixWithOtherDerives;
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct GenericPhantom<T>(core::marker::PhantomData<T>);
|
||||
pub struct Generic<T>(T);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct GenericPhantom<T>(core::marker::PhantomData<T>);
|
||||
|
||||
mod _hidden {
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct Reexported;
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub struct InPubFn;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub(crate) struct PubCrate;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub(super) struct PubSuper;
|
||||
}
|
||||
|
||||
pub use _hidden::Reexported;
|
||||
pub fn _from_mod() -> _hidden::InPubFn {
|
||||
_hidden::InPubFn
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct InternalTy;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -4,28 +4,28 @@
|
|||
#![warn(clippy::derive_partial_eq_without_eq)]
|
||||
|
||||
// Don't warn on structs that aren't PartialEq
|
||||
struct NotPartialEq {
|
||||
pub struct NotPartialEq {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
||||
// Eq can be derived but is missing
|
||||
#[derive(Debug, PartialEq)]
|
||||
struct MissingEq {
|
||||
pub struct MissingEq {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
||||
// Eq is derived
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct NotMissingEq {
|
||||
pub struct NotMissingEq {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
||||
// Eq is manually implemented
|
||||
#[derive(PartialEq)]
|
||||
struct ManualEqImpl {
|
||||
pub struct ManualEqImpl {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
|
@ -34,13 +34,13 @@ impl Eq for ManualEqImpl {}
|
|||
|
||||
// Cannot be Eq because f32 isn't Eq
|
||||
#[derive(PartialEq)]
|
||||
struct CannotBeEq {
|
||||
pub struct CannotBeEq {
|
||||
foo: u32,
|
||||
bar: f32,
|
||||
}
|
||||
|
||||
// Don't warn if PartialEq is manually implemented
|
||||
struct ManualPartialEqImpl {
|
||||
pub struct ManualPartialEqImpl {
|
||||
foo: u32,
|
||||
bar: String,
|
||||
}
|
||||
|
|
@ -53,52 +53,74 @@ impl PartialEq for ManualPartialEqImpl {
|
|||
|
||||
// Generic fields should be properly checked for Eq-ness
|
||||
#[derive(PartialEq)]
|
||||
struct GenericNotEq<T: Eq, U: PartialEq> {
|
||||
pub struct GenericNotEq<T: Eq, U: PartialEq> {
|
||||
foo: T,
|
||||
bar: U,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct GenericEq<T: Eq, U: Eq> {
|
||||
pub struct GenericEq<T: Eq, U: Eq> {
|
||||
foo: T,
|
||||
bar: U,
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct TupleStruct(u32);
|
||||
pub struct TupleStruct(u32);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct GenericTupleStruct<T: Eq>(T);
|
||||
pub struct GenericTupleStruct<T: Eq>(T);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct TupleStructNotEq(f32);
|
||||
pub struct TupleStructNotEq(f32);
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum Enum {
|
||||
pub enum Enum {
|
||||
Foo(u32),
|
||||
Bar { a: String, b: () },
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum GenericEnum<T: Eq, U: Eq, V: Eq> {
|
||||
pub enum GenericEnum<T: Eq, U: Eq, V: Eq> {
|
||||
Foo(T),
|
||||
Bar { a: U, b: V },
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
enum EnumNotEq {
|
||||
pub enum EnumNotEq {
|
||||
Foo(u32),
|
||||
Bar { a: String, b: f32 },
|
||||
}
|
||||
|
||||
// Ensure that rustfix works properly when `PartialEq` has other derives on either side
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
struct RustFixWithOtherDerives;
|
||||
pub struct RustFixWithOtherDerives;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct Generic<T>(T);
|
||||
pub struct Generic<T>(T);
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
struct GenericPhantom<T>(core::marker::PhantomData<T>);
|
||||
pub struct GenericPhantom<T>(core::marker::PhantomData<T>);
|
||||
|
||||
mod _hidden {
|
||||
#[derive(PartialEq)]
|
||||
pub struct Reexported;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub struct InPubFn;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub(crate) struct PubCrate;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub(super) struct PubSuper;
|
||||
}
|
||||
|
||||
pub use _hidden::Reexported;
|
||||
pub fn _from_mod() -> _hidden::InPubFn {
|
||||
_hidden::InPubFn
|
||||
}
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct InternalTy;
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,12 @@ LL | #[derive(Debug, PartialEq)]
|
|||
|
|
||||
= note: `-D clippy::derive-partial-eq-without-eq` implied by `-D warnings`
|
||||
|
||||
error: you are deriving `PartialEq` and can implement `Eq`
|
||||
--> $DIR/derive_partial_eq_without_eq.rs:55:10
|
||||
|
|
||||
LL | #[derive(PartialEq)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: you are deriving `PartialEq` and can implement `Eq`
|
||||
--> $DIR/derive_partial_eq_without_eq.rs:61:10
|
||||
|
|
||||
|
|
@ -42,5 +48,23 @@ error: you are deriving `PartialEq` and can implement `Eq`
|
|||
LL | #[derive(Debug, PartialEq, Clone)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error: you are deriving `PartialEq` and can implement `Eq`
|
||||
--> $DIR/derive_partial_eq_without_eq.rs:98:10
|
||||
|
|
||||
LL | #[derive(PartialEq)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: you are deriving `PartialEq` and can implement `Eq`
|
||||
--> $DIR/derive_partial_eq_without_eq.rs:105:14
|
||||
|
|
||||
LL | #[derive(PartialEq)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: you are deriving `PartialEq` and can implement `Eq`
|
||||
--> $DIR/derive_partial_eq_without_eq.rs:108:14
|
||||
|
|
||||
LL | #[derive(PartialEq)]
|
||||
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -291,3 +291,15 @@ fn coerced_closure() {
|
|||
fn slice_fn(_: impl FnOnce() -> &'static [u8]) {}
|
||||
slice_fn(|| arr());
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/7861
|
||||
fn box_dyn() {
|
||||
fn f(_: impl Fn(usize) -> Box<dyn std::any::Any>) {}
|
||||
f(|x| Box::new(x));
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/5939
|
||||
fn not_general_enough() {
|
||||
fn f(_: impl FnMut(&Path) -> std::io::Result<()>) {}
|
||||
f(|path| std::fs::remove_file(path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,3 +291,15 @@ fn coerced_closure() {
|
|||
fn slice_fn(_: impl FnOnce() -> &'static [u8]) {}
|
||||
slice_fn(|| arr());
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/7861
|
||||
fn box_dyn() {
|
||||
fn f(_: impl Fn(usize) -> Box<dyn std::any::Any>) {}
|
||||
f(|x| Box::new(x));
|
||||
}
|
||||
|
||||
// https://github.com/rust-lang/rust-clippy/issues/5939
|
||||
fn not_general_enough() {
|
||||
fn f(_: impl FnMut(&Path) -> std::io::Result<()>) {}
|
||||
f(|path| std::fs::remove_file(path));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
fn for_loops_over_fallibles() {
|
||||
let option = Some(1);
|
||||
let result = option.ok_or("x not found");
|
||||
let mut result = option.ok_or("x not found");
|
||||
let v = vec![0, 1, 2];
|
||||
|
||||
// check over an `Option`
|
||||
|
|
@ -10,11 +10,26 @@ fn for_loops_over_fallibles() {
|
|||
println!("{}", x);
|
||||
}
|
||||
|
||||
// check over an `Option`
|
||||
for x in option.iter() {
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
// check over a `Result`
|
||||
for x in result {
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
// check over a `Result`
|
||||
for x in result.iter_mut() {
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
// check over a `Result`
|
||||
for x in result.into_iter() {
|
||||
println!("{}", x);
|
||||
}
|
||||
|
||||
for x in option.ok_or("x not found") {
|
||||
println!("{}", x);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,16 +7,40 @@ LL | for x in option {
|
|||
= note: `-D clippy::for-loops-over-fallibles` implied by `-D warnings`
|
||||
= help: consider replacing `for x in option` with `if let Some(x) = option`
|
||||
|
||||
error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement
|
||||
error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement
|
||||
--> $DIR/for_loops_over_fallibles.rs:14:14
|
||||
|
|
||||
LL | for x in option.iter() {
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider replacing `for x in option.iter()` with `if let Some(x) = option`
|
||||
|
||||
error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement
|
||||
--> $DIR/for_loops_over_fallibles.rs:19:14
|
||||
|
|
||||
LL | for x in result {
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider replacing `for x in result` with `if let Ok(x) = result`
|
||||
|
||||
error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement
|
||||
--> $DIR/for_loops_over_fallibles.rs:24:14
|
||||
|
|
||||
LL | for x in result.iter_mut() {
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider replacing `for x in result.iter_mut()` with `if let Ok(x) = result`
|
||||
|
||||
error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement
|
||||
--> $DIR/for_loops_over_fallibles.rs:29:14
|
||||
|
|
||||
LL | for x in result.into_iter() {
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider replacing `for x in result.into_iter()` with `if let Ok(x) = result`
|
||||
|
||||
error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement
|
||||
--> $DIR/for_loops_over_fallibles.rs:18:14
|
||||
--> $DIR/for_loops_over_fallibles.rs:33:14
|
||||
|
|
||||
LL | for x in option.ok_or("x not found") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -24,7 +48,7 @@ LL | for x in option.ok_or("x not found") {
|
|||
= help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")`
|
||||
|
||||
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
|
||||
--> $DIR/for_loops_over_fallibles.rs:24:14
|
||||
--> $DIR/for_loops_over_fallibles.rs:39:14
|
||||
|
|
||||
LL | for x in v.iter().next() {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
@ -32,7 +56,7 @@ LL | for x in v.iter().next() {
|
|||
= note: `#[deny(clippy::iter_next_loop)]` on by default
|
||||
|
||||
error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement
|
||||
--> $DIR/for_loops_over_fallibles.rs:29:14
|
||||
--> $DIR/for_loops_over_fallibles.rs:44:14
|
||||
|
|
||||
LL | for x in v.iter().next().and(Some(0)) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -40,7 +64,7 @@ LL | for x in v.iter().next().and(Some(0)) {
|
|||
= help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`
|
||||
|
||||
error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement
|
||||
--> $DIR/for_loops_over_fallibles.rs:33:14
|
||||
--> $DIR/for_loops_over_fallibles.rs:48:14
|
||||
|
|
||||
LL | for x in v.iter().next().ok_or("x not found") {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -48,7 +72,7 @@ LL | for x in v.iter().next().ok_or("x not found") {
|
|||
= help: consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")`
|
||||
|
||||
error: this loop never actually loops
|
||||
--> $DIR/for_loops_over_fallibles.rs:45:5
|
||||
--> $DIR/for_loops_over_fallibles.rs:60:5
|
||||
|
|
||||
LL | / while let Some(x) = option {
|
||||
LL | | println!("{}", x);
|
||||
|
|
@ -59,7 +83,7 @@ LL | | }
|
|||
= note: `#[deny(clippy::never_loop)]` on by default
|
||||
|
||||
error: this loop never actually loops
|
||||
--> $DIR/for_loops_over_fallibles.rs:51:5
|
||||
--> $DIR/for_loops_over_fallibles.rs:66:5
|
||||
|
|
||||
LL | / while let Ok(x) = result {
|
||||
LL | | println!("{}", x);
|
||||
|
|
@ -67,5 +91,5 @@ LL | | break;
|
|||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ fn main() {
|
|||
let _ = vec.iter().filter(|x| x == &"2").nth(2).cloned();
|
||||
|
||||
let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))]
|
||||
.iter().flatten().cloned();
|
||||
.iter()
|
||||
.flatten().cloned();
|
||||
|
||||
// Not implemented yet
|
||||
let _ = vec.iter().cloned().filter(|x| x.starts_with('2'));
|
||||
|
|
@ -43,6 +44,9 @@ fn main() {
|
|||
|
||||
// Should probably stay as it is.
|
||||
let _ = [0, 1, 2, 3, 4].iter().cloned().take(10);
|
||||
|
||||
// `&Range<_>` doesn't implement `IntoIterator`
|
||||
let _ = [0..1, 2..5].iter().cloned().flatten();
|
||||
}
|
||||
|
||||
// #8527
|
||||
|
|
|
|||
|
|
@ -45,6 +45,9 @@ fn main() {
|
|||
|
||||
// Should probably stay as it is.
|
||||
let _ = [0, 1, 2, 3, 4].iter().cloned().take(10);
|
||||
|
||||
// `&Range<_>` doesn't implement `IntoIterator`
|
||||
let _ = [0..1, 2..5].iter().cloned().flatten();
|
||||
}
|
||||
|
||||
// #8527
|
||||
|
|
|
|||
|
|
@ -1,44 +1,56 @@
|
|||
error: called `cloned().last()` on an `Iterator`. It may be more efficient to call `last().cloned()` instead
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:8:29
|
||||
|
|
||||
LL | let _: Option<String> = vec.iter().cloned().last();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec.iter().last().cloned()`
|
||||
| ^^^^^^^^^^----------------
|
||||
| |
|
||||
| help: try this: `.last().cloned()`
|
||||
|
|
||||
= note: `-D clippy::iter-overeager-cloned` implied by `-D warnings`
|
||||
|
||||
error: called `cloned().next()` on an `Iterator`. It may be more efficient to call `next().cloned()` instead
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:10:29
|
||||
|
|
||||
LL | let _: Option<String> = vec.iter().chain(vec.iter()).cloned().next();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec.iter().chain(vec.iter()).next().cloned()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
|
||||
| |
|
||||
| help: try this: `.next().cloned()`
|
||||
|
||||
error: called `cloned().count()` on an `Iterator`. It may be more efficient to call `count()` instead
|
||||
error: unneeded cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:12:20
|
||||
|
|
||||
LL | let _: usize = vec.iter().filter(|x| x == &"2").cloned().count();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec.iter().filter(|x| x == &"2").count()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------
|
||||
| |
|
||||
| help: try this: `.count()`
|
||||
|
|
||||
= note: `-D clippy::redundant-clone` implied by `-D warnings`
|
||||
|
||||
error: called `cloned().take(...)` on an `Iterator`. It may be more efficient to call `take(...).cloned()` instead
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:14:21
|
||||
|
|
||||
LL | let _: Vec<_> = vec.iter().cloned().take(2).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec.iter().take(2).cloned()`
|
||||
| ^^^^^^^^^^-----------------
|
||||
| |
|
||||
| help: try this: `.take(2).cloned()`
|
||||
|
||||
error: called `cloned().skip(...)` on an `Iterator`. It may be more efficient to call `skip(...).cloned()` instead
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:16:21
|
||||
|
|
||||
LL | let _: Vec<_> = vec.iter().cloned().skip(2).collect();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec.iter().skip(2).cloned()`
|
||||
| ^^^^^^^^^^-----------------
|
||||
| |
|
||||
| help: try this: `.skip(2).cloned()`
|
||||
|
||||
error: called `cloned().nth(...)` on an `Iterator`. It may be more efficient to call `nth(...).cloned()` instead
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:18:13
|
||||
|
|
||||
LL | let _ = vec.iter().filter(|x| x == &"2").cloned().nth(2);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec.iter().filter(|x| x == &"2").nth(2).cloned()`
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------
|
||||
| |
|
||||
| help: try this: `.nth(2).cloned()`
|
||||
|
||||
error: called `cloned().flatten()` on an `Iterator`. It may be more efficient to call `flatten().cloned()` instead
|
||||
error: unnecessarily eager cloning of iterator items
|
||||
--> $DIR/iter_overeager_cloned.rs:20:13
|
||||
|
|
||||
LL | let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))]
|
||||
|
|
@ -50,8 +62,8 @@ LL | | .flatten();
|
|||
|
|
||||
help: try this
|
||||
|
|
||||
LL ~ let _ = [Some(Some("str".to_string())), Some(Some("str".to_string()))]
|
||||
LL ~ .iter().flatten().cloned();
|
||||
LL ~ .iter()
|
||||
LL ~ .flatten().cloned();
|
||||
|
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
|
|
|||
|
|
@ -35,3 +35,53 @@ fn to_opt<T>(_: T) -> Option<T> {
|
|||
fn to_res<T>(_: T) -> Result<T, ()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
struct Issue8920<'a> {
|
||||
option_field: Option<String>,
|
||||
result_field: Result<String, ()>,
|
||||
ref_field: Option<&'a usize>,
|
||||
}
|
||||
|
||||
fn issue_8920() {
|
||||
let mut vec = vec![Issue8920 {
|
||||
option_field: Some(String::from("str")),
|
||||
result_field: Ok(String::from("str")),
|
||||
ref_field: Some(&1),
|
||||
}];
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter_map(|f| f.option_field.clone());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter_map(|f| f.ref_field.cloned());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter_map(|f| f.ref_field.copied());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter_map(|f| f.result_field.clone().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter_map(|f| f.result_field.as_ref().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter_map(|f| f.result_field.as_deref().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.filter_map(|f| f.result_field.as_mut().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.filter_map(|f| f.result_field.as_deref_mut().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter_map(|f| f.result_field.to_owned().ok());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,3 +35,62 @@ fn to_opt<T>(_: T) -> Option<T> {
|
|||
fn to_res<T>(_: T) -> Result<T, ()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
struct Issue8920<'a> {
|
||||
option_field: Option<String>,
|
||||
result_field: Result<String, ()>,
|
||||
ref_field: Option<&'a usize>,
|
||||
}
|
||||
|
||||
fn issue_8920() {
|
||||
let mut vec = vec![Issue8920 {
|
||||
option_field: Some(String::from("str")),
|
||||
result_field: Ok(String::from("str")),
|
||||
ref_field: Some(&1),
|
||||
}];
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter(|f| f.option_field.is_some())
|
||||
.map(|f| f.option_field.clone().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter(|f| f.ref_field.is_some())
|
||||
.map(|f| f.ref_field.cloned().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter(|f| f.ref_field.is_some())
|
||||
.map(|f| f.ref_field.copied().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.clone().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_ref().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_deref().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.filter(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_mut().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.filter(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_deref_mut().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.filter(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.to_owned().unwrap());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,77 @@ error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
|||
LL | let _ = (0..).filter(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `filter_map(|a| to_res(a).ok())`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:54:10
|
||||
|
|
||||
LL | .filter(|f| f.option_field.is_some())
|
||||
| __________^
|
||||
LL | | .map(|f| f.option_field.clone().unwrap());
|
||||
| |_________________________________________________^ help: try: `filter_map(|f| f.option_field.clone())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:59:10
|
||||
|
|
||||
LL | .filter(|f| f.ref_field.is_some())
|
||||
| __________^
|
||||
LL | | .map(|f| f.ref_field.cloned().unwrap());
|
||||
| |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.cloned())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:64:10
|
||||
|
|
||||
LL | .filter(|f| f.ref_field.is_some())
|
||||
| __________^
|
||||
LL | | .map(|f| f.ref_field.copied().unwrap());
|
||||
| |_______________________________________________^ help: try: `filter_map(|f| f.ref_field.copied())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:69:10
|
||||
|
|
||||
LL | .filter(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.clone().unwrap());
|
||||
| |_________________________________________________^ help: try: `filter_map(|f| f.result_field.clone().ok())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:74:10
|
||||
|
|
||||
LL | .filter(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_ref().unwrap());
|
||||
| |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_ref().ok())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:79:10
|
||||
|
|
||||
LL | .filter(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_deref().unwrap());
|
||||
| |____________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref().ok())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:84:10
|
||||
|
|
||||
LL | .filter(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_mut().unwrap());
|
||||
| |__________________________________________________^ help: try: `filter_map(|f| f.result_field.as_mut().ok())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:89:10
|
||||
|
|
||||
LL | .filter(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_deref_mut().unwrap());
|
||||
| |________________________________________________________^ help: try: `filter_map(|f| f.result_field.as_deref_mut().ok())`
|
||||
|
||||
error: `filter(..).map(..)` can be simplified as `filter_map(..)`
|
||||
--> $DIR/manual_filter_map.rs:94:10
|
||||
|
|
||||
LL | .filter(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.to_owned().unwrap());
|
||||
| |____________________________________________________^ help: try: `filter_map(|f| f.result_field.to_owned().ok())`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -35,3 +35,53 @@ fn to_opt<T>(_: T) -> Option<T> {
|
|||
fn to_res<T>(_: T) -> Result<T, ()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
struct Issue8920<'a> {
|
||||
option_field: Option<String>,
|
||||
result_field: Result<String, ()>,
|
||||
ref_field: Option<&'a usize>,
|
||||
}
|
||||
|
||||
fn issue_8920() {
|
||||
let mut vec = vec![Issue8920 {
|
||||
option_field: Some(String::from("str")),
|
||||
result_field: Ok(String::from("str")),
|
||||
ref_field: Some(&1),
|
||||
}];
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find_map(|f| f.option_field.clone());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find_map(|f| f.ref_field.cloned());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find_map(|f| f.ref_field.copied());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find_map(|f| f.result_field.clone().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find_map(|f| f.result_field.as_ref().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find_map(|f| f.result_field.as_deref().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.find_map(|f| f.result_field.as_mut().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.find_map(|f| f.result_field.as_deref_mut().ok());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find_map(|f| f.result_field.to_owned().ok());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,3 +35,62 @@ fn to_opt<T>(_: T) -> Option<T> {
|
|||
fn to_res<T>(_: T) -> Result<T, ()> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
struct Issue8920<'a> {
|
||||
option_field: Option<String>,
|
||||
result_field: Result<String, ()>,
|
||||
ref_field: Option<&'a usize>,
|
||||
}
|
||||
|
||||
fn issue_8920() {
|
||||
let mut vec = vec![Issue8920 {
|
||||
option_field: Some(String::from("str")),
|
||||
result_field: Ok(String::from("str")),
|
||||
ref_field: Some(&1),
|
||||
}];
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find(|f| f.option_field.is_some())
|
||||
.map(|f| f.option_field.clone().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find(|f| f.ref_field.is_some())
|
||||
.map(|f| f.ref_field.cloned().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find(|f| f.ref_field.is_some())
|
||||
.map(|f| f.ref_field.copied().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.clone().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_ref().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_deref().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.find(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_mut().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter_mut()
|
||||
.find(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.as_deref_mut().unwrap());
|
||||
|
||||
let _ = vec
|
||||
.iter()
|
||||
.find(|f| f.result_field.is_ok())
|
||||
.map(|f| f.result_field.to_owned().unwrap());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,5 +18,77 @@ error: `find(..).map(..)` can be simplified as `find_map(..)`
|
|||
LL | let _ = (0..).find(|&n| to_res(n).is_ok()).map(|a| to_res(a).unwrap_or(1));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `find_map(|a| to_res(a).ok())`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:54:10
|
||||
|
|
||||
LL | .find(|f| f.option_field.is_some())
|
||||
| __________^
|
||||
LL | | .map(|f| f.option_field.clone().unwrap());
|
||||
| |_________________________________________________^ help: try: `find_map(|f| f.option_field.clone())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:59:10
|
||||
|
|
||||
LL | .find(|f| f.ref_field.is_some())
|
||||
| __________^
|
||||
LL | | .map(|f| f.ref_field.cloned().unwrap());
|
||||
| |_______________________________________________^ help: try: `find_map(|f| f.ref_field.cloned())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:64:10
|
||||
|
|
||||
LL | .find(|f| f.ref_field.is_some())
|
||||
| __________^
|
||||
LL | | .map(|f| f.ref_field.copied().unwrap());
|
||||
| |_______________________________________________^ help: try: `find_map(|f| f.ref_field.copied())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:69:10
|
||||
|
|
||||
LL | .find(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.clone().unwrap());
|
||||
| |_________________________________________________^ help: try: `find_map(|f| f.result_field.clone().ok())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:74:10
|
||||
|
|
||||
LL | .find(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_ref().unwrap());
|
||||
| |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_ref().ok())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:79:10
|
||||
|
|
||||
LL | .find(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_deref().unwrap());
|
||||
| |____________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref().ok())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:84:10
|
||||
|
|
||||
LL | .find(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_mut().unwrap());
|
||||
| |__________________________________________________^ help: try: `find_map(|f| f.result_field.as_mut().ok())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:89:10
|
||||
|
|
||||
LL | .find(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.as_deref_mut().unwrap());
|
||||
| |________________________________________________________^ help: try: `find_map(|f| f.result_field.as_deref_mut().ok())`
|
||||
|
||||
error: `find(..).map(..)` can be simplified as `find_map(..)`
|
||||
--> $DIR/manual_find_map.rs:94:10
|
||||
|
|
||||
LL | .find(|f| f.result_field.is_ok())
|
||||
| __________^
|
||||
LL | | .map(|f| f.result_field.to_owned().unwrap());
|
||||
| |____________________________________________________^ help: try: `find_map(|f| f.result_field.to_owned().ok())`
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
clippy::unit_arg,
|
||||
clippy::match_ref_pats,
|
||||
clippy::redundant_pattern_matching,
|
||||
clippy::for_loops_over_fallibles,
|
||||
dead_code
|
||||
)]
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
clippy::unit_arg,
|
||||
clippy::match_ref_pats,
|
||||
clippy::redundant_pattern_matching,
|
||||
clippy::for_loops_over_fallibles,
|
||||
dead_code
|
||||
)]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:14:5
|
||||
--> $DIR/manual_map_option.rs:15:5
|
||||
|
|
||||
LL | / match Some(0) {
|
||||
LL | | Some(_) => Some(2),
|
||||
|
|
@ -10,7 +10,7 @@ LL | | };
|
|||
= note: `-D clippy::manual-map` implied by `-D warnings`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:19:5
|
||||
--> $DIR/manual_map_option.rs:20:5
|
||||
|
|
||||
LL | / match Some(0) {
|
||||
LL | | Some(x) => Some(x + 1),
|
||||
|
|
@ -19,7 +19,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(0).map(|x| x + 1)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:24:5
|
||||
--> $DIR/manual_map_option.rs:25:5
|
||||
|
|
||||
LL | / match Some("") {
|
||||
LL | | Some(x) => Some(x.is_empty()),
|
||||
|
|
@ -28,7 +28,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some("").map(|x| x.is_empty())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:29:5
|
||||
--> $DIR/manual_map_option.rs:30:5
|
||||
|
|
||||
LL | / if let Some(x) = Some(0) {
|
||||
LL | | Some(!x)
|
||||
|
|
@ -38,7 +38,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(0).map(|x| !x)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:36:5
|
||||
--> $DIR/manual_map_option.rs:37:5
|
||||
|
|
||||
LL | / match Some(0) {
|
||||
LL | | Some(x) => { Some(std::convert::identity(x)) }
|
||||
|
|
@ -47,7 +47,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(0).map(std::convert::identity)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:41:5
|
||||
--> $DIR/manual_map_option.rs:42:5
|
||||
|
|
||||
LL | / match Some(&String::new()) {
|
||||
LL | | Some(x) => Some(str::len(x)),
|
||||
|
|
@ -56,7 +56,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(&String::new()).map(|x| str::len(x))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:51:5
|
||||
--> $DIR/manual_map_option.rs:52:5
|
||||
|
|
||||
LL | / match &Some([0, 1]) {
|
||||
LL | | Some(x) => Some(x[0]),
|
||||
|
|
@ -65,7 +65,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some([0, 1]).as_ref().map(|x| x[0])`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:56:5
|
||||
--> $DIR/manual_map_option.rs:57:5
|
||||
|
|
||||
LL | / match &Some(0) {
|
||||
LL | | &Some(x) => Some(x * 2),
|
||||
|
|
@ -74,7 +74,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(0).map(|x| x * 2)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:61:5
|
||||
--> $DIR/manual_map_option.rs:62:5
|
||||
|
|
||||
LL | / match Some(String::new()) {
|
||||
LL | | Some(ref x) => Some(x.is_empty()),
|
||||
|
|
@ -83,7 +83,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.is_empty())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:66:5
|
||||
--> $DIR/manual_map_option.rs:67:5
|
||||
|
|
||||
LL | / match &&Some(String::new()) {
|
||||
LL | | Some(x) => Some(x.len()),
|
||||
|
|
@ -92,7 +92,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.len())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:71:5
|
||||
--> $DIR/manual_map_option.rs:72:5
|
||||
|
|
||||
LL | / match &&Some(0) {
|
||||
LL | | &&Some(x) => Some(x + x),
|
||||
|
|
@ -101,7 +101,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(0).map(|x| x + x)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:84:9
|
||||
--> $DIR/manual_map_option.rs:85:9
|
||||
|
|
||||
LL | / match &mut Some(String::new()) {
|
||||
LL | | Some(x) => Some(x.push_str("")),
|
||||
|
|
@ -110,7 +110,7 @@ LL | | };
|
|||
| |_________^ help: try this: `Some(String::new()).as_mut().map(|x| x.push_str(""))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:90:5
|
||||
--> $DIR/manual_map_option.rs:91:5
|
||||
|
|
||||
LL | / match &mut Some(String::new()) {
|
||||
LL | | Some(ref x) => Some(x.len()),
|
||||
|
|
@ -119,7 +119,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.len())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:95:5
|
||||
--> $DIR/manual_map_option.rs:96:5
|
||||
|
|
||||
LL | / match &mut &Some(String::new()) {
|
||||
LL | | Some(x) => Some(x.is_empty()),
|
||||
|
|
@ -128,7 +128,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(String::new()).as_ref().map(|x| x.is_empty())`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:100:5
|
||||
--> $DIR/manual_map_option.rs:101:5
|
||||
|
|
||||
LL | / match Some((0, 1, 2)) {
|
||||
LL | | Some((x, y, z)) => Some(x + y + z),
|
||||
|
|
@ -137,7 +137,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some((0, 1, 2)).map(|(x, y, z)| x + y + z)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:105:5
|
||||
--> $DIR/manual_map_option.rs:106:5
|
||||
|
|
||||
LL | / match Some([1, 2, 3]) {
|
||||
LL | | Some([first, ..]) => Some(first),
|
||||
|
|
@ -146,7 +146,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some([1, 2, 3]).map(|[first, ..]| first)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:110:5
|
||||
--> $DIR/manual_map_option.rs:111:5
|
||||
|
|
||||
LL | / match &Some((String::new(), "test")) {
|
||||
LL | | Some((x, y)) => Some((y, x)),
|
||||
|
|
@ -155,7 +155,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some((String::new(), "test")).as_ref().map(|(x, y)| (y, x))`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:168:5
|
||||
--> $DIR/manual_map_option.rs:169:5
|
||||
|
|
||||
LL | / match Some(0) {
|
||||
LL | | Some(x) => Some(vec![x]),
|
||||
|
|
@ -164,7 +164,7 @@ LL | | };
|
|||
| |_____^ help: try this: `Some(0).map(|x| vec![x])`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:173:5
|
||||
--> $DIR/manual_map_option.rs:174:5
|
||||
|
|
||||
LL | / match option_env!("") {
|
||||
LL | | Some(x) => Some(String::from(x)),
|
||||
|
|
@ -173,7 +173,7 @@ LL | | };
|
|||
| |_____^ help: try this: `option_env!("").map(String::from)`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:193:12
|
||||
--> $DIR/manual_map_option.rs:194:12
|
||||
|
|
||||
LL | } else if let Some(x) = Some(0) {
|
||||
| ____________^
|
||||
|
|
@ -184,7 +184,7 @@ LL | | };
|
|||
| |_____^ help: try this: `{ Some(0).map(|x| x + 1) }`
|
||||
|
||||
error: manual implementation of `Option::map`
|
||||
--> $DIR/manual_map_option.rs:201:12
|
||||
--> $DIR/manual_map_option.rs:202:12
|
||||
|
|
||||
LL | } else if let Some(x) = Some(0) {
|
||||
| ____________^
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
|
||||
#[warn(clippy::all, clippy::needless_borrow)]
|
||||
#[allow(unused_variables, clippy::unnecessary_mut_passed)]
|
||||
fn main() {
|
||||
|
|
@ -96,3 +98,10 @@ trait Trait {}
|
|||
impl<'a> Trait for &'a str {}
|
||||
|
||||
fn h(_: &dyn Trait) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn check_expect_suppression() {
|
||||
let a = 5;
|
||||
#[expect(clippy::needless_borrow)]
|
||||
let _ = x(&&a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// run-rustfix
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
|
||||
#[warn(clippy::all, clippy::needless_borrow)]
|
||||
#[allow(unused_variables, clippy::unnecessary_mut_passed)]
|
||||
fn main() {
|
||||
|
|
@ -96,3 +98,10 @@ trait Trait {}
|
|||
impl<'a> Trait for &'a str {}
|
||||
|
||||
fn h(_: &dyn Trait) {}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn check_expect_suppression() {
|
||||
let a = 5;
|
||||
#[expect(clippy::needless_borrow)]
|
||||
let _ = x(&&a);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:9:15
|
||||
--> $DIR/needless_borrow.rs:11:15
|
||||
|
|
||||
LL | let _ = x(&&a); // warn
|
||||
| ^^^ help: change this to: `&a`
|
||||
|
|
@ -7,91 +7,91 @@ LL | let _ = x(&&a); // warn
|
|||
= note: `-D clippy::needless-borrow` implied by `-D warnings`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:13:13
|
||||
--> $DIR/needless_borrow.rs:15:13
|
||||
|
|
||||
LL | mut_ref(&mut &mut b); // warn
|
||||
| ^^^^^^^^^^^ help: change this to: `&mut b`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:25:13
|
||||
--> $DIR/needless_borrow.rs:27:13
|
||||
|
|
||||
LL | &&a
|
||||
| ^^^ help: change this to: `&a`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:27:15
|
||||
--> $DIR/needless_borrow.rs:29:15
|
||||
|
|
||||
LL | 46 => &&a,
|
||||
| ^^^ help: change this to: `&a`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:33:27
|
||||
--> $DIR/needless_borrow.rs:35:27
|
||||
|
|
||||
LL | break &ref_a;
|
||||
| ^^^^^^ help: change this to: `ref_a`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:40:15
|
||||
--> $DIR/needless_borrow.rs:42:15
|
||||
|
|
||||
LL | let _ = x(&&&a);
|
||||
| ^^^^ help: change this to: `&a`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:41:15
|
||||
--> $DIR/needless_borrow.rs:43:15
|
||||
|
|
||||
LL | let _ = x(&mut &&a);
|
||||
| ^^^^^^^^ help: change this to: `&a`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:42:15
|
||||
--> $DIR/needless_borrow.rs:44:15
|
||||
|
|
||||
LL | let _ = x(&&&mut b);
|
||||
| ^^^^^^^^ help: change this to: `&mut b`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:43:15
|
||||
--> $DIR/needless_borrow.rs:45:15
|
||||
|
|
||||
LL | let _ = x(&&ref_a);
|
||||
| ^^^^^^^ help: change this to: `ref_a`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:46:11
|
||||
--> $DIR/needless_borrow.rs:48:11
|
||||
|
|
||||
LL | x(&b);
|
||||
| ^^ help: change this to: `b`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:53:13
|
||||
--> $DIR/needless_borrow.rs:55:13
|
||||
|
|
||||
LL | mut_ref(&mut x);
|
||||
| ^^^^^^ help: change this to: `x`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:54:13
|
||||
--> $DIR/needless_borrow.rs:56:13
|
||||
|
|
||||
LL | mut_ref(&mut &mut x);
|
||||
| ^^^^^^^^^^^ help: change this to: `x`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:55:23
|
||||
--> $DIR/needless_borrow.rs:57:23
|
||||
|
|
||||
LL | let y: &mut i32 = &mut x;
|
||||
| ^^^^^^ help: change this to: `x`
|
||||
|
||||
error: this expression creates a reference which is immediately dereferenced by the compiler
|
||||
--> $DIR/needless_borrow.rs:56:23
|
||||
--> $DIR/needless_borrow.rs:58:23
|
||||
|
|
||||
LL | let y: &mut i32 = &mut &mut x;
|
||||
| ^^^^^^^^^^^ help: change this to: `x`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:72:13
|
||||
--> $DIR/needless_borrow.rs:74:13
|
||||
|
|
||||
LL | let _ = (&x).0;
|
||||
| ^^^^ help: change this to: `x`
|
||||
|
||||
error: this expression borrows a value the compiler would automatically borrow
|
||||
--> $DIR/needless_borrow.rs:74:22
|
||||
--> $DIR/needless_borrow.rs:76:22
|
||||
|
|
||||
LL | let _ = unsafe { (&*x).0 };
|
||||
| ^^^^^ help: change this to: `(*x)`
|
||||
|
|
|
|||
14
tests/ui/needless_parens_on_range_literals.fixed
Normal file
14
tests/ui/needless_parens_on_range_literals.fixed
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// run-rustfix
|
||||
// edition:2018
|
||||
|
||||
#![warn(clippy::needless_parens_on_range_literals)]
|
||||
#![allow(clippy::almost_complete_letter_range)]
|
||||
|
||||
fn main() {
|
||||
let _ = 'a'..='z';
|
||||
let _ = 'a'..'z';
|
||||
let _ = (1.)..2.;
|
||||
let _ = (1.)..2.;
|
||||
let _ = 'a'..;
|
||||
let _ = ..'z';
|
||||
}
|
||||
14
tests/ui/needless_parens_on_range_literals.rs
Normal file
14
tests/ui/needless_parens_on_range_literals.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
// run-rustfix
|
||||
// edition:2018
|
||||
|
||||
#![warn(clippy::needless_parens_on_range_literals)]
|
||||
#![allow(clippy::almost_complete_letter_range)]
|
||||
|
||||
fn main() {
|
||||
let _ = ('a')..=('z');
|
||||
let _ = 'a'..('z');
|
||||
let _ = (1.)..2.;
|
||||
let _ = (1.)..(2.);
|
||||
let _ = ('a')..;
|
||||
let _ = ..('z');
|
||||
}
|
||||
40
tests/ui/needless_parens_on_range_literals.stderr
Normal file
40
tests/ui/needless_parens_on_range_literals.stderr
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
error: needless parenthesis on range literals can be removed
|
||||
--> $DIR/needless_parens_on_range_literals.rs:8:13
|
||||
|
|
||||
LL | let _ = ('a')..=('z');
|
||||
| ^^^^^ help: try: `'a'`
|
||||
|
|
||||
= note: `-D clippy::needless-parens-on-range-literals` implied by `-D warnings`
|
||||
|
||||
error: needless parenthesis on range literals can be removed
|
||||
--> $DIR/needless_parens_on_range_literals.rs:8:21
|
||||
|
|
||||
LL | let _ = ('a')..=('z');
|
||||
| ^^^^^ help: try: `'z'`
|
||||
|
||||
error: needless parenthesis on range literals can be removed
|
||||
--> $DIR/needless_parens_on_range_literals.rs:9:18
|
||||
|
|
||||
LL | let _ = 'a'..('z');
|
||||
| ^^^^^ help: try: `'z'`
|
||||
|
||||
error: needless parenthesis on range literals can be removed
|
||||
--> $DIR/needless_parens_on_range_literals.rs:11:19
|
||||
|
|
||||
LL | let _ = (1.)..(2.);
|
||||
| ^^^^ help: try: `2.`
|
||||
|
||||
error: needless parenthesis on range literals can be removed
|
||||
--> $DIR/needless_parens_on_range_literals.rs:12:13
|
||||
|
|
||||
LL | let _ = ('a')..;
|
||||
| ^^^^^ help: try: `'a'`
|
||||
|
||||
error: needless parenthesis on range literals can be removed
|
||||
--> $DIR/needless_parens_on_range_literals.rs:13:15
|
||||
|
|
||||
LL | let _ = ..('z');
|
||||
| ^^^^^ help: try: `'z'`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
@ -186,6 +186,23 @@ pub fn test16() {
|
|||
}
|
||||
}
|
||||
|
||||
// Issue #9001: `continue` in struct expression fields
|
||||
pub fn test17() {
|
||||
struct Foo {
|
||||
f: (),
|
||||
}
|
||||
|
||||
let mut n = 0;
|
||||
let _ = loop {
|
||||
break Foo {
|
||||
f: if n < 5 {
|
||||
n += 1;
|
||||
continue;
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test1();
|
||||
test2();
|
||||
|
|
|
|||
87
tests/ui/read_zero_byte_vec.rs
Normal file
87
tests/ui/read_zero_byte_vec.rs
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
#![warn(clippy::read_zero_byte_vec)]
|
||||
#![allow(clippy::unused_io_amount)]
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
|
||||
extern crate futures;
|
||||
use futures::io::{AsyncRead, AsyncReadExt};
|
||||
use tokio::io::{AsyncRead as TokioAsyncRead, AsyncReadExt as _, AsyncWrite as TokioAsyncWrite, AsyncWriteExt as _};
|
||||
|
||||
fn test() -> io::Result<()> {
|
||||
let cap = 1000;
|
||||
let mut f = File::open("foo.txt").unwrap();
|
||||
|
||||
// should lint
|
||||
let mut data = Vec::with_capacity(20);
|
||||
f.read_exact(&mut data).unwrap();
|
||||
|
||||
// should lint
|
||||
let mut data2 = Vec::with_capacity(cap);
|
||||
f.read_exact(&mut data2)?;
|
||||
|
||||
// should lint
|
||||
let mut data3 = Vec::new();
|
||||
f.read_exact(&mut data3)?;
|
||||
|
||||
// should lint
|
||||
let mut data4 = vec![];
|
||||
let _ = f.read(&mut data4)?;
|
||||
|
||||
// should lint
|
||||
let _ = {
|
||||
let mut data5 = Vec::new();
|
||||
f.read(&mut data5)
|
||||
};
|
||||
|
||||
// should lint
|
||||
let _ = {
|
||||
let mut data6: Vec<u8> = Default::default();
|
||||
f.read(&mut data6)
|
||||
};
|
||||
|
||||
// should not lint
|
||||
let mut buf = [0u8; 100];
|
||||
f.read(&mut buf)?;
|
||||
|
||||
// should not lint
|
||||
let mut empty = vec![];
|
||||
let mut data7 = vec![];
|
||||
f.read(&mut empty);
|
||||
|
||||
// should not lint
|
||||
f.read(&mut data7);
|
||||
|
||||
// should not lint
|
||||
let mut data8 = Vec::new();
|
||||
data8.resize(100, 0);
|
||||
f.read_exact(&mut data8)?;
|
||||
|
||||
// should not lint
|
||||
let mut data9 = vec![1, 2, 3];
|
||||
f.read_exact(&mut data9)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn test_futures<R: AsyncRead + Unpin>(r: &mut R) {
|
||||
// should lint
|
||||
let mut data = Vec::new();
|
||||
r.read(&mut data).await.unwrap();
|
||||
|
||||
// should lint
|
||||
let mut data2 = Vec::new();
|
||||
r.read_exact(&mut data2).await.unwrap();
|
||||
}
|
||||
|
||||
async fn test_tokio<R: TokioAsyncRead + Unpin>(r: &mut R) {
|
||||
// should lint
|
||||
let mut data = Vec::new();
|
||||
r.read(&mut data).await.unwrap();
|
||||
|
||||
// should lint
|
||||
let mut data2 = Vec::new();
|
||||
r.read_exact(&mut data2).await.unwrap();
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
64
tests/ui/read_zero_byte_vec.stderr
Normal file
64
tests/ui/read_zero_byte_vec.stderr
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:17:5
|
||||
|
|
||||
LL | f.read_exact(&mut data).unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data.resize(20, 0); f.read_exact(&mut data).unwrap();`
|
||||
|
|
||||
= note: `-D clippy::read-zero-byte-vec` implied by `-D warnings`
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:21:5
|
||||
|
|
||||
LL | f.read_exact(&mut data2)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `data2.resize(cap, 0); f.read_exact(&mut data2)?;`
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:25:5
|
||||
|
|
||||
LL | f.read_exact(&mut data3)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:29:5
|
||||
|
|
||||
LL | let _ = f.read(&mut data4)?;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:34:9
|
||||
|
|
||||
LL | f.read(&mut data5)
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:40:9
|
||||
|
|
||||
LL | f.read(&mut data6)
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:70:5
|
||||
|
|
||||
LL | r.read(&mut data).await.unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:74:5
|
||||
|
|
||||
LL | r.read_exact(&mut data2).await.unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:80:5
|
||||
|
|
||||
LL | r.read(&mut data).await.unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: reading zero byte data to `Vec`
|
||||
--> $DIR/read_zero_byte_vec.rs:84:5
|
||||
|
|
||||
LL | r.read_exact(&mut data2).await.unwrap();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
// FIXME: run-rustfix waiting on multi-span suggestions
|
||||
|
||||
#![feature(lint_reasons)]
|
||||
#![warn(clippy::ref_binding_to_reference)]
|
||||
#![allow(clippy::needless_borrowed_reference)]
|
||||
|
||||
|
|
@ -73,3 +74,12 @@ impl T1 for S {
|
|||
let _: &&String = x;
|
||||
}
|
||||
}
|
||||
|
||||
fn check_expect_suppression() {
|
||||
let x = String::new();
|
||||
#[expect(clippy::ref_binding_to_reference)]
|
||||
let _: &&String = match Some(&x) {
|
||||
Some(ref x) => x,
|
||||
None => return,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: this pattern creates a reference to a reference
|
||||
--> $DIR/ref_binding_to_reference.rs:30:14
|
||||
--> $DIR/ref_binding_to_reference.rs:31:14
|
||||
|
|
||||
LL | Some(ref x) => x,
|
||||
| ^^^^^
|
||||
|
|
@ -11,7 +11,7 @@ LL | Some(x) => &x,
|
|||
| ~ ~~
|
||||
|
||||
error: this pattern creates a reference to a reference
|
||||
--> $DIR/ref_binding_to_reference.rs:36:14
|
||||
--> $DIR/ref_binding_to_reference.rs:37:14
|
||||
|
|
||||
LL | Some(ref x) => {
|
||||
| ^^^^^
|
||||
|
|
@ -25,7 +25,7 @@ LL ~ &x
|
|||
|
|
||||
|
||||
error: this pattern creates a reference to a reference
|
||||
--> $DIR/ref_binding_to_reference.rs:46:14
|
||||
--> $DIR/ref_binding_to_reference.rs:47:14
|
||||
|
|
||||
LL | Some(ref x) => m2!(x),
|
||||
| ^^^^^
|
||||
|
|
@ -36,7 +36,7 @@ LL | Some(x) => m2!(&x),
|
|||
| ~ ~~
|
||||
|
||||
error: this pattern creates a reference to a reference
|
||||
--> $DIR/ref_binding_to_reference.rs:51:15
|
||||
--> $DIR/ref_binding_to_reference.rs:52:15
|
||||
|
|
||||
LL | let _ = |&ref x: &&String| {
|
||||
| ^^^^^
|
||||
|
|
@ -48,7 +48,7 @@ LL ~ let _: &&String = &x;
|
|||
|
|
||||
|
||||
error: this pattern creates a reference to a reference
|
||||
--> $DIR/ref_binding_to_reference.rs:57:12
|
||||
--> $DIR/ref_binding_to_reference.rs:58:12
|
||||
|
|
||||
LL | fn f2<'a>(&ref x: &&'a String) -> &'a String {
|
||||
| ^^^^^
|
||||
|
|
@ -61,7 +61,7 @@ LL ~ x
|
|||
|
|
||||
|
||||
error: this pattern creates a reference to a reference
|
||||
--> $DIR/ref_binding_to_reference.rs:64:11
|
||||
--> $DIR/ref_binding_to_reference.rs:65:11
|
||||
|
|
||||
LL | fn f(&ref x: &&String) {
|
||||
| ^^^^^
|
||||
|
|
@ -73,7 +73,7 @@ LL ~ let _: &&String = &x;
|
|||
|
|
||||
|
||||
error: this pattern creates a reference to a reference
|
||||
--> $DIR/ref_binding_to_reference.rs:72:11
|
||||
--> $DIR/ref_binding_to_reference.rs:73:11
|
||||
|
|
||||
LL | fn f(&ref x: &&String) {
|
||||
| ^^^^^
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#![feature(lint_reasons)]
|
||||
#![warn(clippy::same_name_method)]
|
||||
#![allow(dead_code, non_camel_case_types)]
|
||||
|
||||
|
|
@ -108,4 +109,19 @@ mod should_not_lint {
|
|||
}
|
||||
}
|
||||
|
||||
mod check_expect_suppression {
|
||||
use crate::T1;
|
||||
|
||||
struct S;
|
||||
|
||||
impl S {
|
||||
#[expect(clippy::same_name_method)]
|
||||
fn foo() {}
|
||||
}
|
||||
|
||||
impl T1 for S {
|
||||
fn foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,61 +1,61 @@
|
|||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:20:13
|
||||
--> $DIR/same_name_method.rs:21:13
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: `-D clippy::same-name-method` implied by `-D warnings`
|
||||
note: existing `foo` defined here
|
||||
--> $DIR/same_name_method.rs:24:13
|
||||
--> $DIR/same_name_method.rs:25:13
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:34:13
|
||||
--> $DIR/same_name_method.rs:35:13
|
||||
|
|
||||
LL | fn clone() {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: existing `clone` defined here
|
||||
--> $DIR/same_name_method.rs:30:18
|
||||
--> $DIR/same_name_method.rs:31:18
|
||||
|
|
||||
LL | #[derive(Clone)]
|
||||
| ^^^^^
|
||||
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:44:13
|
||||
--> $DIR/same_name_method.rs:45:13
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: existing `foo` defined here
|
||||
--> $DIR/same_name_method.rs:48:13
|
||||
--> $DIR/same_name_method.rs:49:13
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:58:13
|
||||
--> $DIR/same_name_method.rs:59:13
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: existing `foo` defined here
|
||||
--> $DIR/same_name_method.rs:61:9
|
||||
--> $DIR/same_name_method.rs:62:9
|
||||
|
|
||||
LL | impl T1 for S {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: method's name is the same as an existing method in a trait
|
||||
--> $DIR/same_name_method.rs:70:13
|
||||
--> $DIR/same_name_method.rs:71:13
|
||||
|
|
||||
LL | fn foo() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: existing `foo` defined here
|
||||
--> $DIR/same_name_method.rs:73:9
|
||||
--> $DIR/same_name_method.rs:74:9
|
||||
|
|
||||
LL | impl T1 for S {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue