mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-23 21:23:20 +00:00
Replace tabs by spaces
This commit is contained in:
parent
b8cdefb6cf
commit
40e180d8c7
@ -23,28 +23,28 @@ impl LintPass for UnnecessaryMutPassed {
|
||||
impl LateLintPass for UnnecessaryMutPassed {
|
||||
fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
|
||||
if let &ExprCall(ref fn_expr, ref arguments) = &e.node {
|
||||
let borrowed_table = cx.tcx.tables.borrow();
|
||||
let funtion_type = match borrowed_table.node_types.get(&fn_expr.id) {
|
||||
Some(funtion_type) => funtion_type,
|
||||
None => unreachable!(), // A function with unknown type is called.
|
||||
// If this happened the compiler would have aborted the
|
||||
// compilation long ago.
|
||||
};
|
||||
let borrowed_table = cx.tcx.tables.borrow();
|
||||
let funtion_type = match borrowed_table.node_types.get(&fn_expr.id) {
|
||||
Some(funtion_type) => funtion_type,
|
||||
None => unreachable!(), // A function with unknown type is called.
|
||||
// If this happened the compiler would have aborted the
|
||||
// compilation long ago.
|
||||
};
|
||||
if let TypeVariants::TyBareFn(_, ref b) = funtion_type.sty {
|
||||
let parameters = b.sig.skip_binder().inputs.clone();
|
||||
for (argument, parameter) in arguments.iter().zip(parameters.iter()) {
|
||||
match parameter.sty {
|
||||
TypeVariants::TyRef(_, TypeAndMut {ty: _, mutbl: MutImmutable}) |
|
||||
TypeVariants::TyRawPtr(TypeAndMut {ty: _, mutbl: MutImmutable}) => {
|
||||
if let Expr_::ExprAddrOf(MutMutable, _) = argument.node {
|
||||
if let ExprPath(_, path) = fn_expr.node.clone() {
|
||||
span_lint(cx, UNNECESSARY_MUT_PASSED,
|
||||
TypeVariants::TyRef(_, TypeAndMut {ty: _, mutbl: MutImmutable}) |
|
||||
TypeVariants::TyRawPtr(TypeAndMut {ty: _, mutbl: MutImmutable}) => {
|
||||
if let Expr_::ExprAddrOf(MutMutable, _) = argument.node {
|
||||
if let ExprPath(_, path) = fn_expr.node.clone() {
|
||||
span_lint(cx, UNNECESSARY_MUT_PASSED,
|
||||
argument.span, &format!("This argument of the \
|
||||
function \"{}\" doesn't need to be mutable", path));
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user