Skip to content

Commit 3177a6f

Browse files
committed
Explain why we are using a Scalar and not a Pointer
1 parent 3fba811 commit 3177a6f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/librustc/mir/interpret/value.rs

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ pub enum ConstValue<'tcx> {
2323
Scalar(Scalar),
2424

2525
/// Used only for slices and strings (`&[T]`, `&str`, `*const [T]`, `*mut str`, `Box<str>`, ...)
26+
///
27+
/// Empty slices don't necessarily have an address backed by an `AllocId`, thus we also need to
28+
/// enable integer pointers. The `Scalar` type covers exactly those two cases. While we could
29+
/// create dummy-`AllocId`s, the additional code effort for the conversions doesn't seem worth
30+
/// it.
2631
Slice(Scalar, u64),
2732

2833
/// An allocation + offset into the allocation.

0 commit comments

Comments
 (0)