Skip to content

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

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
saethlin:panic-runtimes-dont-share
Aug 3, 2026
Merged

Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins)#160306
rust-bors[bot] merged 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.

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.

Why would we introduce more conditional dependencies?

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.

We might want to turn the profiler runtime into one in the future for build-std for example. (if we don't turn that into a regular C static library instead)

@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.

@saethlin

saethlin commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

@bors r=bjorn3

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 601ee8e has been approved by bjorn3

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 3, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
Rollup of 3 pull requests

Successful merges:

 - #160306 (Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins))
 - #160254 (Rerun the goal with doubled recursion limit even if the goal has ty vars)
 - #160380 (Improve the test for patterns in fn pointers)
@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit 601ee8e with merge 34c93c4...

Workflow: https://github.com/rust-lang/rust/actions/runs/30787902693

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins)

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.
@jhpratt

jhpratt commented Aug 3, 2026

Copy link
Copy Markdown
Member

@bors yield

@rust-bors

rust-bors Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #160414.

rust-bors Bot pushed a commit that referenced this pull request Aug 3, 2026
Rollup of 3 pull requests

Successful merges:

 - #160306 (Don't use exported generics from conditional dependencies (panic runtimes and profiler-builtins))
 - #160254 (Rerun the goal with doubled recursion limit even if the goal has ty vars)
 - #160380 (Improve the test for patterns in fn pointers)
@rust-bors
rust-bors Bot merged commit f1113e0 into rust-lang:main Aug 3, 2026
13 of 14 checks passed
rust-timer added a commit that referenced this pull request Aug 3, 2026
Rollup merge of #160306 - saethlin:panic-runtimes-dont-share, r=bjorn3

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

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 this to the 1.99.0 milestone Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

6 participants