about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
AgeCommit message (Collapse)AuthorLines
2024-08-14Auto merge of #129076 - matthiaskrgr:rollup-rg8mi2x, r=matthiaskrgrbors-1/+1
Rollup of 6 pull requests Successful merges: - #128410 (Migrate `remap-path-prefix-dwarf` `run-make` test to rmake) - #128759 (alloc: add ToString specialization for `&&str`) - #128873 (Add windows-targets crate to std's sysroot) - #129001 (chore(lib): Enhance documentation for core::fmt::Formatter's write_fm…) - #129061 (Use `is_lang_item` more) - #129062 (Remove a no-longer-true assert) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-14Rollup merge of #129061 - compiler-errors:lang-item, r=UrgauMatthias Krüger-1/+1
Use `is_lang_item` more Few places that I missed since introducing `TyCtxt::is_lang_item`.
2024-08-14Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errorsbors-2/+2
Shrink `TyKind::FnPtr`. By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI. r? `@compiler-errors`
2024-08-13Use is_lang_item moreMichael Goulet-1/+1
2024-08-12Rollup merge of #128712 - compiler-errors:normalize-borrowck, r=lcnrMatthias Krüger-1/+5
Normalize struct tail properly for `dyn` ptr-to-ptr casting in new solver Realized that the new solver didn't handle ptr-to-ptr casting correctly. r? lcnr Built on #128694
2024-08-11Remove struct_tail_no_normalizationMichael Goulet-1/+5
2024-08-11Use assert_matches around the compilerMichael Goulet-1/+1
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-2/+2
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-08-08Rename struct_tail_erasing_lifetimes to struct_tail_for_codegenMichael Goulet-2/+2
2024-08-08Do normalize when computing struct tails in codegenMichael Goulet-1/+1
2024-08-02Move ZST ABI handling to `rustc_target`beetrees-25/+2
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-3/+1
Bump bootstrap compiler to new beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-29Reformat `use` declarations.Nicholas Nethercote-28/+26
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28step cfg(bootstrap)Mark Rousskov-3/+1
2024-07-24Make sure that args are compatible in resolve_associated_itemMichael Goulet-2/+13
2024-07-12Auto merge of #123351 - beetrees:x86-ret-snan-rust, r=nikic,workingjubileebors-0/+34
Ensure floats are returned losslessly by the Rust ABI on 32-bit x86 Solves #115567 for the (default) `"Rust"` ABI. When compiling for 32-bit x86, this PR changes the `"Rust"` ABI to return floats indirectly instead of in x87 registers (with the exception of single `f32`s, which this PR returns in general purpose registers as they are small enough to fit in one). No change is made to the `"C"` ABI as that ABI requires x87 register usage and therefore will need a different solution.
2024-07-11Remove extern "wasm" ABINikita Popov-2/+1
Remove the unstable `extern "wasm"` ABI (`wasm_abi` feature tracked in #83788). As discussed in https://github.com/rust-lang/rust/pull/127513#issuecomment-2220410679 and following, this ABI is a failed experiment that did not end up being used for anything. Keeping support for this ABI in LLVM 19 would require us to switch wasm targets to the `experimental-mv` ABI, which we do not want to do. It should be noted that `Abi::Wasm` was internally used for two things: The `-Z wasm-c-abi=legacy` ABI that is still used by default on some wasm targets, and the `extern "wasm"` ABI. Despite both being `Abi::Wasm` internally, they were not the same. An explicit `extern "wasm"` additionally enabled the `+multivalue` feature. I've opted to remove `Abi::Wasm` in this patch entirely, instead of keeping it as an ABI with only internal usage. Both `-Z wasm-c-abi` variants are now treated as part of the normal C ABI, just with different different treatment in adjust_for_foreign_abi.
2024-07-07iter_identity is a better nameMichael Goulet-5/+3
2024-07-03Auto merge of #125507 - compiler-errors:type-length-limit, r=lcnrbors-2/+2
Re-implement a type-size based limit r? lcnr This PR reintroduces the type length limit added in #37789, which was accidentally made practically useless by the caching changes to `Ty::walk` in #72412, which caused the `walk` function to no longer walk over identical elements. Hitting this length limit is not fatal unless we are in codegen -- so it shouldn't affect passes like the mir inliner which creates potentially very large types (which we observed, for example, when the new trait solver compiles `itertools` in `--release` mode). This also increases the type length limit from `1048576 == 2 ** 20` to `2 ** 24`, which covers all of the code that can be reached with craterbot-check. Individual crates can increase the length limit further if desired. Perf regression is mild and I think we should accept it -- reinstating this limit is important for the new trait solver and to make sure we don't accidentally hit more type-size related regressions in the future. Fixes #125460
2024-07-02Miscellaneous renamingMichael Goulet-2/+2
2024-07-02Rollup merge of #127136 - compiler-errors:coroutine-closure-env-shim, r=oli-obkMatthias Krüger-2/+2
Fix `FnMut::call_mut`/`Fn::call` shim for async closures that capture references I adjusted async closures to be able to implement `Fn` and `FnMut` *even if* they capture references, as long as those references did not need to borrow data from the closure captures themselves. See #125259. However, when I did this, I didn't actually relax an assertion in the `build_construct_coroutine_by_move_shim` shim code, which builds the `Fn`/`FnMut`/`FnOnce` implementations for async closures. Therefore, if we actually tried to *call* `FnMut`/`Fn` on async closures, it would ICE. This PR adjusts this assertion to ensure that we only capture immutable references in closures if they implement `Fn`/`FnMut`. It also adds a bunch of tests and makes more of the async-closure tests into `build-pass` since we often care about these tests actually generating the right closure shims and stuff. I think it might be excessive to *always* use build-pass here, but 🤷 it's not that big of a deal. Fixes #127019 Fixes #127012 r? oli-obk
2024-06-29Fix FnMut/Fn shim for coroutine-closures that capture referencesMichael Goulet-2/+2
2024-06-28address review commentsDeadbeef-65/+34
2024-06-28general fixups and turn `TODO`s into `FIXME`sDeadbeef-2/+2
2024-06-28temporarily disable effects on specialization testsDeadbeef-1/+6
2024-06-28implement new effects desugaringDeadbeef-3/+165
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-20/+20
2024-06-16Auto merge of #126505 - compiler-errors:no-vtable, r=lcnrbors-6/+16
Only compute vtable information during codegen This PR removes vtable information from the `Object` and `TraitUpcasting` candidate sources in the trait solvers, and defers the computation of relevant information to `Instance::resolve`. This is because vtables really aren't a thing in the trait world -- they're an implementation detail in codegen. Previously it was just easiest to tangle this information together since we were already doing the work of looking at all the supertraits in the trait solver, and specifically because we use traits to represent when it's possible to call a method via a vtable (`Object` candidate) and do upcasting (`Unsize` candidate). but I am somewhat suspicious we're doing a *lot* of extra work, especially in polymorphic contexts, so let's see what perf says.
2024-06-14Only compute vtable information during codegenMichael Goulet-6/+16
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-6/+6
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-2/+4
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-10ScalarInt: size mismatches are a bug, do not delay the panicRalf Jung-1/+1
2024-06-05ty::Expr reviewsBoxy-1/+1
2024-06-05Add `Ty` to `ConstKind::Value`Boxy-4/+1
2024-06-05Basic removal of `Ty` from places (boring)Boxy-25/+16
2024-06-04Downsize `ty::Expr`Boxy-8/+25
2024-06-01Uplift TypeRelation and RelateMichael Goulet-1/+2
2024-06-01Ensure floats are returned losslessly by the Rust ABI on 32-bit x86beetrees-0/+34
2024-05-31Auto merge of #124662 - zetanumbers:needs_async_drop, r=oli-obkbors-21/+19
Implement `needs_async_drop` in rustc and optimize async drop glue This PR expands on #121801 and implements `Ty::needs_async_drop` which works almost exactly the same as `Ty::needs_drop`, which is needed for #123948. Also made compiler's async drop code to look more like compiler's regular drop code, which enabled me to write an optimization where types which do not use `AsyncDrop` can simply forward async drop glue to `drop_in_place`. This made size of the async block from the [async_drop test](https://github.com/zetanumbers/rust/blob/67980dd6fb11917d23d01a19c2cf4cfc3978aac8/tests/ui/async-await/async-drop.rs) to decrease by 12%.
2024-05-30Auto merge of #125711 - oli-obk:const_block_ice2, r=Nadrierilbors-1/+1
Make `body_owned_by` return the `Body` instead of just the `BodyId` fixes #125677 Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly. This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too. I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
2024-05-29Make `body_owned_by` return the body directly.Oli Scherer-1/+1
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-29Optimize async drop glue for some old typesDaria Sukhonina-2/+3
2024-05-29Start implementing needs_async_drop and relatedDaria Sukhonina-20/+17
2024-05-29Auto merge of #125695 - RalfJung:fn_arg_sanity_check, r=jieyouxubors-1/+2
fn_arg_sanity_check: fix panic message The `\n` inside a raw string doesn't actually make a newline...
2024-05-29fn_arg_sanity_check: fix panic messageRalf Jung-1/+2
also update csky comment in abi/compatibility test
2024-05-28Add an intrinsic for `ptr::metadata`Scott McMurray-1/+1
2024-05-27Rollup merge of #125597 - compiler-errors:early-binder, r=jackh726Guillaume Gomez-5/+5
Uplift `EarlyBinder` into `rustc_type_ir` We also need to give `EarlyBinder` a `'tcx` param, so that we can carry the `Interner` in the `EarlyBinder` too. This is necessary because otherwise we have an unconstrained `I: Interner` parameter in many of the `EarlyBinder`'s inherent impls. I also generally think that this is desirable to have, in case we later want to track some state in the `EarlyBinder`. r? lcnr
2024-05-26Give EarlyBinder a tcx parameterMichael Goulet-5/+5
We are gonna need it to uplift EarlyBinder
2024-05-24Remove `DefId` from `EarlyParamRegion` (tedium/diagnostics)Boxy-5/+1
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_ty_utils`.Nicholas Nethercote-3/+8