]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/large_stack_arrays.rs
Auto merge of #6278 - ThibsG:DerefAddrOf, r=llogiq
[rust.git] / clippy_lints / src / large_stack_arrays.rs
index aa394c85e308c91d67d4023bd35a156275802828..9fd3780e14e04023423491d9c94cac1994de5b3a 100644 (file)
@@ -1,7 +1,7 @@
-use rustc::mir::interpret::ConstValue;
-use rustc::ty::{self, ConstKind};
-use rustc_hir::*;
+use rustc_hir::{Expr, ExprKind};
 use rustc_lint::{LateContext, LateLintPass};
+use rustc_middle::mir::interpret::ConstValue;
+use rustc_middle::ty::{self, ConstKind};
 use rustc_session::{declare_tool_lint, impl_lint_pass};
 
 use if_chain::if_chain;
@@ -38,11 +38,11 @@ pub fn new(maximum_allowed_size: u64) -> Self {
 
 impl_lint_pass!(LargeStackArrays => [LARGE_STACK_ARRAYS]);
 
-impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeStackArrays {
-    fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
+impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
+    fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
         if_chain! {
             if let ExprKind::Repeat(_, _) = expr.kind;
-            if let ty::Array(element_type, cst) = cx.tables.expr_ty(expr).kind;
+            if let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind();
             if let ConstKind::Value(val) = cst.val;
             if let ConstValue::Scalar(element_count) = val;
             if let Ok(element_count) = element_count.to_machine_usize(&cx.tcx);
@@ -57,6 +57,7 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
                         "allocating a local array larger than {} bytes",
                         self.maximum_allowed_size
                     ),
+                    None,
                     &format!(
                         "consider allocating on the heap with `vec!{}.into_boxed_slice()`",
                         snippet(cx, expr.span, "[...]")