about summary refs log tree commit diff
path: root/compiler/rustc_query_system
AgeCommit message (Collapse)AuthorLines
2022-09-08Auto merge of #101303 - jyn514:jnelson/handle-cycle-enum, r=cjgillotbors-5/+63
Make `HandleCycleError` an enum instead of a macro-generated closure Helps with https://github.com/rust-lang/rust/issues/96524. Based on https://github.com/rust-lang/rust/pull/100943 to avoid merge conflicts, so it looks larger than it is (only the last commit is relevant). cc https://rust-lang.zulipchat.com/#narrow/stream/241847-t-compiler.2Fwg-incr-comp/topic/Moving.20.60Value.60.20to.20rustc_query_system.20.2396524 r? `@cjgillot`
2022-09-07Use HashStable_Generic in rustc_type_irEric Holk-0/+3
A lot of the types in this crate implemented HashStable directly to avoid circular dependencies. One way around that is to use HashStable_Generic. We adopt that here to avoid a lot of boilerplate. This doesn't update all the types, because some would require `I: Interner + HashStable`.
2022-09-06Make `HandleCycleError` an enum instead of a macro-generated closureJoshua Nelson-5/+63
- Add a `HandleCycleError` enum to rustc_query_system, along with a `handle_cycle_error` function - Move `Value` to rustc_query_system, so `handle_cycle_error` can use it - Move the `Value` impls from rustc_query_impl to rustc_middle. This is necessary due to orphan rules.
2022-09-05UPDATE - into_diagnostic to take a Handler instead of a ParseSessJhonny Bill Mena-1/+1
Suggested by the team in this Zulip Topic https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20SessionDiagnostic.20on.20Handler Handler already has almost all the capabilities of ParseSess when it comes to diagnostic emission, in this migration we only needed to add the ability to access source_map from the emitter in order to get a Snippet and the start_point. Not sure if this is the best way to address this gap
2022-09-01Don't create two new closures for each queryJoshua Nelson-0/+3
- Parameterize DepKindStruct over `'tcx` This allows passing in an invariant function pointer in `query_callback`, rather than having to try and make it work for any lifetime. - Add a new `execute_query` function to `QueryDescription` so we can call `tcx.$name` without needing to be in a macro context
2022-09-01Auto merge of #100869 - nnethercote:replace-ThinVec, r=spastorinobors-6/+6
Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec` `rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations. r? `@spastorino`
2022-08-31SessionDiagnostic for QueryOverflow errorLi Yuanheng-1/+5
2022-08-31delete leftover commentLi Yuanheng-1/+0
2022-08-31use derive proc macro to impl SessionDiagnosticYuanheng Li-53/+79
fixes `SessionSubdiagnostic` to accept multiple attributes emitting list of fluent message remains unresolved
2022-08-31link related issue to FIXMELi Yuanheng-1/+1
Co-authored-by: David Wood <agile.lion3441@fuligin.ink>
2022-08-31migrate rustc_query_system to use SessionDiagnosticYuanheng Li-46/+86
with manual impl SessionDiagnostic
2022-08-29Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.Nicholas Nethercote-6/+6
`rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations.
2022-08-24add `depth_limit` in `QueryVTable`SparrowLii-13/+23
2022-08-16Auto merge of #100441 - nnethercote:shrink-ast-Attribute, r=petrochenkovbors-3/+3
Shrink `ast::Attribute`. r? `@ghost`
2022-08-16Shrink `ast::Attribute`.Nicholas Nethercote-3/+3
2022-08-07Remove unused hashing infra.Camille GILLOT-22/+7
2022-08-07Derive HashStable for HIR Expr and Ty.Camille GILLOT-14/+0
2022-08-07Stop forcing the hashing of bodies in types and expressions.Camille GILLOT-14/+8
2022-07-29Remove useless closure.Camille GILLOT-5/+3
2022-07-28Remove guess_head_span.Camille GILLOT-6/+2
2022-07-20consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)Ralf Jung-10/+10
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-9/+9
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-09Auto merge of #99028 - tmiasko:inline, r=estebankbors-0/+4
Miscellaneous inlining improvements Add `#[inline]` to a few trivial non-generic methods from a perf report that otherwise wouldn't be candidates for inlining.
2022-07-07Miscellaneous inlining improvementsTomasz Miąsko-0/+4
Add `#[inline]` to a few trivial non-generic methods from a perf report that otherwise wouldn't be candidates for inlining.
2022-07-07Auto merge of #95573 - cjgillot:lower-query, r=michaelwoeristerbors-22/+39
Make lowering a query Split from https://github.com/rust-lang/rust/pull/88186. This PR refactors the relationship between lowering and the resolver outputs in order to make lowering itself a query. In a first part, lowering is changed to avoid modifying resolver outputs, by maintaining its own data structures for creating new `NodeId`s and so. Then, the `TyCtxt` is modified to allow creating new `LocalDefId`s from inside it. This is done by: - enclosing `Definitions` in a lock, so as to allow modification; - creating a query `register_def` whose purpose is to declare a `LocalDefId` to the query system. See `TyCtxt::create_def` and `TyCtxt::iter_local_def_id` for more detailed explanations of the design.
2022-07-06Use a dedicated DepKind for the forever-red node.Camille GILLOT-6/+8
2022-07-06Create a forever red node and use it to force side effects.Camille GILLOT-2/+20
2022-07-06Make AST lowering a query.Camille GILLOT-6/+6
2022-07-06Allow to create definitions inside the query system.Camille GILLOT-13/+10
2022-07-06incr: cache dwarf objects in work productsDavid Wood-2/+6
Cache DWARF objects alongside object files in work products when those exist so that DWARF object files are available for thorin in packed mode in incremental scenarios. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-03Auto merge of #98570 - SparrowLii:deadlock, r=cjgillotbors-2/+1
get rid of `tcx` in deadlock handler when parallel compilation This is a very obscure and hard-to-trace problem that affects thread scheduling. If we copy `tcx` to the deadlock handler thread, it will perform unpredictable behavior and cause very weird problems when executing `try_collect_active_jobs`(For example, the deadlock handler thread suddenly preempts the content of the blocked worker thread and executes the unknown judgment branch, like #94654). Fortunately we can avoid this behavior by precomputing `query_map`. This change fixes the following ui tests failure on my environment when set `parallel-compiler = true`: ``` [ui] src/test\ui\async-await\no-const-async.rs [ui] src/test\ui\infinite\infinite-struct.rs [ui] src/test\ui\infinite\infinite-tag-type-recursion.rs [ui] src/test\ui\issues\issue-3008-1.rs [ui] src/test\ui\issues\issue-3008-2.rs [ui] src/test\ui\issues\issue-32326.rs [ui] src/test\ui\issues\issue-57271.rs [ui] src/test\ui\issues\issue-72554.rs [ui] src/test\ui\parser\fn-header-semantic-fail.rs [ui] src/test\ui\union\union-nonrepresentable.rs ``` Updates #75760 Fixes #94654
2022-06-29get rid of `tcx` in deadlock handler when parallel compilationSparrowLii-2/+1
2022-06-27Update `smallvec` to 1.8.1.Nicholas Nethercote-1/+1
This pulls in https://github.com/servo/rust-smallvec/pull/282, which gives some small wins for rustc.
2022-06-18Remove `likely!` and `unlikely!` macro from compilerGary Guo-8/+10
2022-06-17Auto merge of #98106 - cjgillot:split-definitions, r=michaelwoeristerbors-2/+9
Split up `Definitions` and `ResolverAstLowering`. Split off https://github.com/rust-lang/rust/pull/95573 r? `@michaelwoerister`
2022-06-16Move `finish` out of the `Encoder` trait.Nicholas Nethercote-1/+1
This simplifies things, but requires making `CacheEncoder` non-generic. (This was previously merged as commit 4 in #94732 and then was reverted in #97905 because it caused a perf regression.)
2022-06-15Auto merge of #98084 - nnethercote:rm-thread-local-IGNORED_ATTRIBUTES, ↵bors-10/+1
r=michaelwoerister Remove thread-local `IGNORED_ATTRIBUTES`. It's just a copy of the read-only global `ich::IGNORED_ATTRIBUTES`, and can be removed without any effect. r? `@michaelwoerister`
2022-06-15Rollup merge of #98083 - nnethercote:rename-Encoder, r=bjorn3Yuki Okushi-3/+3
Rename rustc_serialize::opaque::Encoder as MemEncoder. This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports). (This was previously merged as commit 5 in #94732 and then was reverted in #97905 because of a perf regression caused by commit 4 in #94732.) r? ```@bjorn3```
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-2/+9
2022-06-14Remove thread-local `IGNORED_ATTRIBUTES`.Nicholas Nethercote-10/+1
It's just a copy of the read-only global `ich::IGNORED_ATTRIBUTES`, and can be removed without any effect.
2022-06-14Rename rustc_serialize::opaque::Encoder as MemEncoder.Nicholas Nethercote-3/+3
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports). (This was previously merged as commit 5 in #94732 and then was reverted in #97905 because of a perf regression caused by commit 4 in #94732.)
2022-06-13remove currently unused depsklensy-1/+0
2022-06-10Revert dc08bc51f2c58a0f5f815a07f9bb3d671153b5a1.Nicholas Nethercote-1/+1
2022-06-10Revert b983e42936feab29f6333e9835913afc6b4a394e.Nicholas Nethercote-3/+3
2022-06-08Rename `rustc_serialize::opaque::Encoder` as `MemEncoder`.Nicholas Nethercote-3/+3
This avoids the name clash with `rustc_serialize::Encoder` (a trait), and allows lots qualifiers to be removed and imports to be simplified (e.g. fewer `as` imports).
2022-06-08Move `finish` out of the `Encoder` trait.Nicholas Nethercote-1/+1
This simplifies things, but requires making `CacheEncoder` non-generic.
2022-06-08Use delayed error handling for `Encodable` and `Encoder` infallible.Nicholas Nethercote-15/+12
There are two impls of the `Encoder` trait: `opaque::Encoder` and `opaque::FileEncoder`. The former encodes into memory and is infallible, the latter writes to file and is fallible. Currently, standard `Result`/`?`/`unwrap` error handling is used, but this is a bit verbose and has non-trivial cost, which is annoying given how rare failures are (especially in the infallible `opaque::Encoder` case). This commit changes how `Encoder` fallibility is handled. All the `emit_*` methods are now infallible. `opaque::Encoder` requires no great changes for this. `opaque::FileEncoder` now implements a delayed error handling strategy. If a failure occurs, it records this via the `res` field, and all subsequent encoding operations are skipped if `res` indicates an error has occurred. Once encoding is complete, the new `finish` method is called, which returns a `Result`. In other words, there is now a single `Result`-producing method instead of many of them. This has very little effect on how any file errors are reported if `opaque::FileEncoder` has any failures. Much of this commit is boring mechanical changes, removing `Result` return values and `?` or `unwrap` from expressions. The more interesting parts are as follows. - serialize.rs: The `Encoder` trait gains an `Ok` associated type. The `into_inner` method is changed into `finish`, which returns `Result<Vec<u8>, !>`. - opaque.rs: The `FileEncoder` adopts the delayed error handling strategy. Its `Ok` type is a `usize`, returning the number of bytes written, replacing previous uses of `FileEncoder::position`. - Various methods that take an encoder now consume it, rather than being passed a mutable reference, e.g. `serialize_query_result_cache`.
2022-06-06Make saved_file field of WorkProduct non-optionalbjorn3-1/+1
A WorkProduct without a saved file is useless
2022-06-06Remove unnecessary cgu name length hashbjorn3-1/+0
This is a tiny optimization
2022-06-02Address review comments.Nicholas Nethercote-14/+11