]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_utils/src/eager_or_lazy.rs
Change InferCtxtBuilder from enter to build
[rust.git] / src / tools / clippy / clippy_utils / src / eager_or_lazy.rs
index 91c9c382c236bcbc87c535976c33944fba629bf8..8724a4cd651debb4103aeb8f9541807ee204b953 100644 (file)
@@ -113,7 +113,17 @@ fn visit_expr(&mut self, e: &'tcx Expr<'_>) {
                     },
                     args,
                 ) => match self.cx.qpath_res(path, hir_id) {
-                    Res::Def(DefKind::Ctor(..) | DefKind::Variant, _) | Res::SelfCtor(_) => (),
+                    Res::Def(DefKind::Ctor(..) | DefKind::Variant, _) | Res::SelfCtor(_) => {
+                        if self
+                            .cx
+                            .typeck_results()
+                            .expr_ty(e)
+                            .has_significant_drop(self.cx.tcx, self.cx.param_env)
+                        {
+                            self.eagerness = Lazy;
+                            return;
+                        }
+                    },
                     Res::Def(_, id) if self.cx.tcx.is_promotable_const_fn(id) => (),
                     // No need to walk the arguments here, `is_const_evaluatable` already did
                     Res::Def(..) if is_const_evaluatable(self.cx, e) => {