Skip to content

Commit 5d23265

Browse files
committed
Port #[rustc_dummy]
1 parent 86e05cd commit 5d23265

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
@@ -242,6 +242,9 @@ pub enum AttributeKind {
242242
/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
243243
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
244244

245+
/// Represents `#[rustc_dummy]`.
246+
Dummy,
247+
245248
/// Represents [`#[export_name]`](https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute).
246249
ExportName {
247250
/// 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
@@ -22,6 +22,7 @@ impl AttributeKind {
2222
ConstStabilityIndirect => No,
2323
Deprecation { .. } => Yes,
2424
DocComment { .. } => Yes,
25+
Dummy => No,
2526
ExportName { .. } => Yes,
2627
Inline(..) => No,
2728
LinkSection { .. } => 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, PubTransparentParser};
@@ -123,6 +124,7 @@ attribute_parsers!(
123124
Single<ConstContinueParser>,
124125
Single<ConstStabilityIndirectParser>,
125126
Single<DeprecationParser>,
127+
Single<DummyParser>,
126128
Single<ExportNameParser>,
127129
Single<InlineParser>,
128130
Single<LinkNameParser>,

compiler/rustc_passes/src/check_attr.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
193193
Attribute::Parsed(
194194
AttributeKind::BodyStability { .. }
195195
| AttributeKind::ConstStabilityIndirect
196-
| AttributeKind::MacroTransparency(_),
196+
| AttributeKind::MacroTransparency(_)
197+
| AttributeKind::Dummy,
197198
) => { /* do nothing */ }
198199
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
199200
self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target)

0 commit comments

Comments
 (0)