Skip to content

Commit e6bbed9

Browse files
committed
Add test
1 parent a9bec0c commit e6bbed9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/ui/issue_4266.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// compile-flags: --edition 2018
2+
#![feature(async_await)]
3+
#![allow(dead_code)]
4+
5+
async fn sink1<'a>(_: &'a str) {} // lint
6+
async fn sink1_elided(_: &str) {} // ok
7+
8+
async fn one_to_one<'a>(s: &'a str) -> &'a str { s } // lint
9+
async fn one_to_one_elided(s: &str) -> &str { s } // ok
10+
async fn all_to_one<'a>(a: &'a str, _b: &'a str) -> &'a str { a } // ok
11+
// async fn unrelated(_: &str, _: &str) {} // Not allowed in async fn
12+
13+
// #3988
14+
struct Foo;
15+
impl Foo {
16+
pub async fn foo(&mut self) {} // ok
17+
}
18+
19+
// rust-lang/rust#61115
20+
async fn print(s: &str) { // ok
21+
println!("{}", s);
22+
}
23+
24+
fn main() {}

tests/ui/issue_4266.stderr

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
2+
--> $DIR/issue_4266.rs:5:1
3+
|
4+
LL | async fn sink1<'a>(_: &'a str) {} // lint
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `-D clippy::needless-lifetimes` implied by `-D warnings`
8+
9+
error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
10+
--> $DIR/issue_4266.rs:8:1
11+
|
12+
LL | async fn one_to_one<'a>(s: &'a str) -> &'a str { s } // lint
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
error: aborting due to 2 previous errors
16+

0 commit comments

Comments
 (0)