Skip to content

properly decrement available_depth on cycles and provisional cache hits - #163185

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sjwang05:depth-budget-fix
Sep 24, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sjwang05:depth-budget-fix

Conversation

@sjwang05

Copy link
Copy Markdown
Contributor

cc https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/overflow.20fcw.20depends.20on.20cached.20results.20with.20cycles/with/625345435

With this change, the fuzzer doesn't seem to catch any mismatches or errors. If we decrement only on a cycle and not on a provisional cache hit, the fuzzer does report some mismatches.

I decided to directly pass available_depth instead of using the lower_available_depth arg since allowed_depth_for_nested already computes available_depth based on lower_available_depth.

r? lcnr

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Sep 22, 2026
@sjwang05

sjwang05 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

If we decrement only on a cycle and not on a provisional cache hit, the fuzzer does report some mismatches.

and here is one such program whose result depends on the provisional cache! :D

#![recursion_limit = "6"]
use std::marker::PhantomData;

// We need to decrement available_depth on provisional cache hits.
// e.g., in the following example:
// A: Send, avail = 6
// -> PhantomData<A>: Send, avail = 5
//    -> A: Send, avail = 4
// -> B: Send, avail = 5
//    -> C: Send, avail = 4
//       -> PhantomData<A>: Send, provisional cache hit, avail = 4 if we don't decrement
struct A(PhantomData<A>, B);
struct B(C);
struct C(PhantomData<A>);
struct W<T>(T);

fn require<T: Send>() {}

fn main() {
    require::<A>();
    require::<W<W<W<W<A>>>>>();
}

I've added both the cycle and provisional cache versions as uitests

Comment thread compiler/rustc_type_ir/src/search_graph/mod.rs Outdated
@lcnr

lcnr commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e9824e4 has been approved by lcnr

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 Sep 23, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 23, 2026
properly decrement available_depth on cycles and provisional cache hits

cc https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/overflow.20fcw.20depends.20on.20cached.20results.20with.20cycles/with/625345435

With this change, the fuzzer doesn't seem to catch any mismatches or errors. If we decrement only on a cycle and not on a provisional cache hit, the fuzzer does report some mismatches.

I decided to directly pass `available_depth` instead of using the `lower_available_depth` arg since `allowed_depth_for_nested` already computes `available_depth` based on `lower_available_depth`.

r? lcnr
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
Rollup of 8 pull requests

Successful merges:

 - #162976 (fix quadratic naming of duplicate sidebar links)
 - #163222 (Enable EII tests for cg_gcc)
 - #162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - #163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - #163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - #163185 (properly decrement available_depth on cycles and provisional cache hits)
 - #163214 (revert r14 register names for arm)
 - #163226 (miri subtree update)
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
Rollup of 8 pull requests

Successful merges:

 - #162976 (fix quadratic naming of duplicate sidebar links)
 - #163222 (Enable EII tests for cg_gcc)
 - #162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - #163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - #163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - #163185 (properly decrement available_depth on cycles and provisional cache hits)
 - #163214 (revert r14 register names for arm)
 - #163226 (miri subtree update)
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #162976 (fix quadratic naming of duplicate sidebar links)
 - #161275 (Refactor `core::cmp::{smallest, largest}` & add `mir-opt` test)
 - #163143 (cg_llvm: Use fewer FFI calls to check the target CPU's features)
 - #163188 (Adjust for Arm64EC name mangling when checking for exported symbols)
 - #163211 (`rustc_builtin_macros` cleanup, part 6)
 - #161386 (Don't merge distinct impl candidates)
 - #162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - #163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - #163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - #163185 (properly decrement available_depth on cycles and provisional cache hits)
 - #163214 (revert r14 register names for arm)
 - #163226 (miri subtree update)
 - #163228 (Add regression test for trait predicate with escaping bounds)
 - #163234 (`rustc_dump_symbol_name`: add demangling information as a note instead)
@rust-bors
rust-bors Bot merged commit 90e3ba3 into rust-lang:main Sep 24, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
Rollup merge of #163185 - sjwang05:depth-budget-fix, r=lcnr

properly decrement available_depth on cycles and provisional cache hits

cc https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/overflow.20fcw.20depends.20on.20cached.20results.20with.20cycles/with/625345435

With this change, the fuzzer doesn't seem to catch any mismatches or errors. If we decrement only on a cycle and not on a provisional cache hit, the fuzzer does report some mismatches.

I decided to directly pass `available_depth` instead of using the `lower_available_depth` arg since `allowed_depth_for_nested` already computes `available_depth` based on `lower_available_depth`.

r? lcnr
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Sep 25, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#162976 (fix quadratic naming of duplicate sidebar links)
 - rust-lang/rust#161275 (Refactor `core::cmp::{smallest, largest}` & add `mir-opt` test)
 - rust-lang/rust#163143 (cg_llvm: Use fewer FFI calls to check the target CPU's features)
 - rust-lang/rust#163188 (Adjust for Arm64EC name mangling when checking for exported symbols)
 - rust-lang/rust#163211 (`rustc_builtin_macros` cleanup, part 6)
 - rust-lang/rust#161386 (Don't merge distinct impl candidates)
 - rust-lang/rust#162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - rust-lang/rust#163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - rust-lang/rust#163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - rust-lang/rust#163185 (properly decrement available_depth on cycles and provisional cache hits)
 - rust-lang/rust#163214 (revert r14 register names for arm)
 - rust-lang/rust#163226 (miri subtree update)
 - rust-lang/rust#163228 (Add regression test for trait predicate with escaping bounds)
 - rust-lang/rust#163234 (`rustc_dump_symbol_name`: add demangling information as a note instead)
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. 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.

3 participants