-
Notifications
You must be signed in to change notification settings - Fork 13.4k
#[used(linker)]
attribute
#91504
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
#[used(linker)]
attribute
#91504
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
03733ca
`#[used(linker)]` attribute (https://github.com/dtolnay/linkme/issues…
cynecx e075586
add tests and fix comments
cynecx 438826f
add more tests and make used(linker/compiler) mutually exclusive
cynecx 933963e
Add tracking issue
nikic 1705933
Move tests into attributes directory to pacify tidy
nikic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.