about summary refs log tree commit diff
path: root/compiler/rustc_infer/src
AgeCommit message (Collapse)AuthorLines
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
2022-11-14Drop `relate_opaque_item_substs`.Camille GILLOT-0/+1
2022-11-12Inherit generics for impl-trait.Camille GILLOT-27/+37
2022-11-12Rollup merge of #104206 - compiler-errors:ocx-more-2, r=lcnrDylan DPC-26/+0
Remove `save_and_restore_in_snapshot_flag`, use `ObligationCtxt` more r? ```@lcnr```
2022-11-10Auto merge of #103636 - chenyukang:yukang/fix-103587-sugg-if-let, ↵bors-0/+82
r=jackh276,davidtwco Recover from common if let syntax mistakes/typos Fixes #103587
2022-11-09Remove save_and_restore_in_snapshot_flagMichael Goulet-26/+0
2022-11-09Auto merge of #103723 - CastilloDel:master, r=jackh726bors-1/+2
Remove allow(rustc::potential_query_instability) in rustc_trait_selection Related to https://github.com/rust-lang/rust/issues/84447 This PR needs to be benchmarked to check for regressions.
2022-11-09Auto merge of #103171 - jackh726:gen-interior-hrtb-error, r=cjgillotbors-7/+95
Better error for HRTB error from generator interior cc #100013 This is just a first pass at an error. It could be better, and shouldn't really be emitted in the first place. But this is better than what was being emitted before.
2022-11-08Reduce the scope of allow(rustc::potential_query_instability) in ↵CastilloDel-1/+2
rustc_trait_selection Make InferCtxtExt use a FxIndexMap This should be faster, because the map is only being used to iterate, which is supposed to be faster with the IndexMap Make the user_computed_preds use an IndexMap It is being used mostly for iteration, so the change shouldn't result in a perf hit Make the RegionDeps fields use an IndexMap This change could be a perf hit. Both `larger` and `smaller` are used for iteration, but they are also used for insertions. Make types_without_default_bounds use an IndexMap It uses extend, but it also iterates and removes items. Not sure if this will be a perf hit. Make InferTtxt.reported_trait_errors use an IndexMap This change brought a lot of other changes. The map seems to have been mostly used for iteration, so the performance shouldn't suffer. Add FIXME to change ProvisionalEvaluationCache.map to use an IndexMap Right now this results in a perf hit. IndexMap doesn't have the `drain_filter` API, so in `on_completion` we now need to iterate two times over the map.
2022-11-08use subdiagnostic for sugesting add letyukang-6/+14
2022-11-08fix #103587, Recover from common if let syntax mistakes/typosyukang-0/+74
2022-11-08Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, ↵Dylan DPC-2/+3
r=eholk Move `fallback_has_occurred` state tracking to `FnCtxt` Removes a ton of callsites that defaulted to `false`
2022-11-07Add a known that this is a known limitationJack Huey-0/+1
2022-11-07Get spans for a couple more region types, add some optimizations, and extend ↵Jack Huey-1/+1
test
2022-11-07Add an optional Span to BrAnon and use it to print better error for HRTB ↵Jack Huey-7/+94
error from generator interior
2022-11-07Auto merge of #103218 - CastilloDel:infer, r=jackh726bors-22/+27
Remove #![allow(rustc::potential_query_instability)] from rustc_infer Related to #84447 This PR probably needs to be benchmarked to check for regressions.
2022-11-06Move fallback_has_occurred to FnCtxtMichael Goulet-2/+3
2022-11-06Auto merge of #103975 - oli-obk:tracing, r=jackh726bors-1/+1
Some tracing and comment cleanups Pulled out of https://github.com/rust-lang/rust/pull/101900 to see if that is the perf impact
2022-11-04Refactor tcx mk_const parameters.Mateusz-25/+20
2022-11-04Some tracing and comment cleanupsOli Scherer-1/+1
2022-11-01Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwcoManish Goregaokar-5/+10
Change #[suggestion_*] attributes to use style="..." As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter. It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all. Best reviewed commit-by-commit, there's a bit of noise in there. cc #100717 `@compiler-errors` r? `@davidtwco`
2022-11-01Auto merge of #103590 - compiler-errors:ocx-more, r=lcnrbors-1/+1
(almost) Always use `ObligationCtxt` when dealing with canonical queries Hope this is a step in the right direction. cc rust-lang/types-team#50. r? `@lcnr`
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-1/+1
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-28Remove #![allow(rustc::potential_query_instability)] from rustc_inferCastilloDel-22/+27
Change reported_violations to use IndexSet It is being used to iterate and to insert, without a lot of lookups so hopefully it won't be a perf hit Change MiniGraph.nodes to use IndexSet It is being used to iterate and to insert, without performing lookups so hopefully it won't be a perf hit Change RegionConstraintData.givens to a FxIndexSet This might result in a perf hit. Remove was being used in `givens`, and `FxIndexSet` doesn't allow calling remove without losing the fixed iteration order. So it was necessary to change remove to `shift_remove`, but this method is slower. Change OpaqueTypesVisitor to use stable sets and maps This could also be a perf hit. Make TraitObject visitor use a stable set
2022-10-28Rollup merge of #103641 - compiler-errors:issue-103624, r=cjgillotMatthias Krüger-6/+6
Don't carry MIR location in `ConstraintCategory::CallArgument` It turns out that `ConstraintCategory::CallArgument` cannot just carry a MIR location in it, since we may bubble them up to totally different MIR bodies. So instead, revert the commit a6b5f95fb028f9feb4a2957c06b35035be2c6155, and instead just erase regions from the original `Option<Ty<'tcx>>` that it carried, so that it doesn't ICE with the changes in #103220. Best reviewed in parts -- the first is just a revert, and the second is where the meaningful changes happen. Fixes #103624
2022-10-27Revert "Make ClosureOutlivesRequirement not rely on an unresolved type"Michael Goulet-6/+6
This reverts commit a6b5f95fb028f9feb4a2957c06b35035be2c6155.
2022-10-27(almost) Always use ObligationCtxt when dealing with canonical queriesMichael Goulet-1/+1