mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-19 01:24:05 +00:00
d71e9c4f10
Ignore generated fresh lifetimes in elision check <!-- Thank you for making Clippy better! We're collecting our changelog from pull request descriptions. If your PR only updates to the latest nightly, you can leave the `changelog` entry as `none`. Otherwise, please write a short comment explaining your change. If your PR fixes an issue, you can add "fixes #issue_number" into this PR description. This way the issue will be automatically closed when your PR is merged. If you added a new lint, here's a checklist for things that will be checked during review or continuous integration. - [ ] Followed [lint naming conventions][lint_naming] - [ ] Added passing UI tests (including committed `.stderr` file) - [ ] `cargo test` passes locally - [ ] Executed `util/dev update_lints` - [ ] Added lint documentation - [ ] Run `cargo fmt` Note that you can skip the above if you are just opening a WIP PR in order to get feedback. Delete this line and everything above before opening your PR --> fixes #3988 changelog: Ignore generated fresh lifetimes in elision check. **HELP**: It seems `tests/ui` are compiled under edition 2015, and I don't know how to add tests for this properly. Here is the test input it had already passed: ```rust #![feature(async_await)] #![allow(dead_code)] async fn sink1<'a>(_: &'a str) {} // lint async fn sink1_elided(_: &str) {} // ok async fn one_to_one<'a>(s: &'a str) -> &'a str { s } // lint async fn one_to_one_elided(s: &str) -> &str { s } // ok async fn all_to_one<'a>(a: &'a str, _b: &'a str) -> &'a str { a } // ok // async fn unrelated(_: &str, _: &str) {} // Not allowed in async fn // #3988 struct Foo; impl Foo { pub async fn foo(&mut self) {} // ok } // rust-lang/rust#61115 async fn print(s: &str) { // ok println!("{}", s); } fn main() {} ```
247 lines
5.3 KiB
Text
247 lines
5.3 KiB
Text
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:31:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | Foo { bar: 42 };
|
|
LL | | 0..10;
|
|
... |
|
|
LL | | foo();
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
= note: `-D clippy::if-same-then-else` implied by `-D warnings`
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:23:13
|
|
|
|
|
LL | if true {
|
|
| _____________^
|
|
LL | | Foo { bar: 42 };
|
|
LL | | 0..10;
|
|
LL | | ..;
|
|
... |
|
|
LL | | foo();
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:69:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | 0.0
|
|
LL | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:67:21
|
|
|
|
|
LL | let _ = if true {
|
|
| _____________________^
|
|
LL | | 0.0
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:76:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | -0.0
|
|
LL | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:74:21
|
|
|
|
|
LL | let _ = if true {
|
|
| _____________________^
|
|
LL | | -0.0
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:92:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | 42
|
|
LL | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:90:21
|
|
|
|
|
LL | let _ = if true {
|
|
| _____________________^
|
|
LL | | 42
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:106:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | for _ in &[42] {
|
|
LL | | let foo: &Option<_> = &Some::<u8>(42);
|
|
... |
|
|
LL | | }
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:97:13
|
|
|
|
|
LL | if true {
|
|
| _____________^
|
|
LL | | for _ in &[42] {
|
|
LL | | let foo: &Option<_> = &Some::<u8>(42);
|
|
LL | | if true {
|
|
... |
|
|
LL | | }
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:125:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | let bar = if true { 42 } else { 43 };
|
|
LL | |
|
|
... |
|
|
LL | | bar + 1;
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:118:13
|
|
|
|
|
LL | if true {
|
|
| _____________^
|
|
LL | | let bar = if true { 42 } else { 43 };
|
|
LL | |
|
|
LL | | while foo() {
|
|
... |
|
|
LL | | bar + 1;
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:155:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | if let Some(a) = Some(42) {}
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:153:13
|
|
|
|
|
LL | if true {
|
|
| _____________^
|
|
LL | | if let Some(a) = Some(42) {}
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:162:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | if let (1, .., 3) = (1, 2, 3) {}
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:160:13
|
|
|
|
|
LL | if true {
|
|
| _____________^
|
|
LL | | if let (1, .., 3) = (1, 2, 3) {}
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:212:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | std::f32::NAN
|
|
LL | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:210:21
|
|
|
|
|
LL | let _ = if true {
|
|
| _____________________^
|
|
LL | | std::f32::NAN
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:219:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | //~ ERROR same body as `if` block
|
|
LL | | r#try!(Ok("foo"));
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:217:13
|
|
|
|
|
LL | if true {
|
|
| _____________^
|
|
LL | | r#try!(Ok("foo"));
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/if_same_then_else.rs:244:12
|
|
|
|
|
LL | } else {
|
|
| ____________^
|
|
LL | | let foo = "";
|
|
LL | | return Ok(&foo[0..]);
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:241:20
|
|
|
|
|
LL | } else if true {
|
|
| ____________________^
|
|
LL | | let foo = "";
|
|
LL | | return Ok(&foo[0..]);
|
|
LL | | } else {
|
|
| |_____^
|
|
|
|
error: this `if` has the same condition as a previous if
|
|
--> $DIR/if_same_then_else.rs:241:15
|
|
|
|
|
LL | } else if true {
|
|
| ^^^^
|
|
|
|
|
= note: `#[deny(clippy::ifs_same_cond)]` on by default
|
|
note: same as this
|
|
--> $DIR/if_same_then_else.rs:235:8
|
|
|
|
|
LL | if true {
|
|
| ^^^^
|
|
|
|
error: aborting due to 12 previous errors
|
|
|