about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/queries.rs
AgeCommit message (Collapse)AuthorLines
2025-07-04Save metadata among work products.Camille GILLOT-1/+14
2025-06-23Add codegen timing sectionJakub Beránek-1/+2
2025-06-16Emit linker timing sectionJakub Beránek-0/+2
2025-06-03Only borrow EncodedMetadata in codegen_cratebjorn3-2/+6
And move passing it to the linker to the driver code.
2024-12-14Remove the parse querybjorn3-75/+1
2024-12-14Get rid of of the global_ctxt querybjorn3-46/+2
2024-12-12Move type size and vtable size printing to start_codegenbjorn3-12/+0
2024-12-06Remove all threading through of ErrorGuaranteed from the driverbjorn3-24/+20
It was inconsistently done (sometimes even within a single function) and most of the rest of the compiler uses fatal errors instead, which need to be caught using catch_with_exit_code anyway. Using fatal errors instead of ErrorGuaranteed everywhere in the driver simplifies things a bit.
2024-12-06Move some timers aroundbjorn3-2/+5
2024-11-09Move some code from Compiler::enter to GlobalCtxt::finishbjorn3-24/+6
2024-11-09Don't mutably borrow GlobalCtxt in QueryResult::enterbjorn3-1/+1
This allows re-entrant entering of the GlobalCtxt
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-08-24Fix `elided_named_lifetimes` in codePavel Grigorenko-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-6/+7
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-01Inline Query::default()bjorn3-8/+2
2024-07-01Minor changebjorn3-2/+2
2024-07-01Move codegen_and_build_linker from Queries to Linkerbjorn3-29/+30
2024-06-30Move -Zprint-type-sizes and -Zprint-vtable-sizes into codegen_and_build_linkerbjorn3-0/+12
2024-06-22Inline write_dep_info querybjorn3-7/+0
2024-06-22Move has_errors_or_delayed_bugs check into start_codegenbjorn3-8/+1
2024-06-22Call check_for_rustc_errors_attr from start_codegenbjorn3-38/+1
2024-06-22Move almost all code from Queries::global_ctxt into passes::create_global_ctxtbjorn3-72/+10
2024-04-19Remove `feed_local_crate` in favor of creating the `CrateNum` via `TyCtxt`Oli Scherer-4/+4
2024-04-19Move `stable_crate_ids` from `CrateStore` to `Untracked`Oli Scherer-4/+10
This way it's like `Definitions`, which creates `DefId`s by interning `DefPathData`s, but for interning stable crate hashes
2024-03-13Make incremental sessions identity no longer depend on the crate names ↵John Kåre Alsaker-3/+3
provided by source code
2024-03-12Verify that query keys result in unique dep nodesJohn Kåre Alsaker-0/+2
2024-03-07Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkovGuillaume Gomez-9/+3
Remove `feed_local_def_id` best reviewed commit by commit Basically I returned `TyCtxtFeed` from `create_def` and then preserved that in the local caches based on https://github.com/rust-lang/rust/pull/121084 r? ````@petrochenkov````
2024-03-05Prevent feeding `CRATE_DEF_ID` queries outside the resolverOli Scherer-9/+3
2024-03-05Get rid of `feed_local_def_id`Oli Scherer-1/+1
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-1/+1
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-02-22Inline and remove `Session::compile_status`.Nicholas Nethercote-1/+3
Because it's now simple enough that it doesn't provide much benefit.
2024-02-22Overhaul the handling of errors at the top-level.Nicholas Nethercote-6/+6
Currently `emit_stashed_diagnostic` is called from four(!) different places: `print_error_count`, `DiagCtxtInner::drop`, `abort_if_errors`, and `compile_status`. And `flush_delayed` is called from two different places: `DiagCtxtInner::drop` and `Queries`. This is pretty gross! Each one should really be called from a single place, but there's a bunch of entanglements. This commit cleans up this mess. Specifically, it: - Removes all the existing calls to `emit_stashed_diagnostic`, and adds a single new call in `finish_diagnostics`. - Removes the early `flush_delayed` call in `codegen_and_build_linker`, replacing it with a simple early return if delayed bugs are present. - Changes `DiagCtxtInner::drop` and `DiagCtxtInner::flush_delayed` so they both assert that the stashed diagnostics are empty (i.e. processed beforehand). - Changes `interface::run_compiler` so that any errors emitted during `finish_diagnostics` (i.e. late-emitted stashed diagnostics) are counted and cannot be overlooked. This requires adding `ErrorGuaranteed` return values to several functions. - Removes the `stashed_err_count` call in `analysis`. This is possible now that we don't have to worry about calling `flush_delayed` early from `codegen_and_build_linker` when stashed diagnostics are pending. - Changes the `span_bug` case in `handle_tuple_field_pattern_match` to a `delayed_span_bug`, because it now can be reached due to the removal of the `stashed_err_count` call in `analysis`. - Slightly changes the expected output of three tests. If no errors are emitted but there are delayed bugs, the error count is no longer printed. This is because delayed bugs are now always printed after the error count is printed (or not printed, if the error count is zero). There is a lot going on in this commit. It's hard to break into smaller pieces because the existing code is very tangled. It took me a long time and a lot of effort to understand how the different pieces interact, and I think the new code is a lot simpler and easier to understand.
2024-02-17Make `CodegenBackend::join_codegen` infallible.Nicholas Nethercote-1/+1
Because they all are, in practice.
2024-02-12Tweak delayed bug mentions.Nicholas Nethercote-3/+3
Now that we have both `delayed_bug` and `span_delayed_bug`, it makes sense to use the generic term "delayed bug" more.
2024-01-10Rename `{create,emit}_warning` as `{create,emit}_warn`.Nicholas Nethercote-3/+2
For consistency with `warn`/`struct_warn`, and also `{create,emit}_err`, all of which use an abbreviated form.
2024-01-08Make `DiagnosticBuilder::emit` consuming.Nicholas Nethercote-1/+1
This works for most of its call sites. This is nice, because `emit` very much makes sense as a consuming operation -- indeed, `DiagnosticBuilderState` exists to ensure no diagnostic is emitted twice, but it uses runtime checks. For the small number of call sites where a consuming emit doesn't work, the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will be removed in subsequent commits.) Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes consuming, while `delay_as_bug_without_consuming` is added (which will also be removed in subsequent commits.) All this requires significant changes to `DiagnosticBuilder`'s chaining methods. Currently `DiagnosticBuilder` method chaining uses a non-consuming `&mut self -> &mut Self` style, which allows chaining to be used when the chain ends in `emit()`, like so: ``` struct_err(msg).span(span).emit(); ``` But it doesn't work when producing a `DiagnosticBuilder` value, requiring this: ``` let mut err = self.struct_err(msg); err.span(span); err ``` This style of chaining won't work with consuming `emit` though. For that, we need to use to a `self -> Self` style. That also would allow `DiagnosticBuilder` production to be chained, e.g.: ``` self.struct_err(msg).span(span) ``` However, removing the `&mut self -> &mut Self` style would require that individual modifications of a `DiagnosticBuilder` go from this: ``` err.span(span); ``` to this: ``` err = err.span(span); ``` There are *many* such places. I have a high tolerance for tedious refactorings, but even I gave up after a long time trying to convert them all. Instead, this commit has it both ways: the existing `&mut self -> Self` chaining methods are kept, and new `self -> Self` chaining methods are added, all of which have a `_mv` suffix (short for "move"). Changes to the existing `forward!` macro lets this happen with very little additional boilerplate code. I chose to add the suffix to the new chaining methods rather than the existing ones, because the number of changes required is much smaller that way. This doubled chainging is a bit clumsy, but I think it is worthwhile because it allows a *lot* of good things to subsequently happen. In this commit, there are many `mut` qualifiers removed in places where diagnostics are emitted without being modified. In subsequent commits: - chaining can be used more, making the code more concise; - more use of chaining also permits the removal of redundant diagnostic APIs like `struct_err_with_code`, which can be replaced easily with `struct_err` + `code_mv`; - `emit_without_diagnostic` can be removed, which simplifies a lot of machinery, removing the need for `DiagnosticBuilderState`.
2024-01-02Report I/O errors with emit_fatal not emit_errBen Kimock-1/+1
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-4/+6
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-1/+1
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-3/+3
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-28resolve: Feed the `def_kind` query immediately on `DefId` creationVadim Petrochenkov-0/+4
2023-11-26Turn write_dep_info into a regular functionbjorn3-0/+7
It has side-effects and as such can't be cached.
2023-11-26Mostly revert "Accept crate name instead of attributes in ↵bjorn3-1/+1
build_output_filenames"
2023-11-26Feed the output filenames into the TyCtxtbjorn3-0/+2
Since the introduction of the crate attribute pre-expansion pass we don't need access to the TyCtxt to compute it.
2023-11-26Serialize OutputFilenames into rmeta filebjorn3-2/+7
This ensures that linking will use the correct crate name even when `#![crate_name = "..."]` is used to specify the crate name.
2023-11-26Inline and remove pre_configurebjorn3-15/+4
2023-11-22Call FileEncoder::finish in rmeta encodingBen Kimock-1/+9
2023-11-22Merge `Queries::{ongoing_codegen,linker}`.Nicholas Nethercote-17/+13
There is no real need for them to be separate.
2023-11-22Make `Compiler::{sess,codegen_backend}` public.Nicholas Nethercote-21/+14
And remove the relevant getters on `Compiler` and `Queries`.