-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Support defaults for static EIIs #156583
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
Support defaults for static EIIs #156583
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| //@ no-prefer-dynamic | ||
| #![crate_type = "rlib"] | ||
| #![feature(extern_item_impls)] | ||
|
|
||
| #[eii(eii1)] | ||
| pub static DECL1: u64 = 5; |
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,9 @@ | ||
| //@ no-prefer-dynamic | ||
| //@ aux-build: decl_with_default.rs | ||
| #![crate_type = "rlib"] | ||
| #![feature(extern_item_impls)] | ||
|
|
||
| extern crate decl_with_default as decl; | ||
|
|
||
| #[decl::eii1] | ||
| pub static EII1_IMPL: u64 = 10; |
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,17 @@ | ||
| //@ run-pass | ||
| //@ check-run-results | ||
| //@ ignore-backends: gcc | ||
| // FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418 | ||
| //@ ignore-windows | ||
| // FIXME(#157649): static EII defaults currently fail to link on Apple targets. | ||
| //@ ignore-apple | ||
| // Tests static EIIs with default implementations. | ||
|
|
||
| #![feature(extern_item_impls)] | ||
|
|
||
| #[eii(eii1)] | ||
| pub static DECL1: u64 = 5; | ||
|
|
||
| fn main() { | ||
| println!("{DECL1}"); | ||
| } |
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 @@ | ||
| 5 |
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 @@ | ||
| //@ only-apple | ||
| //@ ignore-backends: gcc | ||
|
|
||
| #![feature(extern_item_impls)] | ||
| #![crate_type = "lib"] | ||
| #[eii(eii1)] | ||
| pub static DECL1: u64 = 5; | ||
| //~^ ERROR `#[eii]` cannot be used on statics with a value on Apple targets |
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 @@ | ||
| error: `#[eii]` cannot be used on statics with a value on Apple targets | ||
| --> $DIR/default_apple.rs:7:25 | ||
| | | ||
| LL | pub static DECL1: u64 = 5; | ||
| | ^ | ||
| | | ||
| = note: see issue #157649 <https://github.com/rust-lang/rust/issues/157649> for more information | ||
|
|
||
| error: aborting due to 1 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,15 @@ | ||
| //@ aux-build: decl_with_default.rs | ||
| //@ run-pass | ||
| //@ check-run-results | ||
| //@ ignore-backends: gcc | ||
| // FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418 | ||
| //@ ignore-windows | ||
| // FIXME(#157649): static EII defaults currently fail to link on Apple targets. | ||
| //@ ignore-apple | ||
| // Tests that a static EII default can be used from another crate. | ||
|
|
||
| extern crate decl_with_default; | ||
|
|
||
| fn main() { | ||
| println!("{}", decl_with_default::DECL1); | ||
| } |
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 @@ | ||
| 5 |
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,17 @@ | ||
| //@ aux-build: decl_with_default.rs | ||
| //@ aux-build: impl_default_override.rs | ||
| //@ run-pass | ||
| //@ check-run-results | ||
| //@ ignore-backends: gcc | ||
| // FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418 | ||
| //@ ignore-windows | ||
| // FIXME(#157649): static EII defaults currently fail to link on Apple targets. | ||
| //@ ignore-apple | ||
| // Tests that an explicit static EII implementation overrides a cross-crate default. | ||
|
|
||
| extern crate decl_with_default; | ||
| extern crate impl_default_override; | ||
|
|
||
| fn main() { | ||
| println!("{}", decl_with_default::DECL1); | ||
| } |
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 |
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 @@ | ||
| //@ run-pass | ||
| //@ check-run-results | ||
| //@ ignore-backends: gcc | ||
| // FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418 | ||
| //@ ignore-windows | ||
| // FIXME(#157649): static EII defaults currently fail to link on Apple targets. | ||
| //@ ignore-apple | ||
| // Tests that an explicit static EII implementation overrides a local default. | ||
|
|
||
| #![feature(extern_item_impls)] | ||
| #![allow(dead_code)] | ||
|
|
||
| #[eii(eii1)] | ||
| pub static DECL1: u64 = 5; | ||
|
|
||
| #[eii1] | ||
| pub static EII1_IMPL: u64 = 10; | ||
|
|
||
| fn main() { | ||
| println!("{DECL1}"); | ||
| } |
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 |
Oops, something went wrong.
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.