Skip to content

Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins) - #160306

Open
saethlin wants to merge 1 commit into
rust-lang:mainfrom
saethlin:panic-runtimes-dont-share
Open

Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins)#160306
saethlin wants to merge 1 commit into
rust-lang:mainfrom
saethlin:panic-runtimes-dont-share

Conversation

@saethlin

Copy link
Copy Markdown
Member

This is a fix for #159682.

This seems like a generalized footgun for writing FFI plugins? But at least right now, a very specific change to the crates we often swap around seems prudent.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 31, 2026
@rustbot

rustbot commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, types
  • compiler, types expanded to 75 candidates
  • Random selection from 18 candidates

Comment thread compiler/rustc_middle/src/ty/context.rs Outdated
// If std depends on exported generics from the unwinding runtime, it may encounter
// link-time errors when swapped to a different one.
// https://github.com/rust-lang/rust/issues/159682
if self.is_panic_runtime(LOCAL_CRATE) {

@bjorn3 bjorn3 Aug 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check for conditional dependencies here instead of hard coding panic runtimes?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 it seems kind of goofy to export the symbols then never use them but sure

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single crate can be a conditional dependency of one crate and an unconditional dependency of a later crate. For the second crate it would be safe to use the exported generics. I guess it doesn't matter much for panic runtimes. The current code is a bit safer against any future kinds of conditional dependencies we might introduce.

@saethlin
saethlin force-pushed the panic-runtimes-dont-share branch from 39dd7ac to 0fb8cb8 Compare August 1, 2026 17:16
@saethlin saethlin changed the title Don't export shared generics from panic runtime crates Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins) Aug 1, 2026
@rust-log-analyzer

This comment has been minimized.

@saethlin
saethlin force-pushed the panic-runtimes-dont-share branch from 0fb8cb8 to 601ee8e Compare August 1, 2026 18:34
@bjorn3

bjorn3 commented Aug 1, 2026

Copy link
Copy Markdown
Member

r=me with CI passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants