about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2024-06-07Only compute specializes query if specialization is enabled in the crate of ↵Michael Goulet-0/+5
the specialized impl
2024-06-06Revert "Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obk"Rémy Rakic-13/+4
This reverts commit eda4a35f365535af72118118a3597edf5a13c12d, reversing changes made to eb6b35b5bcb3c2a594cb29cd478aeb2893f49d30.
2024-06-05Rollup merge of #123168 - joshtriplett:size-of-prelude, r=AmanieuJubilee-1/+1
Add `size_of` and `size_of_val` and `align_of` and `align_of_val` to the prelude (Note: need to update the PR to add `align_of` and `align_of_val`, and remove the second commit with the myriad changes to appease the lint.) Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it.
2024-06-03check_is_object_safe -> is_object_safeMichael Goulet-1/+1
2024-05-29Start implementing needs_async_drop and relatedDaria Sukhonina-8/+11
2024-05-26Give EarlyBinder a tcx parameterMichael Goulet-21/+23
We are gonna need it to uplift EarlyBinder
2024-05-24Use regular type equating instead of a custom queryOli Scherer-9/+0
2024-05-23Improve the doc of query associated_itemr0cky-1/+1
2024-05-23Rollup merge of #124976 - petrochenkov:usedcrates, r=oli-obkMatthias Krüger-4/+13
rustc: Use `tcx.used_crates(())` more And explain when it should be used. Addresses comments from https://github.com/rust-lang/rust/pull/121167.
2024-05-22rustc: Use `tcx.used_crates(())` moreVadim Petrochenkov-4/+13
And explain when it should be used.
2024-05-21PR feedbackBen Kimock-2/+5
2024-05-21Add a footer in FileEncoder and check for it in MemDecoderBen Kimock-20/+19
2024-05-13Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the preludeJosh Triplett-1/+1
Many, many projects use `size_of` to get the size of a type. However, it's also often equally easy to hardcode a size (e.g. `8` instead of `size_of::<u64>()`). Minimizing friction in the use of `size_of` helps ensure that people use it and make code more self-documenting. The name `size_of` is unambiguous: the name alone, without any prefix or path, is self-explanatory and unmistakeable for any other functionality. Adding it to the prelude cannot produce any name conflicts, as any local definition will silently shadow the one from the prelude. Thus, we don't need to wait for a new edition prelude to add it. Add `size_of_val`, `align_of`, and `align_of_val` as well, with similar justification: widely useful, self-explanatory, unmistakeable for anything else, won't produce conflicts.
2024-04-30Give items related to issue 33140 a more meaningful nameLeón Orell Valerian Liehr-2/+4
2024-04-29Remove `extern crate rustc_macros` from `rustc_middle`.Nicholas Nethercote-0/+3
2024-04-23Auto merge of #123992 - compiler-errors:no-has-typeck-results, r=jackh726bors-4/+0
`has_typeck_results` doesnt need to be a query self-explanatory
2024-04-23Auto merge of #121801 - zetanumbers:async_drop_glue, r=oli-obkbors-0/+8
Add simple async drop glue generation This is a prototype of the async drop glue generation for some simple types. Async drop glue is intended to behave very similar to the regular drop glue except for being asynchronous. Currently it does not execute synchronous drops but only calls user implementations of `AsyncDrop::async_drop` associative function and awaits the returned future. It is not complete as it only recurses into arrays, slices, tuples, and structs and does not have same sensible restrictions as the old `Drop` trait implementation like having the same bounds as the type definition, while code assumes their existence (requires a future work). This current design uses a workaround as it does not create any custom async destructor state machine types for ADTs, but instead uses types defined in the std library called future combinators (deferred_async_drop, chain, ready_unit). Also I recommend reading my [explainer](https://zetanumbers.github.io/book/async-drop-design.html). This is a part of the [MCP: Low level components for async drop](https://github.com/rust-lang/compiler-team/issues/727) work. Feature completeness: - [x] `AsyncDrop` trait - [ ] `async_drop_in_place_raw`/async drop glue generation support for - [x] Trivially destructible types (integers, bools, floats, string slices, pointers, references, etc.) - [x] Arrays and slices (array pointer is unsized into slice pointer) - [x] ADTs (enums, structs, unions) - [x] tuple-like types (tuples, closures) - [ ] Dynamic types (`dyn Trait`, see explainer's [proposed design](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#async-drop-glue-for-dyn-trait)) - [ ] coroutines (https://github.com/rust-lang/rust/pull/123948) - [x] Async drop glue includes sync drop glue code - [x] Cleanup branch generation for `async_drop_in_place_raw` - [ ] Union rejects non-trivially async destructible fields - [ ] `AsyncDrop` implementation requires same bounds as type definition - [ ] Skip trivially destructible fields (optimization) - [ ] New [`TyKind::AdtAsyncDestructor`](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#adt-async-destructor-types) and get rid of combinators - [ ] [Synchronously undroppable types](https://github.com/zetanumbers/posts/blob/main/async-drop-design.md#exclusively-async-drop) - [ ] Automatic async drop at the end of the scope in async context
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-2/+2
We want to run them on all 64-bit platforms.
2024-04-17has_typeck_results doesnt need to be a queryMichael Goulet-4/+0
2024-04-16Rollup merge of #124016 - DaniPopes:dedup-default-providers, r=lcnrGuillaume Gomez-16/+20
Outline default query and hook provider function implementations The default query and hook provider functions call `bug!` with a decently long message. Due to argument inlining in `format_args!` ([`flatten_format_args`](https://github.com/rust-lang/rust/issues/78356)), this ends up duplicating the message for each query, adding ~90KB to `librustc_driver.so` of unreachable panic messages. To avoid this, we can outline the common `bug!` logic.
2024-04-16Add simple async drop glue generationzetanumbers-0/+8
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-16Outline default query and hook provider function implementationsDaniPopes-16/+20
2024-04-16Rollup merge of #123995 - compiler-errors:thir-hooks, r=oli-obkGuillaume Gomez-14/+0
Make `thir_tree` and `thir_flat` into hooks No need for them to be queries, since they are only called with `-Zunpretty`
2024-04-15Make thir_tree and thir_flat into hooksMichael Goulet-14/+0
2024-04-15Just use type_dependent_def_id to figure out what the method is for an exprMichael Goulet-3/+0
2024-04-11move QueryKeyStringCache from rustc_middle to rustc_query_impl, where it ↵klensy-12/+0
actually used also allows to drop measureme dep on rustc_middle
2024-04-11Auto merge of #122213 - estebank:issue-50195, r=oli-obk,estebankbors-0/+16
Provide suggestion to dereference closure tail if appropriate When encoutnering a case like ```rust use std::collections::HashMap; fn main() { let vs = vec![0, 0, 1, 1, 3, 4, 5, 6, 3, 3, 3]; let mut counts = HashMap::new(); for num in vs { let count = counts.entry(num).or_insert(0); *count += 1; } let _ = counts.iter().max_by_key(|(_, v)| v); ``` produce the following suggestion ``` error: lifetime may not live long enough --> $DIR/return-value-lifetime-error.rs:13:47 | LL | let _ = counts.iter().max_by_key(|(_, v)| v); | ------- ^ returning this value requires that `'1` must outlive `'2` | | | | | return type of closure is &'2 &i32 | has type `&'1 (&i32, &i32)` | help: dereference the return value | LL | let _ = counts.iter().max_by_key(|(_, v)| **v); | ++ ``` Fix #50195.
2024-04-09Auto merge of #123099 - oli-obk:span_tcx, r=petrochenkovbors-9/+2
Replace some `CrateStore` trait methods with hooks. Just like with the `CrateStore` trait, this avoids the cyclic definition issues with `CStore` being defined after TyCtxt, but needing to be used in TyCtxt.
2024-04-08Shrink the size of ClosureTypeInfo to fit into 64 bytes againOli Scherer-3/+5
2024-04-08Pass list of defineable opaque types into canonical queriesOli Scherer-4/+4
2024-04-07Auto merge of #123058 - lukas-code:clauses, r=lcnrbors-5/+9
[perf] cache type info for ParamEnv This is an attempt to mitigate some of the perf regressions in https://github.com/rust-lang/rust/pull/122553#issuecomment-2007563027, but seems worth to test and land separately, since it is mostly unrelated to that PR.
2024-04-05Provide suggestion to dereference closure tail if appropriateEsteban Küber-0/+16
When encoutnering a case like ```rust //@ run-rustfix use std::collections::HashMap; fn main() { let vs = vec![0, 0, 1, 1, 3, 4, 5, 6, 3, 3, 3]; let mut counts = HashMap::new(); for num in vs { let count = counts.entry(num).or_insert(0); *count += 1; } let _ = counts.iter().max_by_key(|(_, v)| v); ``` produce the following suggestion ``` error: lifetime may not live long enough --> $DIR/return-value-lifetime-error.rs:13:47 | LL | let _ = counts.iter().max_by_key(|(_, v)| v); | ------- ^ returning this value requires that `'1` must outlive `'2` | | | | | return type of closure is &'2 &i32 | has type `&'1 (&i32, &i32)` | help: dereference the return value | LL | let _ = counts.iter().max_by_key(|(_, v)| **v); | ++ ``` Fix #50195.
2024-04-04Auto merge of #123097 - oli-obk:perf_experiment, r=petrochenkovbors-3/+4
Try using a `dyn Debug` trait object instead of a closure These closures were introduced in https://github.com/rust-lang/rust/pull/93098 let's see if we can't use fmt::Arguments instead cc `@Aaron1011`
2024-04-04cache type info for ParamEnvLukas Markeffsky-5/+9
2024-04-03Rollup merge of #123401 - Zalathar:assert-size-aarch64, r=fmeaseJacob Pratt-2/+2
Check `x86_64` size assertions on `aarch64`, too (Context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Checking.20size.20assertions.20on.20aarch64.3F) Currently the compiler has around 30 sets of `static_assert_size!` for various size-critical data structures (e.g. various IR nodes), guarded by `#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]`. (Presumably this cfg avoids having to maintain separate size values for 32-bit targets and unusual 64-bit targets. Apparently it may have been necessary before the i128/u128 alignment changes, too.) This is slightly incovenient for people on aarch64 workstations (e.g. Macs), because the assertions normally aren't checked until we push to a PR. So this PR adds `aarch64` to the `#[cfg(..)]` guarding all of those assertions in the compiler. --- Implemented with a simple find/replace. Verified by manually inspecting each `static_assert_size!` in `compiler/`, and checking that either the replacement succeeded, or adding aarch64 wouldn't have been appropriate.
2024-04-03Remove MIR unsafe checkMatthew Jasper-6/+0
This also remove safety information from MIR.
2024-04-03Check `x86_64` size assertions on `aarch64`, tooZalathar-2/+2
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to notice when these assertions have been violated.
2024-03-27Use a `dyn Debug` trait object instead of a closure.Oli Scherer-3/+4
Simplifies the API a bit.
2024-03-27Move `CrateStore::expn_hash_to_expn_id` to a hookOli Scherer-6/+1
2024-03-27Start replacing `CStore` trait methods with hooks.Oli Scherer-3/+1
This also avoids the cyclic definition issues with CrateStore being defined after TyCtxt, but needing to be used in TyCtxt.
2024-03-26Remove `CacheSelector` trait now that we can use GATsOli Scherer-59/+56
2024-03-25Auto merge of #122721 - oli-obk:merge_queries, r=davidtwcobors-11/+5
Replace `mir_built` query with a hook and use mir_const everywhere instead A small perf improvement due to less dep graph handling. Mostly just a cleanup to get rid of one of our many mir queries
2024-03-22Rollup merge of #122784 - jswrenn:tag_for_variant, r=compiler-errorsMatthias Krüger-0/+17
Add `tag_for_variant` query This query allows for sharing code between `rustc_const_eval` and `rustc_transmutability`. It's a precursor to a PR I'm working on to entirely replace the bespoke layout computations in `rustc_transmutability`. r? `@compiler-errors`
2024-03-22Add `tag_for_variant` queryJack Wrenn-0/+17
This query allows for sharing code between `rustc_const_eval` and `rustc_transmutability`. Also moves `DummyMachine` to `rustc_const_eval`.
2024-03-20Split item bounds and item super predicatesMichael Goulet-6/+26
2024-03-20Update documentationOli Scherer-4/+5
2024-03-20Rename mir_const query to mir_builtOli Scherer-1/+1
2024-03-20Replace `mir_built` query with a hook and use mir_const everywhere insteadOli Scherer-7/+0
2024-03-18address nitsLukas Markeffsky-1/+1
2024-03-14clean up ADT sized constraint computationLukas Markeffsky-2/+2