Update link_ordinal duplicate attribute handling.

This removes the duplicate check, as this is now handled in a
centralized location.
This commit is contained in:
Eric Huss 2021-11-21 08:02:00 -08:00
parent 4c60ea8228
commit 36dcd4cbd9
3 changed files with 8 additions and 11 deletions

View File

@ -2865,14 +2865,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
} else if attr.has_name(sym::link_name) {
codegen_fn_attrs.link_name = attr.value_str();
} else if attr.has_name(sym::link_ordinal) {
if link_ordinal_span.is_some() {
tcx.sess
.struct_span_err(
attr.span,
"multiple `link_ordinal` attributes on a single definition",
)
.emit();
}
link_ordinal_span = Some(attr.span);
if let ordinal @ Some(_) = check_link_ordinal(tcx, attr) {
codegen_fn_attrs.link_ordinal = ordinal;

View File

@ -4,9 +4,8 @@
#[link(name = "foo", kind = "raw-dylib")]
extern "C" {
#[link_ordinal(1)]
#[link_ordinal(1)] //~ ERROR multiple `link_ordinal` attributes
#[link_ordinal(2)]
//~^ ERROR multiple `link_ordinal` attributes on a single definition
fn foo();
}

View File

@ -7,7 +7,13 @@ LL | #![feature(raw_dylib)]
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
error: multiple `link_ordinal` attributes on a single definition
error: multiple `link_ordinal` attributes
--> $DIR/link-ordinal-multiple.rs:7:5
|
LL | #[link_ordinal(1)]
| ^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/link-ordinal-multiple.rs:8:5
|
LL | #[link_ordinal(2)]