-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rustup to 2016-03-11 #754
Rustup to 2016-03-11 #754
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,21 +53,24 @@ impl LateLintPass for UnnecessaryMutPassed { | |
} | ||
|
||
fn check_arguments(cx: &LateContext, arguments: &[P<Expr>], type_definition: &TyS, name: &str) { | ||
if let TypeVariants::TyBareFn(_, ref fn_type) = type_definition.sty { | ||
let parameters = &fn_type.sig.skip_binder().inputs; | ||
for (argument, parameter) in arguments.iter().zip(parameters.iter()) { | ||
match parameter.sty { | ||
TypeVariants::TyRef(_, TypeAndMut {mutbl: MutImmutable, ..}) | | ||
TypeVariants::TyRawPtr(TypeAndMut {mutbl: MutImmutable, ..}) => { | ||
if let ExprAddrOf(MutMutable, _) = argument.node { | ||
span_lint(cx, | ||
UNNECESSARY_MUT_PASSED, | ||
argument.span, | ||
&format!("The function/method \"{}\" doesn't need a mutable reference", name)); | ||
match type_definition.sty { | ||
TypeVariants::TyFnDef(_, _, ref fn_type) | TypeVariants::TyFnPtr(ref fn_type) => { | ||
let parameters = &fn_type.sig.skip_binder().inputs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This panics for non-fn types:
with I guess: pub fn test2(foo: Box<Fn(Vec<u32>)>) { // pass if #31 is fixed
foo(vec![1, 2, 3])
} The matching just ignores them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's not a function call... that's an overloaded method and you need to do something completely different based on whether the method map has an entry. You should really handle that correctly, perhaps abstracting over it. |
||
for (argument, parameter) in arguments.iter().zip(parameters.iter()) { | ||
match parameter.sty { | ||
TypeVariants::TyRef(_, TypeAndMut {mutbl: MutImmutable, ..}) | | ||
TypeVariants::TyRawPtr(TypeAndMut {mutbl: MutImmutable, ..}) => { | ||
if let ExprAddrOf(MutMutable, _) = argument.node { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this code using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No idea, I was like that. I don’t dislike it. I left it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, but, it should be using |
||
span_lint(cx, | ||
UNNECESSARY_MUT_PASSED, | ||
argument.span, | ||
&format!("The function/method \"{}\" doesn't need a mutable reference", name)); | ||
} | ||
} | ||
_ => {} | ||
} | ||
_ => {} | ||
} | ||
} | ||
_ => (), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&TyS
isTy
...