Skip to content

Commit 84cdff7

Browse files
committed
Port #[link_ordinal] to the new attribute parsing infrastructure.
1 parent b85d685 commit 84cdff7

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

compiler/rustc_attr_parsing/src/attributes/link_attrs.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use rustc_span::{Symbol, sym};
77
use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
88
use crate::context::{AcceptContext, Stage};
99
use crate::parser::ArgParser;
10-
use crate::session_diagnostics::{InvalidLinkOrdinalFormat, LinkOrdinalOutOfRange};
11-
use crate::session_diagnostics::NullOnLinkSection;
10+
use crate::session_diagnostics::{
11+
InvalidLinkOrdinalFormat, LinkOrdinalOutOfRange, NullOnLinkSection,
12+
};
1213

1314
pub(crate) struct LinkNameParser;
1415

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use crate::attributes::codegen_attrs::{
2222
use crate::attributes::confusables::ConfusablesParser;
2323
use crate::attributes::deprecation::DeprecationParser;
2424
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
25-
use crate::attributes::link_attrs::{LinkNameParser, LinkSectionParser, LinkOrdinalParser};
26-
use crate::attributes::lint_helpers::{AsPtrParser, PubTransparentParser, PassByValueParser};
25+
use crate::attributes::link_attrs::{LinkNameParser, LinkOrdinalParser, LinkSectionParser};
26+
use crate::attributes::lint_helpers::{AsPtrParser, PassByValueParser, PubTransparentParser};
2727
use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser};
2828
use crate::attributes::must_use::MustUseParser;
2929
use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser;

compiler/rustc_parse/src/validate_attr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ fn emit_malformed_attribute(
307307
| sym::ignore
308308
| sym::must_use
309309
| sym::track_caller
310+
| sym::link_ordinal
310311
| sym::link_name
311312
| sym::export_name
312313
| sym::rustc_macro_transparency

tests/ui/attributes/malformed-attrs.stderr

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,6 @@ error: malformed `ffi_pure` attribute input
146146
LL | #[unsafe(ffi_pure = 1)]
147147
| ^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[ffi_pure]`
148148

149-
error: malformed `link_ordinal` attribute input
150-
--> $DIR/malformed-attrs.rs:167:5
151-
|
152-
LL | #[link_ordinal]
153-
| ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_ordinal(ordinal)]`
154-
155149
error: malformed `ffi_const` attribute input
156150
--> $DIR/malformed-attrs.rs:171:5
157151
|
@@ -537,6 +531,15 @@ LL | #[rustc_layout_scalar_valid_range_end]
537531
| expected this to be a list
538532
| help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
539533

534+
error[E0539]: malformed `link_ordinal` attribute input
535+
--> $DIR/malformed-attrs.rs:167:5
536+
|
537+
LL | #[link_ordinal]
538+
| ^^^^^^^^^^^^^^^
539+
| |
540+
| expected this to be a list
541+
| help: must be of the form: `#[link_ordinal(ordinal)]`
542+
540543
error[E0565]: malformed `non_exhaustive` attribute input
541544
--> $DIR/malformed-attrs.rs:197:1
542545
|

0 commit comments

Comments
 (0)