Skip to content

Remove 'static requirement on try_as_dyn#150161

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
oli-obk:try_as_dyn_non_static
Jul 24, 2026
Merged

Remove 'static requirement on try_as_dyn#150161
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
oli-obk:try_as_dyn_non_static

Conversation

@oli-obk

@oli-obk oli-obk commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

@rustbot

rustbot commented Dec 19, 2025

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Dec 19, 2025
@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) label Dec 19, 2025
@rustbot

rustbot commented Dec 19, 2025

Copy link
Copy Markdown
Collaborator

r? @SparrowLii

rustbot has assigned @SparrowLii.
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

@rust-log-analyzer

This comment has been minimized.

@oli-obk
oli-obk force-pushed the try_as_dyn_non_static branch 2 times, most recently from e7ef1ee to 29f1dba Compare December 19, 2025 16:44

@danielhenrymantilla danielhenrymantilla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some drive-by comments; but I'm not rustc/HIR-savy, so take these with a grain of salt 🙇

View changes since this review

Comment thread compiler/rustc_hir/src/hir.rs Outdated
Comment thread tests/ui/any/non_static.rs Outdated
Comment thread tests/ui/any/non_static.rs
Comment thread tests/ui/any/non_static.rs Outdated
Comment thread compiler/rustc_hir/src/hir.rs Outdated
Comment thread tests/ui/any/non_static.rs Outdated
Comment thread compiler/rustc_hir/src/hir.rs Outdated
Comment thread compiler/rustc_next_trait_solver/src/solve/trait_goals.rs Outdated
@BoxyUwU

BoxyUwU commented Dec 19, 2025

Copy link
Copy Markdown
Member

r? BoxyUwU

@rustbot rustbot assigned BoxyUwU and unassigned SparrowLii Dec 19, 2025
Comment thread library/core/src/any.rs Outdated
Comment thread tests/ui/any/non_static.rs Outdated
@theemathas

This comment has been minimized.

@theemathas

This comment has been minimized.

@theemathas

This comment has been minimized.

@BoxyUwU BoxyUwU added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2025
@oli-obk
oli-obk force-pushed the try_as_dyn_non_static branch from 29f1dba to fe33b0c Compare January 7, 2026 12:41
@rustbot

This comment has been minimized.

@oli-obk
oli-obk force-pushed the try_as_dyn_non_static branch 3 times, most recently from dfa5c33 to 30f5641 Compare January 7, 2026 12:44
Comment thread tests/ui/any/static_method_bound.rs
@rust-log-analyzer

This comment has been minimized.

@oli-obk

oli-obk commented Jan 13, 2026

Copy link
Copy Markdown
Contributor Author

The hacky solution is obviously not a general fix. But I think it's progress. As a next step I will add the input type as a generic parameter on TryAsDynCompat, at which point we should be able to enforce (in borrowck) that the input type outlives any lifetimes on the dyn Trait or its generic parameters. So if a generic parameter T has a 'static bound, it could be used as an input type for a try_as_dyn irrespective of the bounds on the dyn Trait. In the other direction, we will likely end up rejecting many traits that have generic parameters as the bounds are not something that can be written in Rust.

@theemathas

This comment was marked as resolved.

@BoxyUwU

BoxyUwU commented Jul 23, 2026

Copy link
Copy Markdown
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 23, 2026
@oli-obk
oli-obk force-pushed the try_as_dyn_non_static branch from 7c9448e to b111aec Compare July 23, 2026 09:46
@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@oli-obk

oli-obk commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@bors r=BoxyUwU

@rust-bors

rust-bors Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b111aec has been approved by BoxyUwU

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 23, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…oxyUwU

Remove 'static requirement on try_as_dyn

tracking issue: rust-lang#144361

cc @ivarflakstad @izagawd
rust-bors Bot pushed a commit that referenced this pull request Jul 23, 2026
Rollup of 18 pull requests

Successful merges:

 - #138618 (Support using const pointers in asm `const` operand)
 - #150161 (Remove 'static requirement on try_as_dyn)
 - #158362 (trait solver: account for universes from replace_bound_vars)
 - #159173 (Add allowed list check on EII implementations attributes)
 - #159466 (cmse: clear variant-dependent padding in `enum`s)
 - #159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - #155795 (constify `vec![1, 2, 3]` macro)
 - #157776 (ci: Enable autodiff tests on x86_64 linux)
 - #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs)
 - #159041 (Reorganize `tests/ui/issues` [22/N])
 - #159108 (Reorganize `tests/ui/issues` [23/N])
 - #159138 (doc: document wasm import symbol mangling)
 - #159531 (Reorganize `tests/ui/issues` [28/N])
 - #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable)
 - #159612 (Reorganize `tests/ui/issues` [29/N])
 - #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`)
 - #159759 (rustc-dev-guide subtree update)
 - #159761 (Remove outdated comment for resolve_vars_with_obligations)
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…oxyUwU

Remove 'static requirement on try_as_dyn

tracking issue: rust-lang#144361

