Skip to content

Fancy paramenv accessors that communicate the access pattern better. - #163477

Draft
jdonszelmann wants to merge 1 commit into
rust-lang:mainfrom
jdonszelmann:paramenv-accessors
Draft

jdonszelmann wants to merge 1 commit into
rust-lang:mainfrom
jdonszelmann:paramenv-accessors

Conversation

@jdonszelmann

Copy link
Copy Markdown
Contributor

r? @lcnr or @rust-lang/initiative-trait-system-refactor

This is a single commit, to precede the future change of "compressed trait clauses". It adds a lot of the infrastructure, without making any real changes that may affect performance. As such it forms a separately reviewable step. Even though this isn't on its own such a useful change, it mostly refactors things, it does still make for a nicer API surface.

Importantly, with compressed trait clauses (i.e. encoding some common traits as where self_ty : <bitset of common traits>), it becomes very important to be careful with how we iterate over caller bounds. I've tried other methods, but the typestate API (as proposed in this PR) is the only one I've found that's both ergonomic, and still allows for implementing compressed trait clauses performantly.

Note

I've not used an LLM for any part of this PR, or any other PR I make. This includes any related work like research.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 29, 2026
@jdonszelmann
jdonszelmann force-pushed the paramenv-accessors branch 2 times, most recently from 67c2b09 to 6d71f6c Compare September 29, 2026 10:08
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
[RUSTC-TIMING] icu_normalizer test:false 0.218
    Checking icu_properties v2.2.0
[RUSTC-TIMING] serde_derive test:false 2.279
    Checking serde v1.0.228
error[E0599]: no method named `any` found for struct `CallerBoundsAccessor<I, Iter, CF>` in the current scope
  --> src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs:38:53
   |
38 |         && cx.tcx.param_env(def_id).caller_bounds().any(|bound| {
   |            -----------------------------------------^^^ method not found in `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>`
   |
   = note: the full name for the type has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/build/clippy_utils/fad0b2bc6eeab5a3/out/clippy_utils-fad0b2bc6eeab5a3.long-type-11677082929207487122.txt'
   = note: consider using `--verbose` to print the full type name to the console

[RUSTC-TIMING] serde test:false 0.303
    Checking cargo-platform v0.3.1
[RUSTC-TIMING] cargo_platform test:false 0.092
    Checking cargo_metadata v0.23.1
error[E0277]: `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>` is not an iterator
   --> src/tools/clippy/clippy_utils/src/ty/mod.rs:831:82
    |
831 |             _ => sig_for_projection(cx, proj).or_else(|| sig_from_bounds(cx, ty, cx.param_env.caller_bounds(), None)),
    |                                                          ---------------         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>` is not an iterator
    |                                                          |
    |                                                          required by a bound introduced by this call
    |
    = help: the trait `std::iter::Iterator` is not implemented for `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>`
    = note: required for `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>` to implement `IntoIterator`
note: required by a bound in `sig_from_bounds`
   --> src/tools/clippy/clippy_utils/src/ty/mod.rs:841:19
    |
838 | fn sig_from_bounds<'tcx>(
    |    --------------- required by a bound in this function
...
841 |     clauses: impl IntoIterator<Item = ty::Clause<'tcx>>,
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `sig_from_bounds`
    = note: the full name for the type has been written to '/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/x86_64-unknown-linux-gnu/release/build/clippy_utils/fad0b2bc6eeab5a3/out/clippy_utils-fad0b2bc6eeab5a3.long-type-5651915585591225334.txt'
    = note: consider using `--verbose` to print the full type name to the console

error[E0277]: `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>` is not an iterator
   --> src/tools/clippy/clippy_utils/src/ty/mod.rs:833:49
    |
833 |         ty::Param(_) => sig_from_bounds(cx, ty, cx.param_env.caller_bounds(), None),
    |                         ---------------         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>` is not an iterator
    |                         |
    |                         required by a bound introduced by this call
    |
    = help: the trait `std::iter::Iterator` is not implemented for `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>`
    = note: required for `CallerBoundsAccessor<TyCtxt<'_>, impl Iterator<Item = Clause<'_>>, _>` to implement `IntoIterator`
note: required by a bound in `sig_from_bounds`
   --> src/tools/clippy/clippy_utils/src/ty/mod.rs:841:19
    |
838 | fn sig_from_bounds<'tcx>(
    |    --------------- required by a bound in this function
...

@rust-bors

rust-bors Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #163767) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

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

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc 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.

4 participants