-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Reject linked dylib EII default overrides #156370
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
rust-bors
merged 6 commits into
rust-lang:main
from
qaijuang:eii-dylib-default-override
Jul 10, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b66097b
Move DuplicateEiiImpls to rustc_middle
qaijuang 0c82287
Reject linked dylib EII default overrides
qaijuang 53897bb
address a few nits
qaijuang f6ce3ba
preserve EII rlib-only aux builds
qaijuang 3378897
address suggestions
qaijuang 41bdaed
address follow up nits
qaijuang 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| //@ no-prefer-dynamic | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| #![crate_type = "rlib"] | ||
| #![feature(extern_item_impls)] | ||
|
|
||
|
|
||
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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| //@ no-prefer-dynamic | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and this |
||
| //@ aux-build: decl_with_default.rs | ||
| #![crate_type = "rlib"] | ||
| #![feature(extern_item_impls)] | ||
|
|
||
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 @@ | ||
| #![crate_type = "dylib"] | ||
| #![feature(extern_item_impls)] | ||
|
|
||
| #[eii(eii1)] | ||
| fn decl1(x: u64) {} |
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,20 @@ | ||
| //@ aux-build: dylib_default.rs | ||
| //@ needs-crate-type: dylib | ||
| //@ compile-flags: --emit link | ||
| //@ ignore-backends: gcc | ||
| // FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418 | ||
| //@ ignore-windows | ||
| // Regression test for https://github.com/rust-lang/rust/issues/156320. | ||
| // A default implementation from an upstream dylib has already been selected and | ||
| // must not be overridden by a downstream explicit implementation. | ||
| #![feature(extern_item_impls)] | ||
|
|
||
| extern crate dylib_default; | ||
|
|
||
| #[unsafe(dylib_default::eii1)] | ||
| fn other(x: u64) { | ||
| //~^ ERROR multiple implementations of `#[eii1]` | ||
| println!("1{x}"); | ||
| } | ||
|
|
||
| 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,15 @@ | ||
| error: multiple implementations of `#[eii1]` | ||
| --> $DIR/dylib_default_duplicate.rs:15:1 | ||
| | | ||
| LL | fn other(x: u64) { | ||
| | ^^^^^^^^^^^^^^^^ first implemented here in crate `dylib_default_duplicate` | ||
| | | ||
| ::: $DIR/auxiliary/dylib_default.rs:5:1 | ||
| | | ||
| LL | fn decl1(x: u64) {} | ||
| | ---------------- also implemented here in crate `dylib_default` | ||
| | | ||
| = help: an "externally implementable item" can only have a single implementation in the final artifact. When multiple implementations are found, also in different crates, they conflict | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As there can only be a single default impl, maybe you could add a new
Optionfielddefault_impltoEiiLinkageInfoand removeis_defaultfromEiiLinkageImplInfo? I think it would make the check in link.rs a bit clearer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done as suggested