about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection
AgeCommit message (Collapse)AuthorLines
2023-03-20Enforce non-lifetime-binders in supertrait preds are not object safeMichael Goulet-1/+20
2023-03-19Delay overlap errors if errors are involvedMichael Goulet-1/+5
2023-03-17Fast path that skips over unchanged obligations in process_obligationsThe 8472-0/+23
- only borrow the refcell once per loop - avoid complex matches to reduce branch paths in the hot loop - use a by-ref fast path that avoids mutations at the expense of having false negatives
2023-03-17move `compute_goal` and `evaluate_x` methods to inner moduleBoxy-272/+272
2023-03-17fix bad assertionBoxy-13/+4
2023-03-17replace chain with two `add_goal`Boxy-16/+11
2023-03-17fix let else unformattingBoxy-5/+9
2023-03-17UNACEPTABLEBoxy-9/+9
2023-03-17add commentsBoxy-0/+5
Co-authored-by: lcnr <rust@lcnr.de>
2023-03-17add assertBoxy-2/+9
2023-03-17review nitsBoxy-14/+18
2023-03-17Rollup merge of #109198 - compiler-errors:new-rpitit-default-body, r=spastorinoMatthias Krüger-9/+13
Install projection from RPITIT to default trait method opaque correctly 1. For new lowering strategy `-Zlower-impl-trait-in-trait-to-assoc-ty`, install the correct default trait method projection predicates (RPITIT -> opaque). This makes default trait body tests pass! 2. Fix two WF-checking bugs -- first, we want to make sure that we're always looking for an opaque type in `check_return_position_impl_trait_in_trait_bounds`. That's because the RPITIT projections are normalized to opaques during wfcheck. Second, fix RPITIT's param-envs by not adding the projection predicates that we install on trait methods to make default RPITITs work -- I left a comment why. 3. Also, just a small drive-by for `rustc_on_unimplemented`. Not sure if it affects any tests, but can't hurt. r? ````@spastorino,```` based off of #109140
2023-03-17Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errorsMatthias Krüger-3/+0
Remove box expressions from HIR After #108516, `#[rustc_box]` is used at HIR->THIR lowering and this is no longer emitted, so it can be removed. This is based on top of #108471 to help with conflicts, so 43490488ccacd1a822e9c621f5ed6fca99959a0b is the only relevant commit (sorry for all the duplicated pings!) ````@rustbot```` label +S-blocked
2023-03-16replace usage of `evaluate_goal` with a new `add_goal`Boxy-254/+336
2023-03-16Rollup merge of #109171 - oli-obk:normalization_cleanup, r=compiler-errorsMatthias Krüger-77/+48
Some cleanups in our normalization logic Changed a match to be exhaustive and deduplicated some code. r? ```@compiler-errors``` this pulls out the uncontroversial part of https://github.com/rust-lang/rust/pull/108860
2023-03-16Rollup merge of #109166 - lcnr:define_opaque_types-explicit, r=oli-obkMatthias Krüger-80/+95
make `define_opaque_types` fully explicit based on the idea of #108389. Moved `define_opaque_types` into the actual operations, e.g. `eq`, instead of `infcx.at` because normalization doesn't use `define_opaque_types` and even creates it's own `At` with a different `define_opaque_types` internally. Somewhat surprisingly, coherence actually relies on `DefineOpaqueTypes::Yes` for soundness which was revealed because I've incorrectly used `DefineOpaqueTypes::No` in `equate_impl_headers`. It feels concerning that even though this is the case, we still sometimes use `DefineOpaqueTypes::No` in coherence. I did not look into this as part of this PR as it is purely changing the structure of the code without changing behavior in any way. r? ```@oli-obk```
2023-03-16Fix on_unimplemented_note for RPITITsMichael Goulet-7/+11
2023-03-15Rename impl_trait_in_trait_parent to impl_trait_in_trait_parent_fnSantiago Pastorino-2/+2
2023-03-15Revert "Auto merge of #107376 - aliemjay:remove-givens, r=lcnr"Rémy Rakic-7/+7
This reverts commit e84e5ff04a647ce28540300244a26ba120642eea, reversing changes made to 1716932743a7b3705cbf0c34db0c4e070ed1930d.
2023-03-15always make `define_opaque_types` explicitlcnr-80/+95
2023-03-15Deduplicate logic between projection normalization with and without escaping ↵Oli Scherer-59/+21
bound vars
2023-03-15Exhaustively match over all alias kindsOli Scherer-20/+29
2023-03-15Auto merge of #107376 - aliemjay:remove-givens, r=lcnrbors-7/+7
remove obsolete `givens` from regionck Fixes #106567 r? `@lcnr` (feel free to reassign)
2023-03-14Remove box expressions from HIRclubby789-3/+0
2023-03-14Rollup merge of #108915 - spastorino:new-rpitit-8, r=compiler-errorsMatthias Krüger-0/+4
Remove some direct calls to local_def_id_to_hir_id on diagnostics Was playing with `tests/ui/impl-trait/in-trait/default-body-with-rpit.rs` and was able to remove some ICEs. Still getting ... ``` error[E0277]: `impl Future<Output = Foo::{opaque#0}>` is not a future --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ `impl Future<Output = Foo::{opaque#0}>` is not a future | = help: the trait `Future` is not implemented for `impl Future<Output = Foo::{opaque#0}>` = note: impl Future<Output = Foo::{opaque#0}> must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error[E0277]: the size for values of type `impl Future<Output = Foo::{opaque#0}>` cannot be known at compilation time --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `impl Future<Output = Foo::{opaque#0}>` note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error: internal compiler error: compiler/rustc_hir_typeck/src/closure.rs:724:18: async fn generator return type not an inference variable: Foo::{opaque#1}<'_> --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:39 | 10 | async fn baz(&self) -> impl Debug { | _______________________________________^ 11 | | "" 12 | | } | |_____^ ``` But I guess this is a little bit of progress anyway. This one goes on top of #108700 and #108945 r? `@compiler-errors`
2023-03-14Rollup merge of #108909 - spastorino:new-rpitit-7, r=compiler-errorsMatthias Krüger-3/+3
Fix object safety checks for new RPITITs This one goes on top of #108869 r? `@compiler-errors`
2023-03-14Remove some direct calls to local_def_id_to_hir_id on diagnosticsSantiago Pastorino-0/+4
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-8/+1
Remove `identity_future` indirection This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-13Better names?Michael Goulet-13/+13
2023-03-13Treat projections with infer as placeholder during fast reject in new solverMichael Goulet-15/+49
2023-03-12Rollup merge of #109032 - compiler-errors:shorter, r=BoxyUwUMatthias Krüger-15/+13
Use `TyCtxt::trait_solver_next` in some places Also flip order of if statements to avoid `!`
2023-03-12Fix object safety checks for new RPITITsSantiago Pastorino-3/+2
2023-03-12Filter out RPITITs in object_safety_violations_for_traitSantiago Pastorino-0/+1
2023-03-12Rollup merge of #108841 - jackh726:issue-90528, r=compiler-errorsMatthias Krüger-7/+90
Add suggestion to diagnostic when user has array but trait wants slice. (rebased) Rebase of #91314, except for change to multipart suggestion Resolves #90528 r? ``@compiler-errors`` since you requested the multipart suggestion
2023-03-12Rollup merge of #108726 - est31:backticks_matchmaking_tidy, r=NilstriebMatthias Krüger-2/+3
tidy: enforce comment blocks to have an even number of backticks After PR #108694, most unmatched backticks in `compiler/` comments have been eliminated. This PR adds a tidy lint to ensure no new unmatched backticks are added, and either addresses the lint in the remaining instances it found, or allows it. Very often, backtick containing sections wrap around lines, for example: ```Rust // This function takes a tuple `(Vec<String>, // Box<[u8]>)` and transforms it into `Vec<u8>`. ``` The lint is implemented to work on top of blocks, counting each line with a `//` into a block, and counting if there are an odd or even number of backticks in the entire block, instead of looking at just a single line.
2023-03-11Use TyCtxt::trait_solver_next in some placesMichael Goulet-15/+13
2023-03-11Simplify message pathsest31-1/+1
This makes it easier to open the messages file while developing on features. The commit was the result of automatted changes: for p in compiler/rustc_*; do mv $p/locales/en-US.ftl $p/messages.ftl; rmdir $p/locales; done for p in compiler/rustc_*; do sed -i "s#\.\./locales/en-US.ftl#../messages.ftl#" $p/src/lib.rs; done
2023-03-11Add a fixme and address a more non trivial caseest31-1/+2
Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2023-03-11Address the new odd backticks tidy lint in compiler/est31-1/+1
2023-03-11Rollup merge of #108071 - compiler-errors:new-solver-caching, r=lcnrMatthias Krüger-171/+78
Implement goal caching with the new solver Maybe it's wrong, idk. Opening mostly for first impressions before I go to sleep. r? ``@lcnr,`` cc ``@cjgillot``
2023-03-10Actually cache goalsMichael Goulet-70/+60
2023-03-10Move some solver stuff to middleMichael Goulet-101/+18
2023-03-10Rollup merge of #108947 - compiler-errors:ct-infer-no-shapeshifting, r=BoxyUwUMatthias Krüger-3/+3
Don't even try to combine consts with incompatible types ~I left a more detailed explanation for why this fixes this issue in the UI test, but in general, we should not try to unify const infer vars and rigid consts if they have incompatible types. That's because we don't want something like a `ConstArgHasType` predicate to suddenly go from passing to failing, or vice versa, due to a shallow resolve.~ 1. Use the `type_of` for a parameter in `try_eval_lit_or_param`, instead of the "expected" type from a `WithOptConstParam` def id. 2. Don't combine consts that have incompatible types. Fixes #108781
2023-03-10Rollup merge of #108937 - lcnr:winnowing-enum, r=WaffleLapkinMatthias Krüger-40/+67
improve readability of winnowing
2023-03-10Rollup merge of #108834 - compiler-errors:fn-ptr-fn-obl, r=spastorinoMatthias Krüger-3/+11
Do not ICE when we have fn pointer `Fn` obligations with bound vars in the self type We never supported solving `for<'a> fn(&'a ()): Fn(&'a ())` -- I tried to add that support in #104929, but iirc `@lcnr` wanted to support this more generally by eagerly instantiating trait predicate binders with placeholders. That never happened due to blockers in the old solver, but we probably shouldn't ICE in any case. On the bright side, this passes on the new solver :^)
2023-03-10Rollup merge of #108828 - compiler-errors:new-solver-alias-eq-on-num-var, r=lcnrMatthias Krüger-4/+4
Emit alias-eq when equating numeric var and projection This doesn't fix everything having to do with projections and infer vars, but it does fix a common case I saw in HIR typeck. r? `@lcnr`
2023-03-10Rollup merge of #108960 - compiler-errors:no-body-def-id, r=cjgillotMatthias Krüger-43/+30
Remove `body_def_id` from `Inherited` We can just use the body id from the obligation cause. Follow-up to #108945, only my commit is relevant. r? `@cjgillot` cc `@spastorino`
2023-03-10Rollup merge of #108945 - spastorino:pass-def-id-instead-of-using-hir-id, ↵Matthias Krüger-32/+32
r=compiler-errors Make some report and emit errors take DefIds instead of BodyIds Breaking off from #108915 r? `@compiler-errors`
2023-03-10updating commentlcnr-1/+1
Co-authored-by: Ruby Lazuli <general@patchmixolydic.com>
2023-03-10Unconstrained terms should account for infer vars being equatedMichael Goulet-15/+20