Remove dependency on typeck from lint.
This commit is contained in:
parent
db75f8aa91
commit
adda9c1520
@ -28,9 +28,7 @@
|
||||
|
||||
use metadata::csearch;
|
||||
use middle::def::*;
|
||||
use middle::infer;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::typeck::astconv::ast_ty_to_ty;
|
||||
use middle::{def, pat_util, stability};
|
||||
use middle::const_eval::{eval_const_expr_partial, const_int, const_uint};
|
||||
use util::ppaux::{ty_to_string};
|
||||
@ -84,7 +82,7 @@ fn get_lints(&self) -> LintArray {
|
||||
|
||||
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
|
||||
if let ast::ExprCast(ref expr, ref ty) = e.node {
|
||||
let t_t = ast_ty_to_ty(cx, &infer::new_infer_ctxt(cx.tcx), &**ty);
|
||||
let t_t = ty::expr_ty(cx.tcx, e);
|
||||
if ty::expr_ty(cx.tcx, &**expr) == t_t {
|
||||
cx.span_lint(UNUSED_TYPECASTS, ty.span, "unnecessary type cast");
|
||||
}
|
||||
|
@ -25,18 +25,14 @@
|
||||
//! for all lint attributes.
|
||||
use self::TargetLint::*;
|
||||
|
||||
use middle::infer;
|
||||
use middle::privacy::ExportedItems;
|
||||
use middle::subst;
|
||||
use middle::ty::{mod, Ty};
|
||||
use middle::typeck::astconv::AstConv;
|
||||
use session::{early_error, Session};
|
||||
use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass, LintPassObject};
|
||||
use lint::{Default, CommandLine, Node, Allow, Warn, Deny, Forbid};
|
||||
use lint::builtin;
|
||||
use util::nodemap::FnvHashMap;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
use std::tuple::Tuple2;
|
||||
use std::mem;
|
||||
@ -541,42 +537,6 @@ fn visit_ids(&mut self, f: |&mut ast_util::IdVisitor<Context>|) {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> AstConv<'tcx> for Context<'a, 'tcx>{
|
||||
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> { self.tcx }
|
||||
|
||||
fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype<'tcx> {
|
||||
ty::lookup_item_type(self.tcx, id)
|
||||
}
|
||||
|
||||
fn get_trait_def(&self, id: ast::DefId) -> Rc<ty::TraitDef<'tcx>> {
|
||||
ty::lookup_trait_def(self.tcx, id)
|
||||
}
|
||||
|
||||
fn ty_infer(&self, _span: Span) -> Ty<'tcx> {
|
||||
infer::new_infer_ctxt(self.tcx).next_ty_var()
|
||||
}
|
||||
|
||||
fn associated_types_of_trait_are_valid(&self, _: Ty<'tcx>, _: ast::DefId)
|
||||
-> bool {
|
||||
// FIXME(pcwalton): This is wrong.
|
||||
true
|
||||
}
|
||||
|
||||
fn associated_type_binding(&self,
|
||||
_: Span,
|
||||
_: Option<Ty<'tcx>>,
|
||||
trait_id: ast::DefId,
|
||||
associated_type_id: ast::DefId)
|
||||
-> Ty<'tcx> {
|
||||
// FIXME(pcwalton): This is wrong.
|
||||
let trait_def = self.get_trait_def(trait_id);
|
||||
let index = ty::associated_type_parameter_index(self.tcx,
|
||||
&*trait_def,
|
||||
associated_type_id);
|
||||
ty::mk_param(self.tcx, subst::TypeSpace, index, associated_type_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
|
||||
fn visit_item(&mut self, it: &ast::Item) {
|
||||
self.with_lint_attrs(it.attrs.as_slice(), |cx| {
|
||||
|
Loading…
Reference in New Issue
Block a user