]> git.lizzy.rs Git - rust.git/commitdiff
Address PR's comments
authormcarton <cartonmartin+git@gmail.com>
Wed, 6 Jul 2016 13:36:42 +0000 (15:36 +0200)
committermcarton <cartonmartin+git@gmail.com>
Wed, 6 Jul 2016 13:49:49 +0000 (15:49 +0200)
clippy_lints/src/needless_bool.rs
clippy_lints/src/transmute.rs
clippy_lints/src/utils/sugg.rs

index fa2a350c36f029e567d7d0b3b9b29054350b3297..c3e2a0e61679c73e7e0fe6f999c0fabe9af5abd6 100644 (file)
@@ -59,7 +59,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
                 };
 
                 let hint = if ret {
-                    format!("return {};", snip)
+                    format!("return {}", snip)
                 } else {
                     snip.to_string()
                 };
index 88ed11d26e581b57333c0f223e4e398265d81e52..ba4da0e8f65446f3a6b5decb74c15990e8725221 100644 (file)
@@ -95,9 +95,9 @@ fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
                             |db| {
                                 if let Some(arg) = sugg::Sugg::hir_opt(cx, &*args[0]) {
                                     let sugg = if ptr_ty == rty {
-                                        arg.as_ty(&to_ty.to_string())
+                                        arg.as_ty(to_ty)
                                     } else {
-                                        arg.as_ty(&format!("{} as {}", cx.tcx.mk_ptr(rty), to_ty))
+                                        arg.as_ty(cx.tcx.mk_ptr(rty)).as_ty(to_ty)
                                     };
 
                                     db.span_suggestion(e.span, "try", sugg.to_string());
index 4a9543d47c1cbf793b8589847843fa8c07154397..624c030cdd4487d3053ec918f06da4cbdeb83abf 100644 (file)
@@ -126,8 +126,8 @@ pub fn and(self, rhs: Self) -> Sugg<'static> {
     }
 
     /// Convenience method to create the `<lhs> as <rhs>` suggestion.
-    pub fn as_ty(self, rhs: &str) -> Sugg<'static> {
-        make_assoc(AssocOp::As, &self, &Sugg::NonParen(rhs.into()))
+    pub fn as_ty<R: std::fmt::Display>(self, rhs: R) -> Sugg<'static> {
+        make_assoc(AssocOp::As, &self, &Sugg::NonParen(rhs.to_string().into()))
     }
 
     /// Convenience method to create the `&<expr>` suggestion.