Skip to content

Commit 06f2d73

Browse files
committed
repr_transparent_external_private_fields: treat rustc_pub_transparent types as local
1 parent b9033bd commit 06f2d73

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,8 @@ pub(super) fn check_transparent<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>)
12591259
ty::Tuple(list) => list.iter().try_for_each(|t| check_non_exhaustive(tcx, t)),
12601260
ty::Array(ty, _) => check_non_exhaustive(tcx, *ty),
12611261
ty::Adt(def, args) => {
1262-
if !def.did().is_local() {
1262+
if !def.did().is_local() && !tcx.has_attr(def.did(), sym::rustc_pub_transparent)
1263+
{
12631264
let non_exhaustive = def.is_variant_list_non_exhaustive()
12641265
|| def
12651266
.variants()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ check-pass
2+
3+
#![feature(sync_unsafe_cell)]
4+
#![allow(unused)]
5+
#![deny(repr_transparent_external_private_fields)]
6+
7+
// https://github.com/rust-lang/rust/issues/129470
8+
9+
struct ZST;
10+
11+
#[repr(transparent)]
12+
struct TransparentWithManuallyDropZST {
13+
value: i32,
14+
md: std::mem::ManuallyDrop<ZST>,
15+
mu: std::mem::MaybeUninit<ZST>,
16+
p: std::pin::Pin<ZST>,
17+
pd: std::marker::PhantomData<ZST>,
18+
pp: std::marker::PhantomPinned,
19+
c: std::cell::Cell<ZST>,
20+
uc: std::cell::UnsafeCell<ZST>,
21+
suc: std::cell::SyncUnsafeCell<ZST>,
22+
zst: ZST,
23+
}
24+
25+
fn main() {}

0 commit comments

Comments
 (0)