cc @ivarflakstad @izagawd
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 23, 2026
…oxyUwU

Remove 'static requirement on try_as_dyn

tracking issue: rust-lang#144361

cc @ivarflakstad @izagawd
rust-bors Bot pushed a commit that referenced this pull request Jul 23, 2026
Rollup of 19 pull requests

Successful merges:

 - #150161 (Remove 'static requirement on try_as_dyn)
 - #158362 (trait solver: account for universes from replace_bound_vars)
 - #159173 (Add allowed list check on EII implementations attributes)
 - #159466 (cmse: clear variant-dependent padding in `enum`s)
 - #159718 (Make `DocLinkResMap` an `FxIndexMap`)
 - #155795 (constify `vec![1, 2, 3]` macro)
 - #157776 (ci: Enable autodiff tests on x86_64 linux)
 - #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs)
 - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools)
 - #159041 (Reorganize `tests/ui/issues` [22/N])
 - #159108 (Reorganize `tests/ui/issues` [23/N])
 - #159138 (doc: document wasm import symbol mangling)
 - #159531 (Reorganize `tests/ui/issues` [28/N])
 - #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable)
 - #159612 (Reorganize `tests/ui/issues` [29/N])
 - #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`)
 - #159667 (Make some parser structured suggestions verbose and tweak their wording)
 - #159759 (rustc-dev-guide subtree update)
 - #159761 (Remove outdated comment for resolve_vars_with_obligations)
@jhpratt

jhpratt commented Jul 23, 2026

Copy link
Copy Markdown
Member

@bors try jobs=dist-powerpc64le-linux-gnu

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 23, 2026
Remove 'static requirement on try_as_dyn


try-job: dist-powerpc64le-linux-gnu
@rust-bors

rust-bors Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: f455dc9 (f455dc98eaacec532a74daf2fcbd8c7b7dd33506)
Base parent: 2d8fa67 (2d8fa67781953811835f7ae45f670afbb7f44285)

rust-bors Bot pushed a commit that referenced this pull request Jul 24, 2026
Rollup of 20 pull requests

Successful merges:

 - #150161 (Remove 'static requirement on try_as_dyn)
 - #159412 (Reorganize `tests/ui/issues` [26/N])
 - #159466 (cmse: clear variant-dependent padding in `enum`s)
 - #157905 (Update comments and add tests for `-Zrandomize-layout` for some guaranteed ZSTs)
 - #158479 (Reject static item as direct const generic arg)
 - #159041 (Reorganize `tests/ui/issues` [22/N])
 - #159108 (Reorganize `tests/ui/issues` [23/N])
 - #159138 (doc: document wasm import symbol mangling)
 - #159531 (Reorganize `tests/ui/issues` [28/N])
 - #159608 (early_otherwise: Don't hoist dereferences when the otherwise branch is reachable)
 - #159612 (Reorganize `tests/ui/issues` [29/N])
 - #159653 (run `tests/assembly-llvm/asm/aarch64-types.rs` for `aarch64_be`)
 - #159719 (tests: add UI test for `.swap()` suggestion)
 - #159737 (rustfmt fix: allow file not found errors for external mods annotated with `#[my_macro]`)
 - #159759 (rustc-dev-guide subtree update)
 - #159761 (Remove outdated comment for resolve_vars_with_obligations)
 - #159764 (use `minicore::simd::Simd` more)
 - #159773 (Remove outdated workaround for `P` type)
 - #159778 (use lowest edition the test accepts)
 - #159788 (Avoid ICEing in RPIT method chain suggestion)
@rust-bors
rust-bors Bot merged commit 020394d into rust-lang:main Jul 24, 2026
14 checks passed
@jhpratt

jhpratt commented Jul 24, 2026

Copy link
Copy Markdown
Member

@rust-timer build d7b15f6

@rust-timer

Copy link
Copy Markdown
Collaborator

Missing artifact for sha d7b15f62cab0f17ccb06c005628a2aa2773b912e (https://ci-artifacts.rust-lang.org/rustc-builds/d7b15f62cab0f17ccb06c005628a2aa2773b912e/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz); not built yet, try again later.

@panstromek

Copy link
Copy Markdown
Contributor

We have the artifact now, let's try again.

@rust-timer build d7b15f6

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d7b15f6): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.3%] 19
Regressions ❌
(secondary)
0.4% [0.2%, 0.6%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.3%] 19

Max RSS (memory usage)

Results (secondary 1.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% [3.4%, 3.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-0.7%, -0.7%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.5% [2.5%, 2.5%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.2%, secondary 0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.4%] 65
Regressions ❌
(secondary)
0.3% [0.0%, 0.5%] 50
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.2% [0.0%, 0.4%] 65

Bootstrap: 488.274s -> 487.679s (-0.12%)
Artifact size: 387.66 MiB -> 388.42 MiB (0.20%)

@panstromek

Copy link
Copy Markdown
Contributor

This looks to be caused by metadata and/or dep graph size increase. Can we do something to mitigate the impact?

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

Labels

perf-regression Performance regression. 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. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.