about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/solve/inspect
AgeCommit message (Collapse)AuthorLines
2025-09-18move `mod canonical` out of `eval_ctxt`lcnr-2/+2
2025-09-18support calls on opaque types :<lcnr-1/+1
2025-08-29cleanup proof tree implementation and add cachelcnr-12/+6
2025-06-26Auto merge of #142774 - lcnr:search_graph-2, r=oli-obkbors-6/+6
`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-23Simplify API of solver a bitMichael Goulet-14/+6
2025-06-23inspect: merge `[Canonical]GoalEvaluation`lcnr-6/+6
2025-06-09Apply nested goals certainty to InspectGoals for normalizes-toMichael Goulet-35/+64
2025-06-07Rollup merge of #142126 - compiler-errors:normalize-uv-via-relate, r=BoxyUwUGuillaume Gomez-4/+1
Treat normalizing consts like normalizing types in deeply normalize ...so that we don't end up putting a top-level normalizes-to goal in the fulfillment context, which ICEs. This basically just models the normalize-const code off of the normalize-ty code above it, which uses an alias-relate goal instead. Fixes rust-lang/rust#140571 r? lcnr
2025-06-07Unify normalization of terms in deeply normalizeMichael Goulet-4/+1
2025-06-05Only instantiate impl argsMichael Goulet-28/+53
2025-05-29Auto merge of #141581 - lcnr:fold-clauses, r=compiler-errorsbors-5/+4
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`
2025-05-27Rename unpack to kindMichael Goulet-1/+1
2025-05-26add additional `TypeFlags` fast pathslcnr-5/+4
2025-05-26Don't rerun goals if none of its vars have changedMichael Goulet-3/+4
2025-05-07Use MaybeCause::or to allow constraints from overflows if they are combined ↵Michael Goulet-1/+1
with ambiguity
2025-04-16Fix replacing supertrait aliases in ReplaceProjectionWithMichael Goulet-3/+5
2025-03-15Fold visit into tyMichael Goulet-2/+1
2025-02-19Make fewer crates depend on rustc_ast_irMichael Goulet-2/+1
2025-02-13normalizes-to rework rigid alias handlinglcnr-2/+0
2025-02-05Pass spans around new solverMichael Goulet-3/+6
2025-01-31Manually walk into WF obligations in BestObligation proof tree visitorMichael Goulet-36/+46
2024-10-22remove unused fieldlcnr-1/+1
2024-10-15Be better at reporting alias errorsMichael Goulet-2/+4
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-08-30Remove `#[macro_use] extern crate tracing` from `rustc_trait_selection`.Nicholas Nethercote-0/+1
2024-08-14Rollup merge of #128828 - lcnr:search-graph-11, r=compiler-errors许杰友 Jieyou Xu (Joe)-7/+3
`-Znext-solver` caching This PR has two major changes while also fixing multiple issues found via fuzzing. The main optimization is the ability to not discard provisional cache entries when popping the highest cycle head the entry depends on. This fixes the hang in Fuchsia with `-Znext-solver=coherence`. It also bails if the result of a fixpoint iteration is ambiguous, even without reaching a fixpoint. This is necessary to avoid exponential blowup if a coinductive cycle results in ambiguity, e.g. due to unknowable candidates in coherence. Updating stack entries pretty much exclusively happens lazily now, so `fn check_invariants` ended up being mostly useless and I've removed it. See https://gist.github.com/lcnr/8de338fdb2685581e17727bbfab0622a for the invariants we would be able to assert with it. For a general overview, see the in-process update of the relevant rustc-dev-guide chapter: https://hackmd.io/1ALkSjKlSCyQG-dVb_PUHw r? ```@compiler-errors```
2024-08-12do not use the global solver cache for proof treeslcnr-7/+3
doing so requires overwriting global cache entries and generally adds significant complexity to the solver. This is also only ever done for root goals, so it feels easier to wrap the `evaluate_canonical_goal` in an ordinary query if necessary.
2024-08-11Use assert_matches around the compilerMichael Goulet-2/+4
2024-06-21Rename a bunch of thingsMichael Goulet-1/+1
2024-06-18Fix impl for SolverDelegateMichael Goulet-38/+16
2024-06-18Uplift the new trait solverMichael Goulet-580/+0
2024-06-18SolverDelegateMichael Goulet-7/+11
2024-06-15Rollup merge of #126404 - compiler-errors:alias-relate-terms, r=lcnrGuillaume Gomez-1/+14
Check that alias-relate terms are WF if reporting an error in alias-relate Check that each of the left/right term is WF when deriving a best error obligation for an alias-relate goal. This will make sure that given `<i32 as NotImplemented>::Assoc = ()` will drill down into `i32: NotImplemented` since we currently treat the projection as rigid. r? lcnr
2024-06-14Correctly consider depth when visiting WF goalsMichael Goulet-1/+14
2024-06-13Address nitsMichael Goulet-3/+4
- Remove the ValuePairs glob import - Make DummyPairs -> ValuePairs::Dummy and make it bug more - Fix WC - Make interner return `impl IntoIterator`s
2024-06-12Walk into alias-eq nested goals even if normalization failsMichael Goulet-2/+5
2024-06-05Basic removal of `Ty` from places (boring)Boxy-1/+1
2024-05-28Make ProofTreeBuilder actually generic over internerMichael Goulet-59/+53
2024-05-28refactor analyse visitor to instantiate states in orderlcnr-45/+41
2024-05-24remove proof tree formatter, make em shallowlcnr-167/+72
2024-05-20Rework var resolution in InferCtxtLike, uplift EagerResolverMichael Goulet-1/+1
2024-05-18Make proof tree building genericMichael Goulet-88/+102
2024-05-18Uplift inspect into rustc_type_irMichael Goulet-24/+25
2024-05-13Use a proper probe for shadowing implMichael Goulet-10/+24
2024-05-13Remove `extern crate rustc_middle` from `rustc_trait_selection`.Nicholas Nethercote-0/+1
2024-05-10Rollup merge of #124955 - nnethercote:next_ty_var, r=lcnrMatthias Krüger-11/+2
Use fewer origins when creating type variables. To reduce lots of repetitive boilerplate code. Details in the individual commit messages. r? ``@lcnr``
2024-05-10Use fewer origins when creating type variables.Nicholas Nethercote-11/+2
`InferCtxt::next_{ty,const}_var*` all take an origin, but the `param_def_id` is almost always `None`. This commit changes them to just take a `Span` and build the origin within the method, and adds new methods for the rare cases where `param_def_id` might not be `None`. This avoids a lot of tedious origin building. Specifically: - next_ty_var{,_id_in_universe,_in_universe}: now take `Span` instead of `TypeVariableOrigin` - next_ty_var_with_origin: added - next_const_var{,_in_universe}: takes Span instead of ConstVariableOrigin - next_const_var_with_origin: added - next_region_var, next_region_var_in_universe: these are unchanged, still take RegionVariableOrigin The API inconsistency (ty/const vs region) seems worth it for the large conciseness improvements.
2024-05-09analyse visitor: build proof tree in probelcnr-11/+33
2024-05-07Rollup merge of #124827 - lcnr:generalize-incomplete, r=compiler-errorsMatthias Krüger-1/+4
generalize hr alias: avoid unconstrainable infer vars fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/108 see inline comments for more details r? `@compiler-errors` cc `@BoxyUwU`
2024-05-07generalize hr alias: avoid unconstrainable infer varslcnr-1/+4