]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/box_default.rs
Auto merge of #9870 - koka831:unformat-unused-rounding, r=Jarcho
[rust.git] / clippy_lints / src / box_default.rs
index f35a79dcc73905c11bbd6021b386ea1ba5677452..36daceabe0bea61a034aeac4dd894cbcff834eb0 100644 (file)
@@ -46,7 +46,7 @@ fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
             && !in_external_macro(cx.sess(), expr.span)
             && (expr.span.eq_ctxt(arg.span) || is_vec_expn(cx, arg))
             && seg.ident.name == sym::new
-            && path_def_id(cx, ty) == cx.tcx.lang_items().owned_box()
+            && path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box())
             && is_default_equivalent(cx, arg)
         {
             let arg_ty = cx.typeck_results().expr_ty(arg);
@@ -88,7 +88,7 @@ fn is_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
 
 impl<'tcx> Visitor<'tcx> for InferVisitor {
     fn visit_ty(&mut self, t: &rustc_hir::Ty<'_>) {
-        self.0 |= matches!(t.kind, TyKind::Infer);
+        self.0 |= matches!(t.kind, TyKind::Infer | TyKind::OpaqueDef(..) | TyKind::TraitObject(..));
         if !self.0 {
             walk_ty(self, t);
         }