-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #91504 - cynecx:used_retain, r=nikic
`#[used(linker)]` attribute See dtolnay/linkme#41 (comment).
- Loading branch information
Showing
16 changed files
with
182 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![crate_type = "lib"] | ||
#![feature(used_with_arg)] | ||
|
||
// CHECK: @llvm.used = appending global [1 x i8*]{{.*}}USED_LINKER | ||
#[used(linker)] | ||
static mut USED_LINKER: [usize; 1] = [0]; | ||
|
||
// CHECK-NEXT: @llvm.compiler.used = appending global [1 x i8*]{{.*}}USED_COMPILER | ||
#[used(compiler)] | ||
static mut USED_COMPILER: [usize; 1] = [0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
21 changes: 21 additions & 0 deletions
21
src/test/ui/feature-gates/feature-gate-used_with_arg.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |