about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/layout.rs
AgeCommit message (Collapse)AuthorLines
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-3/+3
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-13Layout of `&dyn Trait<[type error]>` is still wideMichael Goulet-1/+5
2023-03-04Rollup merge of #108669 - Nilstrieb:query-my-uninitness, r=compiler-errorsDylan DPC-1/+6
Allow checking whether a type allows being uninitialized This is useful for clippy ([rust-lang/clippy#10407](https://github.com/rust-lang/rust-clippy/issues/10407)) and for the future `MaybeUninit::assume_init` panics (#100423).
2023-03-03Match end user facing unmatched backticks in compiler/est31-1/+1
2023-03-02Allow checking whether a type allows being uninitializedNilstrieb-1/+6
This is useful for clippy and for the future `MaybeUninit::assume_init` panics.
2023-02-27Unify all validity check intrinsicsNilstrieb-4/+18
Also merges the inhabitedness check into the query to further unify the code paths.
2023-02-27Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errorsMatthias Krüger-0/+17
Unify validity checks into a single query Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one. I am not entirely happy with the naming and key type and open for improvements. r? oli-obk
2023-02-24Rename many interner functions.Nicholas Nethercote-4/+4
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Unify validity checks into a single queryNilstrieb-0/+17
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
2023-02-22Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obkbors-8/+1
Remove type-traversal trait aliases #107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value. Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream). This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c624b9e3bbd7d8e07697e2e9f861a45b6. Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up. r? `@oli-obk`
2023-02-22Remove type-traversal trait aliasesAlan Egerton-8/+1
2023-02-22errors: generate typed identifiers in each crateDavid Wood-3/+4
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-18make first component of dyn* use pointer layout+type, and adjust DynStar commentRalf Jung-1/+1
2023-02-17Replace `mk_foo` calls with `infer_foo` where possible.Nicholas Nethercote-1/+1
There are several `mk_foo`/`intern_foo` pairs, where the former takes an iterator and the latter takes a slice. (This naming convention is bad, but that's a fix for another PR.) This commit changes several `mk_foo` occurrences into `intern_foo`, avoiding the need for some `.iter()`/`.into_iter()` calls. Affected cases: - mk_type_list - mk_tup - mk_substs - mk_const_list
2023-02-13Workaround issue #107747Alan Egerton-0/+7
Only required until fix #107803 is merged into stage0 compiler, expected when beta 1.69.0 is released on 2023-03-09, then this commit can be reverted.
2023-02-06also do not add noalias on not-Unpin BoxRalf Jung-91/+95
2023-02-06make PointerKind directly reflect pointer typesRalf Jung-27/+12
The code that consumes PointerKind (`adjust_for_rust_scalar` in rustc_ty_utils) ended up using PointerKind variants to talk about Rust reference types (& and &mut) anyway, making the old code structure quite confusing: one always had to keep in mind which PointerKind corresponds to which type. So this changes PointerKind to directly reflect the type. This does not change behavior.
2023-01-27Introduce GeneratorWitnessMIR.Camille GILLOT-0/+1
2023-01-22abi: add `AddressSpace` field to `Primitive::Pointer`Erik Desjardins-112/+110
...and remove it from `PointeeInfo`, which isn't meant for this. There are still various places (marked with FIXMEs) that assume all pointers have the same size and alignment. Fixing this requires parsing non-default address spaces in the data layout string, which will be done in a followup.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-1/+1
2023-01-04review comment: Deduplicate dyn ty_and_layout_field codeMichael Goulet-36/+19
2023-01-04Mirror metadata changes in layout sanity checkMichael Goulet-7/+45
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-12-13Combine identical alias armsMichael Goulet-3/+2
2022-12-13Combine projection and opaque into aliasMichael Goulet-4/+4
2022-11-24move some layout logic to rustc_target::abi::layouthkalbasi-19/+12
2022-11-24make rustc_target usable outside of rustchkalbasi-1/+1
2022-11-09Use `LayoutError`'s implementation of `IntoDiagnostic`SLASHLogin-4/+4
2022-10-27Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functionsMaybe Waffle-2/+2
Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions`
2022-10-23Migrate all diagnosticsNilstrieb-3/+3
2022-10-07First batch of review feedback changes from #102110Nathan Stocks-1/+20
2022-10-04It's not about types or consts, but the lack of regionsOli Scherer-2/+2
2022-10-03Move utils from rustc_middle to rustc_ty_utilsCameron Steffen-2334/+5
2022-09-24fix lifetime errorEllis Hoag-2/+8
2022-09-24rebase and update trait namesEllis Hoag-5/+3
2022-09-24impl SessionDiagnostic for LayoutError and Spanned<T>Ellis Hoag-1/+10
2022-09-19extend polymorphization hack comment.lcnr-0/+2
2022-09-19remove the `Subst` trait, always use `EarlyBinder`lcnr-1/+0
2022-09-19do not implement type traversal for `EarlyBinder`lcnr-1/+4
2022-09-13Address code review commentsEric Holk-6/+5
2022-09-12Make dyn-trait-method workMichael Goulet-3/+16
2022-09-12Rename some variantsMichael Goulet-7/+4
2022-09-12Construct dyn* during const interpMichael Goulet-8/+2
2022-09-12Call destructors when dyn* object goes out of scopeEric Holk-3/+12
2022-09-12dyn* through more typechecking and MIREric Holk-2/+24
2022-09-12Plumb dyn trait representation through ty::DynamicEric Holk-1/+2
2022-09-07Use niche-filling optimization even when multiple variants have data.Michael Benfield-116/+198
Fixes #46213
2022-09-07Change name of "dataful" variant to "untagged"Michael Benfield-10/+10
This is in anticipation of a new enum layout, in which the niche optimization may be applied even when multiple variants have data.
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-86/+89
2022-08-31Fix a bunch of typoDezhi Wu-1/+1
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos