Skip to content

Commit 6296fda

Browse files
committed
nits
1 parent e71b496 commit 6296fda

File tree

1 file changed

+8
-8
lines changed
  • compiler/rustc_hir_typeck/src/fn_ctxt

1 file changed

+8
-8
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
129129
}
130130

131131
// We want to emit an error if the const is not structurally resolveable as otherwise
132-
// we can find up conservatively proving `Copy` which may infer the repeat expr count
132+
// we can wind up conservatively proving `Copy` which may infer the repeat expr count
133133
// to something that never required `Copy` in the first place.
134134
let count = self
135135
.structurally_resolve_const(element.span, self.normalize(element.span, count));
@@ -178,14 +178,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
178178

179179
for (element, element_ty, count) in deferred_repeat_expr_checks {
180180
match count.kind() {
181-
ty::ConstKind::Value(val)
182-
if val.try_to_target_usize(self.tcx).is_none_or(|count| count > 1) =>
183-
{
184-
enforce_copy_bound(element, element_ty)
181+
ty::ConstKind::Value(val) => {
182+
if val.try_to_target_usize(self.tcx).is_none_or(|count| count > 1) {
183+
enforce_copy_bound(element, element_ty)
184+
} else {
185+
// If the length is 0 or 1 we don't actually copy the element, we either don't create it
186+
// or we just use the one value.
187+
}
185188
}
186-
// If the length is 0 or 1 we don't actually copy the element, we either don't create it
187-
// or we just use the one value.
188-
ty::ConstKind::Value(_) => (),
189189

190190
// If the length is a generic parameter or some rigid alias then conservatively
191191
// require `element_ty: Copy` as it may wind up being `>1` after monomorphization.

0 commit comments

Comments
 (0)