summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2024-08-31Rollup merge of #129725 - compiler-errors:predicates-of, r=fmeaseMatthias Krüger-4/+8
Stop using `ty::GenericPredicates` for non-predicates_of queries `GenericPredicates` is a struct of several parts: A list of of an item's own predicates, and a parent def id (and some effects related stuff, but ignore that since it's kinda irrelevant). When instantiating these generic predicates, it calls `predicates_of` on the parent and instantiates its predicates, and appends the item's own instantiated predicates too: https://github.com/rust-lang/rust/blob/acb4e8b6251f1d8da36f08e7a70fa23fc581839e/compiler/rustc_middle/src/ty/generics.rs#L407-L413 Notice how this should result in a recursive set of calls to `predicates_of`... However, `GenericPredicates` is *also* misused by a bunch of *other* queries as a convenient way of passing around a list of predicates. For these queries, we don't ever set the parent def id of the `GenericPredicates`, but if we did, then this would be very easy to mistakenly call `predicates_of` instead of some other intended parent query. Given that footgun, and the fact that we don't ever even *use* the parent def id in the `GenericPredicates` returned from queries like `explicit_super_predicates_of`, It really has no benefit over just returning `&'tcx [(Clause<'tcx>, Span)]`. This PR additionally opts to wrap the results of `EarlyBinder`, as we've tended to use that in the return type of these kinds of queries to properly convey that the user has params to deal with, and it also gives a convenient way of iterating over a slice of things after instantiating.
2024-08-29Stop using ty::GenericPredicates for non-predicates_of queriesMichael Goulet-4/+8
2024-08-28Implement RFC 3525.Luca Versari-1/+6
2024-08-28Auto merge of #129546 - compiler-errors:no-pred-on, r=fee1-deadbors-19/+0
Get rid of `predicates_defined_on` This is the uncontroversial part of #129532. This simply inlines the `predicates_defined_on` into into `predicates_of`. Nothing should change here logically.
2024-08-26Stop using a special inner body for the coroutine by-move body for async ↵Michael Goulet-0/+15
closures
2024-08-24Get rid of predicates_defined_onMichael Goulet-19/+0
2024-08-17Use cnum for extern crate dataMichael Goulet-1/+1
2024-08-14Remove redundant type opsMichael Goulet-24/+3
2024-08-10Auto merge of #128746 - compiler-errors:cache-super-outlives, r=lcnrbors-0/+4
Cache supertrait outlives of impl header for soundness check This caches the results of computing the transitive supertraits of an impl and filtering it to its outlives obligations. This is purely an optimization to improve https://github.com/rust-lang/rust/pull/124336.
2024-08-07Disallow enabling features without their implied featuresCaleb Zulawski-1/+1
2024-08-07Add implied target features to target_feature attributeCaleb Zulawski-0/+6
2024-08-06Cache supertrait outlives of impl header for soundness checkMichael Goulet-0/+4
2024-07-29Delegation: support generics for delegation from free functionsBryanskiy-0/+4
2024-07-29Reformat `use` declarations.Nicholas Nethercote-88/+77
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-20Auto merge of #127658 - compiler-errors:precise-capturing-rustdoc-cross, ↵bors-0/+8
r=fmease Add cross-crate precise capturing support to rustdoc Follow-up to #127632. Fixes #127228. r? `@fmease` Tracking: * https://github.com/rust-lang/rust/issues/123432
2024-07-18valtree construction: keep track of which type was valtree-incompatibleRalf Jung-3/+4
2024-07-17Add cross-crate precise capturing support to rustdocMichael Goulet-0/+8
2024-07-14find_field does not need to be a query.Camille GILLOT-4/+0
2024-07-02Miscellaneous renamingMichael Goulet-2/+2
2024-06-29Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obkbors-0/+8
Implement new effects desugaring cc `@rust-lang/project-const-traits.` Will write down notes once I have finished. * [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>` * [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>` * [ ] add types and traits to minicore test * [ ] update rustc-dev-guide Fixes #119717 Fixes #123664 Fixes #124857 Fixes #126148
2024-06-28implement new effects desugaringDeadbeef-0/+8
2024-06-27Make queries more explicitMichael Goulet-13/+19
2024-06-26coverage: Apply `#[coverage(..)]` recursively to nested functionsZalathar-1/+2
2024-06-26coverage: Detach `#[coverage(..)]` from codegen attribute handlingZalathar-0/+8
2024-06-20Auto merge of #126409 - pacak:incr-uplorry, r=michaelwoeristerbors-4/+4
Trying to address an incremental compilation issues This pull request contains two independent changes, one makes it so when `try_force_from_dep_node` fails to recover a query - it marks the node as "red" instead of "green" and the second one makes Debug impl for `DepNode` less panicky if it encounters something from the previous compilation that doesn't map to anything in the current one. I'm not 100% confident that this is the correct approach, but so far I managed to find a bunch of comments suggesting that some things are allowed to fail in a certain way and changes I made are allowing for those things to fail this way and it fixes all the small reproducers I managed to find. Compilation panic this pull request avoids is caused by an automatically generated code on an associated type and it is not happening if something else marks it as outdated first (or close like that, but scenario is quite obscure). Fixes https://github.com/rust-lang/rust/issues/107226 Fixes https://github.com/rust-lang/rust/issues/125367
2024-06-19local_def_path_hash_to_def_id can failMichael Baikov-4/+4
local_def_path_hash_to_def_id is used by Debug impl for DepNode and it looks for DefPathHash inside the current compilation. During incremental compilation we are going through nodes that belong to a previous compilation and might not be present and a simple attempt to print such node with tracing::debug (try_mark_parent_green does it for example) results in a otherwise avoidable panic Panic was added in https://github.com/rust-lang/rust/pull/82183, specifically in 2b60338ee9, with a comment "We only use this mapping for cases where we know that it must succeed.", but I'm not sure if this property holds when we traverse nodes from the old compilation in order to figure out if they are valid or not
2024-06-18Make async drop code more consistent with regular drop codeDaria Sukhonina-6/+27
Fixes #126573
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-9/+9
2024-06-14Only compute vtable information during codegenMichael Goulet-1/+14
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