Skip to content

Commit 799d988

Browse files
committed
Auto merge of #134628 - estebank:const-default, r=oli-obk
Make `Default` const and add some `const Default` impls Full list of `impl const Default` types: - () - bool - char - std::ascii::Char - usize - u8 - u16 - u32 - u64 - u128 - i8 - i16 - i32 - i64 - i128 - f16 - f32 - f64 - f128 - std::marker::PhantomData<T> - Option<T> - std::iter::Empty<T> - std::ptr::Alignment - &[T] - &mut [T] - &str - &mut str - String - Vec<T>
2 parents 21c9e22 + aa7b761 commit 799d988

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clippy_utils/src/visitors.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
use crate::msrvs::Msrv;
12
use crate::ty::needs_ordered_drop;
23
use crate::{get_enclosing_block, path_to_local_id};
4+
use crate::qualify_min_const_fn::is_stable_const_fn;
35
use core::ops::ControlFlow;
46
use rustc_ast::visit::{VisitorResult, try_visit};
57
use rustc_hir::def::{CtorKind, DefKind, Res};
@@ -343,13 +345,13 @@ pub fn is_const_evaluatable<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) ->
343345
.cx
344346
.qpath_res(p, hir_id)
345347
.opt_def_id()
346-
.is_some_and(|id| self.cx.tcx.is_const_fn(id)) => {},
348+
.is_some_and(|id| is_stable_const_fn(self.cx, id, Msrv::default())) => {},
347349
ExprKind::MethodCall(..)
348350
if self
349351
.cx
350352
.typeck_results()
351353
.type_dependent_def_id(e.hir_id)
352-
.is_some_and(|id| self.cx.tcx.is_const_fn(id)) => {},
354+
.is_some_and(|id| is_stable_const_fn(self.cx, id, Msrv::default())) => {},
353355
ExprKind::Binary(_, lhs, rhs)
354356
if self.cx.typeck_results().expr_ty(lhs).peel_refs().is_primitive_ty()
355357
&& self.cx.typeck_results().expr_ty(rhs).peel_refs().is_primitive_ty() => {},

0 commit comments

Comments
 (0)