about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
AgeCommit message (Collapse)AuthorLines
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
2023-03-09Remove body_def_id from InheritedMichael Goulet-43/+30
2023-03-09Make some report and emit errors take DefIds instead of BodyIdsSantiago Pastorino-32/+32
2023-03-09Use param's real type in try_eval_lit_or_paramMichael Goulet-3/+3
2023-03-09Fix canonicalizer bug for int/float vars tooMichael Goulet-4/+4
2023-03-09improve readability of winnowinglcnr-39/+66
2023-03-09Auto merge of #108920 - matthiaskrgr:rollup-qrr9a0u, r=matthiaskrgrbors-14/+38
Rollup of 8 pull requests Successful merges: - #108754 (Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous) - #108759 (1.41.1 supported 32-bit Apple targets) - #108839 (Canonicalize root var when making response from new solver) - #108856 (Remove DropAndReplace terminator) - #108882 (Tweak E0740) - #108898 (Set `LIBC_CHECK_CFG=1` when building Rust code in bootstrap) - #108911 (Improve rustdoc-gui/tester.js code a bit) - #108916 (Remove an unused return value in `rustc_hir_typeck`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-09resolve regions before implied boundsAli MJ Al-Nasrawy-5/+7
2023-03-09remove obsolete `givens` from regionckAli MJ Al-Nasrawy-2/+0
2023-03-08Rollup merge of #108839 - compiler-errors:canonicalize-the-root-var, r=lcnrMatthias Krüger-11/+33
Canonicalize root var when making response from new solver During trait solving, if we equate two inference variables `?0` and `?1` but don't equate them with any rigid types, then `InferCtxt::probe_ty_var` will return `Err` for both of these. The canonicalizer code will then canonicalize the variables independently(!), and the response will not reflect the fact that these two variables have been made equal. This hinders inference and I also don't think it's sound? I haven't thought too much about it past that, so let's talk about it. r? ``@lcnr``
2023-03-08Rollup merge of #108754 - compiler-errors:retry, r=oli-obkMatthias Krüger-3/+5
Retry `pred_known_to_hold_modulo_regions` with fulfillment if ambiguous Fixes #108721 The problem here is that when we're checking `is_sized_raw` during codegen on some type that has a lot of opaques in it, something emits several nested obligations that are individually ambiguous, but when processed together in a loop then apply modulo regions. Since the `evaluate_predicates_recursively` inner loop doesn't process predicates until they stop changing, we return `EvaluatedToAmbig`, which makes the sized check return false incorrectly. See: https://github.com/rust-lang/rust/blob/f15f0ea73972786e426732c5b92ba9a904b866c4/compiler/rustc_trait_selection/src/traits/select/mod.rs#L596-L606 ... Compared to the analogous loop in the new solver: https://github.com/rust-lang/rust/blob/f15f0ea73972786e426732c5b92ba9a904b866c4/compiler/rustc_trait_selection/src/solve/mod.rs#L481-L512 To fix this, if we get ambiguous during `pred_known_to_hold_modulo_regions`, just retry the obligation in a fulfillment context. -- Unfortunately... I don't have a test for this. I've only tested this locally. Pending minimization :/ r? types
2023-03-08Rollup merge of #108901 - LYF1999:yf/108897, r=lcnrMatthias Krüger-2/+2
fix: evaluate with wrong obligation stack fix #108897 r? ``@lcnr``
2023-03-08Rollup merge of #108883 - compiler-errors:post-norm-copy-err, r=BoxyUwUMatthias Krüger-1/+6
Suppress copy impl error when post-normalized type references errors Suppress spurious errors from the `Copy` impl validity check when fields have bad types *post*-normalization, instead of just pre-normalization. ---- The const-generics test regressed recently due to #107965, cc `````@BoxyUwU.````` * I think it's because `[_; 0u32]: Copy` now fails to hold because a nested obligation `ConstArgHasType(0u32, usize)` fails. * It's interesting that `[const_error]` shows up in the type only after normalization, though, but I'm pretty sure that it's due to the evaluate call that happens when normalizing unevaluated consts.
2023-03-08Remove `identity_future` indirectionArpad Borsos-8/+1
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.
2023-03-08Auto merge of #108121 - aliemjay:resolve-var-region, r=lcnrbors-2/+2
always resolve to universal regions if possible `RegionConstraintCollector::opportunistic_resolve_var`, which is used in canonicalization and projection logic, doesn't resolve the region var to an equal universal region. So if we have equated `'static == '1 == '2`, it doesn't resolve `'1` or `'2` to `'static`. Now it does! Addresses review comment https://github.com/rust-lang/rust/pull/107376#discussion_r1093233687. r? `@lcnr`
2023-03-08fix: evaluate with wrong obligation stackyifei-2/+2
2023-03-08Suppress copy impl error when post-normalized type references errorsMichael Goulet-1/+6
2023-03-07fix var equality issue with old canonicalizerMichael Goulet-1/+0
2023-03-07Canonicalize the ROOT VARMichael Goulet-11/+34
2023-03-07Add suggestion to diagnostic when user has array but trait wants slice.Ben Reeves-7/+90
For #90528.