about summary refs log tree commit diff
diff options
context:
space:
mode:
authoruHOOCCOOHu <hooccooh1896@gmail.com>2019-07-19 02:43:10 +0800
committeruHOOCCOOHu <hooccooh1896@gmail.com>2019-07-19 02:43:10 +0800
commite6bbed909ee516b5e50bfb1a3b2b86a6b2988bc3 (patch)
tree07df17cac10f47edd18cfc79440774c287cdf29f
parenta9bec0c8a6020ed61ca150f046455b309283848d (diff)
downloadrust-e6bbed909ee516b5e50bfb1a3b2b86a6b2988bc3.tar.gz
rust-e6bbed909ee516b5e50bfb1a3b2b86a6b2988bc3.zip
Add test
-rw-r--r--tests/ui/issue_4266.rs24
-rw-r--r--tests/ui/issue_4266.stderr16
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/ui/issue_4266.rs b/tests/ui/issue_4266.rs
new file mode 100644
index 00000000000..dbf482ea11a
--- /dev/null
+++ b/tests/ui/issue_4266.rs
@@ -0,0 +1,24 @@
+// compile-flags: --edition 2018
+#![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() {}
diff --git a/tests/ui/issue_4266.stderr b/tests/ui/issue_4266.stderr
new file mode 100644
index 00000000000..3c9740c4a22
--- /dev/null
+++ b/tests/ui/issue_4266.stderr
@@ -0,0 +1,16 @@
+error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
+  --> $DIR/issue_4266.rs:5:1
+   |
+LL | async fn sink1<'a>(_: &'a str) {} // lint
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `-D clippy::needless-lifetimes` implied by `-D warnings`
+
+error: explicit lifetimes given in parameter types where they could be elided (or replaced with `'_` if needed by type declaration)
+  --> $DIR/issue_4266.rs:8:1
+   |
+LL | async fn one_to_one<'a>(s: &'a str) -> &'a str { s } // lint
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+