about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
2023-09-02Signed-off-by: cui fliter <imcusg@gmail.com>cui fliter-1/+1
remove the repetitive word Signed-off-by: cui fliter <imcusg@gmail.com>
2023-09-01Auto merge of #113201 - oli-obk:recursive_type_alias, r=estebank,compiler-errorsbors-1/+20
Permit recursive weak type aliases I saw #63097 and thought "we can do ~~better~~ funnier". So here it is. It's not useful, but it's certainly something. This may actually become feasible with lazy norm (so in 5 years (constant, not reducing over time)). r? `@estebank` cc `@GuillaumeGomez`
2023-08-31Rollup merge of #115373 - lqd:come-on-bors, r=compiler-errorsMatthias Krüger-5/+1
Fix bors missing a commit when merging #115355 bors incorrectly merged an outdated version of PR #115355 (via rollup #115370): - it [recorded r+](https://github.com/rust-lang/rust/pull/115355#issuecomment-1698372365) as approving commit https://github.com/rust-lang/rust/commit/325b585259871c99093b2a2e9463f941b8aa0ceb, and thus merged the original revision https://github.com/rust-lang/rust/commit/7762ac7bb5ac10046a5a9ee838480a78bf150237 - but the branch at the time was at commit https://github.com/rust-lang/rust/commit/eefa07d69baad3207ad520da8590fb44ef989416, so bors missed the `compiler/rustc_trait_selection/src/solve/search_graph/mod.rs` cleanup in commit https://github.com/rust-lang/rust/pull/115355/commits/0e1e964a349681504e7103d4ec70aca5616222fc 😓 Thankfully the change that bors missed was small, and this new PR corrects the situation (as I'd rather avoid having confusing multiple merge commits of PR #115355 in the git history) r? ``@compiler-errors``
2023-08-30Don't record spans for predicates in coherenceMichael Goulet-19/+11
2023-08-30Permit recursive weak type aliasesOli Scherer-1/+20
2023-08-30clean up `local_overflow_limit` computationRémy Rakic-5/+1
fixes bors snafu where it merged an outdated commit and missed this change
2023-08-29handle edge-case of a recursion limit of 0Rémy Rakic-1/+5
2023-08-28Auto merge of #115326 - matthiaskrgr:rollup-qsoa8ar, r=matthiaskrgrbors-20/+9
Rollup of 8 pull requests Successful merges: - #115164 (MIR validation: reject in-place argument/return for packed fields) - #115240 (codegen_llvm/llvm_type: avoid matching on the Rust type) - #115294 (More precisely detect cycle errors from type_of on opaque) - #115310 (Document panic behavior across editions, and improve xrefs) - #115311 (Revert "Suggest using `Arc` on `!Send`/`!Sync` types") - #115317 (Devacationize oli-obk) - #115319 (don't use SnapshotVec in Graph implementation, as it looks unused; use Vec instead) - #115322 (Tweak output of `to_pretty_impl_header` involving only anon lifetimes) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-28Rollup merge of #115322 - estebank:list-tweak, r=compiler-errorsMatthias Krüger-9/+3
Tweak output of `to_pretty_impl_header` involving only anon lifetimes Do not print `impl<> Foo for &Bar`.
2023-08-28Rollup merge of #115311 - dtolnay:usearcself, r=compiler-errorsMatthias Krüger-6/+0
Revert "Suggest using `Arc` on `!Send`/`!Sync` types" Closes https://github.com/rust-lang/rust/issues/114687. This is a clean revert of https://github.com/rust-lang/rust/pull/88936 + https://github.com/rust-lang/rust/pull/115210. The suggestion to Arc\<{Self}\> when Self does not implement Send is *always* wrong. https://github.com/rust-lang/rust/pull/114842 is considering a way to make a more refined suggestion.
2023-08-28Rollup merge of #115294 - compiler-errors:cycle-err, r=oli-obkMatthias Krüger-5/+6
More precisely detect cycle errors from type_of on opaque Not sure if this still needs work. Just putting it up for initial impressions, since it seems that a few people are frustrated with the increased error verbosity due to #113320. Essentially we introduce a new sub-query for `type_of` specifically for opaques which returns a value that is able to distinguish "has errors" from "due to cycle recovery". Fixes #115188 r? `@oli-obk`
2023-08-28Tweak output of `to_pretty_impl_header` involving only anon lifetimesEsteban Küber-9/+3
Do not print `impl<> Foo for &Bar`.
2023-08-28Revert "Suggest using `Arc` on `!Send`/`!Sync` types"David Tolnay-6/+0
This reverts commit 9de1a472b68ed85f396b2e2cc79c3ef17584d6e1.
2023-08-28Better error message for object type with GATMichael Goulet-1/+1
2023-08-27More precisely detect cycle errors from type_of on opaqueMichael Goulet-5/+6
2023-08-27Rollup merge of #114974 - nbdd0121:vtable, r=b-naberGuillaume Gomez-1/+1
Add an (perma-)unstable option to disable vtable vptr This flag is intended for evaluation of trait upcasting space cost for embedded use cases. Compared to the approach in #112355, this option provides a way to evaluate end-to-end cost of trait upcasting. Rationale: https://github.com/rust-lang/rust/issues/112355#issuecomment-1658207769 ## How this flag should be used (after merge) Build your project with and without `-Zno-trait-vptr` flag. If you are using cargo, set `RUSTFLAGS="-Zno-trait-vptr"` in the environment variable. You probably also want to use `-Zbuild-std` or the binary built may be broken. Save both binaries somewhere. ### Evaluate the space cost The option has a direct and indirect impact on vtable space usage. Directly, it gets rid of the trait vptr entry needed to store a pointer to a vtable of a supertrait. (IMO) this is a small saving usually. The larger saving usually comes with the indirect saving by eliminating the vtable of the supertrait (and its parent). Both impacts only affects vtables (notably the number of functions monomorphized should , however where vtable reside can depend on your relocation model. If the relocation model is static, then vtable is rodata (usually stored in Flash/ROM together with text in embedded scenario). If the binary is relocatable, however, the vtable will live in `.data` (more specifically, `.data.rel.ro`), and this will need to reside in RAM (which may be a more scarce resource in some cases), together with dynamic relocation info living in readonly segment. For evaluation, you should run `size` on both binaries, with and without the flag. `size` would output three columns, `text`, `data`, `bss` and the sum `dec` (and it's hex version). As explained above, both `text` and `data` may change. `bss` shouldn't usually change. It'll be useful to see: * Percentage change in text + data (indicating required flash/ROM size) * Percentage change in data + bss (indicating required RAM size)
2023-08-18instantiate response: no unnecessary new universelcnr-1/+1
this previously was a off-by-one error.
2023-08-18Add an (perma-)unstable option to disable vtable vptrGary Guo-1/+1
This flag is intended for evaluation of trait upcasting space cost for embedded use cases.
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-15Rollup merge of #114831 - ↵Guillaume Gomez-7/+15
compiler-errors:next-solver-projection-subst-compat, r=lcnr Check projection args before substitution in new solver Don't ICE when an impl has the wrong kind of GAT arguments r? lcnr
2023-08-15Rollup merge of #114829 - ↵Guillaume Gomez-54/+92
compiler-errors:next-solver-only-unsize-to-dyn-once, r=lcnr Separate `consider_unsize_to_dyn_candidate` from other unsize candidates Move the unsize candidate assembly *just for* `T -> dyn Trait` out of `assemble_candidates_via_self_ty` so that we only consider it once, instead of for every normalization step of the self ty. This makes sure that we don't assemble several candidates that are equal modulo normalization when we really don't care about normalizing the self type of an `T: Unsize<dyn Trait>` goal anyways. Fixes rust-lang/trait-system-refactor-initiative#57 r? lcnr
2023-08-15Rollup merge of #114828 - compiler-errors:next-solver-probe-upcasting, r=lcnrGuillaume Gomez-10/+12
Probe when assembling upcast candidates so they don't step on eachother's toes in new solver Lack of a probe causes one candidate to disqualify the other due to inference side-effects. r? lcnr
2023-08-15Rollup merge of #114827 - compiler-errors:next-solver-dyn-safe-candidates, ↵Guillaume Gomez-0/+5
r=lcnr Only consider object candidates for object-safe dyn types in new solver We apparently allow this per RFC2027 :skull: r? lcnr
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-15Check projection arguments before substitutionMichael Goulet-7/+15
2023-08-15Separate consider_unsize_to_dyn_candidate from other unsize candidatesMichael Goulet-54/+92
2023-08-15Probe when assembling upcast candidates so they don't step on eachother's toesMichael Goulet-10/+12
2023-08-15Only consider object candidates for object-safe dyn typesMichael Goulet-0/+5
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-5/+4
2023-08-13Auto merge of #114457 - lcnr:trait_ref_is_knowable-normalize, r=compiler-errorsbors-119/+167
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-12lower `evaluate_goal` stability check to `warn`lcnr-36/+56
2023-08-12normalize in `trait_ref_is_knowable` in new solverlcnr-83/+111
2023-08-11remove builtin impl for float and int inferlcnr-9/+4
2023-08-10Rollup merge of #114712 - compiler-errors:comment-nits, r=lcnrMichael Goulet-1/+1
Fix a couple of bad comments A couple of nits I saw. Sorry, this really should be folded into some other PR of mine, but I will literally forget if I don't put these up now.
2023-08-10Comment nitsMichael Goulet-1/+1
2023-08-10make the provisional cache slightly less brokenlcnr-40/+57
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-34/+52
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-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-1/+1
r=oli-obk Store the laziness of type aliases in their `DefKind` Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not. With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*: Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates. As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions. --- This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`