diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-03-14 13:28:34 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-05-15 02:45:47 +0300 |
| commit | 4fa24bcb54cd11ec9c5e95d6d0ef366e512d27d6 (patch) | |
| tree | b4cdd23b4393d38383b89a25650f34dabf1ec378 /src | |
| parent | 70b3681bf621bc0de91ffab711b2350068b4c466 (diff) | |
| download | rust-4fa24bcb54cd11ec9c5e95d6d0ef366e512d27d6.tar.gz rust-4fa24bcb54cd11ec9c5e95d6d0ef366e512d27d6.zip | |
rustc: Stricter checking for #[link] attributes
Diffstat (limited to 'src')
54 files changed, 427 insertions, 191 deletions
diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md index 0d02fa7bd6b..d80e4f20869 100644 --- a/src/doc/rustc/src/command-line-arguments.md +++ b/src/doc/rustc/src/command-line-arguments.md @@ -52,7 +52,8 @@ where `KIND` may be one of: If the kind is specified, then linking modifiers can be attached to it. Modifiers are specified as a comma-delimited string with each modifier prefixed with either a `+` or `-` to indicate that the modifier is enabled or disabled, respectively. -The last boolean value specified for a given modifier wins. \ +Specifying multiple `modifiers` arguments in a single `link` attribute, +or multiple identical modifiers in the same `modifiers` argument is not currently supported. \ Example: `-l static:+whole-archive=mylib`. The kind of library and the modifiers can also be specified in a [`#[link]` diff --git a/src/test/ui/empty/empty-linkname.rs b/src/test/ui/empty/empty-linkname.rs index b64123389c2..7113d913cd0 100644 --- a/src/test/ui/empty/empty-linkname.rs +++ b/src/test/ui/empty/empty-linkname.rs @@ -1,4 +1,4 @@ -#[link(name = "")] //~ ERROR: given with empty name +#[link(name = "")] //~ ERROR: link name must not be empty extern "C" {} fn main() {} diff --git a/src/test/ui/empty/empty-linkname.stderr b/src/test/ui/empty/empty-linkname.stderr index b9d1841f16c..adcf3670d1d 100644 --- a/src/test/ui/empty/empty-linkname.stderr +++ b/src/test/ui/empty/empty-linkname.stderr @@ -1,8 +1,8 @@ -error[E0454]: `#[link(name = "")]` given with empty name - --> $DIR/empty-linkname.rs:1:1 +error[E0454]: link name must not be empty + --> $DIR/empty-linkname.rs:1:15 | LL | #[link(name = "")] - | ^^^^^^^^^^^^^^^^^^ empty name given + | ^^ empty link name error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0454.stderr b/src/test/ui/error-codes/E0454.stderr index 6b62bef112f..b9a506fee83 100644 --- a/src/test/ui/error-codes/E0454.stderr +++ b/src/test/ui/error-codes/E0454.stderr @@ -1,8 +1,8 @@ -error[E0454]: `#[link(name = "")]` given with empty name - --> $DIR/E0454.rs:1:1 +error[E0454]: link name must not be empty + --> $DIR/E0454.rs:1:15 | LL | #[link(name = "")] extern "C" {} - | ^^^^^^^^^^^^^^^^^^ empty name given + | ^^ empty link name error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0458.stderr b/src/test/ui/error-codes/E0458.stderr index 0f2fec029e7..e641bba541e 100644 --- a/src/test/ui/error-codes/E0458.stderr +++ b/src/test/ui/error-codes/E0458.stderr @@ -1,12 +1,10 @@ -error[E0458]: unknown kind: `wonderful_unicorn` - --> $DIR/E0458.rs:1:8 +error[E0458]: unknown link kind `wonderful_unicorn`, expected one of: static, dylib, framework, raw-dylib + --> $DIR/E0458.rs:1:15 | LL | #[link(kind = "wonderful_unicorn")] extern "C" {} - | -------^^^^^^^^^^^^^^^^^^^^^^^^^^-- - | | - | unknown kind + | ^^^^^^^^^^^^^^^^^^^ unknown link kind -error[E0459]: `#[link(...)]` specified without `name = "foo"` +error[E0459]: `#[link]` attribute requires a `name = "string"` argument --> $DIR/E0458.rs:1:1 | LL | #[link(kind = "wonderful_unicorn")] extern "C" {} diff --git a/src/test/ui/error-codes/E0459.stderr b/src/test/ui/error-codes/E0459.stderr index 4e0d51e8753..8f0dd25e030 100644 --- a/src/test/ui/error-codes/E0459.stderr +++ b/src/test/ui/error-codes/E0459.stderr @@ -1,4 +1,4 @@ -error[E0459]: `#[link(...)]` specified without `name = "foo"` +error[E0459]: `#[link]` attribute requires a `name = "string"` argument --> $DIR/E0459.rs:1:1 | LL | #[link(kind = "dylib")] extern "C" {} diff --git a/src/test/ui/feature-gates/feature-gate-link_cfg.stderr b/src/test/ui/feature-gates/feature-gate-link_cfg.stderr index 41a7dfc3f37..8f47d596521 100644 --- a/src/test/ui/feature-gates/feature-gate-link_cfg.stderr +++ b/src/test/ui/feature-gates/feature-gate-link_cfg.stderr @@ -1,8 +1,8 @@ -error[E0658]: kind="link_cfg" is unstable - --> $DIR/feature-gate-link_cfg.rs:1:1 +error[E0658]: link cfg is unstable + --> $DIR/feature-gate-link_cfg.rs:1:22 | LL | #[link(name = "foo", cfg(foo))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: see issue #37406 <https://github.com/rust-lang/rust/issues/37406> for more information = help: add `#![feature(link_cfg)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.rs b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.rs index fedee812398..132bc6ab04a 100644 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.rs +++ b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.rs @@ -1,5 +1,5 @@ -#[link(name = "foo", modifiers = "+as-needed")] -//~^ ERROR: `#[link(modifiers="as-needed")]` is unstable +#[link(name = "foo", kind = "dylib", modifiers = "+as-needed")] +//~^ ERROR: linking modifier `as-needed` is unstable extern "C" {} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.stderr b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.stderr index 96750aa6e80..2ef6a1c0404 100644 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.stderr +++ b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_as_needed.stderr @@ -1,8 +1,8 @@ -error[E0658]: `#[link(modifiers="as-needed")]` is unstable - --> $DIR/feature-gate-native_link_modifiers_as_needed.rs:1:34 +error[E0658]: linking modifier `as-needed` is unstable + --> $DIR/feature-gate-native_link_modifiers_as_needed.rs:1:50 | -LL | #[link(name = "foo", modifiers = "+as-needed")] - | ^^^^^^^^^^^^ +LL | #[link(name = "foo", kind = "dylib", modifiers = "+as-needed")] + | ^^^^^^^^^^^^ | = note: see issue #81490 <https://github.com/rust-lang/rust/issues/81490> for more information = help: add `#![feature(native_link_modifiers_as_needed)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.stderr b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.stderr index 900605c3b37..743bcc9a1b3 100644 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.stderr +++ b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle-3.stderr @@ -1,2 +1,2 @@ -error: bundle linking modifier is currently unstable and only accepted on the nightly compiler +error: linking modifier `bundle` is unstable and only accepted on the nightly compiler diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.rs b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.rs index c3c3cff17c4..c1d5a31aaa4 100644 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.rs +++ b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.rs @@ -1,5 +1,5 @@ -#[link(name = "foo", modifiers = "+bundle")] -//~^ ERROR: `#[link(modifiers="bundle")]` is unstable +#[link(name = "foo", kind = "static", modifiers = "+bundle")] +//~^ ERROR: linking modifier `bundle` is unstable extern "C" {} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.stderr b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.stderr index 984b90d9b6c..dcaa7fcc64f 100644 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.stderr +++ b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_bundle.stderr @@ -1,8 +1,8 @@ -error[E0658]: `#[link(modifiers="bundle")]` is unstable - --> $DIR/feature-gate-native_link_modifiers_bundle.rs:1:34 +error[E0658]: linking modifier `bundle` is unstable + --> $DIR/feature-gate-native_link_modifiers_bundle.rs:1:51 | -LL | #[link(name = "foo", modifiers = "+bundle")] - | ^^^^^^^^^ +LL | #[link(name = "foo", kind = "static", modifiers = "+bundle")] + | ^^^^^^^^^ | = note: see issue #81490 <https://github.com/rust-lang/rust/issues/81490> for more information = help: add `#![feature(native_link_modifiers_bundle)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.rs b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.rs index 57527be1112..7b09195dc3f 100644 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.rs +++ b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.rs @@ -1,5 +1,5 @@ #[link(name = "foo", modifiers = "+verbatim")] -//~^ ERROR: `#[link(modifiers="verbatim")]` is unstable +//~^ ERROR: linking modifier `verbatim` is unstable extern "C" {} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.stderr b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.stderr index 5c64c0d21bd..3bfbeb8db35 100644 --- a/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.stderr +++ b/src/test/ui/feature-gates/feature-gate-native_link_modifiers_verbatim.stderr @@ -1,4 +1,4 @@ -error[E0658]: `#[link(modifiers="verbatim")]` is unstable +error[E0658]: linking modifier `verbatim` is unstable --> $DIR/feature-gate-native_link_modifiers_verbatim.rs:1:34 | LL | #[link(name = "foo", modifiers = "+verbatim")] diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib.rs b/src/test/ui/feature-gates/feature-gate-raw-dylib.rs index 995d9ced480..f894f517b38 100644 --- a/src/test/ui/feature-gates/feature-gate-raw-dylib.rs +++ b/src/test/ui/feature-gates/feature-gate-raw-dylib.rs @@ -1,6 +1,6 @@ // only-windows #[link(name = "foo", kind = "raw-dylib")] -//~^ ERROR: kind="raw-dylib" is unstable +//~^ ERROR: link kind `raw-dylib` is unstable extern "C" {} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-raw-dylib.stderr b/src/test/ui/feature-gates/feature-gate-raw-dylib.stderr index bb64af38b2c..ca7a61f6413 100644 --- a/src/test/ui/feature-gates/feature-gate-raw-dylib.stderr +++ b/src/test/ui/feature-gates/feature-gate-raw-dylib.stderr @@ -1,8 +1,8 @@ -error[E0658]: kind="raw-dylib" is unstable - --> $DIR/feature-gate-raw-dylib.rs:2:1 +error[E0658]: link kind `raw-dylib` is unstable + --> $DIR/feature-gate-raw-dylib.rs:2:29 | LL | #[link(name = "foo", kind = "raw-dylib")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information = help: add `#![feature(raw_dylib)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr index 76c317f7410..782d9e39456 100644 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr +++ b/src/test/ui/feature-gates/feature-gate-static-nobundle-2.stderr @@ -1,2 +1,2 @@ -warning: library kind `static-nobundle` has been superseded by specifying `-bundle` on library kind `static`. Try `static:-bundle` +warning: library kind `static-nobundle` has been superseded by specifying modifier `-bundle` with library kind `static`. Try `static:-bundle` diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle.rs b/src/test/ui/feature-gates/feature-gate-static-nobundle.rs index e4bfe8e8e05..50f1b7ff3fc 100644 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle.rs +++ b/src/test/ui/feature-gates/feature-gate-static-nobundle.rs @@ -1,6 +1,6 @@ #[link(name = "foo", kind = "static-nobundle")] -//~^ WARNING: library kind `static-nobundle` has been superseded by specifying modifier `-bundle` with library kind `static` -//~^^ ERROR: kind="static-nobundle" is unstable +//~^ WARNING: link kind `static-nobundle` has been superseded by specifying modifier `-bundle` with link kind `static` +//~^^ ERROR: link kind `static-nobundle` is unstable extern "C" {} fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr b/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr index eaf2e0db511..094661aeb57 100644 --- a/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr +++ b/src/test/ui/feature-gates/feature-gate-static-nobundle.stderr @@ -1,14 +1,14 @@ -warning: library kind `static-nobundle` has been superseded by specifying modifier `-bundle` with library kind `static` - --> $DIR/feature-gate-static-nobundle.rs:1:22 +warning: link kind `static-nobundle` has been superseded by specifying modifier `-bundle` with link kind `static` + --> $DIR/feature-gate-static-nobundle.rs:1:29 | LL | #[link(name = "foo", kind = "static-nobundle")] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ -error[E0658]: kind="static-nobundle" is unstable - --> $DIR/feature-gate-static-nobundle.rs:1:22 +error[E0658]: link kind `static-nobundle` is unstable + --> $DIR/feature-gate-static-nobundle.rs:1:29 | LL | #[link(name = "foo", kind = "static-nobundle")] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ | = note: see issue #37403 <https://github.com/rust-lang/rust/issues/37403> for more information = help: add `#![feature(static_nobundle)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index b0e295178c8..d8d2eca570e 100644 --- a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -581,6 +581,10 @@ mod link { //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted //~| NOTE not an `extern` block + + #[link()] extern "Rust" {} + //~^ WARN attribute should be applied to an `extern` block + //~| WARN this was previously accepted } struct StructForDeprecated; diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index 2431957e539..cf9f89d8fde 100644 --- a/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -310,7 +310,7 @@ LL | | } | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to an `extern` block +warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:554:1 | LL | #[link()] @@ -328,55 +328,55 @@ LL | | } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: `#[must_use]` has no effect when applied to a module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:601:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:605:1 | LL | #[must_use] | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:614:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:618:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:635:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:639:1 | LL | #[crate_name = "0900"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:654:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:658:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:677:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:693:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:1 | LL | #[no_main] | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:1 | LL | #[no_builtins] | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:731:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:735:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:754:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -407,7 +407,7 @@ LL | #![cold] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to an `extern` block +warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:64:1 | LL | #![link()] @@ -863,7 +863,7 @@ LL | #[link_section = "1800"] impl S { } | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to an `extern` block +warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:560:17 | LL | mod inner { #![link()] } @@ -871,7 +871,7 @@ LL | mod inner { #![link()] } | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to an `extern` block +warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:565:5 | LL | #[link()] fn f() { } @@ -879,7 +879,7 @@ LL | #[link()] fn f() { } | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to an `extern` block +warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:570:5 | LL | #[link()] struct S; @@ -887,7 +887,7 @@ LL | #[link()] struct S; | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to an `extern` block +warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:575:5 | LL | #[link()] type T = S; @@ -895,7 +895,7 @@ LL | #[link()] type T = S; | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: attribute should be applied to an `extern` block +warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:580:5 | LL | #[link()] impl S { } @@ -903,260 +903,268 @@ LL | #[link()] impl S { } | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +warning: attribute should be applied to an `extern` block with non-Rust ABI + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:585:5 + | +LL | #[link()] extern "Rust" {} + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + warning: `#[must_use]` has no effect when applied to a module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:603:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:607:17 | LL | mod inner { #![must_use] } | ^^^^^^^^^^^^ warning: `#[must_use]` has no effect when applied to a type alias - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:609:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:613:5 | LL | #[must_use] type T = S; | ^^^^^^^^^^^ warning: `#[must_use]` has no effect when applied to an item - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:611:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:615:5 | LL | #[must_use] impl S { } | ^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:617:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:621:17 | LL | mod inner { #![windows_subsystem="windows"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:624:5 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:623:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:627:5 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:630:5 | LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:629:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:633:5 | LL | #[windows_subsystem = "windows"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:638:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:642:17 | LL | mod inner { #![crate_name="0900"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:641:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:645:5 | LL | #[crate_name = "0900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:644:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:648:5 | LL | #[crate_name = "0900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:647:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:5 | LL | #[crate_name = "0900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:650:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:654:5 | LL | #[crate_name = "0900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:657:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:661:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:660:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:664:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:663:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:667:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:666:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:670:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:669:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:676:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:680:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:683:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:682:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:686:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:689:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:692:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:696:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:699:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:702:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:705:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:709:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:708:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:719:17 | LL | mod inner { #![no_builtins] } | ^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:722:5 | LL | #[no_builtins] fn f() { } | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:725:5 | LL | #[no_builtins] struct S; | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:5 | LL | #[no_builtins] type T = S; | ^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:727:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:731:5 | LL | #[no_builtins] impl S { } | ^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:734:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:738:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:741:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:740:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:744:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:743:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:747:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:757:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:756:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:760:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:759:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:763:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:766:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:769:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1169,5 +1177,5 @@ LL | #![feature(rust1)] | = note: `#[warn(stable_features)]` on by default -warning: 172 warnings emitted +warning: 173 warnings emitted diff --git a/src/test/ui/issues/issue-43925.rs b/src/test/ui/issues/issue-43925.rs index 73d17928251..1a210887154 100644 --- a/src/test/ui/issues/issue-43925.rs +++ b/src/test/ui/issues/issue-43925.rs @@ -1,4 +1,4 @@ -#[link(name = "foo", cfg("rlib"))] //~ ERROR invalid argument for `cfg(..)` +#[link(name = "foo", cfg("rlib"))] //~ ERROR link cfg must have a single predicate argument extern "C" {} fn main() {} diff --git a/src/test/ui/issues/issue-43925.stderr b/src/test/ui/issues/issue-43925.stderr index 7bf64dc693c..b0ad25063de 100644 --- a/src/test/ui/issues/issue-43925.stderr +++ b/src/test/ui/issues/issue-43925.stderr @@ -1,8 +1,8 @@ -error: invalid argument for `cfg(..)` - --> $DIR/issue-43925.rs:1:26 +error: link cfg must have a single predicate argument + --> $DIR/issue-43925.rs:1:22 | LL | #[link(name = "foo", cfg("rlib"))] - | ^^^^^^ + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-43926.rs b/src/test/ui/issues/issue-43926.rs index 0171c12b1cc..6d3003552dc 100644 --- a/src/test/ui/issues/issue-43926.rs +++ b/src/test/ui/issues/issue-43926.rs @@ -1,4 +1,4 @@ -#[link(name = "foo", cfg())] //~ ERROR `cfg()` must have an argument +#[link(name = "foo", cfg())] //~ ERROR link cfg must have a single predicate argument extern "C" {} fn main() {} diff --git a/src/test/ui/issues/issue-43926.stderr b/src/test/ui/issues/issue-43926.stderr index d83e9bd7ed4..f67f91a6bd3 100644 --- a/src/test/ui/issues/issue-43926.stderr +++ b/src/test/ui/issues/issue-43926.stderr @@ -1,4 +1,4 @@ -error: `cfg()` must have an argument +error: link cfg must have a single predicate argument --> $DIR/issue-43926.rs:1:22 | LL | #[link(name = "foo", cfg())] diff --git a/src/test/ui/linkage-attr/bad-extern-link-attrs.rs b/src/test/ui/linkage-attr/bad-extern-link-attrs.rs deleted file mode 100644 index 43fe8c11d7c..00000000000 --- a/src/test/ui/linkage-attr/bad-extern-link-attrs.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[link()] //~ ERROR: specified without `name = -#[link(name = "")] //~ ERROR: with empty name -#[link(name = "foo")] -#[link(name = "foo", kind = "bar")] //~ ERROR: unknown kind -extern "C" {} - -fn main() {} diff --git a/src/test/ui/linkage-attr/bad-extern-link-attrs.stderr b/src/test/ui/linkage-attr/bad-extern-link-attrs.stderr deleted file mode 100644 index 525c605a9cf..00000000000 --- a/src/test/ui/linkage-attr/bad-extern-link-attrs.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0459]: `#[link(...)]` specified without `name = "foo"` - --> $DIR/bad-extern-link-attrs.rs:1:1 - | -LL | #[link()] - | ^^^^^^^^^ missing `name` argument - -error[E0454]: `#[link(name = "")]` given with empty name - --> $DIR/bad-extern-link-attrs.rs:2:1 - | -LL | #[link(name = "")] - | ^^^^^^^^^^^^^^^^^^ empty name given - -error[E0458]: unknown kind: `bar` - --> $DIR/bad-extern-link-attrs.rs:4:22 - | -LL | #[link(name = "foo", kind = "bar")] - | ---------------------^^^^^^^^^^^^-- - | | - | unknown kind - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0454, E0458, E0459. -For more information about an error, try `rustc --explain E0454`. diff --git a/src/test/ui/linkage-attr/link-attr-validation-early.rs b/src/test/ui/linkage-attr/link-attr-validation-early.rs new file mode 100644 index 00000000000..b9a835fb5e9 --- /dev/null +++ b/src/test/ui/linkage-attr/link-attr-validation-early.rs @@ -0,0 +1,8 @@ +// Top-level ill-formed +#[link] //~ ERROR attribute must be of the form + //~| WARN this was previously accepted +#[link = "foo"] //~ ERROR attribute must be of the form + //~| WARN this was previously accepted +extern "C" {} + +fn main() {} diff --git a/src/test/ui/linkage-attr/link-attr-validation-early.stderr b/src/test/ui/linkage-attr/link-attr-validation-early.stderr new file mode 100644 index 00000000000..d36601ed0b4 --- /dev/null +++ b/src/test/ui/linkage-attr/link-attr-validation-early.stderr @@ -0,0 +1,21 @@ +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...")]` + --> $DIR/link-attr-validation-early.rs:2:1 + | +LL | #[link] + | ^^^^^^^ + | + = note: `#[deny(ill_formed_attribute_input)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...")]` + --> $DIR/link-attr-validation-early.rs:4:1 + | +LL | #[link = "foo"] + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/linkage-attr/link-attr-validation-late.rs b/src/test/ui/linkage-attr/link-attr-validation-late.rs new file mode 100644 index 00000000000..b454fbd0ed1 --- /dev/null +++ b/src/test/ui/linkage-attr/link-attr-validation-late.rs @@ -0,0 +1,40 @@ +#![feature(native_link_modifiers_verbatim)] +#![feature(link_cfg)] + +// Top-level ill-formed +#[link(name = "...", "literal")] //~ ERROR unexpected `#[link]` argument +#[link(name = "...", unknown)] //~ ERROR unexpected `#[link]` argument +extern "C" {} + +// Duplicate arguments +#[link(name = "foo", name = "bar")] //~ ERROR multiple `name` arguments +#[link(name = "...", kind = "dylib", kind = "bar")] //~ ERROR multiple `kind` arguments +#[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] //~ ERROR multiple `modifiers` arguments +#[link(name = "...", cfg(FALSE), cfg(FALSE))] //~ ERROR multiple `cfg` arguments +#[link(wasm_import_module = "foo", wasm_import_module = "bar")] //~ ERROR multiple `wasm_import_module` arguments +extern "C" {} + +// Ill-formed arguments +#[link(name)] //~ ERROR link name must be of the form `name = "string"` + //~| ERROR `#[link]` attribute requires a `name = "string"` argument +#[link(name())] //~ ERROR link name must be of the form `name = "string"` + //~| ERROR `#[link]` attribute requires a `name = "string"` argument +#[link(name = "...", kind)] //~ ERROR link kind must be of the form `kind = "string"` +#[link(name = "...", kind())] //~ ERROR link kind must be of the form `kind = "string"` +#[link(name = "...", modifiers)] //~ ERROR link modifiers must be of the form `modifiers = "string"` +#[link(name = "...", modifiers())] //~ ERROR link modifiers must be of the form `modifiers = "string"` +#[link(name = "...", cfg)] //~ ERROR link cfg must be of the form `cfg(/* predicate */)` +#[link(name = "...", cfg = "literal")] //~ ERROR link cfg must be of the form `cfg(/* predicate */)` +#[link(name = "...", cfg("literal"))] //~ ERROR link cfg must have a single predicate argument +#[link(name = "...", wasm_import_module)] //~ ERROR wasm import module must be of the form `wasm_import_module = "string"` +#[link(name = "...", wasm_import_module())] //~ ERROR wasm import module must be of the form `wasm_import_module = "string"` +extern "C" {} + +// Basic modifier validation +#[link(name = "...", modifiers = "")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix +#[link(name = "...", modifiers = "no-plus-minus")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix +#[link(name = "...", modifiers = "+unknown")] //~ ERROR unknown linking modifier `unknown` +#[link(name = "...", modifiers = "+verbatim,+verbatim")] //~ ERROR multiple `verbatim` modifiers +extern "C" {} + +fn main() {} diff --git a/src/test/ui/linkage-attr/link-attr-validation-late.stderr b/src/test/ui/linkage-attr/link-attr-validation-late.stderr new file mode 100644 index 00000000000..bb08f9a4c02 --- /dev/null +++ b/src/test/ui/linkage-attr/link-attr-validation-late.stderr @@ -0,0 +1,147 @@ +error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module + --> $DIR/link-attr-validation-late.rs:5:22 + | +LL | #[link(name = "...", "literal")] + | ^^^^^^^^^ + +error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module + --> $DIR/link-attr-validation-late.rs:6:22 + | +LL | #[link(name = "...", unknown)] + | ^^^^^^^ + +error: multiple `name` arguments in a single `#[link]` attribute + --> $DIR/link-attr-validation-late.rs:10:22 + | +LL | #[link(name = "foo", name = "bar")] + | ^^^^^^^^^^^^ + +error: multiple `kind` arguments in a single `#[link]` attribute + --> $DIR/link-attr-validation-late.rs:11:38 + | +LL | #[link(name = "...", kind = "dylib", kind = "bar")] + | ^^^^^^^^^^^^ + +error: multiple `modifiers` arguments in a single `#[link]` attribute + --> $DIR/link-attr-validation-late.rs:12:47 + | +LL | #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] + | ^^^^^^^^^^^^^^^^^ + +error: multiple `cfg` arguments in a single `#[link]` attribute + --> $DIR/link-attr-validation-late.rs:13:34 + | +LL | #[link(name = "...", cfg(FALSE), cfg(FALSE))] + | ^^^^^^^^^^ + +error: multiple `wasm_import_module` arguments in a single `#[link]` attribute + --> $DIR/link-attr-validation-late.rs:14:36 + | +LL | #[link(wasm_import_module = "foo", wasm_import_module = "bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: link name must be of the form `name = "string"` + --> $DIR/link-attr-validation-late.rs:18:8 + | +LL | #[link(name)] + | ^^^^ + +error[E0459]: `#[link]` attribute requires a `name = "string"` argument + --> $DIR/link-attr-validation-late.rs:18:1 + | +LL | #[link(name)] + | ^^^^^^^^^^^^^ missing `name` argument + +error: link name must be of the form `name = "string"` + --> $DIR/link-attr-validation-late.rs:20:8 + | +LL | #[link(name())] + | ^^^^^^ + +error[E0459]: `#[link]` attribute requires a `name = "string"` argument + --> $DIR/link-attr-validation-late.rs:20:1 + | +LL | #[link(name())] + | ^^^^^^^^^^^^^^^ missing `name` argument + +error: link kind must be of the form `kind = "string"` + --> $DIR/link-attr-validation-late.rs:22:22 + | +LL | #[link(name = "...", kind)] + | ^^^^ + +error: link kind must be of the form `kind = "string"` + --> $DIR/link-attr-validation-late.rs:23:22 + | +LL | #[link(name = "...", kind())] + | ^^^^^^ + +error: link modifiers must be of the form `modifiers = "string"` + --> $DIR/link-attr-validation-late.rs:24:22 + | +LL | #[link(name = "...", modifiers)] + | ^^^^^^^^^ + +error: link modifiers must be of the form `modifiers = "string"` + --> $DIR/link-attr-validation-late.rs:25:22 + | +LL | #[link(name = "...", modifiers())] + | ^^^^^^^^^^^ + +error: link cfg must be of the form `cfg(/* predicate */)` + --> $DIR/link-attr-validation-late.rs:26:22 + | +LL | #[link(name = "...", cfg)] + | ^^^ + +error: link cfg must be of the form `cfg(/* predicate */)` + --> $DIR/link-attr-validation-late.rs:27:22 + | +LL | #[link(name = "...", cfg = "literal")] + | ^^^^^^^^^^^^^^^ + +error: link cfg must have a single predicate argument + --> $DIR/link-attr-validation-late.rs:28:22 + | +LL | #[link(name = "...", cfg("literal"))] + | ^^^^^^^^^^^^^^ + +error: wasm import module must be of the form `wasm_import_module = "string"` + --> $DIR/link-attr-validation-late.rs:29:22 + | +LL | #[link(name = "...", wasm_import_module)] + | ^^^^^^^^^^^^^^^^^^ + +error: wasm import module must be of the form `wasm_import_module = "string"` + --> $DIR/link-attr-validation-late.rs:30:22 + | +LL | #[link(name = "...", wasm_import_module())] + | ^^^^^^^^^^^^^^^^^^^^ + +error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed + --> $DIR/link-attr-validation-late.rs:34:34 + | +LL | #[link(name = "...", modifiers = "")] + | ^^ + +error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed + --> $DIR/link-attr-validation-late.rs:35:34 + | +LL | #[link(name = "...", modifiers = "no-plus-minus")] + | ^^^^^^^^^^^^^^^ + +error: unknown linking modifier `unknown`, expected one of: bundle, verbatim, whole-archive, as-needed + --> $DIR/link-attr-validation-late.rs:36:34 + | +LL | #[link(name = "...", modifiers = "+unknown")] + | ^^^^^^^^^^ + +error: multiple `verbatim` modifiers in a single `modifiers` argument + --> $DIR/link-attr-validation-late.rs:37:34 + | +LL | #[link(name = "...", modifiers = "+verbatim,+verbatim")] + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 24 previous errors + +For more information about this error, try `rustc --explain E0459`. diff --git a/src/test/ui/manual/manual-link-bad-form.rs b/src/test/ui/manual/manual-link-bad-form.rs index 9d092ae6db4..bc9b6be0294 100644 --- a/src/test/ui/manual/manual-link-bad-form.rs +++ b/src/test/ui/manual/manual-link-bad-form.rs @@ -1,5 +1,5 @@ // compile-flags:-l static= -// error-pattern: empty library name given via `-l` +// error-pattern: library name must not be empty fn main() { } diff --git a/src/test/ui/manual/manual-link-bad-form.stderr b/src/test/ui/manual/manual-link-bad-form.stderr index ed3c4c4fc4d..7fd7a1066b4 100644 --- a/src/test/ui/manual/manual-link-bad-form.stderr +++ b/src/test/ui/manual/manual-link-bad-form.stderr @@ -1,4 +1,2 @@ -error: empty library name given via `-l` - -error: aborting due to previous error +error: library name must not be empty diff --git a/src/test/ui/manual/manual-link-bad-kind.rs b/src/test/ui/manual/manual-link-bad-kind.rs index 86830a599b5..d1609338db6 100644 --- a/src/test/ui/manual/manual-link-bad-kind.rs +++ b/src/test/ui/manual/manual-link-bad-kind.rs @@ -1,5 +1,5 @@ // compile-flags:-l bar=foo -// error-pattern: unknown library kind `bar`, expected one of dylib, framework, or static +// error-pattern: unknown library kind `bar`, expected one of: static, dylib, framework fn main() { } diff --git a/src/test/ui/manual/manual-link-bad-kind.stderr b/src/test/ui/manual/manual-link-bad-kind.stderr index 03c33a97512..86146956699 100644 --- a/src/test/ui/manual/manual-link-bad-kind.stderr +++ b/src/test/ui/manual/manual-link-bad-kind.stderr @@ -1,2 +1,2 @@ -error: unknown library kind `bar`, expected one of dylib, framework, or static +error: unknown library kind `bar`, expected one of: static, dylib, framework diff --git a/src/test/ui/manual/manual-link-framework.rs b/src/test/ui/manual/manual-link-framework.rs index 0474526fcc1..57c5966e960 100644 --- a/src/test/ui/manual/manual-link-framework.rs +++ b/src/test/ui/manual/manual-link-framework.rs @@ -1,7 +1,7 @@ // ignore-macos // ignore-ios // compile-flags:-l framework=foo -// error-pattern: native frameworks are only available on macOS targets +// error-pattern: library kind `framework` is only supported on Apple targets fn main() { } diff --git a/src/test/ui/manual/manual-link-framework.stderr b/src/test/ui/manual/manual-link-framework.stderr index 3e8da8b2f93..de045d56c9c 100644 --- a/src/test/ui/manual/manual-link-framework.stderr +++ b/src/test/ui/manual/manual-link-framework.stderr @@ -1,4 +1,4 @@ -error: native frameworks are only available on macOS targets +error: library kind `framework` is only supported on Apple targets error: aborting due to previous error diff --git a/src/test/ui/manual/manual-link-unsupported-kind.rs b/src/test/ui/manual/manual-link-unsupported-kind.rs index 34814db593f..7a40186d504 100644 --- a/src/test/ui/manual/manual-link-unsupported-kind.rs +++ b/src/test/ui/manual/manual-link-unsupported-kind.rs @@ -1,5 +1,5 @@ // compile-flags:-l raw-dylib=foo -// error-pattern: unknown library kind `raw-dylib`, expected one of dylib, framework, or static +// error-pattern: unknown library kind `raw-dylib`, expected one of: static, dylib, framework fn main() { } diff --git a/src/test/ui/manual/manual-link-unsupported-kind.stderr b/src/test/ui/manual/manual-link-unsupported-kind.stderr index acb4463cb04..4965c0af5f2 100644 --- a/src/test/ui/manual/manual-link-unsupported-kind.stderr +++ b/src/test/ui/manual/manual-link-unsupported-kind.stderr @@ -1,2 +1,2 @@ -error: unknown library kind `raw-dylib`, expected one of dylib, framework, or static +error: unknown library kind `raw-dylib`, expected one of: static, dylib, framework diff --git a/src/test/ui/native-library-link-flags/empty-kind-1.rs b/src/test/ui/native-library-link-flags/empty-kind-1.rs index 6f93d38ca93..086d8cff957 100644 --- a/src/test/ui/native-library-link-flags/empty-kind-1.rs +++ b/src/test/ui/native-library-link-flags/empty-kind-1.rs @@ -1,6 +1,6 @@ // Unspecified kind should fail with an error // compile-flags: -l =mylib -// error-pattern: unknown library kind ``, expected one of dylib, framework, or static +// error-pattern: unknown library kind ``, expected one of: static, dylib, framework fn main() {} diff --git a/src/test/ui/native-library-link-flags/empty-kind-1.stderr b/src/test/ui/native-library-link-flags/empty-kind-1.stderr index 2a4a82d538f..37846c0b06f 100644 --- a/src/test/ui/native-library-link-flags/empty-kind-1.stderr +++ b/src/test/ui/native-library-link-flags/empty-kind-1.stderr @@ -1,2 +1,2 @@ -error: unknown library kind ``, expected one of dylib, framework, or static +error: unknown library kind ``, expected one of: static, dylib, framework diff --git a/src/test/ui/native-library-link-flags/empty-kind-2.rs b/src/test/ui/native-library-link-flags/empty-kind-2.rs index c0c35577057..45ec8ec85e3 100644 --- a/src/test/ui/native-library-link-flags/empty-kind-2.rs +++ b/src/test/ui/native-library-link-flags/empty-kind-2.rs @@ -1,6 +1,6 @@ // Unspecified kind should fail with an error // compile-flags: -l :+bundle=mylib -// error-pattern: unknown library kind ``, expected one of dylib, framework, or static +// error-pattern: unknown library kind ``, expected one of: static, dylib, framework fn main() {} diff --git a/src/test/ui/native-library-link-flags/empty-kind-2.stderr b/src/test/ui/native-library-link-flags/empty-kind-2.stderr index 2a4a82d538f..37846c0b06f 100644 --- a/src/test/ui/native-library-link-flags/empty-kind-2.stderr +++ b/src/test/ui/native-library-link-flags/empty-kind-2.stderr @@ -1,2 +1,2 @@ -error: unknown library kind ``, expected one of dylib, framework, or static +error: unknown library kind ``, expected one of: static, dylib, framework diff --git a/src/test/ui/native-library-link-flags/modifiers-override-2.stderr b/src/test/ui/native-library-link-flags/modifiers-override-2.stderr index 9200d7bfb0c..aa5b59c5b6f 100644 --- a/src/test/ui/native-library-link-flags/modifiers-override-2.stderr +++ b/src/test/ui/native-library-link-flags/modifiers-override-2.stderr @@ -1,2 +1,2 @@ -error: duplicating linking modifier is currently unstable and only accepted on the nightly compiler +error: multiple `whole-archive` modifiers in a single `-l` option diff --git a/src/test/ui/native-library-link-flags/modifiers-override.rs b/src/test/ui/native-library-link-flags/modifiers-override.rs index f6d770559e6..3912ac9f13d 100644 --- a/src/test/ui/native-library-link-flags/modifiers-override.rs +++ b/src/test/ui/native-library-link-flags/modifiers-override.rs @@ -3,12 +3,13 @@ #![feature(native_link_modifiers_bundle)] #[link(name = "foo")] -#[link( //~ ERROR multiple `modifiers` arguments in a single `#[link]` attribute +#[link( name = "bar", kind = "static", modifiers = "+whole-archive,-whole-archive", - //~^ ERROR same modifier is used multiple times in a single `modifiers` argument + //~^ ERROR multiple `whole-archive` modifiers in a single `modifiers` argument modifiers = "+bundle" + //~^ ERROR multiple `modifiers` arguments in a single `#[link]` attribute )] extern "C" {} //~^ ERROR overriding linking modifiers from command line is not supported diff --git a/src/test/ui/native-library-link-flags/modifiers-override.stderr b/src/test/ui/native-library-link-flags/modifiers-override.stderr index 8644d2382d2..55362910e71 100644 --- a/src/test/ui/native-library-link-flags/modifiers-override.stderr +++ b/src/test/ui/native-library-link-flags/modifiers-override.stderr @@ -1,29 +1,23 @@ -error: same modifier is used multiple times in a single `modifiers` argument - --> $DIR/modifiers-override.rs:9:5 +error: multiple `modifiers` arguments in a single `#[link]` attribute + --> $DIR/modifiers-override.rs:11:5 | -LL | modifiers = "+whole-archive,-whole-archive", - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | modifiers = "+bundle" + | ^^^^^^^^^^^^^^^^^^^^^ -error: multiple `modifiers` arguments in a single `#[link]` attribute - --> $DIR/modifiers-override.rs:6:1 +error: multiple `whole-archive` modifiers in a single `modifiers` argument + --> $DIR/modifiers-override.rs:9:17 | -LL | / #[link( -LL | | name = "bar", -LL | | kind = "static", -LL | | modifiers = "+whole-archive,-whole-archive", -LL | | -LL | | modifiers = "+bundle" -LL | | )] - | |__^ +LL | modifiers = "+whole-archive,-whole-archive", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: overriding linking modifiers from command line is not supported - --> $DIR/modifiers-override.rs:13:1 + --> $DIR/modifiers-override.rs:14:1 | LL | extern "C" {} | ^^^^^^^^^^^^^ error: overriding linking modifiers from command line is not supported - --> $DIR/modifiers-override.rs:13:1 + --> $DIR/modifiers-override.rs:14:1 | LL | extern "C" {} | ^^^^^^^^^^^^^ diff --git a/src/test/ui/osx-frameworks.rs b/src/test/ui/osx-frameworks.rs index 31b853e24fe..958183ec0d7 100644 --- a/src/test/ui/osx-frameworks.rs +++ b/src/test/ui/osx-frameworks.rs @@ -2,6 +2,6 @@ #[link(name = "foo", kind = "framework")] extern "C" {} -//~^^ ERROR: native frameworks are only available on macOS +//~^^ ERROR: link kind `framework` is only supported on Apple targets fn main() {} diff --git a/src/test/ui/osx-frameworks.stderr b/src/test/ui/osx-frameworks.stderr index f3532913423..e4a5c98dc5c 100644 --- a/src/test/ui/osx-frameworks.stderr +++ b/src/test/ui/osx-frameworks.stderr @@ -1,8 +1,8 @@ -error[E0455]: native frameworks are only available on macOS targets - --> $DIR/osx-frameworks.rs:3:1 +error[E0455]: link kind `framework` is only supported on Apple targets + --> $DIR/osx-frameworks.rs:3:29 | LL | #[link(name = "foo", kind = "framework")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/rfc-1717-dllimport/rename-modifiers.rs b/src/test/ui/rfc-1717-dllimport/rename-modifiers.rs new file mode 100644 index 00000000000..30f4db7180e --- /dev/null +++ b/src/test/ui/rfc-1717-dllimport/rename-modifiers.rs @@ -0,0 +1,9 @@ +// compile-flags: -l dylib=foo:bar +// error-pattern: overriding linking modifiers from command line is not supported + +#![feature(native_link_modifiers_as_needed)] + +#![crate_type = "lib"] + +#[link(name = "foo", kind = "dylib", modifiers = "-as-needed")] +extern "C" {} diff --git a/src/test/ui/rfc-1717-dllimport/rename-modifiers.stderr b/src/test/ui/rfc-1717-dllimport/rename-modifiers.stderr new file mode 100644 index 00000000000..bee639bf26c --- /dev/null +++ b/src/test/ui/rfc-1717-dllimport/rename-modifiers.stderr @@ -0,0 +1,8 @@ +error: overriding linking modifiers from command line is not supported + --> $DIR/rename-modifiers.rs:9:1 + | +LL | extern "C" {} + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs b/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs index 7a5d7ac2934..5856b18aa16 100644 --- a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs +++ b/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.rs @@ -3,5 +3,5 @@ #![feature(raw_dylib)] //~^ WARNING: the feature `raw_dylib` is incomplete #[link(name = "foo", kind = "raw-dylib")] -//~^ ERROR: `#[link(...)]` with `kind = "raw-dylib"` only supported on Windows +//~^ ERROR: link kind `raw-dylib` is only supported on Windows targets extern "C" {} diff --git a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr b/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr index f3879b63f91..600aac81a35 100644 --- a/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr +++ b/src/test/ui/rfc-2627-raw-dylib/raw-dylib-windows-only.stderr @@ -7,11 +7,12 @@ 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: `#[link(...)]` with `kind = "raw-dylib"` only supported on Windows - --> $DIR/raw-dylib-windows-only.rs:5:1 +error[E0455]: link kind `raw-dylib` is only supported on Windows targets + --> $DIR/raw-dylib-windows-only.rs:5:29 | LL | #[link(name = "foo", kind = "raw-dylib")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ error: aborting due to previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0455`. diff --git a/src/test/ui/wasm/wasm-import-module.rs b/src/test/ui/wasm/wasm-import-module.rs index 4152a1065ca..bff08847d37 100644 --- a/src/test/ui/wasm/wasm-import-module.rs +++ b/src/test/ui/wasm/wasm-import-module.rs @@ -1,3 +1,5 @@ +#![feature(link_cfg)] + #[link(name = "...", wasm_import_module)] //~ ERROR: must be of the form extern "C" {} @@ -7,4 +9,13 @@ extern "C" {} #[link(name = "...", wasm_import_module())] //~ ERROR: must be of the form extern "C" {} +#[link(wasm_import_module = "foo", name = "bar")] //~ ERROR: `wasm_import_module` is incompatible with other arguments +extern "C" {} + +#[link(wasm_import_module = "foo", kind = "dylib")] //~ ERROR: `wasm_import_module` is incompatible with other arguments +extern "C" {} + +#[link(wasm_import_module = "foo", cfg(FALSE))] //~ ERROR: `wasm_import_module` is incompatible with other arguments +extern "C" {} + fn main() {} diff --git a/src/test/ui/wasm/wasm-import-module.stderr b/src/test/ui/wasm/wasm-import-module.stderr index 47d6cb68997..e792c33e91a 100644 --- a/src/test/ui/wasm/wasm-import-module.stderr +++ b/src/test/ui/wasm/wasm-import-module.stderr @@ -1,20 +1,38 @@ -error: must be of the form `#[link(wasm_import_module = "...")]` - --> $DIR/wasm-import-module.rs:1:22 +error: wasm import module must be of the form `wasm_import_module = "string"` + --> $DIR/wasm-import-module.rs:3:22 | LL | #[link(name = "...", wasm_import_module)] | ^^^^^^^^^^^^^^^^^^ -error: must be of the form `#[link(wasm_import_module = "...")]` - --> $DIR/wasm-import-module.rs:4:22 +error: wasm import module must be of the form `wasm_import_module = "string"` + --> $DIR/wasm-import-module.rs:6:22 | LL | #[link(name = "...", wasm_import_module(x))] | ^^^^^^^^^^^^^^^^^^^^^ -error: must be of the form `#[link(wasm_import_module = "...")]` - --> $DIR/wasm-import-module.rs:7:22 +error: wasm import module must be of the form `wasm_import_module = "string"` + --> $DIR/wasm-import-module.rs:9:22 | LL | #[link(name = "...", wasm_import_module())] | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: `wasm_import_module` is incompatible with other arguments in `#[link]` attributes + --> $DIR/wasm-import-module.rs:12:8 + | +LL | #[link(wasm_import_module = "foo", name = "bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `wasm_import_module` is incompatible with other arguments in `#[link]` attributes + --> $DIR/wasm-import-module.rs:15:8 + | +LL | #[link(wasm_import_module = "foo", kind = "dylib")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `wasm_import_module` is incompatible with other arguments in `#[link]` attributes + --> $DIR/wasm-import-module.rs:18:8 + | +LL | #[link(wasm_import_module = "foo", cfg(FALSE))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors |
