Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ impl ReprOptions {
self.flags.contains(ReprFlags::IS_C)
}

/// Returns whether this is (implicitly or explicitly) `repr(Rust)`, i.e., its layout
/// is defined by Rust and we make no stable commitments.
#[inline]
pub fn rust(&self) -> bool {
// `linear` is currently just an internal flag we set on Box; that's still `repr(Rust)`.
!self.c() & !self.simd() & !self.scalable() & !self.transparent()
}

#[inline]
pub fn packed(&self) -> bool {
self.pack.is_some()
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_const_eval/src/interpret/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
} else if adt_def.repr().c() {
interp_ok(false)
} else {
// Must be repr(Rust).
// Can't be SIMD or Scalable (since this is a 1-ZST); only Rust is left.
assert!(adt_def.repr().rust());
interp_ok(true)
}
}
Expand Down
Loading