diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-09 23:29:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-09 23:29:56 +0100 |
| commit | 3f4aaf4f2e9fd49736e660475f446619e8734e09 (patch) | |
| tree | ee6ff4aed191d3baab16454560fe605299af423c /src/test/ui | |
| parent | 9634559599537e334cbfa854446d048e6ebe5ee9 (diff) | |
| parent | 170593313a6ac2206107ec52a0d3bb9cc873a97c (diff) | |
| download | rust-3f4aaf4f2e9fd49736e660475f446619e8734e09.tar.gz rust-3f4aaf4f2e9fd49736e660475f446619e8734e09.zip | |
Rollup merge of #91504 - cynecx:used_retain, r=nikic
`#[used(linker)]` attribute See https://github.com/dtolnay/linkme/issues/41#issuecomment-927255631.
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/attributes/used_with_arg.rs | 19 | ||||
| -rw-r--r-- | src/test/ui/attributes/used_with_arg.stderr | 18 | ||||
| -rw-r--r-- | src/test/ui/attributes/used_with_multi_args.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/attributes/used_with_multi_args.stderr | 8 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-used_with_arg.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-used_with_arg.stderr | 21 |
6 files changed, 79 insertions, 0 deletions
diff --git a/src/test/ui/attributes/used_with_arg.rs b/src/test/ui/attributes/used_with_arg.rs new file mode 100644 index 00000000000..ad80ff53f0e --- /dev/null +++ b/src/test/ui/attributes/used_with_arg.rs @@ -0,0 +1,19 @@ +#![feature(used_with_arg)] + +#[used(linker)] +static mut USED_LINKER: [usize; 1] = [0]; + +#[used(compiler)] +static mut USED_COMPILER: [usize; 1] = [0]; + +#[used(compiler)] //~ ERROR `used(compiler)` and `used(linker)` can't be used together +#[used(linker)] +static mut USED_COMPILER_LINKER2: [usize; 1] = [0]; + +#[used(compiler)] //~ ERROR `used(compiler)` and `used(linker)` can't be used together +#[used(linker)] +#[used(compiler)] +#[used(linker)] +static mut USED_COMPILER_LINKER3: [usize; 1] = [0]; + +fn main() {} diff --git a/src/test/ui/attributes/used_with_arg.stderr b/src/test/ui/attributes/used_with_arg.stderr new file mode 100644 index 00000000000..440e5c4a5a0 --- /dev/null +++ b/src/test/ui/attributes/used_with_arg.stderr @@ -0,0 +1,18 @@ +error: `used(compiler)` and `used(linker)` can't be used together + --> $DIR/used_with_arg.rs:9:1 + | +LL | #[used(compiler)] + | ^^^^^^^^^^^^^^^^^ +LL | #[used(linker)] + | ^^^^^^^^^^^^^^^ + +error: `used(compiler)` and `used(linker)` can't be used together + --> $DIR/used_with_arg.rs:13:1 + | +LL | #[used(compiler)] + | ^^^^^^^^^^^^^^^^^ +LL | #[used(linker)] + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/attributes/used_with_multi_args.rs b/src/test/ui/attributes/used_with_multi_args.rs new file mode 100644 index 00000000000..2e17fcfd7a4 --- /dev/null +++ b/src/test/ui/attributes/used_with_multi_args.rs @@ -0,0 +1,6 @@ +#![feature(used_with_arg)] + +#[used(compiler, linker)] //~ expected `used`, `used(compiler)` or `used(linker)` +static mut USED_COMPILER_LINKER: [usize; 1] = [0]; + +fn main() {} diff --git a/src/test/ui/attributes/used_with_multi_args.stderr b/src/test/ui/attributes/used_with_multi_args.stderr new file mode 100644 index 00000000000..c93aafcfc7c --- /dev/null +++ b/src/test/ui/attributes/used_with_multi_args.stderr @@ -0,0 +1,8 @@ +error: expected `used`, `used(compiler)` or `used(linker)` + --> $DIR/used_with_multi_args.rs:3:1 + | +LL | #[used(compiler, linker)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/feature-gates/feature-gate-used_with_arg.rs b/src/test/ui/feature-gates/feature-gate-used_with_arg.rs new file mode 100644 index 00000000000..1c8f01bdef1 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-used_with_arg.rs @@ -0,0 +1,7 @@ +#[used(linker)] //~ ERROR `#[used(linker)]` is currently unstable +static mut USED_LINKER: [usize; 1] = [0]; + +#[used(compiler)] //~ ERROR `#[used(compiler)]` is currently unstable +static mut USED_COMPILER: [usize; 1] = [0]; + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-used_with_arg.stderr b/src/test/ui/feature-gates/feature-gate-used_with_arg.stderr new file mode 100644 index 00000000000..d115bf4e365 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-used_with_arg.stderr @@ -0,0 +1,21 @@ +error[E0658]: `#[used(linker)]` is currently unstable + --> $DIR/feature-gate-used_with_arg.rs:1:1 + | +LL | #[used(linker)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #93798 <https://github.com/rust-lang/rust/issues/93798> for more information + = help: add `#![feature(used_with_arg)]` to the crate attributes to enable + +error[E0658]: `#[used(compiler)]` is currently unstable + --> $DIR/feature-gate-used_with_arg.rs:4:1 + | +LL | #[used(compiler)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #93798 <https://github.com/rust-lang/rust/issues/93798> for more information + = help: add `#![feature(used_with_arg)]` to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. |
