about summary refs log tree commit diff
path: root/compiler/rustc_infer
AgeCommit message (Collapse)AuthorLines
2022-11-28Rollup merge of #104936 - cjgillot:self-rpit-orig-too, r=oli-obkMatthias Krüger-2/+5
Ignore bivariant parameters in test_type_match. https://github.com/rust-lang/rust/pull/103491 made opaque types bivariant with respect of some of their lifetime parameters. Because of this bivariance, some lifetime variables were not unified to anything during borrowck, and were considered as unequal by borrowck type test. This PR makes type test ignore the bivariant parameters in test_type_match. Fixes https://github.com/rust-lang/rust/issues/104815 r? `@oli-obk`
2022-11-28Rollup merge of #104890 - lcnr:small-cleanup, r=fee1-deadDylan DPC-36/+26
small method code cleanup
2022-11-28Rollup merge of #104732 - WaffleLapkin:from_def_idn't, r=compiler-errorsDylan DPC-4/+1
Refactor `ty::ClosureKind` related stuff I've tried to fix all duplication and weirdness, but if I missed something do tell :p r? `@compiler-errors`
2022-11-27Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillotMatthias Krüger-21/+21
Prefer doc comments over `//`-comments in compiler Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-26/+24
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-21/+21
2022-11-27Use `TyCtxt::is_fn_trait` is a couple more placesMaybe Waffle-4/+1
2022-11-27Rename `fn_trait_kind_from_{from_lang=>def_id}` to better convey meaningMaybe Waffle-1/+1
2022-11-26Rollup merge of #104921 - compiler-errors:no-binder-on-fut-ty, r=cjgillotGuillaume Gomez-19/+14
Remove unnecessary binder from `get_impl_future_output_ty` We never construct an `async fn` with a higher-ranked `impl Future` bound anyways, and basically all the call-sites already skip the binder.
2022-11-26Rollup merge of #104788 - compiler-errors:unresolved-ct-in-gen, r=fee1-deadGuillaume Gomez-36/+65
Do not record unresolved const vars in generator interior Don't record types in the generator interior when we see unresolved const variables. We already do this for associated types -- this is important to avoid unresolved inference variables in the generator results during writeback, since the writeback results get stable hashed in incremental mode. Fixes #104787
2022-11-26Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errorsGuillaume Gomez-5/+2
Use the power of adding helper function to simplify code w/ `Mutability` r? `@compiler-errors`
2022-11-26Ignore bivariant parameters in test_type_match.Camille GILLOT-2/+5
2022-11-26Do not record unresolved const vars in generator interiorMichael Goulet-36/+65
2022-11-26Remove unnecessary binder from get_impl_future_output_tyMichael Goulet-19/+14
2022-11-25Auto merge of #99798 - JulianKnodt:ac1, r=BoxyUwUbors-43/+16
Add `ConstKind::Expr` Starting to implement `ty::ConstKind::Abstract`, most of the match cases are stubbed out, some I was unsure what to add, others I didn't want to add until a more complete implementation was ready. r? `@lcnr`
2022-11-25remove `TypeError::ObjectUnsafeCoercion`lcnr-36/+26
2022-11-25Make `expand_abstract_consts` infallibleBoxy-13/+11
2022-11-25Add expand_abstract_constkadmin-6/+2
Adds the ability to directly expand a const to an expr without having to deal with intermediate steps.
2022-11-25Add empty ConstKind::Abstractkadmin-35/+14
Initial pass at expr/abstract const/s Address comments Switch to using a list instead of &[ty::Const], rm `AbstractConst` Remove try_unify_abstract_consts Update comments Add edits Recurse more More edits Prevent equating associated consts Move failing test to ui Changes this test from incremental to ui, and mark it as failing and a known bug. Does not cause the compiler to ICE, so should be ok.
2022-11-25Introduce PredicateKind::ClauseSantiago Pastorino-26/+32
2022-11-24Remove normalize_projection_typeSantiago Pastorino-8/+0
2022-11-23Add `Mutability::ref_prefix_str`, order `Mutability`, simplify codeMaybe Waffle-5/+2
2022-11-23Separate lifetime ident from resolution in HIR.Camille GILLOT-26/+24
2022-11-22Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnrManish Goregaokar-20/+152
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ````@lcnr```` fixes #99840
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-2/+2
Unreserve braced enum variants in value namespace With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed. Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-1/+1
2022-11-21Allow iterators instead of requiring slices that will get turned into iteratorsOli Scherer-1/+1
2022-11-21Assert that various types have the right amount of generic args and fix the ↵Oli Scherer-1/+1
sites that used the wrong amount
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-2/+2
2022-11-21Test generalization during coherenceOli Scherer-1/+5
2022-11-21Add some more assertions for type relations not used during coherenceOli Scherer-8/+13
2022-11-21Type generalization should not look at opaque type in coherenceOli Scherer-2/+1
2022-11-21Remove a function that doesn't actually do anythingOli Scherer-8/+7
2022-11-21Register obligations from type relationOli Scherer-5/+12
2022-11-21Move a field aroundOli Scherer-1/+2
2022-11-21Add an always-ambiguous predicate to make sure that we don't accidentlally ↵Oli Scherer-11/+55
allow trait resolution to prove false things during coherence
2022-11-21Treat different opaque types of the same def id as equal during coherenceOli Scherer-0/+73
2022-11-21Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #104420 (Fix doc example for `wrapping_abs`) - #104499 (rustdoc JSON: Use `Function` everywhere and remove `Method`) - #104500 (`rustc_ast`: remove `ref` patterns) - #104511 (Mark functions created for `raw-dylib` on x86 with DllImport storage class) - #104595 (Add `PolyExistentialPredicate` type alias) - #104605 (deduplicate constant evaluation in cranelift backend) - #104628 (Revert "Update CI to use Android NDK r25b") - #104662 (Streamline deriving on packed structs.) - #104667 (Revert formatting changes of a test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-21Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnrMatthias Krüger-1/+1
Add `PolyExistentialPredicate` type alias Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-28/+39
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-19Rollup merge of #104554 - BoxyUwU:less_unchecked_pls, r=lcnrDylan DPC-14/+21
Use `ErrorGuaranteed::unchecked_claim_error_was_emitted` less there are only like 3 or 4 call sites left after this but it wasnt obvious to me how to remove them
2022-11-19Rollup merge of #104411 - lcnr:bivariance-nll, r=compiler-errorsDylan DPC-2/+3
nll: correctly deal with bivariance fixes #104409 when in a bivariant context, relating stuff should always trivially succeed. Also changes the mir validator to correctly deal with higher ranked regions. r? types cc ``@RalfJung``
2022-11-19drive-by: PolyExistentialPredicateMichael Goulet-1/+1
2022-11-18require an `ErrorGuaranteed` to taint infcx with errorsBoxy-11/+10
2022-11-18rename `is_tainted_by_errors` Boxy-8/+12
2022-11-18`InferCtxt::is_tainted_by_errors` returns `ErrorGuaranteed`Boxy-5/+9
2022-11-16Convert predicates into Predicate in the Obligation constructorOli Scherer-30/+35
2022-11-15mv utility methods into separate modulelcnr-5/+2
2022-11-15nll: correctly deal with bivariancelcnr-2/+6
2022-11-14Deduplicate visitor.Camille GILLOT-3/+3