about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
AgeCommit message (Collapse)AuthorLines
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
2022-11-24move some layout logic to rustc_target::abi::layouthkalbasi-940/+32
2022-11-24make rustc_target usable outside of rustchkalbasi-13/+13
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-0/+6
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-22also sort fields by niche sizes to retain optimizationsThe 8472-3/+16
2022-11-22group fields based on largest power of two dividing its sizeThe 8472-7/+3
2022-11-22optimize field ordering by grouping power-of-two arrays with larger typesThe 8472-4/+13
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-1/+1
2022-11-21Allow iterators instead of requiring slices that will get turned into iteratorsOli Scherer-1/+1
2022-11-21Assert that various types have the right amount of generic args and fix the ↵Oli Scherer-6/+3
sites that used the wrong amount
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-5/+0
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-20Factor out conservative_is_privately_uninhabitedCameron Steffen-60/+2
2022-11-13add is_sized method on Abi and Layout, and use itRalf Jung-1/+1
2022-11-13Create bidirectional bounds between original and duplicated parameters.Camille GILLOT-5/+0
2022-11-10Use const_error_with_guaranteed moreMichael Goulet-1/+3
2022-11-04Refactor tcx mk_const parameters.Mateusz-15/+5