rust-clippy/tests/ui/issue_4266.rs

44 lines
890 B
Rust
Raw Normal View History

2019-07-18 18:43:10 +00:00
#![allow(dead_code)]
#![allow(clippy::uninlined_format_args)]
2019-07-18 18:43:10 +00:00
async fn sink1<'a>(_: &'a str) {} // lint
//~^ ERROR: the following explicit lifetimes could be elided: 'a
//~| NOTE: `-D clippy::needless-lifetimes` implied by `-D warnings`
async fn sink1_elided(_: &str) {} // ok
2019-07-18 18:43:10 +00:00
// lint
async fn one_to_one<'a>(s: &'a str) -> &'a str {
//~^ ERROR: the following explicit lifetimes could be elided: 'a
s
}
2019-07-19 15:03:34 +00:00
// ok
async fn one_to_one_elided(s: &str) -> &str {
s
}
2019-07-19 15:03:34 +00:00
// ok
async fn all_to_one<'a>(a: &'a str, _b: &'a str) -> &'a str {
a
}
2019-07-18 18:43:10 +00:00
// async fn unrelated(_: &str, _: &str) {} // Not allowed in async fn
2019-07-18 18:43:10 +00:00
// #3988
struct Foo;
impl Foo {
// ok
pub async fn new(&mut self) -> Self {
//~^ ERROR: methods called `new` usually take no `self`
Foo {}
}
}
// rust-lang/rust#61115
// ok
async fn print(s: &str) {
println!("{}", s);
2019-07-18 18:43:10 +00:00
}
fn main() {}