about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
AgeCommit message (Collapse)AuthorLines
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-19/+17
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-19/+29
2023-02-17Rollup merge of #108133 - kylematsuda:earlybinder-cleanups, r=compiler-errorsMatthias Krüger-3/+5
Small cleanups around `EarlyBinder` Cleaning up a few things that were brought up by `@lcnr` in reviewing #106696: - [make `issue33140_self_ty` query return `Option<EarlyBinder<Ty>>`](https://github.com/rust-lang/rust/pull/106696#discussion_r1067821423) - [small style improvement](https://github.com/rust-lang/rust/pull/106696#discussion_r1067816772)
2023-02-16Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgrbors-5/+2
Rollup of 7 pull requests Successful merges: - #106347 (More accurate spans for arg removal suggestion) - #108057 (Prevent some attributes from being merged with others on reexports) - #108090 (`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`) - #108092 (note issue for feature(packed_bundled_libs)) - #108099 (use chars instead of strings where applicable) - #108115 (Do not ICE on unmet trait alias bounds) - #108125 (Add new people to the compiletest review rotation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-16make issue33140_self_ty return Option<EarlyBinder<Ty>>Kyle Matsuda-3/+5
2023-02-16Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errorsbors-3/+2
Optimize `mk_region` PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions. r? `@compiler-errors`
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-5/+2
2023-02-15Copy `ty::AssocItem` all other the placeMaybe Waffle-1/+1
2023-02-15Auto merge of #108006 - cjgillot:def-impl, r=oli-obkbors-1/+1
Avoid accessing HIR when it can be avoided Experiment to see if it helps some incremental cases. Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged. r? `@ghost`
2023-02-15Rollup merge of #107163 - mikebenfield:parameters-pr, r=TaKO8KiDylan DPC-11/+11
Remove some superfluous type parameters from layout.rs. Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2023-02-15Add specialized variants of `mk_region`.Nicholas Nethercote-3/+2
Much like there are specialized variants of `mk_ty`. This will enable some optimization in the next commit. Also rename the existing `re_error*` functions as `mk_re_error*`, for consistency.
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-1/+1
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-1/+2
2023-02-13layout: deal with placeholders, ICE on bound typeslcnr-5/+2
a placeholder type is the same as a param as they represent "this could be any type". A bound type represents a type inside of a `for<T>` or `exists<T>`. When entering a forall or exists `T` should be instantiated as a existential (inference var) or universal (placeholder). You should never observe a bound variable without its binder.
2023-02-07Auto merge of #106180 - RalfJung:dereferenceable-generators, r=nbdd0121bors-19/+20
make &mut !Unpin not dereferenceable, and Box<!Unpin> not noalias See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 and [this LLVM discussion](https://discourse.llvm.org/t/interaction-of-noalias-and-dereferenceable/66979). The exact semantics of how `noalias` and `dereferenceable` interact are unclear, and `@comex` found a case of LLVM actually exploiting that ambiguity for optimizations. I think for now we should treat LLVM `dereferenceable` as implying a "fake read" to happen immediately at the top of the function (standing in for the spurious reads that LLVM might introduce), and that fake read is subject to all the usual `noalias` restrictions. This means we cannot put `dereferenceable` on `&mut !Unpin` references as those references can alias with other references that are being read and written inside the function (e.g. for self-referential generators), meaning the fake read introduces aliasing conflicts with those other accesses. For `&` this is already not a problem due to https://github.com/rust-lang/rust/pull/98017 which removed the `dereferenceable` attribute for other reasons. Regular `&mut Unpin` references are unaffected, so I hope the impact of this is going to be tiny. The first commit does some refactoring of the `PointerKind` enum since I found the old code very confusing each time I had to touch it. It doesn't change behavior. Fixes https://github.com/rust-lang/miri/issues/2714 EDIT: Turns out our `Box<!Unpin>` treatment was incorrect, too, so the PR also fixes that now (in codegen and Miri): we do not put `noalias` on these boxes any more.
2023-02-07Auto merge of #107693 - petrochenkov:metable, r=oli-obkbors-3/+6
rustc_metadata: Encode/decode some `LazyArrays` without an `Option` and a couple of related changes, see individual commits. Addresses comments in https://github.com/rust-lang/rust/pull/107166#discussion_r1083417124 and https://github.com/rust-lang/rust/pull/107166#discussion_r1083768417, cc `@cjgillot` `@oli-obk.`
2023-02-06also do not add noalias on not-Unpin BoxRalf Jung-5/+4
2023-02-06make &mut !Unpin not dereferenceableRalf Jung-6/+9
See https://github.com/rust-lang/unsafe-code-guidelines/issues/381 for discussion.
2023-02-06make PointerKind directly reflect pointer typesRalf Jung-17/+16
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-02-05Sort Generator `print-type-sizes` according to their yield pointsArpad Borsos-1/+10
Especially when trying to diagnose runaway future sizes, it might be more intuitive to sort the variants according to the control flow (aka their yield points) rather than the size of the variants.
2023-02-05rustc_metadata: Encode/decode some `LazyArray`s without an `Option`Vadim Petrochenkov-3/+6
Also add asserts to decoding `LazyArray`s with `Option`
2023-01-31Extend `-Z print-type-sizes` to distinguish generator upvars and locals from ↵Felix S. Klock II-1/+4
"normal" ADT fields.
2023-01-30nitsMichael Goulet-4/+0
2023-01-28Make unsizing_params_for_adt into a queryMichael Goulet-0/+52
2023-01-27Pacify tidy.Camille GILLOT-2/+2
2023-01-27Remember where a type was kept in MIR.Camille GILLOT-2/+2
2023-01-27Introduce GeneratorWitnessMIR.Camille GILLOT-2/+11
2023-01-27Always require Drop for generators.Camille GILLOT-0/+7
2023-01-26fix up subst_identity vs skip_binder; add some FIXMEs as identified in reviewKyle Matsuda-2/+2
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-4/+4
EarlyBinder to fn_sig in metadata
2023-01-26replace usages of fn_sig query with bound_fn_sigKyle Matsuda-3/+3
2023-01-26Rollup merge of #107248 - erikdesjardins:addrspace, r=oli-obkMatthias Krüger-6/+6
abi: add AddressSpace field to Primitive::Pointer ...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 (and various other changes), which will be done in a followup. (That is, if it's actually worth it to support multiple different pointer sizes. There is a lot of code that would be affected by that.) Fixes #106367 r? ``@oli-obk`` cc ``@Patryk27``
2023-01-23fix: use LocalDefId instead of HirId in trait resVincenzo Palazzo-9/+2
use LocalDefId instead of HirId in trait resolution to simplify the obligation clause resolution Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-22abi: add `AddressSpace` field to `Primitive::Pointer`Erik Desjardins-6/+6
...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-21Remove some superfluous type parameters from layout.rs.Michael Benfield-11/+11
Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2023-01-19Transform async ResumeTy in generator transformArpad Borsos-7/+27
- Eliminates all the `get_context` calls that async lowering created. - Replace all `Local` `ResumeTy` types with `&mut Context<'_>`. The `Local`s that have their types replaced are: - The `resume` argument itself. - The argument to `get_context`. - The yielded value of a `yield`. The `ResumeTy` hides a `&mut Context<'_>` behind an unsafe raw pointer, and the `get_context` function is being used to convert that back to a `&mut Context<'_>`. Ideally the async lowering would not use the `ResumeTy`/`get_context` indirection, but rather directly use `&mut Context<'_>`, however that would currently lead to higher-kinded lifetime errors. See <https://github.com/rust-lang/rust/issues/105501>. The async lowering step and the type / lifetime inference / checking are still using the `ResumeTy` indirection for the time being, and that indirection is removed here. After this transform, the generator body only knows about `&mut Context<'_>`.
2023-01-18Also remove `#![feature(control_flow_enum)]` where possibleScott McMurray-1/+0
2023-01-17Auto merge of #106294 - Nilstrieb:noundef-everything, r=nikicbors-7/+1
Put `noundef` on all scalars that don't allow uninit Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those. Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them. The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. After #99182, this function now doesn't return uninit values anymore, making users of it safe from this change. The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec). This is hopefully rare enough to not break anything. cc `@nagisa` `@scottmcm` `@nikic`
2023-01-17Improve commentsNilstrieb-6/+0
2023-01-17Put `noundef` on all scalars that don't allow uninitNilstrieb-1/+1
Previously, it was only put on scalars with range validity invariants like bool, was uninit was obviously invalid for those. Since then, we have normatively declared all uninit primitives to be undefined behavior and can therefore put `noundef` on them. The remaining concern was the `mem::uninitialized` function, which cause quite a lot of UB in the older parts of the ecosystem. This function now doesn't return uninit values anymore, making users of it safe from this change. The only real sources of UB where people could encounter uninit primitives are `MaybeUninit::uninit().assume_init()`, which has always be clear in the docs about being UB and from heap allocations (like reading from the spare capacity of a vec. This is hopefully rare enough to not break anything.
2023-01-16ConstBlocks are poly if their substs are polyMichael Goulet-2/+42
2023-01-14fix various subst_identity vs skip_binderKyle Matsuda-2/+2
2023-01-14change impl_trait_ref query to return EarlyBinder; remove ↵Kyle Matsuda-3/+3
bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata
2023-01-14change usages of impl_trait_ref to bound_impl_trait_refKyle Matsuda-10/+13
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-1/+1
2023-01-10Change type of box_noalias to boolTomasz Miąsko-1/+1
2023-01-10Change type of mutable_noalias to boolTomasz Miąsko-1/+1
2023-01-06Auto merge of #106474 - erikdesjardins:noalias, r=bjorn3bors-12/+7
cleanup: handle -Zmutable-noalias like -Zbox-noalias r? `@bjorn3` cc `@RalfJung` this will conflict with #106180
2023-01-04Rollup merge of #106403 - compiler-errors:rename-hir-methods, r=cjgillotMichael Goulet-1/+1
Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent` The `hir::Map::get_parent_node` function doesn't return a `Node`, and I think that's quite confusing. Let's rename it to something that sounds more like something that gets the parent hir id => `hir::Map::parent_id`. Same with `find_parent_node` => `opt_parent_id`. Also, combine `hir.get(hir.parent_id(hir_id))` and similar `hir.find(hir.parent_id(hir_id))` function into new functions that actually retrieve the parent node in one call. This last commit is the only one that might need to be looked at closely.
2023-01-04cleanup: handle -Zmutable-noalias like -Zbox-noaliasErik Desjardins-12/+7