about summary refs log tree commit diff
path: root/clippy_utils/src
diff options
context:
space:
mode:
authorAaron Christiansen <aaronc20000@gmail.com>2022-06-25 23:15:44 +0100
committerAaron Christiansen <aaronc20000@gmail.com>2022-07-15 15:49:04 +0100
commit4c43aa7053a38ea7e0bb3aca2ffec4e734f7164f (patch)
tree3cfba8382ad10f00848de305d3040283b4e58836 /clippy_utils/src
parentaa0706bf20bd6f647c0132e0779e99b7c11208df (diff)
Fix suggestion for `async` in redundant_closure_call
Fix redundant_closure_call for single-expression async closures

Add Sugg::asyncify

Use Sugg for redundant_closure_call implementation
Diffstat (limited to 'clippy_utils/src')
-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> {