Skip to content

Commit 061b906

Browse files
Return false from needs_drop for all zero-sized arrays
1 parent c27f756 commit 061b906

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/librustc/ty/util.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,9 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>
10961096

10971097
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
10981098

1099+
// Zero-length arrays never contain anything to drop.
1100+
ty::Array(_, len) if len.try_eval_usize(tcx, param_env) == Some(0) => false,
1101+
10991102
// Structural recursion.
11001103
ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty),
11011104

0 commit comments

Comments
 (0)