about summary refs log tree commit diff
path: root/clippy_utils
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-02 12:39:37 +0000
committerbors <bors@rust-lang.org>2022-08-02 12:39:37 +0000
commit05e7d5481b7d405f0ebb04f3c83fb19618871c19 (patch)
treef0c67a3e0d8c7476778de5bb6b4d9db909e023d8 /clippy_utils
parent00e59cdad015ab7148e4777e637782b35c3821cc (diff)
parent4c43aa7053a38ea7e0bb3aca2ffec4e734f7164f (diff)
Auto merge of #9053 - AaronC81:fix-9052, r=flip1995
Fix suggestions for `async` closures in redundant_closure_call

Fixes #9052

changelog: Fix suggestions given by [`redundant_closure_call`] for async closures
Diffstat (limited to 'clippy_utils')
-rw-r--r--clippy_utils/src/sugg.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/clippy_utils/src/sugg.rs b/clippy_utils/src/sugg.rs
index bad291dfc25..081c98e2f3c 100644
--- a/clippy_utils/src/sugg.rs
+++ b/clippy_utils/src/sugg.rs
@@ -315,6 +315,12 @@ impl<'a> Sugg<'a> {
         Sugg::NonParen(Cow::Owned(format!("{{ {} }}", self)))
     }
 
+    /// Convenience method to prefix the expression with the `async` keyword.
+    /// Can be used after `blockify` to create an async block.
+    pub fn asyncify(self) -> Sugg<'static> {
+        Sugg::NonParen(Cow::Owned(format!("async {}", self)))
+    }
+
     /// Convenience method to create the `<lhs>..<rhs>` or `<lhs>...<rhs>`
     /// suggestion.
     pub fn range(self, end: &Self, limit: ast::RangeLimits) -> Sugg<'static> {