1
Fork 0

Finish rustup.

This commit is contained in:
Eduard-Mihai Burtescu 2017-06-05 00:28:01 +03:00
parent edef6c53c0
commit 010974fafe
12 changed files with 131 additions and 111 deletions

View file

@ -1,5 +1,6 @@
use rustc::lint::*;
use rustc::ty::{TypeAndMut, TypeVariants, TyS};
use rustc::ty::subst::Subst;
use rustc::hir::*;
use utils::span_lint;
@ -34,23 +35,19 @@ impl LintPass for UnnecessaryMutPassed {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
let borrowed_table = cx.tables;
match e.node {
ExprCall(ref fn_expr, ref arguments) => {
let function_type = borrowed_table.node_types
.get(&fn_expr.id)
.expect("A function with an unknown type is called. If this happened, the compiler would have \
aborted the compilation long ago");
if let ExprPath(ref path) = fn_expr.node {
check_arguments(cx,
arguments,
function_type,
cx.tables.expr_ty(fn_expr),
&print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)));
}
},
ExprMethodCall(ref name, _, ref arguments) => {
let def_id = borrowed_table.type_dependent_defs[&e.id].def_id();
let method_type = cx.tcx.type_of(def_id);
let def_id = cx.tables.type_dependent_defs[&e.id].def_id();
let substs = cx.tables.node_substs(e.id);
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
check_arguments(cx, arguments, method_type, &name.node.as_str())
},
_ => (),