Skip to content

Commit

Permalink
repr_transparent_external_private_fields: treat `rustc_pub_transparen…
Browse files Browse the repository at this point in the history
…t` types as local
  • Loading branch information
GrigorenkoPV committed Aug 24, 2024
1 parent b9033bd commit 06f2d73
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_hir_analysis/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,8 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
ty::Tuple(list) => list.iter().try_for_each(|t| check_non_exhaustive(tcx, t)),
ty::Array(ty, _) => check_non_exhaustive(tcx, *ty),
ty::Adt(def, args) => {
if !def.did().is_local() {
if !def.did().is_local() && !tcx.has_attr(def.did(), sym::rustc_pub_transparent)
{
let non_exhaustive = def.is_variant_list_non_exhaustive()
|| def
.variants()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//@ check-pass

#![feature(sync_unsafe_cell)]
#![allow(unused)]
#![deny(repr_transparent_external_private_fields)]

// https://github.com/rust-lang/rust/issues/129470

struct ZST;

#[repr(transparent)]
struct TransparentWithManuallyDropZST {
value: i32,
md: std::mem::ManuallyDrop<ZST>,
mu: std::mem::MaybeUninit<ZST>,
p: std::pin::Pin<ZST>,
pd: std::marker::PhantomData<ZST>,
pp: std::marker::PhantomPinned,
c: std::cell::Cell<ZST>,
uc: std::cell::UnsafeCell<ZST>,
suc: std::cell::SyncUnsafeCell<ZST>,
zst: ZST,
}

fn main() {}

0 comments on commit 06f2d73

Please sign in to comment.