summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/needless_lifetimes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui/needless_lifetimes.rs')
-rw-r--r--src/tools/clippy/tests/ui/needless_lifetimes.rs52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/tools/clippy/tests/ui/needless_lifetimes.rs b/src/tools/clippy/tests/ui/needless_lifetimes.rs
index 2efc93675..ddfd10430 100644
--- a/src/tools/clippy/tests/ui/needless_lifetimes.rs
+++ b/src/tools/clippy/tests/ui/needless_lifetimes.rs
@@ -1,13 +1,20 @@
+// run-rustfix
+// aux-build:macro_rules.rs
+
#![warn(clippy::needless_lifetimes)]
#![allow(
- dead_code,
+ unused,
clippy::boxed_local,
+ clippy::extra_unused_type_parameters,
clippy::needless_pass_by_value,
clippy::unnecessary_wraps,
dyn_drop,
clippy::get_first
)]
+#[macro_use]
+extern crate macro_rules;
+
fn distinct_lifetimes<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: u8) {}
fn distinct_and_static<'a, 'b>(_x: &'a u8, _y: &'b u8, _z: &'static u8) {}
@@ -495,4 +502,47 @@ mod pr_9743_output_lifetime_checks {
}
}
+mod in_macro {
+ macro_rules! local_one_input_macro {
+ () => {
+ fn one_input<'a>(x: &'a u8) -> &'a u8 {
+ unimplemented!()
+ }
+ };
+ }
+
+ // lint local macro expands to function with needless lifetimes
+ local_one_input_macro!();
+
+ // no lint on external macro
+ macro_rules::needless_lifetime!();
+
+ macro_rules! expanded_lifetime {
+ ($l:lifetime) => {
+ fn f<$l>(arg: &$l str) -> &$l str {
+ arg
+ }
+ }
+ }
+
+ expanded_lifetime!('a);
+}
+
+mod issue5787 {
+ use std::sync::MutexGuard;
+
+ struct Foo;
+
+ impl Foo {
+ // doesn't get linted without async
+ pub async fn wait<'a, T>(&self, guard: MutexGuard<'a, T>) -> MutexGuard<'a, T> {
+ guard
+ }
+ }
+
+ async fn foo<'a>(_x: &i32, y: &'a str) -> &'a str {
+ y
+ }
+}
+
fn main() {}