diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/async-await/unused-lifetime.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/async-await/unused-lifetime.rs')
-rw-r--r-- | tests/ui/async-await/unused-lifetime.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui/async-await/unused-lifetime.rs b/tests/ui/async-await/unused-lifetime.rs new file mode 100644 index 000000000..6cfd36ba9 --- /dev/null +++ b/tests/ui/async-await/unused-lifetime.rs @@ -0,0 +1,39 @@ +// Check "unused_lifetimes" lint on both async and sync functions +// Both cases should be diagnosed the same way. + +// edition:2018 + +#![deny(unused_lifetimes)] + +async fn async_wrong_without_args<'a>() {} //~ ERROR lifetime parameter `'a` never used + +async fn async_wrong_1_lifetime<'a>(_: &i32) {} //~ ERROR lifetime parameter `'a` never used + +async fn async_wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} //~ ERROR lifetime parameter `'b` never used + +async fn async_right_1_lifetime<'a>(_: &'a i32) {} + +async fn async_right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {} + +async fn async_right_trait_bound_lifetime<'a, I>(_: I) +where + I: Iterator<Item = &'a i32> +{} + +fn wrong_without_args<'a>() {} //~ ERROR lifetime parameter `'a` never used + +fn wrong_1_lifetime<'a>(_: &i32) {} //~ ERROR lifetime parameter `'a` never used + +fn wrong_2_lifetimes<'a, 'b>(_: &'a i32, _: &i32) {} //~ ERROR lifetime parameter `'b` never used + +fn right_1_lifetime<'a>(_: &'a i32) {} + +fn right_2_lifetimes<'a, 'b>(_: &'a i32, _: &'b i32) {} + +fn right_trait_bound_lifetime<'a, I>(_: I) +where + I: Iterator<Item = &'a i32> +{} + + +fn main() {} |