Skip to content

Commit f6aa2a6

Browse files
Merge pull request #8 from tylerreisinger/reject_mut_ref
Reject mut reference args
2 parents 46aa7c4 + 3e9cf73 commit f6aa2a6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/lib.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -418,13 +418,6 @@ fn get_args_and_types(f: &syn::ItemFn, config: &config::Config) ->
418418
let arg_name;
419419
if let syn::Pat::Ident(ref pat_ident) = arg_captured.pat {
420420
arg_name = pat_ident.ident.clone();
421-
if let Some(m) = pat_ident.mutability {
422-
if !config.ignore_args.contains(&arg_name) {
423-
let diag = m.span.unstable()
424-
.error("`mut` arguments are not supported with lru_cache as this could lead to incorrect results being stored");
425-
return Err(DiagnosticError::new(diag));
426-
}
427-
}
428421
segments.push(syn::PathSegment { ident: pat_ident.ident.clone(), arguments: syn::PathArguments::None });
429422
} else {
430423
let diag = arg_captured.span().unstable()
@@ -438,6 +431,11 @@ fn get_args_and_types(f: &syn::ItemFn, config: &config::Config) ->
438431

439432
// If the arg type is a reference, remove the reference because the arg will be cloned
440433
if let syn::Type::Reference(type_reference) = &arg_captured.ty {
434+
if let Some(m) = type_reference.mutability {
435+
let diag = m.span.unstable()
436+
.error("`mut` reference arguments are not supported as this could lead to incorrect results being stored");
437+
return Err(DiagnosticError::new(diag));
438+
}
441439
types.push(type_reference.elem.as_ref().to_owned()); // as_ref -> to_owned unboxes the type
442440
} else {
443441
types.push(arg_captured.ty.clone());

0 commit comments

Comments
 (0)