diff options
| author | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-08-24 19:44:12 +0300 |
|---|---|---|
| committer | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-08-24 23:05:37 +0300 |
| commit | b9033bdd92aa697dee77fa581c22d418b5bdf308 (patch) | |
| tree | 9a92a061019c58bfc0c7fa323c0a6842c25fff2a /compiler/rustc_passes/src | |
| parent | f167efad2f51088d86180ee89177b3d7c9e7c2f5 (diff) | |
| download | rust-b9033bdd92aa697dee77fa581c22d418b5bdf308.tar.gz rust-b9033bdd92aa697dee77fa581c22d418b5bdf308.zip | |
New `#[rustc_pub_transparent]` attribute
Diffstat (limited to 'compiler/rustc_passes/src')
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/errors.rs | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index c93fb5c23b1..9ca4bb09b3e 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -245,6 +245,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { self.check_coroutine(attr, target); } [sym::linkage, ..] => self.check_linkage(attr, span, target), + [sym::rustc_pub_transparent, ..] => self.check_rustc_pub_transparent( attr.span, span, attrs), [ // ok sym::allow @@ -2381,6 +2382,18 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } } + + fn check_rustc_pub_transparent(&self, attr_span: Span, span: Span, attrs: &[Attribute]) { + if !attrs + .iter() + .filter(|attr| attr.has_name(sym::repr)) + .filter_map(|attr| attr.meta_item_list()) + .flatten() + .any(|nmi| nmi.has_name(sym::transparent)) + { + self.dcx().emit_err(errors::RustcPubTransparent { span, attr_span }); + } + } } impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> { diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs index 1190e60f41f..f6a57b7d098 100644 --- a/compiler/rustc_passes/src/errors.rs +++ b/compiler/rustc_passes/src/errors.rs @@ -623,6 +623,15 @@ pub struct RustcStdInternalSymbol { } #[derive(Diagnostic)] +#[diag(passes_rustc_pub_transparent)] +pub struct RustcPubTransparent { + #[primary_span] + pub attr_span: Span, + #[label] + pub span: Span, +} + +#[derive(Diagnostic)] #[diag(passes_link_ordinal)] pub struct LinkOrdinal { #[primary_span] |
