Repository navigation
Conversation
Use the calling crate's configured recursion limit instead of the fixed depth of 50. Track the scalar separately and cache it in DbInterner to avoid broad incremental invalidation and repeated solver-loop queries. Cover default and explicit limits, calling-crate selection, and incremental attribute edits. Replace depth-sensitive debug snapshots with type assertions. Refs rust-lang#23396. AI assistance was used for investigation, implementation, tests, and this commit message.
The CI debug test builds overflow libtest's default 2 MiB stack when exercising the crate recursion limit. Set the default RUST_MIN_STACK to 16 MiB, matching stdx::thread::DEFAULT_STACK_SIZE used by analyzer workers. Keep the deep inference fixtures and assertions unchanged. Validated the full workspace with Rust 1.98.1, CI RUSTFLAGS, and nextest: 8188 passed, 10 skipped. AI assistance was used to investigate and prepare this change.
Contributor
|
First, @YUZHEthefool already claimed this in #23193, although perhaps you didn't know because you didn't see that issue. Second, I've said multiple times that we cannot just change this and need to investigate the consequences. The change itself is trivial, that investigation is the real work. Third and most severe of all, you didn't follow our AI policy. You said you've reviewed the implementation, but I doubt that and if even you did, you probably don't have the knowledge of the codebase to do that because the code quality is in no way good. Worse, your PR description is very likely AI-generated as well which is a clear violation of the policy. I'm closing this now. If you'll repeat this behavior we'll reach to moderation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes #23396.
The issue's diesel-async query compiles with rustc, but rust-analyzer reports E0282 on the query and E0308 (
expected String, found str) at its return value. The trait solver'sInterner::recursion_limitcurrently returns a fixed depth of 50, ignoring the crate's configured limit. A dependency-free regression with a finite, 64-layer trait obligation also fails to infer the expectedu32at that fixed depth.Change
Use the active calling crate's existing
DefMaprecursion limit: 128 by default, or its explicit#![recursion_limit = "..."]value. This removes the hard-coded solver limit rather than special-casing Diesel or suppressing either diagnostic.The numeric limit is exposed as a separately tracked field of
DefMapPair, so consumers do not depend on unrelated changes to the full definition map.DbInternerreads it once during construction and stores au32; solver calls then read the cached scalar. Contexts without a crate retain the default value.The tests cover the default depth, an explicitly raised limit, calling-crate rather than dependency-crate selection, and low/high/low attribute edits in the same incremental database. Three existing crash-regression snapshots that pinned incidental recursive-reference expansion counts now assert inferred types instead. An obsolete query-log test referring to the removed
trait_solve_shimquery is replaced with the incremental inferred-type regression.Corresponding rustc implementation
References are pinned to the revision in this checkout's
rust-version:Interner for TyCtxt::recursion_limitdelegates to the current compilation context's recursion limit.get_recursion_limitreads the crate attribute, defaulting to 128.This patch follows that crate-attribute/default policy through rust-analyzer's existing
DefMapimplementation. The limit belongs to the crate being analyzed, not the dependency defining a referenced trait. This change does not add support for rustc's unstablemin_recursion_limitoption.Verification
The following results were obtained by the AI-assisted local workflow on macOS arm64 using nightly Rust 1.100.0:
{unknown}instead ofu32) and pass with it.hir-def,hir-ty, andide-diagnostics: 2,279 tests passed, 5 ignored.hir-ty/src/lower.rs; this is not a warning-free/full-CI claim.Commands:
cargo +nightly test --release --locked -p hir-def -p hir-ty -p ide-diagnostics --lib cargo +nightly build --release --locked -p rust-analyzer cargo +nightly fmt --all --check cargo +nightly clippy --release --locked -p hir-def -p hir-ty -p ide-diagnostics --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderrThe full upstream cross-platform CI matrix has not been run locally.
Tradeoff
A higher default limit, or an explicitly high crate limit, can increase the work required for pathological recursive types. Three paired local CLI measurements on the issue reproducer had median elapsed times of 4.176 seconds before and 4.223 seconds after the change. This small sample is not a general guarantee about IDE responsiveness.
Declaration
The code changes were generated using OpenAI’s GPT-Astra. I reviewed the implementation and verified the fix.