about summary refs log tree commit diff
path: root/compiler/rustc_metadata/src
AgeCommit message (Collapse)AuthorLines
2022-12-24Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholkMatthias Krüger-3/+3
rustc: Remove needless lifetimes
2022-12-22A few metadata nitsNilstrieb-26/+11
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-3/+3
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-16Auto merge of #102318 - Amanieu:default_alloc_error_handler, r=oli-obkbors-16/+3
Stabilize default_alloc_error_handler Tracking issue: #66741 This turns `feature(default_alloc_error_handler)` on by default, which causes the compiler to automatically generate a default OOM handler which panics if `#[alloc_error_handler]` is not provided. The FCP completed over 2 years ago but the stabilization was blocked due to an issue with unwinding. This was fixed by #88098 so stabilization can be unblocked. Closes #66741
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-09Fold `Definitions` into the untracked dataOli Scherer-3/+3
2022-12-09Move the untracked cstore and source_span into a structOli Scherer-0/+3
2022-12-09Generate crate loaders on the flyOli Scherer-29/+31
2022-12-08Make encode_info_for_trait_item use queries instead of accessing the HIRSantiago Pastorino-12/+4
2022-12-07Use `Symbol` for the crate name instead of `String`/`str`Oli Scherer-5/+4
2022-12-03Remove all but one call site of `prepare_outputs` and fetch the value from ↵Oli Scherer-6/+4
the TyCtxt instead
2022-11-29Make inferred_outlives_crate return ClauseSantiago Pastorino-1/+1
2022-11-28Rollup merge of #104360 - petrochenkov:stabverb, r=TaKO8KiDylan DPC-8/+5
Stabilize native library modifier `verbatim` Stabilization report - https://github.com/rust-lang/rust/pull/104360#issuecomment-1312724787. cc https://github.com/rust-lang/rust/issues/81490 Closes https://github.com/rust-lang/rust/issues/99425
2022-11-27Stabilize native library modifier `verbatim`Vadim Petrochenkov-8/+5
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-2/+2
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-22Rollup merge of #104621 - YC:master, r=davidtwcoManish Goregaokar-2/+8
Fix --extern library finding errors - `crate_name` is not specified/passed to `metadata_crate_location_unknown_type` https://github.com/rust-lang/rust/blob/c493bae0d8efd75723460ce5c371f726efa93f15/compiler/rustc_error_messages/locales/en-US/metadata.ftl#L274-L275 - `metadata_lib_filename_form` is missing `$` - Add additional check to ensure that library is file Testing 1. Create file `a.rs` ```rust extern crate t; fn main() {} ``` 1. Create empty file `x` 1. Create empty directory `y` 1. Run ```sh $ rustc -o a a.rs --extern t=x $ rustc -o a a.rs --extern t=y ``` Both currently panic with stable.
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-22Tests for bad --extern library path and fileSteven Tang-1/+0
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-20Check that library is fileSteven Tang-0/+6
2022-11-20Fix CrateLocationUnknownType errorSteven Tang-1/+2
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-12/+8
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-16Use `as_deref` in compiler (but only where it makes sense)Maybe Waffle-2/+2
2022-11-14Wrap bundlen static libraries into object filesDaniil Belov-4/+9
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-03Stabilize default_alloc_error_handlerAmanieu d'Antras-16/+3
Closes #66741
2022-11-01Auto merge of #103217 - mejrs:track, r=eholkbors-0/+2
Track where diagnostics were created. This implements the `-Ztrack-diagnostics` flag, which uses `#[track_caller]` to track where diagnostics are created. It is meant as a debugging tool much like `-Ztreat-err-as-bug`. For example, the following code... ```rust struct A; struct B; fn main(){ let _: A = B; } ``` ...now emits the following error message: ``` error[E0308]: mismatched types --> src\main.rs:5:16 | 5 | let _: A = B; | - ^ expected struct `A`, found struct `B` | | | expected due to this -Ztrack-diagnostics: created at compiler\rustc_infer\src\infer\error_reporting\mod.rs:2275:31 ```
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-12/+122
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-31Add more track_callermejrs-0/+2