summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/layout.rs
AgeCommit message (Collapse)AuthorLines
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
2021-08-30rustc_target: `TyAndLayout::field` should never error.Eduard-Mihai Burtescu-48/+53
2021-08-27rustc_target: require `TyAbiInterface` in `LayoutOf`.Eduard-Mihai Burtescu-0/+14
2021-08-27rustc_target: rename `TyAndLayoutMethods` to `TyAbiInterface`.Eduard-Mihai Burtescu-4/+8
2021-08-27rustc_target: add lifetime parameter to `LayoutOf`.Eduard-Mihai Burtescu-13/+9
2021-08-27Auto merge of #88326 - eddyb:inline-ty-layout-methods, r=oli-obkbors-0/+10
`#[inline]` non-generic `pub fn`s in `rustc_target::abi` and `ty::layout`. Mostly doing this as a perf curiosity, having spotted that `#[inline]` usage is a bit spotty.
2021-08-26Auto merge of #87280 - lcnr:lazy-anon-const-default-substs, r=nikomatsakisbors-2/+4
lazily "compute" anon const default substs Continuing the work of #83086, this implements the discussed solution for the [unused substs problem](https://github.com/rust-lang/project-const-generics/blob/master/design-docs/anon-const-substs.md#unused-substs). As of now, anonymous constants inherit all of their parents generics, even if they do not use them, e.g. in `fn foo<T, const N: usize>() -> [T; N + 1]`, the array length has `T` as a generic parameter even though it doesn't use it. These *unused substs* cause some backwards incompatible, and imo incorrect behavior, e.g. #78369. --- We do not actually filter any generic parameters here and the `default_anon_const_substs` query still a dummy which only checks that - we now prevent the previously existing query cycles and are able to call `predicates_of(parent)` when computing the substs of anonymous constants - the default anon consts substs only include the typeflags we assume it does. Implementing that filtering will be left as future work. --- The idea of this PR is to delay the creation of the anon const substs until after we've computed `predicates_of` for the parent of the anon const. As the predicates of the parent can however contain the anon const we still have to create a `ty::Const` for it. We do this by changing the substs field of `ty::Unevaluated` to an option and modifying accesses to instead call the method `unevaluated.substs(tcx)` which returns the substs as before. If the substs - now `substs_` - of `ty::Unevaluated` are `None`, it means that the anon const currently has its default substs, i.e. the substs it has when first constructed, which are the generic parameters it has available. To be able to call `unevaluated.substs(tcx)` in a `TypeVisitor`, we add the non-defaulted method `fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>>`. In case `tcx_for_anon_const_substs` returns `None`, unknown anon const default substs are skipped entirely. Even when `substs_` is `None` we still have to treat the constant as if it has its default substs. To do this, `TypeFlags` are modified so that it is clear whether they can still change when *exposing* any anon const default substs. A new flag, `HAS_UNKNOWN_DEFAULT_CONST_SUBSTS`, is added in case some default flags are missing. The rest of this PR are some smaller changes to either not cause cycles by trying to access the default anon const substs too early or to be able to access the `tcx` in previously unused locations. cc `@rust-lang/project-const-generics` r? `@nikomatsakis`
2021-08-26`#[inline]` non-generic `pub fn`s in `rustc_target::abi` and `ty::layout`.Eduard-Mihai Burtescu-0/+10
2021-08-26Auto merge of #88308 - eddyb:cooked-layouts, r=nagisabors-75/+33
Morph `layout_raw` query into `layout_of`. Before this PR, `LayoutCx::layout_of` wrapped the `layout_raw` query, to: * normalize the type, before attempting to compute the layout * pass the layout to `record_layout_for_printing`, for `-Zprint-type-sizes` Moving those two responsibilities into the query may reduce overhead (due to cached calls skipping those steps), but I want to do a perf run to know. One of the changes I had to make was changing the return type of the query, to be able to both get out the type produced by normalizing inside the query *and* to match the signature of the old `TyCtxt::layout_of`. This change may be worse, perf-wise, so that's another reason I want to check. r? `@nagisa` cc `@oli-obk`
2021-08-26reviewlcnr-2/+2
2021-08-26update `TypeFlags` to deal with missing ct substslcnr-2/+4
2021-08-25Auto merge of #85499 - jackh726:assoc-type-norm-rebase, r=nikomatsakisbors-2/+1
Normalize projections under binders Fixes #70243 Fixes #70120 Fixes #62529 Fixes #87219 Issues to followup on after (probably fixed, but no test added here): #76956 #56556 #79207 #85636 r? `@nikomatsakis`
2021-08-24Normalize associated types with bound varsJack Huey-2/+1
2021-08-25Auto merge of #88242 - bonega:allocation_range, r=oli-obkbors-16/+23
Use custom wrap-around type instead of RangeInclusive Two reasons: 1. More memory is allocated than necessary for `valid_range` in `Scalar`. The range is not used as an iterator and `exhausted` is never used. 2. `contains`, `count` etc. methods in `RangeInclusive` are doing very unhelpful(and dangerous!) things when used as a wrap-around range. - In general this PR wants to limit potentially confusing methods, that have a low probability of working. Doing a local perf run, every metric shows improvement except for instructions. Max-rss seem to have a very consistent improvement. Sorry - newbie here, probably doing something wrong.
2021-08-24Morph `layout_raw` query into `layout_of`.Eduard-Mihai Burtescu-75/+33
2021-08-23add `with_start` and `with_end`Andreas Liljeqvist-5/+3
2021-08-23Rename to WrappingRangeAndreas Liljeqvist-8/+8
2021-08-23implement contains_zero methodAndreas Liljeqvist-4/+2