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