about summary refs log tree commit diff
path: root/compiler/rustc_next_trait_solver/src
AgeCommit message (Collapse)AuthorLines
2025-07-30Distinguish appending and replacing self ty in predicatesMichael Goulet-10/+12
2025-07-30extend commentlcnr-0/+13
2025-07-29resuse eagerly resolved goal from previous iterationlcnr-12/+32
2025-07-26Auto merge of #143500 - compiler-errors:characterize-less, r=lcnrbors-4/+9
Skip walking into param-env component if it has no placeholder/re-var Although it only provides a minor perf improvement, it seems like it could matter in more pathological cases.
2025-07-25uniquify root goals during HIR typecklcnr-24/+57
2025-07-18update commentlcnr-4/+2
2025-07-15Add the core logic in old and new solverstiif-0/+26
2025-07-05Don't compress input universesMichael Goulet-111/+10
2025-07-05[perf] Skip walking into param-env component if it has no placeholder/re-varMichael Goulet-4/+9
2025-07-05Canonicalize input ty/ct infer/placeholder in the root universeMichael Goulet-8/+23
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-4/+4
2025-07-02Auto merge of #142974 - cuviper:stage0-bump, r=Mark-Simulacrumbors-1/+1
Update stage0 to 1.89.0-beta.1 - Update version placeholders - Update stage0 to 1.89.0-beta.1 - Update `STAGE0_MISSING_TARGETS` - Update `cfg(bootstrap)` r? `@Mark-Simulacrum` try-job: dist-i586-gnu-i586-i686-musl
2025-07-01Remove support for dyn*Michael Goulet-3/+1
2025-07-01Update `cfg(bootstrap)`Josh Stone-1/+1
2025-06-30Rollup merge of #143066 - compiler-errors:let-chain-solver, r=lcnrdianqk-91/+80
Use let chains in the new solver Self-explanatory Let chains are stable as of today r? lcnr
2025-06-27Rollup merge of #142806 - compiler-errors:norm-ct-has-ty, r=lcnr,BoxyUwUMatthias Krüger-0/+1
Normalize before computing ConstArgHasType goal in new solver This is a fix for rust-lang/rust#139905. See the description I left in the test. I chose to fix this by normalizing the type before matching on its `.kind()` in `compute_const_arg_has_type_goal` (since it feels somewhat consistent with how we normalize types before assembling their candidates, for example); however, there are several other solutions that come to mind for fixing this ICE: 1. (this solution) 2. Giving `ConstKind::Error` a proper type, like `ConstKind::Value`, so that consts don't go from failing to passing `ConstArgHasType` goals after normalization (i.e. `UNEVALUATED` would normalize into a `ConstKind::Error(_, bool)` type rather than losing its type altogether). 3. Just suppressing the errors and accepting the fact that goals can go from fail->pass after normalization. Thoughts? Happy to discuss this fix further. r? `@BoxyUwU`
2025-06-27Rollup merge of #139858 - oli-obk:new-const-traits-syntax, r=fee1-deadMatthias Krüger-11/+11
New const traits syntax This PR only affects the AST and doesn't actually change anything semantically. All occurrences of `~const` outside of libcore have been replaced by `[const]`. Within libcore we have to wait for rustfmt to be bumped in the bootstrap compiler. This will happen "automatically" (when rustfmt is run) during the bootstrap bump, as rustfmt converts `~const` into `[const]`. After this we can remove the `~const` support from the parser Caveat discovered during impl: there is no legacy bare trait object recovery for `[const] Trait` as that snippet in type position goes down the slice /array parsing code and will error r? ``@fee1-dead`` cc ``@nikomatsakis`` ``@traviscross`` ``@compiler-errors``
2025-06-27Use one more let chainMichael Goulet-24/+23
2025-06-27Use let chains in the new solverMichael Goulet-67/+57
2025-06-26Rollup merge of #143073 - yotamofek:pr/fix-let-chains-fixmes, r=compiler-errorsMichael Goulet-9/+8
Fix some fixmes that were waiting for let chains Was inspired by looking at rust-lang/rust#143066 and spotting two fixmes that were missed, so... r? `@compiler-errors` 😅 Yay, let chains!
2025-06-26Rollup merge of #142927 - compiler-errors:note-find-const, r=BoxyUwUMichael Goulet-1/+1
Add note to `find_const_ty_from_env` Add a note to `find_const_ty_from_env` to explain why it has an `unwrap` which "often" causes ICEs. Also, uplift it into the new trait solver. This avoids needing to go through the interner to call this method which is otherwise an inherent method in the compiler. I can remove this part if desired. r? `@boxyuwu`
2025-06-26Fix some fixmes that were waiting for let chainsYotam Ofek-9/+8
2025-06-26Auto merge of #142774 - lcnr:search_graph-2, r=oli-obkbors-137/+47
`evaluate_goal` avoid unnecessary step based on rust-lang/rust#142617. This does not mess with the debug logging for the trait solver and is a very nice cleanup for rust-lang/rust#142735. E.g. for ```rust #[derive(Clone)] struct Wrapper<T>(T); #[derive(Clone)] struct Nested; // using a separate type to avoid the fast paths fn is_clone<T: Clone>() {} fn main() { is_clone::<Wrapper<Nested>>(); } ``` We get the following proof tree with `RUSTC_LOG=rustc_type_ir::search_graph=debug,rustc_next_trait_solver=debug` ``` rustc_next_trait_solver::solve::eval_ctxt::evaluate_root_goal goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Wrapper<Nested> as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, generate_proof_tree=No, span=src/main.rs:7:5: 7:34 (#0), stalled_on=None rustc_type_ir::search_graph::evaluate_goal input=CanonicalQueryInput { canonical: Canonical { value: QueryInput { goal: Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Wrapper<Nested> as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }, typing_mode: Analysis { defining_opaque_types_and_generators: [] } }, step_kind_from_parent=Unknown rustc_next_trait_solver::solve::eval_ctxt::probe::enter source=Impl(DefId(0:10 ~ main[21d2]::{impl#0})) rustc_next_trait_solver::solve::eval_ctxt::add_goal source=ImplWhereBound, goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<_ as std::marker::Sized>, polarity:Positive), bound_vars: [] } } rustc_next_trait_solver::solve::eval_ctxt::add_goal source=ImplWhereBound, goal=Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<_ as std::clone::Clone>, polarity:Positive), bound_vars: [] } } rustc_type_ir::search_graph::evaluate_goal input=CanonicalQueryInput { canonical: Canonical { value: QueryInput { goal: Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: Binder { value: TraitPredicate(<Nested as std::clone::Clone>, polarity:Positive), bound_vars: [] } }, predefined_opaques_in_body: PredefinedOpaques(PredefinedOpaquesData { opaque_types: [] }) }, max_universe: U0, variables: [] }, typing_mode: Analysis { defining_opaque_types_and_generators: [] } }, step_kind_from_parent=Unknown 0ms DEBUG rustc_type_ir::search_graph global cache hit, required_depth=0 0ms DEBUG rustc_type_ir::search_graph return=Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) rustc_next_trait_solver::solve::eval_ctxt::probe::enter source=BuiltinImpl(Misc) rustc_next_trait_solver::solve::trait_goals::merge_trait_candidates candidates=[Candidate { source: Impl(DefId(0:10 ~ main[21d2]::{impl#0})), result: Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] } }] 0ms DEBUG rustc_next_trait_solver::solve::trait_goals return=Ok((Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }, Some(Misc))) 0ms DEBUG rustc_type_ir::search_graph insert global cache, evaluation_result=EvaluationResult { encountered_overflow: false, required_depth: 1, heads: CycleHeads { heads: {} }, nested_goals: NestedGoals { nested_goals: {} }, result: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) } 0ms DEBUG rustc_type_ir::search_graph return=Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, variables: [] }) ```
2025-06-26Change const trait bound syntax from ~const to [const]Oli Scherer-11/+11
2025-06-25Normalize before computing ConstArgHasType goalMichael Goulet-0/+1
2025-06-25Auto merge of #142746 - compiler-errors:super-implied-outlives, r=lcnrbors-9/+6
Apply `impl_super_outlives` optimization to new trait solver I never did rust-lang/rust#128746 for the new solver. r? lcnr
2025-06-23Simplify API of solver a bitMichael Goulet-25/+22
2025-06-23Uplift find_const_ty_from_envMichael Goulet-1/+1
2025-06-23inspect: merge `[Canonical]GoalEvaluation`lcnr-82/+24
2025-06-23`evaluate_goal`: avoid unnecessary steplcnr-62/+30
2025-06-22Rollup merge of #142617 - lcnr:search_graph-3, r=compiler-errorsJacob Pratt-1/+1
improve search graph docs, reset `encountered_overflow` between reruns I think this shouldn't really matter for now. It will be more relevant for my current rework as we otherwise cannot partially reevaluate the root goal in case there has been overflow during the prervious iteration. r? ````@BoxyUwU````
2025-06-19Apply impl_super_outlives optimization to new trait solverMichael Goulet-9/+6
2025-06-18`evaluate_goal`: accept different inputslcnr-1/+1
2025-06-18Implement lint against direct uses of rustc_type_ir in compiler cratesRomain Perier-0/+1
This commit adds a lint to prevent the use of rustc_type_ir in random compiler crates, except for type system internals traits, which are explicitly allowed. Moreover, this fixes diagnostic_items() to include the CRATE_OWNER_ID, otherwise rustc_diagnostic_item attribute is ignored on the crate root.
2025-06-16trait_sel: skip elaboration of sizedness supertraitDavid Wood-4/+47
As a performance optimization, skip elaborating the supertraits of `Sized`, and if a `MetaSized` obligation is being checked, then look for a `Sized` predicate in the parameter environment. This makes the `ParamEnv` smaller which should improve compiler performance as it avoids all the iteration over the larger `ParamEnv`.
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `?Sized` typesDavid Wood-111/+60
Expand the automatic implementation of `MetaSized` and `PointeeSized` so that it is also implemented on non-`Sized` types, just not `ty::Foreign` (extern type).
2025-06-16trait_sel: `{Meta,Pointee}Sized` on `Sized` typesDavid Wood-0/+82
Introduce the `MetaSized` and `PointeeSized` traits as supertraits of `Sized` and initially implement it on everything that currently implements `Sized` to isolate any changes that simply adding the traits introduces.
2025-06-13TypeVisiting binders no longer requires TypeFolding its interiorMichael Goulet-1/+1
2025-06-13Replace escaping bound vars in ty/ct visiting, not binder visitingMichael Goulet-12/+44
2025-06-13Uplift BoundVarReplacerMichael Goulet-0/+159
2025-06-13Make connection between Placeholder and Bound a bit more clear in the type ↵Michael Goulet-4/+4
abstraction
2025-06-11Auto merge of #141763 - lcnr:fixme-gamer, r=BoxyUwUbors-3/+10
`FIXME(-Znext-solver)` triage r? `@BoxyUwU`
2025-06-08add `param_env` cache to canonicalizationlcnr-14/+60
2025-06-08move `canonicalize_param_env` into sub-fnlcnr-25/+30
2025-06-06Filter out universals and lifetimes from stalled_varsMichael Goulet-1/+12
2025-06-03`FIXME(-Znext-solver)` triagelcnr-3/+10
Co-authored-by: Michael Goulet <michael@errs.io>
2025-06-01Auto merge of #141731 - compiler-errors:tweak-fast-path-trait, r=lcnrbors-7/+8
Tweak fast path trait handling (1.) Make it more sound by considering polarity (lol) (2.) Make it more general, by considering higher-ranked size/copy/clone (2.) Make it less observable, by only doing copy/clone fast path if there are no regions involved r? lcnr
2025-05-30Auto merge of #141651 - compiler-errors:less-assert, r=lcnrbors-11/+12
Make some assertions in solver into debug assertions These may or may not be expensive :> r? lcnr
2025-05-29Tweak fast path trait handlingMichael Goulet-7/+8
2025-05-29Auto merge of #141581 - lcnr:fold-clauses, r=compiler-errorsbors-8/+50
add additional `TypeFlags` fast paths Some crates, e.g. `diesel`, have items with a lot of where-clauses (more than 150). In these cases checking the `TypeFlags` of the whole `param_env` can be very beneficial. This adds `fn fold_clauses` to mirror the existing `fn visit_clauses` and then uses this in folders which fold `ParamEnv`s. Split out from rust-lang/rust#141451, depends on rust-lang/rust#141442. r? `@compiler-errors`