};
let hint = if ret {
- format!("return {};", snip)
+ format!("return {}", snip)
} else {
snip.to_string()
};
|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());
}
/// 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.