about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src
AgeCommit message (Collapse)AuthorLines
2023-01-28Rollup merge of #107339 - aliemjay:covariant, r=lcnrMatthias Krüger-5/+3
internally change regions to be covariant Surprisingly, we consider the reference type `&'a T` to be contravaraint in its lifetime parameter. This is confusing and conflicts with the documentation we have in the reference, rustnomicon, and rustc-dev-guide. This also arguably not the correct use of terminology since we can use `&'static u8` in a place where `&' a u8` is expected, this implies that `&'static u8 <: &' a u8` and consequently `'static <: ' a`, hence covariance. Because of this, when relating two types, we used to switch the argument positions in a confusing way: `Subtype(&'a u8 <: &'b u8) => Subtype('b <: 'a) => Outlives('a: 'b) => RegionSubRegion('b <= 'a)` The reason for the current behavior is probably that we wanted `Subtype('b <: 'a)` and `RegionSubRegion('b <= 'a)` to be equivalent, but I don' t think this is a good reason since these relations are sufficiently different in that the first is a relation in the subtyping lattice and is intrinsic to the type-systems, while the the second relation is an implementation detail of regionck. This PR changes this behavior to use covariance, so.. `Subtype(&'a u8 <: &'b u8) => Subtype('a <: 'b) => Outlives('a: 'b) => RegionSubRegion('b <= 'a) ` Resolves #103676 r? `@lcnr`
2023-01-28Rollup merge of #107100 - compiler-errors:issue-107087, r=lcnrMatthias Krüger-46/+66
Use proper `InferCtxt` when probing for associated types in astconv Fixes #107087
2023-01-27Compute generator saved locals on MIR.Camille GILLOT-3/+36
2023-01-27Introduce GeneratorWitnessMIR.Camille GILLOT-6/+7
2023-01-27update comment on trait objectsAli MJ Al-Nasrawy-1/+1
2023-01-26fix up subst_identity vs skip_binder; add some FIXMEs as identified in reviewKyle Matsuda-5/+5
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-24/+30
EarlyBinder to fn_sig in metadata
2023-01-26replace usages of fn_sig query with bound_fn_sigKyle Matsuda-20/+26
2023-01-27internally change regions to be covariantAli MJ Al-Nasrawy-5/+3
2023-01-23Use proper InferCtxt when probing for associated types in astconvMichael Goulet-46/+66
2023-01-23fix: use LocalDefId instead of HirId in trait resVincenzo Palazzo-112/+117
use LocalDefId instead of HirId in trait resolution to simplify the obligation clause resolution Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-21Rollup merge of #106578 - compiler-errors:recursive-opaque-closure, r=TaKO8KiMichael Goulet-6/+53
Label closure captures/generator locals that make opaque types recursive cc https://github.com/rust-lang/rust/issues/46415#issuecomment-1374665828
2023-01-21Auto merge of #106977 - michaelwoerister:unord_id_collections, r=oli-obkbors-9/+6
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc) This PR changes the `rustc_data_structures::define_id_collections!` macro to use `UnordMap` and `UnordSet` instead of `FxHashMap` and `FxHashSet`. This should account for a large portion of hash-maps being used in places where they can cause trouble. The changes required are moderate but non-zero: - In some places the collections are extracted into sorted vecs. - There are a few instances where for-loops have been changed to extends. ~~Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.~~ Performance does not seem to be negatively affected ([perf-run here](https://github.com/rust-lang/rust/pull/106977#issuecomment-1396776699)). Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533). r? `@ghost`
2023-01-21Label closure captures/generator locals that make opaque types recursiveMichael Goulet-6/+53
2023-01-20Auto merge of #105102 - compiler-errors:copy-impl-considering-regions, r=lcnrbors-44/+66
Check ADT fields for copy implementations considering regions Fixes #88901 r? `@ghost`
2023-01-20Add and use expect methods to hir.Maybe Waffle-20/+16
2023-01-20Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstriebbors-328/+275
Remove some `ref` patterns from the compiler Previous PR: https://github.com/rust-lang/rust/pull/105368 r? `@Nilstrieb`
2023-01-19Auto merge of #107038 - compiler-errors:dont-wfcheck-non-local-rpit, r=oli-obkbors-1/+12
Don't wf-check non-local RPITs We were using `ty::is_impl_trait_defn(..).is_none()` to check if we need to add WF obligations for an opaque type. This is *supposed* to be checking if the type is a TAIT, since RPITs' wfness is implied by wf checking its parent item, but since `is_impl_trait_defn` returns `None` for non-local RPIT and async futures, we unnecessarily consider wf predicates for an RPIT if it is coming from a foreign crate. Fixes #107036 r? `@oli-obk` but feel free to reassign
2023-01-19Encode whether foreign opaques are TAITs or notMichael Goulet-1/+12
2023-01-19Auto merge of #106910 - aliemjay:alias-ty-in-regionck, r=oli-obkbors-3/+3
even more unify Projection/Opaque handling in region outlives code edit: This continues ate the same pace as #106829. New changes are described in https://github.com/rust-lang/rust/pull/106910#issuecomment-1383251254. ~This touches `OutlivesBound`, `Component`, `GenericKind` enums.~ r? `@oli-obk` (because of overlap with #95474)
2023-01-19even more unify Projection/Opaque in outlives codeAli MJ Al-Nasrawy-3/+3
2023-01-19Rollup merge of #106931 - Ezrashaw:docs-e0208, r=compiler-errorsGuillaume Gomez-3/+2
document + UI test `E0208` and make its output more user-friendly Cleans up `E0208`'s output a lot. It could actually be useful for someone learning about variance now. I also added a UI test for it in `tests/ui/error-codes/` and wrote some docs for it. r? `@GuillaumeGomez` another error code, can't be bothered to find the issue :P. Obviously there's some compiler stuff, so you'll have to hand it off. Part of https://github.com/rust-lang/rust/issues/61137.
2023-01-19Use UnordMap instead of FxHashMap in define_id_collections!().Michael Woerister-9/+6
2023-01-18remove error code from `#[rustc_variance]` and document its remainsEzra Shaw-3/+2
2023-01-17Stop using `BREAK` & `CONTINUE` in compilerScott McMurray-10/+10
Switching them to `Break(())` and `Continue(())` instead. libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17Rollup merge of #106970 - kylematsuda:earlybinder-item-bounds, r=lcnrMatthias Krüger-3/+7
Switch to `EarlyBinder` for `item_bounds` query Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78). Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `item_bounds` query and removes `bound_item_bounds`. r? `@lcnr`
2023-01-17Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger-47/+47
Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17change item_bounds query to return EarlyBinder; remove bound_item_bounds queryKyle Matsuda-3/+7
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-47/+47
2023-01-17Self review suggestionsMaybe Waffle-3/+3
- add back accidentally removed new lines - try to deref in patterns, rather than in expressions (maybe this was the reason of perf regression?...)
2023-01-17Review suggestionsMaybe Waffle-16/+14
2023-01-17`rustc_hir_analysis`: remove `ref` patternsMaybe Waffle-168/+161
2023-01-17`rustc_hir_analysis`: some general code improvementsMaybe Waffle-114/+92
2023-01-17Don't call closures immediately, use `try{}` blocksMaybe Waffle-45/+23
2023-01-17Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorinoMatthias Krüger-14/+6
Unify `Opaque`/`Projection` handling in region outlives code They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias` r? types
2023-01-16Add missing normalization for union fields typesGuillaume Gomez-1/+1
2023-01-15Remove bound_{explicit,}_item_boundsMichael Goulet-5/+4
2023-01-15Make InstantiatedPredicates impl IntoIteratorMichael Goulet-11/+9
2023-01-15instantiate_own doesn't need to return a pair of vectorsMichael Goulet-12/+13
2023-01-15Rollup merge of #106072 - eopb:dyn-derive, r=estebankMatthias Krüger-1/+7
fix: misleading "add dyn keyword before derive macro" suggestion Fixes #106071
2023-01-14fix: misleading add `dyn` to derive macro suggestionEthan Brierley-1/+7
2023-01-14fix various subst_identity vs skip_binderKyle Matsuda-4/+5
2023-01-14change impl_trait_ref query to return EarlyBinder; remove ↵Kyle Matsuda-35/+34
bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata
2023-01-14change usages of impl_trait_ref to bound_impl_trait_refKyle Matsuda-22/+30
2023-01-14change const_param_default query to return EarlyBinder; remove ↵Kyle Matsuda-5/+3
bound_const_param_default query; add EarlyBinder to const_param_default in metadata
2023-01-14change usages of const_param_default query to bound_const_param_defaultKyle Matsuda-2/+2
2023-01-13Unify Opaque/Projection handling in region outlives codeMichael Goulet-14/+6
2023-01-13Suggest lifetime bound in illegal Copy implMichael Goulet-43/+63
2023-01-13Check ADT fields for copy implementations considering regionsMichael Goulet-2/+4
2023-01-13Rollup merge of #106585 - estebank:issue-46585, r=compiler-errorsMatthias Krüger-17/+157
When suggesting writing a fully qualified path probe for appropriate types Address the more common part of #46585.