about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/check
AgeCommit message (Collapse)AuthorLines
2022-11-22Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnrManish Goregaokar-0/+8
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ````@lcnr```` fixes #99840
2022-11-22Auto merge of #104711 - Dylan-DPC:rollup-gkw1qr8, r=Dylan-DPCbors-43/+37
Rollup of 6 pull requests Successful merges: - #104295 (Check generics parity before collecting return-position `impl Trait`s in trait) - #104464 (Reduce exceptions overallocation on non Windows x86_64) - #104615 (Create def_id for async fns during lowering) - #104669 (Only declare bindings for if-let guards once per arm) - #104701 (Remove a lifetime resolution hack from `compare_predicate_entailment`) - #104710 (disable strict-provenance-violating doctests in Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-22Rollup merge of #104701 - compiler-errors:rpitit-remove-reempty-hack, r=TaKO8KiDylan DPC-11/+1
Remove a lifetime resolution hack from `compare_predicate_entailment` This is not needed anymore, probably due to #102334 equating the function signatures fully in `collect_trait_impl_trait_tys`. Also, the assertion in in #102903 makes sure that this is actually fixed, so I'm pretty confident this isn't needed.
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-1/+1
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-22Remove a hack from compare_predicate_entailmentMichael Goulet-11/+1
2022-11-22Delay bug to deduplicate diagnosticsMichael Goulet-8/+10
2022-11-22drive-by: style nitsMichael Goulet-25/+19
2022-11-22Check generics parity between impl and trait before collecting RPITITsMichael Goulet-3/+11
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-1/+1
2022-11-21Add helper to create the trait ref for a lang itemOli 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-4/+1
sites that used the wrong amount
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-1/+1
2022-11-21Add an always-ambiguous predicate to make sure that we don't accidentlally ↵Oli Scherer-0/+4
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/+4
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-63/+57
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 #104593 - compiler-errors:rpitit-object-safety-spans, ↵Matthias Krüger-3/+1
r=fee1-dead Improve spans for RPITIT object-safety errors No reason why we can't point at the `impl Trait` that causes the object-safety violation. Also [drive-by: Add is_async fn to hir::IsAsync](https://github.com/rust-lang/rust/pull/104593/commits/c4165f3a965e258531928180195637455299c6f3), which touches clippy too.
2022-11-19Rollup merge of #104411 - lcnr:bivariance-nll, r=compiler-errorsDylan DPC-10/+6
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: Add is_async fn to hir::IsAsyncMichael Goulet-3/+1
2022-11-17Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errorsMatthias Krüger-17/+16
Convert predicates into Predicate in the Obligation constructor instead of having almost all callers do that. This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
2022-11-17Rollup merge of #103852 - compiler-errors:rpitit-early-from-impl, r=lcnrMatthias Krüger-1/+7
Don't remap early-bound regions for return-position `impl Trait` in trait originating from `impl` long title :sweat: We don't want to remap early-bound regions that originate from the `impl`s themselves, since they have no corresponding region in the trait. Not sure if there's a better condition than checking if the EBR's def-id's parent is the impl -- maybe we should be checking if the region comes from the method or RPITIT... :shrug: r? types Fixes #103850
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-1/+1
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-16Convert predicates into Predicate in the Obligation constructorOli Scherer-17/+16
2022-11-15Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obkbors-1/+1
interpret: support for per-byte provenance Also factors the provenance map into its own module. The third commit does the same for the init mask. I can move it in a separate PR if you prefer. Fixes https://github.com/rust-lang/miri/issues/2181 r? `@oli-obk`
2022-11-15use `ocx` type relation routineslcnr-10/+6
2022-11-14Deduplicate visitor.Camille GILLOT-96/+19
2022-11-13Store a LocalDefId in hir::GenericParam.Camille GILLOT-1/+1
2022-11-13Create bidirectional bounds between original and duplicated parameters.Camille GILLOT-13/+16
2022-11-12Make impl_trait_projections a feature gate.Camille GILLOT-8/+11
2022-11-12Inherit generics for impl-trait.Camille GILLOT-14/+79
2022-11-12Auto merge of #104310 - Dylan-DPC:rollup-wgt1z4a, r=Dylan-DPCbors-105/+142
Rollup of 7 pull requests Successful merges: - #102049 (Add the `#[derive_const]` attribute) - #103970 (Unhide unknown spans) - #104206 (Remove `save_and_restore_in_snapshot_flag`, use `ObligationCtxt` more) - #104214 (Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures) - #104267 (rustdoc: use checkbox instead of switch for settings toggles) - #104302 (Update cargo) - #104303 (UI tests can be assigned to T-compiler) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-12Rollup merge of #104214 - Nilstrieb:returns_impl_Ice, r=compiler-errorsDylan DPC-105/+142
Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures Previously, a `delay_span_bug` was isssued, failing normalization. This create a `TyKind::Error` in the signature, which caused `compare_predicate_entailment` to swallow its signature mismatch error, causing ICEs because no error was emitted. fixes #104183 r? ``@compiler-errors``
2022-11-12Auto merge of #103530 - cjgillot:hir-lifetimes-direct, r=estebankbors-1/+1
Resolve lifetimes independently for each item-like. Now that the heavy-lifting is done on the AST and during lowering, we do not need to perform HIR lifetime resolution on a full item at once. Instead, we can treat each item-like independently, and look at `generics_of` the parent exceptionally for associated items.
2022-11-11Tweak signatures in rustc_middle::hir::map.Camille GILLOT-1/+1
2022-11-09Rollup merge of #104156 - oli-obk:autoderef, r=estebankManish Goregaokar-2/+1
Cleanups in autoderef impl Just something I noticed. Turns out the `overloaded_span` is not actually used separately from the main span, so I merged them.
2022-11-09Emit error in `collecting_trait_impl_trait_tys` on mismatched signaturesNilstrieb-105/+142
Previously, a `delay_span_bug` was isssued, failing normalization. This create a `TyKind::Error` in the signature, which caused `compare_predicate_entailment` to swallow its signature mismatch error, causing ICEs because no error was emitted.
2022-11-09Auto merge of #103723 - CastilloDel:master, r=jackh726bors-11/+11
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-6/+11
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-11/+11
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-08Remove overloaded_span argument from `new`, where it is usually redundant ↵Oli Scherer-2/+1
with the main span
2022-11-08Rollup merge of #104094 - lcnr:on_unimplemented-move, r=wesleywiserDylan DPC-1/+2
fully move `on_unimplemented` to `error_reporting` the `traits` module has a few too many submodules in my opinion.
2022-11-08Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, ↵Dylan DPC-7/+7
r=eholk Move `fallback_has_occurred` state tracking to `FnCtxt` Removes a ton of callsites that defaulted to `false`
2022-11-08add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed'yukang-2/+2
2022-11-07Add an optional Span to BrAnon and use it to print better error for HRTB ↵Jack Huey-6/+11
error from generator interior
2022-11-07fully move `on_unimplemented` to error reportinglcnr-1/+2
2022-11-06interpret: support for per-byte provenanceRalf Jung-1/+1
2022-11-06Move fallback_has_occurred to FnCtxtMichael Goulet-7/+7
2022-11-05Adjust diagnostics, bless testsMichael Goulet-2/+8
2022-11-05Enforce rust-check ABI in signatures, callsMichael Goulet-0/+22
2022-11-04Refactor tcx mk_const parameters.Mateusz-7/+4