-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
Changes from 5 commits
b66097b
0c82287
53897bb
f6ce3ba
3378897
41bdaed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,7 +39,7 @@ use rustc_session::Session; | |
| use rustc_session::config::{CrateType, OutputFilenames, OutputType}; | ||
| use rustc_session::cstore::{self, CrateSource}; | ||
| use rustc_session::lint::builtin::LINKER_MESSAGES; | ||
| use rustc_span::Symbol; | ||
| use rustc_span::{Span, Symbol}; | ||
|
|
||
| pub mod assert_module_sources; | ||
| pub mod back; | ||
|
|
@@ -255,6 +255,19 @@ impl SymbolExport { | |
| } | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Encodable, Decodable)] | ||
| pub struct EiiLinkageImplInfo { | ||
| pub span: Span, | ||
| pub impl_crate: CrateNum, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Encodable, Decodable)] | ||
| pub struct EiiLinkageInfo { | ||
| pub name: Symbol, | ||
| pub impls: Vec<EiiLinkageImplInfo>, | ||
|
Member
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. As there can only be a single default impl, maybe you could add a new
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. Done as suggested |
||
| pub default_impl: Option<EiiLinkageImplInfo>, | ||
| } | ||
|
|
||
| /// Misc info we load from metadata to persist beyond the tcx. | ||
| /// | ||
| /// Note: though `CrateNum` is only meaningful within the same tcx, information within `CrateInfo` | ||
|
|
@@ -281,6 +294,9 @@ pub struct CrateInfo { | |
| pub used_crate_source: UnordMap<CrateNum, Arc<CrateSource>>, | ||
| pub used_crates: Vec<CrateNum>, | ||
| pub dependency_formats: Arc<Dependencies>, | ||
| /// EII implementations used by the link-time duplicate check, so `-Zno-link` can serialize the data needed by a | ||
| /// later `-Zlink-only` invocation. | ||
| pub eii_linkage: Vec<EiiLinkageInfo>, | ||
| pub windows_subsystem: Option<WindowsSubsystemKind>, | ||
| pub natvis_debugger_visualizers: BTreeSet<DebuggerVisualizerFile>, | ||
| pub lint_level_specs: CodegenLintLevelSpecs, | ||
|
|
||
| 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)] | ||
|
|
||
|
|
||
| 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)] | ||
|
|
||
| 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) {} |
| 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() {} |
| 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 | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.