summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/layout.rs
AgeCommit message (Collapse)AuthorLines
2022-03-30Spellchecking compiler commentsYuri Astrakhan-2/+2
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-39/+40
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-07Clarify `Layout` interning.Nicholas Nethercote-42/+61
`Layout` is another type that is sometimes interned, sometimes not, and we always use references to refer to it so we can't take any advantage of the uniqueness properties for hashing or equality checks. This commit renames `Layout` as `LayoutS`, and then introduces a new `Layout` that is a newtype around an `Interned<LayoutS>`. It also interns more layouts than before. Previously layouts within layouts (via the `variants` field) were never interned, but now they are. Hence the lifetime on the new `Layout` type. Unlike other interned types, these ones are in `rustc_target` instead of `rustc_middle`. This reflects the existing structure of the code, which does layout-specific stuff in `rustc_target` while `TyAndLayout` is generic over the `Ty`, allowing the type-specific stuff to occur in `rustc_middle`. The commit also adds a `HashStable` impl for `Interned`, which was needed. It hashes the contents, unlike the `Hash` impl which hashes the pointer.
2022-03-03Revert #26494 regressionVin Singh-5/+1
2022-02-26Apply noundef attribute to all scalar types which do not permit raw initErik Desjardins-0/+5
Beyond `&`/`&mut`/`Box`, this covers `char`, discriminants, `NonZero*`, etc. All such types currently cause a Miri error if left uninitialized, and an `invalid_value` lint in cases like `mem::uninitialized::<char>()` Note that this _does not_ change whether or not it is UB for `u64` (or other integer types with no invalid values) to be undef.
2022-02-21use `List<Ty<'tcx>>` for tupleslcnr-8/+6
2022-02-19Adopt let else in more placesest31-9/+6
2022-02-13Auto merge of #93670 - erikdesjardins:noundef, r=nikicbors-1/+7
Apply noundef attribute to &T, &mut T, Box<T>, bool This doesn't handle `char` because it's a bit awkward to distinguish it from `u32` at this point in codegen. Note that this _does not_ change whether or not it is UB for `&`, `&mut`, or `Box` to point to undef. It only applies to the pointer itself, not the pointed-to memory. Fixes (partially) #74378. r? `@nikic` cc `@RalfJung`
2022-02-09Make FnAbiError Copy.Camille GILLOT-26/+17
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-16/+25
2022-02-08Auto merge of #93561 - Amanieu:more-unwind-abi, r=nagisabors-14/+17
Add more *-unwind ABI variants The following *-unwind ABIs are now supported: - "C-unwind" - "cdecl-unwind" - "stdcall-unwind" - "fastcall-unwind" - "vectorcall-unwind" - "thiscall-unwind" - "aapcs-unwind" - "win64-unwind" - "sysv64-unwind" - "system-unwind" cc `@rust-lang/wg-ffi-unwind`
2022-02-05Apply noundef attribute to &T, &mut T, Box<T>, boolErik Desjardins-1/+7
This doesn't handle `char` because it's a bit awkward to distinguish it from u32 at this point in codegen. Note that for some types (like `&Struct` and `&mut Struct`), we already apply `dereferenceable`, which implies `noundef`, so the IR does not change.
2022-02-03Auto merge of #92932 - ouz-a:master, r=oli-obkbors-1/+4
Temporary fix for the layout of aligned enums Fix for the issue #92464 ~~I was after this issue for quite some time now, I have a temporary fix for it. I think the current problem is [here](https://github.com/ouz-a/rust/blob/e75f96763f99d56d03ada939fe05cbeb2254888d/compiler/rustc_middle/src/ty/layout.rs#L1305-L1310) created `tag` value might be wrong, because when I checked `min` and `max` values it's always between 0..1, which results in wrong size comparison in a few lines down below. I think `min` and `max` values don't take `#[repr(aligned(8))]` into consideration and just act from base values assigned inside the enum. If what I am saying is true, aligned enums were created with the wrong layout for some time.~~ ~~As stated in the title this is only a temporary fix and I think this needs further investigation, if someone wants to mentor it I would like to work on that too.~~ 😸 **Edit: Weird some tests fail now going to close this for now...** **Edit2: I made it work again.** I think I figured out the main problem of the issue, layout types of aligned enums with custom discriminant types were not handled, which resulted in confusing(such as this issue) behavior down the line, this is a kinda hacky fix for the issue.
2022-02-02Add more *-unwind ABI variantsAmanieu d'Antras-14/+17
The following *-unwind ABIs are now supported: - "C-unwind" - "cdecl-unwind" - "stdcall-unwind" - "fastcall-unwind" - "vectorcall-unwind" - "thiscall-unwind" - "aapcs-unwind" - "win64-unwind" - "sysv64-unwind" - "system-unwind"
2022-02-01fix for the issue #92464ouz-a-1/+4
2022-01-15initial revertEllen-4/+2
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-8/+7
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2021-12-20try to fix ICE in fn_abi_of_instanceRalf Jung-4/+7
2021-12-19Rollup merge of #91984 - Aaron1011:rustc-middle-lifetime, r=oli-obkMatthias Krüger-8/+8
Remove `in_band_lifetimes` from `rustc_middle` See #91867 This was mostly straightforward. In several places, I take advantage of the fact that lifetimes are non-hygenic: a macro declares the 'tcx' lifetime, which is then used in types passed in as macro arguments.
2021-12-15Remove `in_band_lifetimes` from `rustc_middle`Aaron Hill-8/+8
See #91867 This was mostly straightforward. In several places, I take advantage of the fact that lifetimes are non-hygenic: a macro declares the 'tcx' lifetime, which is then used in types passed in as macro arguments.
2021-12-14Minor cleanupChase Wilson-4/+4
2021-12-03Rollup merge of #90854 - sanxiyn:unsized-and-uninhabited, r=estebankMatthias Krüger-1/+1
Type can be unsized and uninhabited Fix #88150.
2021-12-01address reviewb-naber-0/+4
2021-12-01implement version of normalize_erasing_regions that doesn't assume value is ↵b-naber-1/+18
normalizable
2021-11-13Type can be unsized and uninhabitedSeo Sanghyeon-1/+1
2021-11-05Update LLVM comments around NoAliasMutRefJosh Stone-3/+4
2021-10-16Adopt let_else across the compilerest31-9/+4
This performs a substitution of code following the pattern: let <id> = if let <pat> = ... { identity } else { ... : ! }; To simplify it to: let <pat> = ... { identity } else { ... : ! }; By adopting the let_else feature.
2021-10-10Auto merge of #88952 - skrap:add-armv7-uclibc, r=nagisabors-2/+2
Add new tier-3 target: armv7-unknown-linux-uclibceabihf This change adds a new tier-3 target: armv7-unknown-linux-uclibceabihf This target is primarily used in embedded linux devices where system resources are slim and glibc is deemed too heavyweight. Cross compilation C toolchains are available [here](https://toolchains.bootlin.com/) or via [buildroot](https://buildroot.org). The change is based largely on a previous PR #79380 with a few minor modifications. The author of that PR was unable to push the PR forward, and graciously allowed me to take it over. Per the [target tier 3 policy](https://github.com/rust-lang/rfcs/blob/master/text/2803-target-tier-policy.md), I volunteer to be the "target maintainer". This is my first PR to Rust itself, so I apologize if I've missed things!
2021-10-08clippy::complexity fixesMatthias Krüger-2/+2
2021-10-06Rollup merge of #89329 - tmiasko:print-type-sizes-no-fields, r=jackh726Manish Goregaokar-2/+5
print-type-sizes: skip field printing for primitives Fixes #86528.
2021-10-06Add new target armv7-unknown-linux-uclibceabihfYannick Koehler-2/+2
Co-authored-by: Jonah Petri <jonah@petri.us>
2021-10-03Remove re-export.Camille GILLOT-1/+0
2021-09-30Implemented -Z randomize-layoutChase Wilson-13/+35
2021-09-28print-type-sizes: skip field printing for primitivesTomasz MiÄ…sko-2/+5
2021-09-18[HACK(eddyb)] arena-allocate but don't intern `FnAbi`s.Eduard-Mihai Burtescu-1/+1
2021-09-18Querify `fn_abi_of_{fn_ptr,instance}`.Eduard-Mihai Burtescu-58/+65
2021-09-18ty::layout: replicate `layout_of` setup for `fn_abi_of_{fn_ptr,instance}`.Eduard-Mihai Burtescu-106/+115
2021-09-18ty::layout: intern `FnAbi`s as `&'tcx`.Eduard-Mihai Burtescu-8/+8
2021-09-18ty::layout: propagate errors up to (but not out of) `FnAbi::of_*`.Eduard-Mihai Burtescu-25/+104
2021-09-18rustc_target: `adjust_for_cabi` -> `adjust_for_foreign_abi`.Eduard-Mihai Burtescu-1/+1
2021-09-18ty::layout: split out a private trait from `FnAbiExt`.Eduard-Mihai Burtescu-10/+21
2021-09-18ty::layout: move `trait FnAbiExt` to just before its `impl`.Eduard-Mihai Burtescu-28/+28
2021-09-09Rename `(un)signed` to `(un)signed_int`Andreas Liljeqvist-2/+2
2021-09-09Move `unsigned_max` etc into `Size` againAndreas Liljeqvist-4/+4
2021-09-09Make `abi::Abi` `Copy` and remove a *lot* of refsAndreas Liljeqvist-40/+32
fix fix Remove more refs and clones fix more fix
2021-09-09Remove `contains_zero`, respect the compilerAndreas Liljeqvist-1/+1
2021-09-02ty::layout: split `LayoutOf` into required and (blanket) provided halves.Eduard-Mihai Burtescu-4/+10
2021-09-02ty::layout: implement `layout_of` automatically as a default method.Eduard-Mihai Burtescu-11/+50
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-17/+48
2021-08-30rustc_target: remove `LayoutOf` bound from `TyAbiInterface`.Eduard-Mihai Burtescu-24/+30