New #[rustc_pub_transparent]
attribute
This commit is contained in:
parent
f167efad2f
commit
b9033bdd92
11 changed files with 86 additions and 0 deletions
|
@ -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> {
|
||||
|
|
|
@ -622,6 +622,15 @@ pub struct RustcStdInternalSymbol {
|
|||
pub span: Span,
|
||||
}
|
||||
|
||||
#[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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue