about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src/rmeta
AgeCommit message (Collapse)AuthorLines
2023-01-09Use newtype for unused generic parametersNilstrieb-4/+4
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-17/+11
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2022-12-28Auto merge of #106129 - compiler-errors:compare_method-tweaks, r=BoxyUwUbors-2/+2
Some `compare_method` tweaks 1. Make some of the comparison functions' names more regular 2. Reduce pub scope of some of the things in `compare_method` ~3. Remove some unnecessary opaque type handling code -- `InferCtxt` already is in a mode that doesn't define opaque types~ * moved to a different PR 4. Bubble up `ErrorGuaranteed` for region constraint errors in `compare_method` - Improves a redundant error message in one unit test. 5. Move the `compare_method` module to have a more general name, since it's more like `compare_impl_item` :) 6. Rename `collect_trait_impl_trait_tys`
2022-12-28better names and a commentMichael Goulet-2/+2
2022-12-25Rollup merge of #106137 - matthiaskrgr:clippy_style, r=jyn514Matthias Krüger-1/+1
fix more clippy::style findings match_result_ok obfuscated_if_else single_char_add writeln_empty_string collapsible_match iter_cloned_collect unnecessary_mut_passed r? `@compiler-errors`
2022-12-25Rollup merge of #105955 - ↵Matthias Krüger-1/+1
Nilstrieb:no-trivial-opt-wrappers-we-have-field-accesses-for-that, r=cjgillot Remove wrapper functions for some unstable options They are trivial and just forward to the option. Like most other options, we can just access it directly.
2022-12-25fix more clippy::style findingsMatthias Krüger-1/+1
match_result_ok obfuscated_if_else single_char_add writeln_empty_string collapsible_match iter_cloned_collect unnecessary_mut_passed
2022-12-25fix some typosKaDiWa-1/+1
2022-12-24Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholkMatthias Krüger-1/+1
rustc: Remove needless lifetimes
2022-12-22A few metadata nitsNilstrieb-20/+9
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-12-20Remove wrapper functions for some unstable optionsNilstrieb-1/+1
They are trivial and just forward to the option. Like most other options, we can just access it directly.
2022-12-18Rollup merge of #105869 - matthiaskrgr:clone_on_copy, r=compiler-errorsMatthias Krüger-1/+1
don't clone Copy types
2022-12-18don't restuct references just to reborrowMatthias Krüger-2/+2
2022-12-18don't clone Copy typesMatthias Krüger-1/+1
2022-12-14Auto merge of #104986 - compiler-errors:opaques, r=oli-obkbors-2/+2
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias` Implements https://github.com/rust-lang/types-team/issues/79. This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so: ``` enum AliasKind { Projection, Opaque, } struct AliasTy<'tcx> { def_id: DefId, substs: SubstsRef<'tcx>, } ``` Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example: ```diff match ty.kind() { - ty::Opaque(..) => + ty::Alias(ty::Opaque, ..) => {} _ => {} } ``` This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically. r? `@ghost`
2022-12-13Combine projection and opaque into aliasMichael Goulet-1/+1
2022-12-13ProjectionTy.item_def_id -> ProjectionTy.def_idMichael Goulet-1/+1
2022-12-13Make some diagnostics not depend on the source of what they reference being ↵Oli Scherer-7/+9
available
2022-12-11Rollup merge of #105472 - spastorino:make-encoder-use-queries, r=oli-obkMatthias Krüger-12/+4
Make encode_info_for_trait_item use queries instead of accessing the HIR This change avoids accessing the HIR on `encode_info_for_trait_item` and uses queries. We will need to execute this function for elements that have no HIR and by using queries we will be able to feed for definitions that have no HIR. r? ``@oli-obk``
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-1/+0
2022-12-09Move the untracked cstore and source_span into a structOli Scherer-0/+3
2022-12-08Make encode_info_for_trait_item use queries instead of accessing the HIRSantiago Pastorino-12/+4
2022-11-29Make inferred_outlives_crate return ClauseSantiago Pastorino-1/+1
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-4/+4
2022-11-26Auto merge of #104730 - petrochenkov:modchild5, r=cjgillotbors-80/+50
rustc_metadata: Switch module children decoding to an iterator Previously https://github.com/rust-lang/rust/pull/103578, https://github.com/rust-lang/rust/pull/103524 and previous PRs simplified it as much as possible. A couple of cleanup commits is also added. r? `@cjgillot`
2022-11-25Add empty ConstKind::Abstractkadmin-7/+1
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-24Auto merge of #104507 - WaffleLapkin:asderefsyou, r=wesleywiserbors-1/+1
Use `as_deref` in compiler (but only where it makes sense) This simplifies some code :3 (there are some changes that are not exacly `as_deref`, but more like "clever `Option`/`Result` method use")
2022-11-22rustc_metadata: Cleanup to `get_module_children`Vadim Petrochenkov-49/+26
to unify proc-macro and non-proc-macro cases in particular.
2022-11-22rustc_metadata: Switch module children decoding to an iteratorVadim Petrochenkov-59/+54
2022-11-22rustc_metadata: Do not encode empty reexport listsVadim Petrochenkov-7/+5
This is more a cleanup than optimization
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-76/+30
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-22Split `MacArgs` in two.Nicholas Nethercote-1/+1
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-76/+30
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-2/+2
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-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-1/+1
2022-11-13Store a LocalDefId in hir::Variant & hir::Field.Camille GILLOT-5/+2
2022-11-13Store a LocalDefId in hir::GenericParam.Camille GILLOT-2/+1
2022-11-13Store LocalDefId in hir::Closure.Camille GILLOT-5/+5
2022-11-12Compute variance for opaques too.Camille GILLOT-2/+2
2022-11-01Auto merge of #103496 - petrochenkov:effvisdoc2, r=lqdbors-2/+1
rustc_metadata: Encode even less doc comments The fact that `def_id` is in the `tcx.privacy_access_levels(())` table is not very meaningful, especially after https://github.com/rust-lang/rust/pull/102026, `is_exported` (or `is_reachable` in the worst case) is what you need. Follow up to https://github.com/rust-lang/rust/pull/98450. r? `@GuillaumeGomez` `@lqd`
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-0/+12
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-29Encode LangItem directlyCameron Steffen-19/+11
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-16/+17
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-29rustc_metadata: Encode even less doc commentsVadim Petrochenkov-2/+1
2022-10-29Auto merge of #102233 - petrochenkov:effvis, r=jackh726bors-3/+2
privacy: Rename "accessibility levels" to "effective visibilities" And a couple of other naming and comment tweaks. Related to https://github.com/rust-lang/rust/issues/48054 For `enum Level` I initially used naming `enum EffectiveVisibilityLevel`, but it was too long and inconvenient because it's used pretty often. So I shortened it to just `Level`, if it needs to be used from some context where this name would be ambiguous, then it can be imported with renaming like `use rustc_middle::privacy::Level as EffVisLevel` or something.
2022-10-27Rollup merge of #103524 - petrochenkov:modchild4, r=cjgillotMatthias Krüger-50/+53
rustc_metadata: Add struct and variant constructors to module children at encoding time instead of decoding time. Continuation of https://github.com/rust-lang/rust/pull/95899. The last time it caused some ICEs from generator use, but not everything seems ok.
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-3/+2
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-26Auto merge of #103284 - compiler-errors:const-sad, r=oli-obkbors-41/+15
Revert "Unify tcx.constness and param env constness checks" Too much of a perf regression https://github.com/rust-lang/rust/pull/102975#issuecomment-1282702513, and an attempt in #103263 didn't fix it except for just a tiny bit. This change isn't really needed (see https://github.com/rust-lang/rust/pull/102830#issuecomment-1272514096), so this should be an easy revert.
2022-10-25rustc_metadata: Add constructors to module children at encoding timeVadim Petrochenkov-50/+53
instead of decoding time.