use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir as hir;
+use rustc_hir::{BlockCheckMode, UnsafeSource};
use rustc_lint::LateContext;
use rustc_middle::ty;
use rustc_span::source_map::Span;
let ty = cx.typeck_results().expr_ty(&args[0]).peel_refs();
match ty.kind() {
- ty::Slice(_) | ty::Array(_, _) => return,
+ ty::Slice(_) | ty::Array(_, _) | ty::Str => return,
_ => (),
}
}
}
}
-
if args.len() == 2 {
match args[1].kind {
hir::ExprKind::Call(ref fun, ref or_args) => {
hir::ExprKind::Index(..) | hir::ExprKind::MethodCall(..) => {
check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
},
- _ => {},
+ hir::ExprKind::Block(block, _) => {
+ if let BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) = block.rules {
+ if let Some(block_expr) = block.expr {
+ if let hir::ExprKind::MethodCall(..) = block_expr.kind {
+ check_general_case(cx, name, method_span, &args[0], &args[1], expr.span, None);
+ }
+ }
+ }
+ },
+ _ => (),
}
}
}