match (&expr.kind, expected.kind(), checked_ty.kind()) {
(_, &ty::Ref(_, exp, _), &ty::Ref(_, check, _)) => match (exp.kind(), check.kind()) {
(&ty::Str, &ty::Array(arr, _) | &ty::Slice(arr)) if arr == self.tcx.types.u8 => {
- if let hir::ExprKind::Lit(_) = expr.kind {
- if let Ok(src) = sm.span_to_snippet(sp) {
- if replace_prefix(&src, "b\"", "\"").is_some() {
+ if let hir::ExprKind::Lit(_) = expr.kind
+ && let Ok(src) = sm.span_to_snippet(sp)
+ && replace_prefix(&src, "b\"", "\"").is_some()
+ {
let pos = sp.lo() + BytePos(1);
return Some((
sp.with_hi(pos),
));
}
}
- }
- }
(&ty::Array(arr, _) | &ty::Slice(arr), &ty::Str) if arr == self.tcx.types.u8 => {
- if let hir::ExprKind::Lit(_) = expr.kind {
- if let Ok(src) = sm.span_to_snippet(sp) {
- if replace_prefix(&src, "\"", "b\"").is_some() {
+ if let hir::ExprKind::Lit(_) = expr.kind
+ && let Ok(src) = sm.span_to_snippet(sp)
+ && replace_prefix(&src, "\"", "b\"").is_some()
+ {
return Some((
sp.shrink_to_lo(),
"consider adding a leading `b`",
Applicability::MachineApplicable,
true,
));
- }
- }
+
}
}
_ => {}