about summary refs log tree commit diff
path: root/compiler/rustc_next_trait_solver/src
AgeCommit message (Collapse)AuthorLines
2025-10-02Auto merge of #147138 - jackh726:split-canonical-bound, r=lcnrbors-38/+26
Split Bound index into Canonical and Bound See [#t-types/trait-system-refactor > perf `async-closures/post-mono-higher-ranked-hang.rs`](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/perf.20.60async-closures.2Fpost-mono-higher-ranked-hang.2Ers.60/with/541535613) for context Things compile and tests pass, but not sure if this actually solves the perf issue (edit: it does). Opening up this to do a perf (and maybe crater) run. r? lcnr
2025-09-30Split Bound into Canonical and Boundjackh726-38/+26
2025-09-30add testslcnr-1/+4
2025-09-29cleanup `try_evaluate_added_goals`lcnr-14/+5
2025-09-29Fn-trait goals, eagerly instantiate binderlcnr-117/+90
to avoid overflow from proving `for<'a> opaque<'a>: Sized`
2025-09-28Rollup merge of #147061 - lcnr:provisional-cache-woops, r=BoxyUwUMatthias Krüger-9/+17
fix rebasing cycle heads when not reaching a fixpoint fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/232 annoyingly subtle, imagine the following proof tree - A (no cycle head usages, final result Y) - *ignored* B (depends on A with provisional result X) - A (cycle, provisional result X) - B (using the cache entry here incorrectly assumes A has final result X) r? ``@BoxyUwU``
2025-09-26allow method calls on opaqueslcnr-1/+3
2025-09-26predefined opaques use `List`lcnr-9/+6
2025-09-26rename `search_graph::Delegate` fnslcnr-2/+2
2025-09-26fix cycle head usages trackinglcnr-7/+15
2025-09-18canonical: yeet `EvalCtxt`, mk `Canonicalizer` privatelcnr-211/+233
2025-09-18move `mod canonical` out of `eval_ctxt`lcnr-229/+227
2025-09-18Auto merge of #145993 - lcnr:allow-calling-opaques, r=BoxyUwUbors-65/+113
`-Znext-solver` allow `ExprKind::Call` for not-yet defined opaques Based on https://github.com/rust-lang/rust/pull/146329. Revival of rust-lang/rust#140496. See the comment on `OpaqueTypesJank`. I've used the following document while working on this https://hackmd.io/Js61f8PRTcyaiyqS-fH9iQ. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/181. It does introduce one subtle footgun we may want to handle before stabilization, opened https://github.com/rust-lang/trait-system-refactor-initiative/issues/230 for that. Also cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/231 for deref and index operations r? `@BoxyUwU`
2025-09-18support calls on opaque types :<lcnr-65/+113
2025-09-17Remove `DynKind`León Orell Valerian Liehr-14/+12
2025-09-11incompletely prefer opaque type bounds when self type bottoms out in inferMichael Goulet-13/+168
2025-09-11consider the `sub_unification_table` in `stalled_on`lcnr-24/+33
2025-09-08Auto merge of #140375 - lcnr:subrelations-infcx, r=BoxyUwUbors-56/+91
eagerly compute `sub_unification_table` again Previously called `sub_relations`. We still only using them for diagnostics right now. This mostly reverts rust-lang/rust#119989. Necessary for type inference guidance due to not-yet defined opaque types, cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/182. We could use them for cycle detection in generalization and it seems desirable to do so in the future. However, this is unsound with the old trait solver as its cache does not track these `sub_unification_table` in any way. We now properly track the `sub_unification_table` when canonicalizing so using them in the new solver is totally sound and the performance impact is far more manageable than I thought back in rust-lang/rust#119989. r? `@compiler-errors`
2025-09-08Rollup merge of #146111 - ChayimFriedman2:more-ns-specific-defid, r=lcnrMatthias Krüger-25/+40
Migrate more things in the new solver to specific `DefId`s Continuation of https://github.com/rust-lang/rust/pull/145377. I migrated the rest of the types, except aliases. Aliases are problematic because opaques and associated types share the same type in the new solver. `@jackh726,` `@lcnr,` `@ShoyuVanilla` I'd like to hear ideas here. Anyway, even if we do nothing with them we already got a substantial improvement. r? types
2025-09-08reviewlcnr-4/+10
2025-09-08optimize `CanonicalVarValues::instantiate`lcnr-10/+5
2025-09-08pass `sub_relations` into canonical querieslcnr-42/+71
2025-09-08inline `CanonicalTyVarKind`lcnr-12/+9
2025-09-08eagerly compute `sub_relations` againlcnr-5/+13
2025-09-04Don't require next-solver `ProbeRef` to be `Copy`Chayim Refael Friedman-2/+2
rust-analyzer would like to use a non-interned `Probe` there. Also rename it to `Probe` for this reason.
2025-09-02Migrate more things in the new solver to specific `DefId`sChayim Refael Friedman-25/+40
2025-08-29cleanup proof tree implementation and add cachelcnr-387/+235
2025-08-29Auto merge of #145377 - ChayimFriedman2:solver-def-id, r=lcnrbors-81/+89
Switch next solver to use a specific associated type for trait def id The compiler just puts `DefId` in there, but rust-analyzer uses different types for each kind of item. See [the Zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/185405-t-compiler.2Frust-analyzer/topic/Implmentating.20New.20Trait.20Solver/near/534329794). In short, it will be a tremendous help to r-a to use specific associated types, while for the solver and the compiler it's a small change. So I ported `TraitId`, as a proof of concept and it's also likely the most impactful. r? types
2025-08-25Switch next solver to use a specific associated type for trait def idChayim Refael Friedman-81/+89
The compiler just puts `DefId` in there, but rust-analyzer uses different types for each kind of item.
2025-08-25support non-defining uses in HIR typecklcnr-148/+51
2025-08-23Auto merge of #145796 - samueltardieu:rollup-linfi86, r=samueltardieubors-7/+11
Rollup of 14 pull requests Successful merges: - rust-lang/rust#143898 (opt-dist: rebuild rustc when doing static LLVM builds) - rust-lang/rust#144452 (std/sys/fd: Relax `READ_LIMIT` on Darwin) - rust-lang/rust#145234 (match exhaustiveness diagnostics: show a trailing comma on singleton tuple consructors in witness patterns (and clean up a little)) - rust-lang/rust#145515 (Optimize `char::encode_utf8`) - rust-lang/rust#145540 (interpret/allocation: get_range on ProvenanceMap) - rust-lang/rust#145670 (port `sanitize` attribute to the new parsing infrastructure) - rust-lang/rust#145713 (next-solver: fix `feature(const_trait_impl)` bootstrap) - rust-lang/rust#145729 (Remove two duplicated crates) - rust-lang/rust#145744 (miri: also detect aliasing of in-place argument and return place) - rust-lang/rust#145774 (Remove default opts from config) - rust-lang/rust#145781 (Remove profile section from Clippy) - rust-lang/rust#145782 (rustdoc: make attributes render consistently) - rust-lang/rust#145787 (citool: cleanup `mismatched_lifetime_syntaxes` warnings) - rust-lang/rust#145791 (Fix ICE when validating transmuting ZST to inhabited enum) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-22change HIR typeck unification handling approachlcnr-36/+6
2025-08-21next-solver fix const_trait_impl bootstraplcnr-7/+11
2025-08-19Auto merge of #145600 - jieyouxu:rollup-jw0bpnt, r=jieyouxubors-22/+19
Rollup of 15 pull requests Successful merges: - rust-lang/rust#145338 (actually provide the correct args to coroutine witnesses) - rust-lang/rust#145429 (Couple of codegen_fn_attrs improvements) - rust-lang/rust#145452 (Do not strip binaries in bootstrap everytime if they are unchanged) - rust-lang/rust#145464 (Stabilize `const_pathbuf_osstring_new` feature) - rust-lang/rust#145474 (Properly recover from parenthesized use-bounds (precise capturing lists) plus small cleanups) - rust-lang/rust#145486 (Fix `unicode_data.rs` mention message) - rust-lang/rust#145490 (Trace some basic I/O operations in bootstrap) - rust-lang/rust#145493 (remove `should_render` in `PrintAttribute` derive) - rust-lang/rust#145500 (Port must_use to the new target checking) - rust-lang/rust#145505 (Simplify span caches) - rust-lang/rust#145510 (Visit and print async_fut local for async drop.) - rust-lang/rust#145511 (Rust build fails on OpenBSD after using file_lock feature) - rust-lang/rust#145532 (resolve: debug for block module) - rust-lang/rust#145533 (Reorder `lto` options from most to least optimizing) - rust-lang/rust#145537 (Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation.) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-19Rollup merge of #145537 - zachs18:metasized-negative-bound-fix, r=davidtwco许杰友 Jieyou Xu (Joe)-4/+13
Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation. This example should fail to compile (and does under this PR, with the old and new solvers), but currently compiles successfully ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=6e0e5d0ae0cdf0571dea97938fb4a86d)), because (IIUC) the old solver's `lazily_elaborate_sizedness_candidate`/callers and the new solver's `TraitPredicate::fast_reject_assumption`/`match_assumption` consider a `T: _ Sized` candidate to satisfy a `T: _ MetaSized` obligation, for either polarity `_`, when that should only hold for positive polarity. ```rs #![feature(negative_bounds)] #![feature(sized_hierarchy)] use std::marker::MetaSized; fn foo<T: !MetaSized>() {} fn bar<T: !Sized + MetaSized>() { foo::<T>(); //~^ ERROR the trait bound `T: !MetaSized` is not satisfied // error under this PR } ``` Only observable with the internal-only `feature(negative_bounds)`, so might just be "wontfix". This example is added as a test in this PR (as well as testing that `foo<()>` and `foo<str>` are disallowed for `fn foo<T: !MetaSized`). cc `@davidtwco` for `feature(sized_hierarchy)` Maybe similar to 91c53c9 from <https://github.com/rust-lang/rust/pull/143307>
2025-08-19Rollup merge of #145338 - lcnr:coroutine-witness-yikes, r=compiler-errors许杰友 Jieyou Xu (Joe)-18/+6
actually provide the correct args to coroutine witnesses rust-lang/rust#145194 accidentally provided all arguments of the closure to the witness, but the witness only takes the generic parameters of the defining scope: https://github.com/rust-lang/rust/blob/216cdb7b22b637cef75b7225c642cb7587192643/compiler/rustc_hir_typeck/src/closure.rs#L164 Fixes rust-lang/rust#145288
2025-08-17Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation.Zachary S-4/+13
2025-08-16run spellcheck as a tidy extra check in cibinarycat-1/+1
2025-08-14update commentlcnr-0/+12
2025-08-14ignore head usages of ignored candidateslcnr-54/+138
2025-08-13`fn new_coroutine_witness_for_coroutine` woopslcnr-18/+6
2025-08-11significantly improve provisional cache rebasinglcnr-1/+3
2025-08-09some `derive_more` refactorsDeadbeef-4/+12
some clauses can be merged together without requiring an attribute for each trait derived. also manually impl `Eq` because the `derive_where` generated code is too much for my comfort
2025-08-05we only merge candidates for trait and normalizes-to goalslcnr-69/+48
2025-08-04Rollup merge of #144694 - compiler-errors:with-self-ty, r=SparrowLiiStuart Cook-10/+12
Distinguish prepending and replacing self ty in predicates There are two kinds of functions called `with_self_ty`: 1. Prepends the `Self` type onto an `ExistentialPredicate` which lacks it in its internal representation. 2. Replaces the `Self` type of an existing predicate, either for diagnostics purposes or in the new trait solver when normalizing that self type. This PR distinguishes these two because I often want to only grep for one of them. Namely, let's call it `with_replaced_self_ty` when all we're doing is replacing the self type.
2025-08-03Auto merge of #144732 - lcnr:ignore-shadowed-impls, r=compiler-errorsbors-3/+24
dont assemble shadowed impl candidates Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/109. I've originally intended to fix this by supporting lazy reevaluation when rerunning cycles. This ended up being really difficult, see https://github.com/lcnr/search_graph for my notes used while working on this. It is also insufficient for the `rayon-hang-2.rs` test as we end up with goals which we need to rerun for all combinations of provisional results. While landing such an optimization in the future may still be desirable, it is very difficult and insufficient to fix these hangs. Also see the relevant [zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/rustc-rayon.20hang/near/527850058). I was previously opposed to avoiding assembling shadowed impls as it may prevent future improvements in this area, cc rust-lang/rust#141226. Going to track this and the reasoning behind it in https://github.com/rust-lang/trait-system-refactor-initiative/issues/226. r? `@BoxyUwU` `@compiler-errors`
2025-07-31Remove the witness type from coroutine argsMichael Goulet-3/+17
2025-07-31Stall coroutines based off of ty::Coroutine, not ty::CoroutineWitnessMichael Goulet-7/+4
2025-07-31dont assemble shadowed impl candidateslcnr-3/+24
2025-07-31Auto merge of #144405 - lcnr:hir-typeck-uniquify, r=BoxyUwUbors-34/+100
uniquify root goals during HIR typeck We need to rely on region identity to deal with hangs such as https://github.com/rust-lang/trait-system-refactor-initiative/issues/210 and to keep the current behavior of `fn try_merge_responses`. This is a problem as borrowck starts by replacing each *occurrence* of a region with a unique inference variable. This frequently splits a single region during HIR typeck into multiple distinct regions. As we assume goals to always succeed during borrowck, relying on two occurances of a region being identical during HIR typeck causes ICE. See the now fixed examples in https://github.com/rust-lang/trait-system-refactor-initiative/issues/27 and rust-lang/rust#139409. We've previously tried to avoid this issue by always *uniquifying* regions when canonicalizing goals. This prevents caching subtrees during canonicalization which resulted in hangs for very large types. People rely on such types in practice, which caused us to revert our attempt to reinstate `#[type_length_limit]` in https://github.com/rust-lang/rust/pull/127670. The complete list of changes here: - rust-lang/rust#107981 - rust-lang/rust#110180 - rust-lang/rust#114117 - rust-lang/rust#130821 After more consideration, all occurrences of such large types need to happen outside of typeck/borrowck. We know this as we already walk over all types in the MIR body when replacing their regions with nll vars. This PR therefore enables us to rely on region identity inside of the trait solver by exclusively **uniquifying root goals during HIR typeck**. These are the only goals we assume to hold during borrowck. This is insufficient as type inference variables may "hide" regions we later uniquify. Because of this, we now stash proven goals which depend on inference variables in HIR typeck and reprove them after writeback. This closes https://github.com/rust-lang/trait-system-refactor-initiative/issues/127. This was originally part of rust-lang/rust#144258 but I've moved it into a separate PR. While I believe we need to rely on region identity to fix the performance issues in some way, I don't know whether rust-lang/rust#144258 is the best approach to actually do so. Regardless of how we deal with the hangs however, this change is necessary and desirable regardless. r? `@compiler-errors` or `@BoxyUwU`