about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
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-02Rollup merge of #124624 - WaffleLapkin:old_unit, r=fmeaseMatthias Krüger-2/+2
Use `tcx.types.unit` instead of `Ty::new_unit(tcx)` I don't think there is any need for the function, given that we can just access the `.types`, similarly to all other primitives?
2024-05-02Inline & delete `Ty::new_unit`, since it's just a field accessWaffle Lapkin-2/+2
2024-05-02shallow resolve in orphan checklcnr-36/+43
2024-05-02Auto merge of #124521 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68bors-1/+0
Bump bootstrap compiler to latest beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday This also cherry-picks d716d72586548963f32e5c8d57c41db0065fa6e0 from the beta branching, to continue to workaround #122758. r? bootstrap
2024-05-01Step bootstrap cfgsMark Rousskov-1/+0
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-01Rollup merge of #124566 - lcnr:normalizes-to-proof-tree, r=compiler-errorsMatthias Krüger-50/+120
fix `NormalizesTo` proof tree issue fixes #124422 cc #121848 r? ``@compiler-errors``
2024-05-01reviewlcnr-13/+15
2024-05-01Auto merge of #124356 - fmease:fewer-magic-numbers-in-names, r=lcnrbors-6/+6
Cleanup: Replace item names referencing GitHub issues or error codes with something more meaningful **lcnr** in https://github.com/rust-lang/rust/pull/117164#pullrequestreview-1969935387: > […] while I know that there's precendent to name things `Issue69420`, I really dislike this as it requires looking up the issue to figure out the purpose of such a variant. Actually referring to the underlying issue, e.g. `AliasMayNormToUncovered` or whatever and then linking to the issue in a doc comment feels a lot more desirable to me. We should ideally rename all the functions and enums which currently use issue numbers. I've grepped through `compiler/` like crazy and think that I've found all instances of this pattern. However, I haven't renamed `compute_2229_migrations_*`. Should I? The first commit introduces an abhorrent and super long name for an item because naming is hard but also scary looking / unwelcoming names are good for things related to temporary-ish backcompat hacks. I'll let you discover it by yourself. Contains a bit of drive-by cleanup and a diag migration bc that was the simplest option. r? lcnr or compiler
2024-04-30Auto merge of #117164 - fmease:orphan-norm, r=lcnrbors-67/+115
Lazily normalize inside trait ref during orphan check & consider ty params in rigid alias types to be uncovered Fixes #99554, fixes rust-lang/types-team#104. Fixes #114061. Supersedes #100555. Tracking issue for the future compatibility lint: #124559. r? lcnr
2024-04-30Give items related to issue 33140 a more meaningful nameLeón Orell Valerian Liehr-6/+6
2024-04-30fix `NormalizesTo` proof tree issuelcnr-50/+118
2024-04-30Normalize trait ref before orphan check & consider ty params in alias types ↵León Orell Valerian Liehr-67/+115
to be uncovered
2024-04-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-14/+25
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-329/+341
2024-04-29Make names more accurateMichael Goulet-15/+29
2024-04-29Remove `extern crate smallvec` from a couple of crates.Nicholas Nethercote-4/+2
2024-04-29Remove `extern crate rustc_data_structures` from numerous crates.Nicholas Nethercote-4/+1
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-6/+22
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-238/+421
`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-25Rollup merge of #124381 - compiler-errors:derived-for-wf, r=lcnrMichael Goulet-4/+4
Renamed `DerivedObligation` to `WellFormedDeriveObligation` It's used when computing `WellFormed` obligations, so let's give it a less ambiguous name.
2024-04-25Rollup merge of #124379 - compiler-errors:remove-new-solver-lookup-behavior, ↵Michael Goulet-7/+9
r=lcnr Remove special-casing for `SimplifiedType` for next solver It's unnecessary due to the way that we fully normalize the self type before assembly begins. r? lcnr
2024-04-25Renamed DerivedObligation to WellFormedDeriveObligationMichael Goulet-4/+4
2024-04-25use `EagerResolver`lcnr-1/+3
2024-04-25hir typeck: look into nested goalslcnr-237/+418
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-24Suggest cloning captured binding in `move` closureEsteban Küber-1/+10
``` error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure --> $DIR/borrowck-move-by-capture.rs:9:29 | LL | let bar: Box<_> = Box::new(3); | --- captured outer variable LL | let _g = to_fn_mut(|| { | -- captured by this `FnMut` closure LL | let _h = to_fn_once(move || -> isize { *bar }); | ^^^^^^^^^^^^^^^^ ---- | | | | | variable moved due to use in closure | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait | `bar` is moved here | help: clone the value before moving it into the closure | LL ~ let value = bar.clone(); LL ~ let _h = to_fn_once(move || -> isize { value }); | ```
2024-04-24Modify `find_expr` from `Span` to better account for closuresEsteban Küber-6/+13
Start pointing to where bindings were declared when they are captured in closures: ``` error[E0597]: `x` does not live long enough --> $DIR/suggest-return-closure.rs:23:9 | LL | let x = String::new(); | - binding `x` declared here ... LL | |c| { | --- value captured here LL | x.push(c); | ^ borrowed value does not live long enough ... LL | } | -- borrow later used here | | | `x` dropped here while still borrowed ``` Suggest cloning in more cases involving closures: ``` error[E0507]: cannot move out of `foo` in pattern guard --> $DIR/issue-27282-move-ref-mut-into-guard.rs:11:19 | LL | if { (|| { let mut bar = foo; bar.take() })(); false } => {}, | ^^ --- move occurs because `foo` has type `&mut Option<&i32>`, which does not implement the `Copy` trait | | | `foo` is moved here | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard help: consider cloning the value if the performance cost is acceptable | LL | if { (|| { let mut bar = foo.clone(); bar.take() })(); false } => {}, | ++++++++ ```
2024-04-23Rollup merge of #124218 - Xiretza:subsubdiagnostics, r=davidtwcoLeón Orell Valerian Liehr-1/+1
Allow nesting subdiagnostics in #[derive(Subdiagnostic)]
2024-04-23Rollup merge of #120929 - long-long-float:wrap-dyn-in-suggestion, r=fmeaseLeón Orell Valerian Liehr-8/+19
Wrap dyn type with parentheses in suggestion Close #120223 Fix wrong suggestion that is grammatically incorrect. Specifically, I added parentheses to dyn types that need lifetime bound. ``` help: consider adding an explicit lifetime bound | 4 | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static, | + +++++++++++ ```
2024-04-23Rollup merge of #124168 - oli-obk:define_opaque_types12, r=lcnrMatthias Krüger-1/+1
Use `DefiningOpaqueTypes::Yes` in rustdoc, where the `InferCtxt` is guaranteed to have no opaque types it can define r? `@lcnr` I manually checked there it's always `tcx.infer_ctxt().build()`
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-1/+117
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-22Rollup merge of #124183 - compiler-errors:unnecessary-by-ref, r=oli-obkGuillaume Gomez-6/+6
Stop taking `ParamTy`/`ParamConst`/`EarlyParamRegion`/`AliasTy` by ref It's unnecessary and is annoying when we have it by value.
2024-04-23Wrap dyn type with parentheses in suggestionlong-long-float-8/+19
2024-04-22Use `DefiningOpaqueTypes::Yes`, as the `InferCtxt` we use has no opaque ↵Oli Scherer-1/+1
types it may define
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-21Pass translation closure to add_to_diag_with() as referenceXiretza-1/+1
2024-04-20merge two impl blocksLukas Markeffsky-2/+0
2024-04-20remove `InferCtxt::clear_caches`Lukas Markeffsky-3/+0
2024-04-20include ParamEnv in projection cache keyLukas Markeffsky-11/+16
2024-04-19Stop taking ParamTy/ParamConst/EarlyParamRegion/AliasTy by refMichael Goulet-6/+6