mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Fix ICE #1969
This commit is contained in:
parent
f1847f7a98
commit
56068b1b67
3 changed files with 20 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
use rustc::hir::intravisit;
|
||||
use rustc::hir;
|
||||
use rustc::lint::*;
|
||||
use rustc::ty;
|
||||
use std::collections::HashSet;
|
||||
use syntax::ast;
|
||||
use syntax::abi::Abi;
|
||||
|
@ -150,9 +151,11 @@ impl<'a, 'tcx> Functions {
|
|||
.collect::<HashSet<_>>();
|
||||
|
||||
if !raw_ptrs.is_empty() {
|
||||
let tables = cx.tcx.body_tables(body.id());
|
||||
let mut v = DerefVisitor {
|
||||
cx: cx,
|
||||
ptrs: raw_ptrs,
|
||||
tables,
|
||||
};
|
||||
|
||||
hir::intravisit::walk_expr(&mut v, expr);
|
||||
|
@ -172,13 +175,14 @@ fn raw_ptr_arg(arg: &hir::Arg, ty: &hir::Ty) -> Option<hir::def_id::DefId> {
|
|||
struct DerefVisitor<'a, 'tcx: 'a> {
|
||||
cx: &'a LateContext<'a, 'tcx>,
|
||||
ptrs: HashSet<hir::def_id::DefId>,
|
||||
tables: &'a ty::TypeckTables<'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
match expr.node {
|
||||
hir::ExprCall(ref f, ref args) => {
|
||||
let ty = self.cx.tables.expr_ty(f);
|
||||
let ty = self.tables.expr_ty(f);
|
||||
|
||||
if type_is_unsafe_function(self.cx, ty) {
|
||||
for arg in args {
|
||||
|
@ -187,7 +191,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
|
|||
}
|
||||
},
|
||||
hir::ExprMethodCall(_, _, ref args) => {
|
||||
let def_id = self.cx.tables.type_dependent_defs()[expr.hir_id].def_id();
|
||||
let def_id = self.tables.type_dependent_defs()[expr.hir_id].def_id();
|
||||
let base_type = self.cx.tcx.type_of(def_id);
|
||||
|
||||
if type_is_unsafe_function(self.cx, base_type) {
|
||||
|
|
|
@ -30,7 +30,7 @@ struct ClippyCompilerCalls {
|
|||
|
||||
impl ClippyCompilerCalls {
|
||||
fn new(run_lints: bool) -> Self {
|
||||
ClippyCompilerCalls {
|
||||
Self {
|
||||
default: RustcDefaultCalls,
|
||||
run_lints: run_lints,
|
||||
}
|
||||
|
|
13
tests/run-pass/ice-1969.rs
Normal file
13
tests/run-pass/ice-1969.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
#![feature(plugin)]
|
||||
#![plugin(clippy)]
|
||||
#![allow(clippy)]
|
||||
|
||||
fn main() { }
|
||||
|
||||
pub trait Convert {
|
||||
type Action: From<*const f64>;
|
||||
|
||||
fn convert(val: *const f64) -> Self::Action {
|
||||
val.into()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue