match ty.kind() {
ty::Slice(_) => true,
ty::Adt(def, _) if def.is_box() => may_slice(cx, ty.boxed_ty()),
- ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::vec_type),
- ty::Array(_, size) => size
- .try_eval_usize(cx.tcx, cx.param_env)
- .map_or(false, |size| size < 32),
+ ty::Adt(..) => is_type_diagnostic_item(cx, ty, sym::Vec),
+ ty::Array(_, size) => size.try_eval_usize(cx.tcx, cx.param_env).is_some(),
ty::Ref(_, inner, _) => may_slice(cx, inner),
_ => false,
}
}
- if let hir::ExprKind::MethodCall(path, _, args, _) = expr.kind {
- if path.ident.name == sym::iter && may_slice(cx, cx.typeck_results().expr_ty(&args[0])) {
- Some(&args[0])
+ if let hir::ExprKind::MethodCall(path, _, [self_arg, ..], _) = &expr.kind {
+ if path.ident.name == sym::iter && may_slice(cx, cx.typeck_results().expr_ty(self_arg)) {
+ Some(self_arg)
} else {
None
}
// for regular string: "a"
&snip[1..(snip.len() - 1)]
};
- let hint = format!("'{}'", if ch == "'" { "\\'" } else { ch });
+
+ let hint = format!("'{}'", match ch {
+ "'" => "\\'" ,
+ r"\" => "\\\\",
+ _ => ch,
+ });
+
Some(hint)
} else {
None