about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2023-09-11inspect: strongly typed CandidateKindlcnr-103/+66
2023-09-11inspect: handle `None` in `nested`lcnr-27/+7
2023-09-11split GoalEvaluation and CanonicalGoalEvaluationlcnr-60/+98
the unnormalized goal is in the callers inference context, while anything inside of the `CanonicalGoalEvaluation` is inside of a new one.
2023-09-11Disentangle `Debug` and `Display` for `Ty`.Nicholas Nethercote-1/+1
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
2023-09-10Point out if a local trait has no implementationsMichael Goulet-5/+21
2023-09-10Implement fallback for effect paramDeadbeef-0/+3
2023-09-07Don't suggest dereferencing to unsized typeMichael Goulet-1/+14
2023-09-06Auto merge of #115529 - chenyukang:yukang-fix-115402-overflowsize, ↵bors-0/+10
r=compiler-errors Fix error report for size overflow from transmute Fixes #115402 The span in the error reporting always points to the `dst`, this is an old issue, I may open another PR to fix it.
2023-09-06Fix error report for size overflow from transmuteyukang-0/+10
2023-09-05 unconstrained region vars: do not ICE ICE babylcnr-9/+5
2023-09-05Rollup merge of #115519 - compiler-errors:next-solver-assoc-ice, r=lcnrMatthias Krüger-1/+15
Don't ICE on associated type projection without feature gate in new solver Self-explanatory, we should avoid ICEs when the feature gate is not enabled. Continue to ICE when the feature gate *is* enabled, though. Fixes #115500
2023-09-05Auto merge of #115467 - compiler-errors:assoc-ty-object-safety, r=oli-obkbors-0/+9
Do not require associated types with Self: Sized to uphold bounds when confirming object candidate RPITITs and associated types that have `Self: Sized` bounds are opted out of the `dyn Trait` well-formedness check that happens during confirmation. This ensures that we can actually *use* `dyn Trait`s that have associated types that, e.g., have GATs and RPITITs and other naughty things as long as those are opted-out of object safety via a `Self: Sized` bound. Fixes #115464 This seems like a natural part of https://github.com/rust-lang/rust/pull/112319#issuecomment-1592574451, and I don't think needs re-litigation. r? `@oli-obk`
2023-09-03Don't ICE on associated type projection without feature gateMichael Goulet-1/+15
2023-09-02Do not require associated types with Self: Sized to uphold bounds when ↵Michael Goulet-6/+6
confirming object candidate
2023-09-02RPITITs are considered object-safe, they're always on Self:Sized methodsMichael Goulet-0/+9
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/+21
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/+21
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