]> git.lizzy.rs Git - rust.git/commitdiff
Fix ICE #1969
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 21 Aug 2017 10:57:33 +0000 (12:57 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Mon, 21 Aug 2017 10:57:33 +0000 (12:57 +0200)
clippy_lints/src/functions.rs
src/main.rs
tests/run-pass/ice-1969.rs [new file with mode: 0644]

index 1bb8780ea4afd3678fdcdc0d8f7a32547fbed34c..9d9bf38c39748915e4575851cfbcb3ce1e9147cb 100644 (file)
@@ -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 @@ fn check_raw_ptr(
                 .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 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
                 }
             },
             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) {
index 8e92eb55ff09385a6f1bacad20277af6259e5e25..8e8ed032c1fe4638c7297ae33d69e94f9019c503 100644 (file)
@@ -30,7 +30,7 @@ struct ClippyCompilerCalls {
 
 impl ClippyCompilerCalls {
     fn new(run_lints: bool) -> Self {
-        ClippyCompilerCalls {
+        Self {
             default: RustcDefaultCalls,
             run_lints: run_lints,
         }
diff --git a/tests/run-pass/ice-1969.rs b/tests/run-pass/ice-1969.rs
new file mode 100644 (file)
index 0000000..23a002a
--- /dev/null
@@ -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()
+    }
+}