Check for arrays with size > 32
This commit is contained in:
parent
f9682ca563
commit
0ae2ece91e
1 changed files with 11 additions and 6 deletions
|
@ -1128,7 +1128,12 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
|
||||||
let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs();
|
let fn_arg_tys = method_type.fn_sig(cx.tcx).inputs();
|
||||||
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
|
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
|
||||||
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
|
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
|
||||||
lint_iter_method(cx, args, arg, method_name);
|
match cx.tables.expr_ty(&args[0]).sty {
|
||||||
|
// If the length is greater than 32 no traits are implemented for array and
|
||||||
|
// therefore we cannot use `&`.
|
||||||
|
ty::TypeVariants::TyArray(_, size) if const_to_u64(size) > 32 => (),
|
||||||
|
_ => lint_iter_method(cx, args, arg, method_name)
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
let object = snippet(cx, args[0].span, "_");
|
let object = snippet(cx, args[0].span, "_");
|
||||||
span_lint_and_sugg(
|
span_lint_and_sugg(
|
||||||
|
|
Loading…
Add table
Reference in a new issue