Skip to content

Commit 2eba6bb

Browse files
Check drop is trivial before checking ty needs drop
1 parent 54eccd9 commit 2eba6bb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ impl Qualif for NeedsDrop {
147147
}
148148

149149
fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
150+
// Avoid selecting for simple cases, such as builtin types.
151+
if ty::util::is_trivially_const_drop(ty) {
152+
return false;
153+
}
154+
150155
ty.needs_drop(cx.tcx, cx.typing_env)
151156
}
152157

compiler/rustc_feature/src/unstable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ declare_features! (
426426
(unstable, const_async_blocks, "1.53.0", Some(85368)),
427427
/// Allows `const || {}` closures in const contexts.
428428
(incomplete, const_closures, "1.68.0", Some(106003)),
429-
/// Uwu
429+
/// Allows using `~const Destruct` bounds and calling drop impls in const contexts.
430430
(unstable, const_destruct, "CURRENT_RUSTC_VERSION", Some(133214)),
431431
/// Allows `for _ in _` loops in const contexts.
432432
(unstable, const_for, "1.56.0", Some(87575)),

0 commit comments

Comments
 (0)