about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-08-07Structurally normalize weak and inherent tooMichael Goulet-1/+3
2023-08-07Rollup merge of #114196 - compiler-errors:bubble-pls, r=lcnrMatthias Krüger-23/+24
Bubble up nested goals from equation in `predicates_for_object_candidate` This used to be needed for https://github.com/rust-lang/rust/pull/114036#discussion_r1273987510, but since it's no longer, I'm opening this as a separate PR. This also fixes one ICEing UI test: (`tests/ui/unboxed-closures/issue-53448.rs`) r? `@lcnr`
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-1/+1
2023-08-07Migrate a trait selection error to use diagnostic translationDeadbeef-34/+52
2023-08-07Rollup merge of #114549 - chenyukang:yukang-review-resolve-part, r=petrochenkovMatthias Krüger-14/+12
Style fix and refactor on resolve diagnostics - coding style - refactor api of `span_look_ahead`
2023-08-06refactor on span_look_aheadyukang-14/+12
2023-08-06lower impl const to bind to host effect paramDeadbeef-21/+0
2023-08-05Also report when goals go from ok to errorMichael Goulet-2/+8
2023-08-04Rollup merge of #114490 - kernelmethod:error-reporting-typos, r=compiler-errorsMichael Goulet-1/+1
Fix a typo in the error reporting for sealed traits. Fixes a typo in error reporting: "implelement" -> "implement"
2023-08-04Rollup merge of #114287 - lcnr:overflow, r=compiler-errorsMichael Goulet-531/+447
update overflow handling in the new trait solver implements https://hackmd.io/QY0dfEOgSNWwU4oiGnVRLw?view. I want to clean up this doc and add it to the rustc-dev-guide, but I think this PR is ready for merge as is, even without the dev-guide entry. r? `@compiler-errors`
2023-08-05Fix a typo in the error reporting for sealed traits.kernelmethod-1/+1
2023-08-04Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31Matthias Krüger-1/+1
Improve spans for indexing expressions fixes #114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
2023-08-04Rollup merge of #113945 - chenyukang:yukang-fix-113447-slice-2, r=cjgillotMatthias Krüger-3/+13
Fix wrong span for trait selection failure error reporting Fixes #113447
2023-08-04Improve spans for indexing expressionsNilstrieb-1/+1
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-04Auto merge of #114036 - compiler-errors:upcast-to-fewer-assocs, r=lcnrbors-110/+234
Rework upcasting confirmation to support upcasting to fewer projections in target bounds This PR implements a modified trait upcasting algorithm that is resilient to changes in the number of associated types in the bounds of the source and target trait objects. It does this by equating each bound of the target trait ref individually against the bounds of the source trait ref, rather than doing them all together by constructing a new trait object. #### The new way we do trait upcasting confirmation 1. Equate the target trait object's principal trait ref with one of the supertraits of the source trait object's principal. https://github.com/rust-lang/rust/blob/fdcab310b2a57a4e9cc0b2629abd27afda49cd80/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2509-L2525 2. Make sure that every auto trait in the *target* trait object is present in the source trait ref's bounds. https://github.com/rust-lang/rust/blob/fdcab310b2a57a4e9cc0b2629abd27afda49cd80/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2559-L2562 3. For each projection in the *target* trait object, make sure there is exactly one projection that equates with it in the source trait ref's bound. If there is more than one, bail with ambiguity. https://github.com/rust-lang/rust/blob/fdcab310b2a57a4e9cc0b2629abd27afda49cd80/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2526-L2557 * Since there may be more than one that applies, we probe first to check that there is exactly one, then we equate it outside of a probe once we know that it's unique. 4. Make sure the lifetime of the source trait object outlives the lifetime of the target. <details> <summary>Meanwhile, this is how we used to do upcasting:</summary> 1. For each supertrait of the source trait object, take that supertrait, append the source object's projection bounds, and the *target* trait object's auto trait bounds, and make this into a new object type: https://github.com/rust-lang/rust/blob/d12c6e947ceacf3b22c154caf9532b390d8dc88a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs#L915-L929 2. Then equate it with the target trait object: https://github.com/rust-lang/rust/blob/d12c6e947ceacf3b22c154caf9532b390d8dc88a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs#L936 This will be a type mismatch if the target trait object has fewer projection bounds, since we compare the bounds structurally in relate: https://github.com/rust-lang/rust/blob/d12c6e947ceacf3b22c154caf9532b390d8dc88a/compiler/rustc_middle/src/ty/relate.rs#L696-L698 </details> Fixes #114035 Also fixes #114113, because I added a normalize call in the old solver. r? types
2023-08-04Rollup merge of #114355 - compiler-errors:resolve_vars_early, r=lcnrMatthias Krüger-91/+144
resolve before canonicalization in new solver, ICE if unresolved Fold the values with a resolver before canonicalization instead of making it happen within canonicalization. This allows us to filter trivial region constraints from the external constraints. r? ``@lcnr``
2023-08-03Remove trivial region constraintsMichael Goulet-1/+6
2023-08-03resolve before canonicalization, ICE if unresolvedMichael Goulet-67/+114
2023-08-03separate calculation and interning of external query constraintsMichael Goulet-27/+28
2023-08-03Don't be incompleteMichael Goulet-92/+128
2023-08-03Fix upcasting with normalization in old solver, add a testMichael Goulet-2/+12
2023-08-03short-circuit when proj def ids differMichael Goulet-14/+20
2023-08-03Rework upcastingMichael Goulet-96/+168
2023-08-04enable suggest convert to slice for binary operationyukang-3/+5
2023-08-03Fix wrong span for trait selection failure error reportingyukang-0/+8
2023-08-03inline helper methods into `with_new_goal`lcnr-115/+80
2023-08-03rewrite stack dependent overflow handlinglcnr-173/+180
2023-08-03handle overflow in the `EvalCtxt` separatelylcnr-189/+156
2023-08-03add `ensure_sufficient_stack` to the new solverlcnr-18/+21
2023-08-03fix `make_ambiguous_response_no_constraints`lcnr-47/+41
we previously had incorrect universes in the query response.
2023-08-03avoid more `ty::Binder:dummy`lcnr-36/+16
2023-08-03builtin impl confirmation wuhulcnr-23/+17
2023-08-02Remove constness from `TraitPredicate`Deadbeef-95/+46
2023-08-02Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obkNilstrieb-5/+6
Use `upvar_tys` in more places, make it return a list Just a cleanup that fell out of a PR that I was gonna write, but that PR kinda got stuck.
2023-08-02Auto merge of #114358 - matthiaskrgr:rollup-d810m9e, r=matthiaskrgrbors-5/+17
Rollup of 6 pull requests Successful merges: - #114178 (Account for macros when suggesting a new let binding) - #114199 (Don't unsize coerce infer vars in select in new solver) - #114301 (Don't check unnecessarily that impl trait is RPIT) - #114314 (Tweaks to `adt_sized_constraint`) - #114322 (Fix invalid slice coercion suggestion reported in turbofish) - #114340 ([rustc_attr][nit] Replace `filter` + `is_some` with `map_or`.) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-02Rollup merge of #114322 - Urgau:fix-issue-110063, r=compiler-errorsMatthias Krüger-3/+12
Fix invalid slice coercion suggestion reported in turbofish This PR fixes the invalid slice coercion suggestion reported in turbofish and inferred generics by not emitting them. Fixes https://github.com/rust-lang/rust/issues/110063
2023-08-02Rollup merge of #114314 - compiler-errors:sized-crit, r=lcnrMatthias Krüger-2/+2
Tweaks to `adt_sized_constraint` fixes a comment, but also some other nits. r? lcnr
2023-08-02Auto merge of #114170 - lcnr:add-commmentz, r=compiler-errorsbors-10/+0
add `dropck_outlives` comments
2023-08-01Use upvar_tys in more places, make it a listMichael Goulet-5/+6
2023-08-01Don't select infer -> dyn TraitMichael Goulet-0/+3
2023-08-01Convert adt_sized_constraint to early-binder, use listMichael Goulet-2/+2
2023-08-01Rename `maybe_suggest_convert_to_slice` fn name to consistent namingUrgau-3/+3
2023-08-01Fix invalid slice coercion suggestion reported in turbofishUrgau-0/+9
2023-07-31Rollup merge of #114200 - compiler-errors:detect-tail-unsize-then-upcast, r=lcnrMatthias Krüger-5/+20
Detect trait upcasting through struct tail unsizing in new solver select Oops, we were able to hide trait upcasting behind a parent unsize goal that evaluated to `Certainty::Yes`. Let's do rematching for `Certainty::Yes` unsize goals with `BuiltinImplSource::Misc` sources (corresponding to all of the other unsize rules) to make sure we end up selecting any nested goals which may be satisfied via `BuiltinImplSource::TraitUpcasting` or `::TupleUnsizing`. r? ``@lcnr``
2023-07-31Rollup merge of #114169 - lcnr:unsize, r=compiler-errorsMatthias Krüger-218/+258
refactor builtin unsize handling, extend comments r? `@compiler-errors`
2023-07-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-153/+128
2023-07-29Detect trait upcasting through struct tail unsizingMichael Goulet-5/+20
2023-07-29Bubble up nested goals from equation in predicates_for_object_candidateMichael Goulet-23/+24
2023-07-29Auto merge of #111916 - fee1-dead-contrib:noop-method-call-warn, ↵bors-2/+1
r=compiler-errors make `noop_method_call` warn by default r? `@compiler-errors`
2023-07-28Lower generic const items to HIRLeón Orell Valerian Liehr-0/+2