-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
#[patchable_function_entries]
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
- Loading branch information
Showing
9 changed files
with
83 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
#![feature(patchable_function_entry)] | ||
// compile-flags: -Z patchable-function-entry=15,10 | ||
|
||
#![crate_type = "lib"] | ||
|
||
// This should have the default, as set by the compile flags | ||
#[no_mangle] | ||
pub fn foo() {} | ||
|
||
// The attribute should override the compile flags | ||
#[no_mangle] | ||
#[patchable_function_entry(prefix(1), entry(2))] | ||
pub fn bar() {} | ||
|
||
// If we override an attribute to 0 or unset, the attribute should go away | ||
#[no_mangle] | ||
#[patchable_function_entry(entry(0))] | ||
pub fn baz() {} | ||
|
||
// CHECK: @foo() unnamed_addr #0 | ||
// CHECK: @bar() unnamed_addr #1 | ||
// CHECK: @baz() unnamed_addr #2 | ||
|
||
// CHECK: attributes #0 = { {{.*}}"patchable-function-entry"="5"{{.*}}"patchable-function-prefix"="10" {{.*}} } | ||
// CHECK: attributes #1 = { {{.*}}"patchable-function-entry"="2"{{.*}}"patchable-function-prefix"="1" {{.*}} } | ||
// CHECK-NOT: attributes #2 = { {{.*}}patchable-function-entry{{.*}} } | ||
// CHECK-NOT: attributes #2 = { {{.*}}patchable-function-prefix{{.*}} } | ||
// CHECK: attributes #2 = { {{.*}} } |
3 changes: 3 additions & 0 deletions
3
tests/ui/feature-gates/feature-gate-patchable-function-entry.rs
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,3 @@ | ||
#[patchable_function_entry(entry(1), prefix(1))] | ||
//~^ ERROR: the `#[patchable_function_entry]` attribute is an experimental feature | ||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
tests/ui/feature-gates/feature-gate-patchable-function-entry.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,12 @@ | ||
error[E0658]: the `#[patchable_function_entry]` attribute is an experimental feature | ||
--> $DIR/feature-gate-patchable-function-entry.rs:1:1 | ||
| | ||
LL | #[patchable_function_entry(entry(1), prefix(1))] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #9999 <https://github.com/rust-lang/rust/issues/9999> for more information | ||
= help: add `#![feature(patchable_function_entry)]` to the crate attributes to enable | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |