summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
AgeCommit message (Collapse)AuthorLines
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
2023-01-04Split `-Zchalk` flag into `-Ztrait-solver=(stock|chalk|next)` flagMichael Goulet-1/+2
2023-01-04layout_of: `T: Thin` implies `sizeof(&T) == sizeof(usize)`Michael Goulet-8/+28
2023-01-04rename get_parent_node to parent_idMichael Goulet-1/+1
2023-01-03Auto merge of #106371 - RalfJung:no-ret-position-noalias, r=nikicbors-2/+4
do not add noalias in return position `noalias` as a return attribute in LLVM indicates that the returned pointer does not alias anything else that is reachable from the caller, *including things reachable before this function call*. This is clearly not the case with a function like `fn id(Box<T>) -> Box<T>`, so we cannot use this attribute. Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/385 (including an actual miscompilation that `@comex` managed to produce).
2023-01-02do not add noalias in return positionRalf Jung-2/+4
2022-12-24Rename some compare_method functionsMichael Goulet-1/+1
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-14/+11
2022-12-15Rollup merge of #105623 - compiler-errors:generator-type-size-fix, r=NilstriebMatthias Krüger-7/+23
Fix `-Z print-type-sizes` for generators with discriminant field ordered first Fixes #105589 Fixes #105591
2022-12-14Consider discriminant fields that are ordered before variant fieldsMichael Goulet-7/+23
2022-12-13Combine identical alias armsMichael Goulet-5/+2
2022-12-13Combine projection and opaque into aliasMichael Goulet-3/+6
2022-12-12normalize receiver substs and erase the regionsTakayuki Maeda-1/+7
use a smaller example
2022-12-10Rollup merge of #105082 - Swatinem:async-abi, r=compiler-errorsMatthias Krüger-5/+17
Fix Async Generator ABI This change was missed when making async generators implement `Future` directly. It did not cause any problems in codegen so far, as `GeneratorState<(), Output>` happens to have the same ABI as `Poll<Output>`.
2022-12-10Rollup merge of #104019 - compiler-errors:print-generator-sizes, r=wesleywiserMatthias Krüger-27/+116
Compute generator sizes with `-Zprint_type_sizes` Fixes #103887 r? `@pnkfelix`
2022-12-08Fix Async Generator ABIArpad Borsos-5/+17
This change was missed when making async generators implement `Future` directly. It did not cause any problems in codegen so far, as `GeneratorState<(), Output>` happens to have the same ABI as `Poll<Output>`.
2022-12-08Move has_structural_eq_impls provider to rustc_ty_utilsMichael Goulet-0/+46
2022-12-08Pull out logic into distinct functionsMichael Goulet-184/+165
2022-12-07Properly print generator interior type sizesMichael Goulet-86/+188
2022-12-07Compute generator sizes with -Zprint_type_sizesMichael Goulet-0/+6
2022-11-29Auto merge of #105012 - WaffleLapkin:into, r=oli-obkbors-18/+14
Make `tcx.mk_const` more permissive wrt `kind` argument (`impl Into`) r? `@oli-obk` you've asked for this >:)
2022-11-28Remove `Const::from_value`Maybe Waffle-2/+2
...it's just `mk_const` but without the sparcles
2022-11-28Simplify calls to `tcx.mk_const`Maybe Waffle-16/+12
`mk_const(ty::ConstKind::X(...), ty)` can now be simplified to `mk_cosnt(..., ty)`. I searched with the following regex: \mk_const\([\n\s]*(ty::)?ConstKind\ I've left `ty::ConstKind::{Bound, Error}` as-is, they seem clearer this way.
2022-11-28Rollup merge of #105006 - RalfJung:scalar-pair-alignment, r=eddybMatthias Krüger-262/+272
stricter alignment enforcement for ScalarPair `@eddyb` [indicated](https://github.com/rust-lang/rust/pull/103926#discussion_r1033315005) that alignment violating this check might be a bug. So let's see what the test suite says. (Only the 2nd commit actually changes behavior... but I couldn't not do that other cleanup.^^) Does the PR CI runner even enable debug assertions though...?
2022-11-28stricter alignment enforcement for ScalarPair and VectorRalf Jung-15/+22
2022-11-28Rollup merge of #104732 - WaffleLapkin:from_def_idn't, r=compiler-errorsDylan DPC-1/+1
Refactor `ty::ClosureKind` related stuff I've tried to fix all duplication and weirdness, but if I missed something do tell :p r? `@compiler-errors`
2022-11-28sanity_check_layout: less rightwards driftRalf Jung-262/+265
2022-11-27Auto merge of #103917 - oli-obk:layout_math, r=RalfJung,lcnrbors-14/+14
Various cleanups around scalar layout restrictions Pulled out of https://github.com/rust-lang/rust/pull/103724
2022-11-27Rename `fn_trait_kind_from_{from_lang=>def_id}` to better convey meaningMaybe Waffle-1/+1
2022-11-25Auto merge of #99798 - JulianKnodt:ac1, r=BoxyUwUbors-296/+256
Add `ConstKind::Expr` Starting to implement `ty::ConstKind::Abstract`, most of the match cases are stubbed out, some I was unsure what to add, others I didn't want to add until a more complete implementation was ready. r? `@lcnr`
2022-11-25move 2 candidates into builtin candidatelcnr-2/+0
2022-11-25reduce duplicated argument logicBoxy-64/+40
2022-11-25Add empty ConstKind::Abstractkadmin-296/+280
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-25Some manual formatting of let..else statementsOli Scherer-14/+14
2022-11-24Auto merge of #103693 - HKalbasi:master, r=oli-obkbors-952/+44
Make rustc_target usable outside of rustc I'm working on showing type size in rust-analyzer (https://github.com/rust-lang/rust-analyzer/pull/13490) and I currently copied rustc code inside rust-analyzer, which works, but is bad. With this change, I would become able to use `rustc_target` and `rustc_index` directly in r-a, reducing the amount of copy needed. This PR contains some feature flag to put nightly features behind them to make crates buildable on the stable compiler + makes layout related types generic over index type + removes interning of nested layouts.
2022-11-24move things from rustc_target::abi to rustc_abihkalbasi-10/+10