Skip to content

Commit 832a525

Browse files
committed
Add debug assert.
1 parent fda0301 commit 832a525

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

compiler/rustc_ast_lowering/src/format.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,10 @@ fn expand_format_args<'hir>(
349349
return hir::ExprKind::Call(from_str, args);
350350
}
351351

352+
// It shouldn't be possible to have an empty literal here. Encoding an empty literal
353+
// would result in a single 0 byte, which marks the end of the template byte sequence.
354+
debug_assert!(!s.is_empty());
355+
352356
// Encode the literal in chunks of up to u16::MAX bytes, split at utf-8 boundaries.
353357
while !s.is_empty() {
354358
let len = s.floor_char_boundary(usize::from(u16::MAX));

0 commit comments

Comments
 (0)