about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/solve
AgeCommit message (Collapse)AuthorLines
2024-05-10Use fewer origins when creating type variables.Nicholas Nethercote-33/+8
`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/+34
2024-05-07Rollup merge of #124846 - compiler-errors:const-eval, r=lcnrMatthias Krüger-3/+3
Don't ICE when we cannot eval a const to a valtree in the new solver Use `const_eval_resolve` instead of `try_const_eval_resolve` because naming aside, the former doesn't ICE when a value can't be evaluated to a valtree. r? lcnr
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
2024-05-07Don't ICE when we cannot eval a const to a valtree in the new solverMichael Goulet-3/+3
2024-05-06Rollup merge of #124809 - lcnr:prepopulate-opaques, r=compiler-errorsMatthias Krüger-9/+6
borrowck: prepopulate opaque storage more eagerly otherwise we ICE due to ambiguity when normalizing while computing implied bounds. r? ``@compiler-errors``
2024-05-06Rollup merge of #124759 - compiler-errors:impl-args, r=lcnrMatthias Krüger-65/+93
Record impl args in the proof tree in new solver Rather than rematching them during select. Also use `ImplSource::Param` instead of `ImplSource::Builtin` for alias-bound candidates, so we don't ICE in `Instance::resolve`. r? lcnr
2024-05-06Use correct ImplSource for alias boundsMichael Goulet-2/+1
2024-05-06Record impl args in the InsepctCandiate rather than rematching during selectMichael Goulet-65/+94
2024-05-06Rollup merge of #124771 - compiler-errors:cand-has-failing-wc, r=lcnrMatthias Krüger-6/+42
Don't consider candidates with no failing where clauses when refining obligation causes in new solver Improves error messages when we have param-env candidates that don't deeply unify (i.e. after alias-bounds). r? lcnr
2024-05-06Rollup merge of #124724 - compiler-errors:prefer-lower, r=lcnrMatthias Krüger-5/+13
Prefer lower vtable candidates in select in new solver Also, adjust the select visitor to only winnow when the *parent* goal is `Certainty::Yes`. This means that we won't winnow in cases when we have any ambiguous inference guidance from two candidates. r? lcnr
2024-05-06switch new solver to directly inject opaque typeslcnr-9/+6
2024-05-06Don't consider candidates with no failing where clausesMichael Goulet-6/+42
2024-05-06Prefer lower vtable candidates in select in new solverMichael Goulet-5/+13
2024-05-04Rollup merge of #124718 - compiler-errors:record-impl-args, r=lcnrMatthias Krüger-2/+6
Record impl args in the proof tree Weren't recording these since they went through a different infcx method r? lcnr
2024-05-04Rollup merge of #124717 - compiler-errors:do-not-recomment-next-solver, r=lcnrMatthias Krüger-0/+9
Implement `do_not_recommend` in the new solver Put the test into `diagnostic_namespace` test folder even though it's not in the diagnostic namespace, because it should be soon. r? lcnr cc `@weiznich`
2024-05-04Record impl args in the proof treeMichael Goulet-2/+6
2024-05-04Implement do_not_recommend in the new solverMichael Goulet-0/+9
2024-05-04Only consider ambiguous goals when finding best obligation for ambiguitiesMichael Goulet-9/+11
2024-05-03Rollup merge of #124418 - compiler-errors:better-cause, r=lcnrMichael Goulet-40/+200
Use a proof tree visitor to refine the `Obligation` for error reporting in new solver With the magic of `ProofTreeVisitor`, we can close the gap that we have on `ObligationCause`s being not as descriptive in the new trait solver. r? lcnr Needs some work and obviously documentation.
2024-05-02Use ObligationCtxt in favor of TraitEngine in many placesMichael Goulet-10/+8
2024-05-02Higher ranked goal source, do overflow handling less badlyMichael Goulet-80/+87
2024-05-02Use a proof tree visitor to refine the Obligation for error reportingMichael Goulet-10/+147
2024-05-02Record more kinds of things as impl where boundsMichael Goulet-12/+13
2024-05-02Store goal source in InspectGoalMichael Goulet-12/+27
2024-05-02Record certainty before evaluating nesteds, so we make candidatesMichael Goulet-2/+2
2024-05-02shallow resolve in orphan checklcnr-8/+16
2024-05-02Auto merge of #124529 - compiler-errors:select, r=lcnrbors-328/+156
Rewrite select (in the new solver) to use a `ProofTreeVisitor` We can use a proof tree visitor rather than collecting and recomputing all the nested goals ourselves. Based on #124415
2024-05-01Rewrite select to use a ProofTreeVisitorMichael Goulet-328/+156
2024-05-01reviewlcnr-13/+15
2024-04-30fix `NormalizesTo` proof tree issuelcnr-50/+118
2024-04-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-0/+5
Remove many `#[macro_use] extern crate foo` items This requires the addition of more `use` items, which often make the code more verbose. But they also make the code easier to read, because `#[macro_use]` obscures where macros are defined. r? `@fee1-dead`
2024-04-29Split out instantiate_nested_goalsMichael Goulet-36/+43
2024-04-29Take proof trees by value in inspect goalMichael Goulet-15/+12
2024-04-29Only register candidate if it is associated w a shallow certaintyMichael Goulet-38/+28
2024-04-29Actually use probes when needed and stop relying on existing outer probesMichael Goulet-326/+339
2024-04-29Make names more accurateMichael Goulet-15/+29
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-0/+5
2024-04-27Record certainty of evaluate_added_goals_and_make_canonical_response call in ↵Michael Goulet-0/+40
candidate
2024-04-26Auto merge of #122385 - lcnr:analyze-obligations-for-infer, r=compiler-errorsbors-235/+414
`obligations_for_self_ty`: use `ProofTreeVisitor` for nested goals As always, dealing with proof trees continues to be a hacked together mess. After this PR and #124380 the only remaining blocker for core is https://github.com/rust-lang/trait-system-refactor-initiative/issues/90. There is also a `ProofTreeVisitor` issue causing an ICE when compiling `alloc` which I will handle in a separate PR. This issue likely affects coherence diagnostics more generally. The core idea is to extend the proof tree visitor to support visiting nested candidates without using a `probe`. We then simply recurse into nested candidates if they are the only potentially applicable candidate for a given goal and check whether the self type matches the expected one. For that to work, we need to improve `CanonicalState` to also handle unconstrained inference variables created inside of the trait solver. This is done by extending the `var_values` of `CanoncalState` with each fresh inference variables. Furthermore, we also store the state of all inference variables at the end of each probe. When recursing into `InspectCandidates` we then unify the values of all these states. r? `@compiler-errors`
2024-04-25use `EagerResolver`lcnr-1/+3
2024-04-25hir typeck: look into nested goalslcnr-234/+411
uses a `ProofTreeVisitor` to look into nested goals when looking at the pending obligations during hir typeck. Used by closure signature inference, coercion, and for async functions.
2024-04-25Remove special-casing for SimplifiedType for next solverMichael Goulet-7/+9
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+72
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-22Fix copy-paste typo in the comment within ↵Daria Sukhonina-2/+2
consider_builtin_async_destruct_candidate
2024-04-22Exhaustivelly match TyKind in consider_builtin_async_destruct_candidateDaria Sukhonina-1/+1
2024-04-17Use non-exhaustive matches for TyKindDaria Sukhonina-6/+6
Also no longer export noop async_drop_in_place_raw
2024-04-16Auto merge of #123537 - compiler-errors:shallow, r=lcnrbors-1/+1
Simplify shallow resolver to just fold ty/consts Probably faster than using a whole folder?
2024-04-16Add simple async drop glue generationzetanumbers-0/+72
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801