about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/queries.rs
AgeCommit message (Collapse)AuthorLines
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`.
2023-11-22Add comments about a timer.Nicholas Nethercote-0/+3
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-17Make `Compiler::sess` private.Nicholas Nethercote-1/+1
Like `Compiler::codegen_backend`.
2023-11-17Remove a low-value local variable.Nicholas Nethercote-3/+2
2023-11-17Rename `Linker::prepare_outputs` as `output_filenames`.Nicholas Nethercote-5/+5
It matches the type, and a noun makes more sense than a verb. The `output_filenames` function still uses a profiling label named `prepare_outputs`, but I think that makes sense as a verb and can be left unchanged.
2023-11-17Move `CodegenBackend` out of `Linker`.Nicholas Nethercote-11/+6
It can easily be passed in. And that removes the single clone of `Compiler::codegen_backend`, which means it no longer needs to be `Lrc`.
2023-11-17Move `Session` out of `Linker`.Nicholas Nethercote-16/+10
It can easily be passed in. And that removes the single clone of `Compiler::session`, which means it no longer needs to be `Lrc`.
2023-11-17Streamline `Queries::linker`.Nicholas Nethercote-19/+13
2023-11-17Move `lint_store` from `GlobalCtxt` to `Session`.Nicholas Nethercote-7/+0
This was made possible by the removal of plugin support, which simplified lint store creation. This simplifies the places in rustc and rustdoc that call `describe_lints`, which are early on. The lint store is now built before those places, so they don't have to create their own lint store for temporary use, they can just use the main one.
2023-11-17Inline and remove `create_lint_store`.Nicholas Nethercote-2/+6
2023-11-04Remove support for compiler plugins.Nicholas Nethercote-6/+2
They've been deprecated for four years. This commit includes the following changes. - It eliminates the `rustc_plugin_impl` crate. - It changes the language used for lints in `compiler/rustc_driver_impl/src/lib.rs` and `compiler/rustc_lint/src/context.rs`. External lints are now called "loaded" lints, rather than "plugins" to avoid confusion with the old plugins. This only has a tiny effect on the output of `-W help`. - E0457 and E0498 are no longer used. - E0463 is narrowed, now only relating to unfound crates, not plugins. - The `plugin` feature was moved from "active" to "removed". - It removes the entire plugins chapter from the unstable book. - It removes quite a few tests, mostly all of those in `tests/ui-fulldeps/plugin/`. Closes #29597.
2023-10-25Stop telling people to submit bugs for internal feature ICEsNilstrieb-3/+5
This keeps track of usage of internal features, and changes the message to instead tell them that using internal features is not supported. See MCP 620.
2023-09-24Don't use a thread to load the dep graphJohn Kåre Alsaker-44/+3
2023-09-11Rollup merge of #115730 - bjorn3:some_driver_refactors, r=compiler-errorsMatthias Krüger-0/+2
Some more small driver refactors To improve clarity and simplify some code.
2023-09-10Deprecate the pre_configure querybjorn3-0/+2
Only deprecating it rather than making it private to just in case someone has a use case for it.
2023-09-09Use `FreezeLock` for `CStore`John Kåre Alsaker-4/+2
2023-09-02Rename `Freeze` to `FreezeLock`John Kåre Alsaker-2/+4
2023-09-02Add `Freeze` type and use it to store `Definitions`John Kåre Alsaker-2/+2
2023-09-01Use `OnceLock` for `SingleCache`John Kåre Alsaker-3/+3
2023-08-14Fix review commentbjorn3-1/+1
2023-08-13Remove metadata_loader querybjorn3-4/+4
It is only used by CrateLoader. We can store the metadata loader in CStore instead which CrateLoader has access to.
2023-08-13Pass WorkProductMap to build_dep_graph instead of FxIndexMapbjorn3-9/+1
Constructing an FxIndexMap is useless work as the iteration order never matters.
2023-08-13Inline queries for crate_name, crate_types and stable_crate_idbjorn3-45/+19
All of them are not exported from rustc_interface and used only during global_ctxt(). Inlining them makes it easier to follow the order of queries and slightly reduces line count.