]> git.lizzy.rs Git - rust.git/commitdiff
remove clone in manual_async_fn lint
authorMatthias Krüger <matthias.krueger@famsik.de>
Tue, 22 Dec 2020 02:11:35 +0000 (03:11 +0100)
committerMatthias Krüger <matthias.krueger@famsik.de>
Tue, 22 Dec 2020 02:12:12 +0000 (03:12 +0100)
clippy_lints/src/manual_async_fn.rs
clippy_lints/src/unused_unit.rs
clippy_lints/src/utils/mod.rs

index 7b3b450ef93e943fad6882126463f32a42617ebd..29439e52c48e1252fda7a8e275741ff127a413e6 100644 (file)
@@ -69,7 +69,7 @@ fn check_fn(
                     |diag| {
                         if_chain! {
                             if let Some(header_snip) = snippet_opt(cx, header_span);
-                            if let Some(ret_pos) = position_before_rarrow(header_snip.clone());
+                            if let Some(ret_pos) = position_before_rarrow(&header_snip);
                             if let Some((ret_sugg, ret_snip)) = suggested_ret(cx, output);
                             then {
                                 let help = format!("make the function `async` and {}", ret_sugg);
index f61fd2ecd735d915964c5b3ce80bfaa6da56e29e..a31cd5fda849ed918211bf6d6822cf8555b3954c 100644 (file)
@@ -120,7 +120,7 @@ fn is_unit_expr(expr: &ast::Expr) -> bool {
 
 fn lint_unneeded_unit_return(cx: &EarlyContext<'_>, ty: &ast::Ty, span: Span) {
     let (ret_span, appl) = if let Ok(fn_source) = cx.sess().source_map().span_to_snippet(span.with_hi(ty.span.hi())) {
-        position_before_rarrow(fn_source).map_or((ty.span, Applicability::MaybeIncorrect), |rpos| {
+        position_before_rarrow(&fn_source).map_or((ty.span, Applicability::MaybeIncorrect), |rpos| {
             (
                 #[allow(clippy::cast_possible_truncation)]
                 ty.span.with_lo(BytePos(span.lo().0 + rpos as u32)),
index 424856090f261f598dfe200fc7fd65652f6fa04e..1c68e837c4ab97286410fc51e7f3347bb8356b3e 100644 (file)
@@ -788,8 +788,7 @@ pub fn indent_of<T: LintContext>(cx: &T, span: Span) -> Option<usize> {
 /// fn into3(self)   -> () {}
 ///               ^
 /// ```
-#[allow(clippy::needless_pass_by_value)]
-pub fn position_before_rarrow(s: String) -> Option<usize> {
+pub fn position_before_rarrow(s: &str) -> Option<usize> {
     s.rfind("->").map(|rpos| {
         let mut rpos = rpos;
         let chars: Vec<char> = s.chars().collect();