Skip to content

Commit 429deed

Browse files
committed
Port #[rustc_dummy]
1 parent 25cf7d1 commit 429deed

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ pub enum AttributeKind {
240240
/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
241241
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
242242

243+
/// Represents `#[rustc_dummy]`.
244+
Dummy,
245+
243246
/// Represents [`#[export_name]`](https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute).
244247
ExportName {
245248
/// The name to export this item with.

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ impl AttributeKind {
2525
ConstStabilityIndirect => No,
2626
Deprecation { .. } => Yes,
2727
DocComment { .. } => Yes,
28+
Dummy => No,
2829
ExportName { .. } => Yes,
2930
Ignore { .. } => No,
3031
Inline(..) => No,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
use rustc_attr_data_structures::AttributeKind;
2+
use rustc_feature::{AttributeTemplate, template};
3+
use rustc_span::{Symbol, sym};
4+
5+
use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
6+
use crate::context::{AcceptContext, Stage};
7+
use crate::parser::ArgParser;
8+
9+
pub(crate) struct DummyParser;
10+
impl<S: Stage> SingleAttributeParser<S> for DummyParser {
11+
const PATH: &[Symbol] = &[sym::rustc_dummy];
12+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
13+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Ignore;
14+
const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really
15+
16+
fn convert(_: &mut AcceptContext<'_, '_, S>, _: &ArgParser<'_>) -> Option<AttributeKind> {
17+
Some(AttributeKind::Dummy)
18+
}
19+
}

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ pub(crate) mod cfg;
3030
pub(crate) mod codegen_attrs;
3131
pub(crate) mod confusables;
3232
pub(crate) mod deprecation;
33+
pub(crate) mod dummy;
3334
pub(crate) mod inline;
3435
pub(crate) mod link_attrs;
3536
pub(crate) mod lint_helpers;

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use crate::attributes::codegen_attrs::{
2121
};
2222
use crate::attributes::confusables::ConfusablesParser;
2323
use crate::attributes::deprecation::DeprecationParser;
24+
use crate::attributes::dummy::DummyParser;
2425
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
2526
use crate::attributes::link_attrs::{LinkNameParser, LinkSectionParser};
2627
use crate::attributes::lint_helpers::{AsPtrParser, PassByValueParser, PubTransparentParser};
@@ -127,6 +128,7 @@ attribute_parsers!(
127128

128129
// tidy-alphabetical-start
129130
Single<DeprecationParser>,
131+
Single<DummyParser>,
130132
Single<ExportNameParser>,
131133
Single<IgnoreParser>,
132134
Single<InlineParser>,

compiler/rustc_passes/src/check_attr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
207207
Attribute::Parsed(
208208
AttributeKind::BodyStability { .. }
209209
| AttributeKind::ConstStabilityIndirect
210-
| AttributeKind::MacroTransparency(_),
210+
| AttributeKind::MacroTransparency(_)
211+
| AttributeKind::Dummy,
211212
) => { /* do nothing */ }
212213
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
213214
self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target)

0 commit comments

Comments
 (0)