link_ordinal is available for foreign static
This commit is contained in:
parent
4a5e83c939
commit
e614bbcd30
4 changed files with 21 additions and 8 deletions
|
@ -263,5 +263,5 @@ passes-rustc-lint-opt-ty = `#[rustc_lint_opt_ty]` should be applied to a struct
|
||||||
passes-rustc-lint-opt-deny-field-access = `#[rustc_lint_opt_deny_field_access]` should be applied to a field
|
passes-rustc-lint-opt-deny-field-access = `#[rustc_lint_opt_deny_field_access]` should be applied to a field
|
||||||
.label = not a field
|
.label = not a field
|
||||||
|
|
||||||
passes-link-ordinal = attribute should be applied to a foreign function
|
passes-link-ordinal = attribute should be applied to a foreign function or static
|
||||||
.label = not a foreign function
|
.label = not a foreign function or static
|
|
@ -1864,7 +1864,7 @@ impl CheckAttrVisitor<'_> {
|
||||||
|
|
||||||
fn check_link_ordinal(&self, attr: &Attribute, _span: Span, target: Target) -> bool {
|
fn check_link_ordinal(&self, attr: &Attribute, _span: Span, target: Target) -> bool {
|
||||||
match target {
|
match target {
|
||||||
Target::ForeignFn => true,
|
Target::ForeignFn | Target::ForeignStatic => true,
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx.sess.emit_err(errors::LinkOrdinal { attr_span: attr.span });
|
self.tcx.sess.emit_err(errors::LinkOrdinal { attr_span: attr.span });
|
||||||
false
|
false
|
||||||
|
|
|
@ -2,17 +2,24 @@
|
||||||
//~^ WARN the feature `raw_dylib` is incomplete
|
//~^ WARN the feature `raw_dylib` is incomplete
|
||||||
|
|
||||||
#[link_ordinal(123)]
|
#[link_ordinal(123)]
|
||||||
//~^ ERROR attribute should be applied to a foreign function
|
//~^ ERROR attribute should be applied to a foreign function or static
|
||||||
struct Foo {}
|
struct Foo {}
|
||||||
|
|
||||||
#[link_ordinal(123)]
|
#[link_ordinal(123)]
|
||||||
//~^ ERROR attribute should be applied to a foreign function
|
//~^ ERROR attribute should be applied to a foreign function or static
|
||||||
fn test() {}
|
fn test() {}
|
||||||
|
|
||||||
|
#[link_ordinal(42)]
|
||||||
|
//~^ ERROR attribute should be applied to a foreign function or static
|
||||||
|
static mut imported_val: i32 = 123;
|
||||||
|
|
||||||
#[link(name = "exporter", kind = "raw-dylib")]
|
#[link(name = "exporter", kind = "raw-dylib")]
|
||||||
extern {
|
extern {
|
||||||
#[link_ordinal(13)]
|
#[link_ordinal(13)]
|
||||||
fn imported_function();
|
fn imported_function();
|
||||||
|
|
||||||
|
#[link_ordinal(42)]
|
||||||
|
static mut imported_variable: i32;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -7,17 +7,23 @@ LL | #![feature(raw_dylib)]
|
||||||
= note: `#[warn(incomplete_features)]` on by default
|
= note: `#[warn(incomplete_features)]` on by default
|
||||||
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
|
= note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function
|
error: attribute should be applied to a foreign function or static
|
||||||
--> $DIR/link-ordinal-not-foreign-fn.rs:4:1
|
--> $DIR/link-ordinal-not-foreign-fn.rs:4:1
|
||||||
|
|
|
|
||||||
LL | #[link_ordinal(123)]
|
LL | #[link_ordinal(123)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function
|
error: attribute should be applied to a foreign function or static
|
||||||
--> $DIR/link-ordinal-not-foreign-fn.rs:8:1
|
--> $DIR/link-ordinal-not-foreign-fn.rs:8:1
|
||||||
|
|
|
|
||||||
LL | #[link_ordinal(123)]
|
LL | #[link_ordinal(123)]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors; 1 warning emitted
|
error: attribute should be applied to a foreign function or static
|
||||||
|
--> $DIR/link-ordinal-not-foreign-fn.rs:12:1
|
||||||
|
|
|
||||||
|
LL | #[link_ordinal(42)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors; 1 warning emitted
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue