summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2023-09-09 unconstrained region vars: do not ICE ICE babylcnr-9/+5
2023-08-30Revert "Suggest using `Arc` on `!Send`/`!Sync` types"David Tolnay-6/+0
This reverts commit 9de1a472b68ed85f396b2e2cc79c3ef17584d6e1. (cherry picked from commit 823bacb6e3b04c0c9eecb53cc04d4ef96e45d20a)
2023-08-18Auto merge of #114611 - nnethercote:type-system-chess, r=compiler-errorsbors-9/+4
Speed up compilation of `type-system-chess` [`type-system-chess`](https://github.com/rust-lang/rustc-perf/pull/1680) is an unusual program that implements a compile-time chess position solver in the trait system(!) This PR is about making it compile faster. r? `@ghost`
2023-08-15Rollup merge of #114819 - estebank:issue-78124, r=compiler-errorsMatthias Krüger-1/+1
Point at return type when it influences non-first `match` arm When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-08-15more nitsMichael Goulet-17/+49
2023-08-15Reuse the selection context, compute failing obligations first in ambig modeMichael Goulet-88/+78
2023-08-15nitsMichael Goulet-3/+3
Co-authored-by: lcnr <rust@lcnr.de>
2023-08-15Implement lint against coinductive impl overlapMichael Goulet-6/+75
2023-08-15more span infoMichael Goulet-7/+9
2023-08-14Point at return type when it influences non-first `match` armEsteban Küber-1/+1
When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-08-14Remove constness from `ImplSource::Param`Deadbeef-4/+3
2023-08-13Auto merge of #114457 - lcnr:trait_ref_is_knowable-normalize, r=compiler-errorsbors-26/+44
normalize in `trait_ref_is_knowable` in new solver fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/51 Alternatively we could avoid normalizing the self type and do this at the end of the `assemble_candidates_via_self_ty` stack by splitting candidates into: - applicable without normalizing self type - applicable for aliases, even if they can be normalized - applicable for stuff which cannot get normalized further I don't think this would have any significant benefits and it also seems non-trivial to avoid normalizing only the self type in `trait_ref_is_knowable`. r? `@compiler-errors`
2023-08-12normalize in `trait_ref_is_knowable` in new solverlcnr-26/+44
2023-08-11remove builtin impl for float and int inferlcnr-5/+2
2023-08-10Comment nitsMichael Goulet-1/+1
2023-08-09Suggest using `Arc` on `!Send`/`!Sync` typesEsteban Kuber-0/+6
2023-08-09Rollup merge of #114548 - fee1-dead-contrib:migrate-to-trans, r=davidtwcoMatthias Krüger-33/+17
Migrate a trait selection error to use diagnostic translation
2023-08-08Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obkbors-21/+0
correctly lower `impl const` to bind to host effect param r? `@oli-obk`
2023-08-08Only dedup obligation after new ones have been added.Nicholas Nethercote-4/+4
2023-08-08Size the `deduped` set appropriately.Nicholas Nethercote-1/+1
Avoids lots of resizing as the set fills up.
2023-08-08Simplify the boolean logic in a closure.Nicholas Nethercote-6/+1
And rename a closure argument.
2023-08-08Rollup merge of #114594 - compiler-errors:new-solver-resolve-aliases, r=lcnrMatthias Krüger-1/+3
Structurally normalize weak and inherent in new solver It seems pretty obvious to me that we should be normalizing weak and inherent aliases too, since they can always be normalized. This PR still leaves open the question of what to do with opaques, though 💀 **Also**, we need to structurally resolve the target of a coercion, for the UI test to work. r? `@lcnr`
2023-08-07Structurally normalize weak and inherent tooMichael Goulet-1/+3
2023-08-07Migrate a trait selection error to use diagnostic translationDeadbeef-33/+17
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-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-73/+141
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-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-5/+6
2023-08-03Rework upcastingMichael Goulet-59/+80
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-03builtin impl confirmation wuhulcnr-23/+17
2023-08-02Remove constness from `TraitPredicate`Deadbeef-93/+45
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-4/+13
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-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-01Convert adt_sized_constraint to early-binder, use listMichael Goulet-1/+1
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-30inline format!() args up to and including rustc_codegen_llvmMatthias Krüger-153/+128
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`