about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2024-01-17Move `check_mod_impl_wf` query call out of track_errors and bubble errors up ↵Oli Scherer-1/+2
instead.
2024-01-16Get rid of the hir_owner query.Camille GILLOT-13/+0
2024-01-15Cache local DefId-keyed queries without hashingMark Rousskov-1/+2
Foreign maps are used to cache external DefIds, typically backed by metadata decoding. In the future we might skip caching `V` there (since loading from metadata usually is already cheap enough), but for now this cuts down on the impact to memory usage and time to None-init a bunch of memory. Foreign data is usually much sparser, since we're not usually loading *all* entries from the foreign crate(s).
2024-01-11`specialization_graph_of`'s `errored` field is used in the only call site, ↵Oli Scherer-2/+10
and used to immediately throw away the rest of the value. Let's use `Result` to statically signal that this is happening
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-1/+1
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
2024-01-08Don't check for recursion in generator witness fieldsMichael Goulet-4/+11
2024-01-08Value recovery can take the whole CycleErrorMichael Goulet-1/+1
2024-01-06Auto merge of #119478 - bjorn3:no_serialize_specialization, r=wesleywiserbors-123/+100
Avoid specialization in the metadata serialization code With the exception of a perf-only specialization for byte slices and byte vectors. This uses the same trick of introducing a new trait and having the Encodable and Decodable derives add a bound to it as used for TyEncoder/TyDecoder. The new code is clearer about which encoder/decoder uses which impl and it reduces the dependency of rustc on specialization, making it easier to remove support for specialization entirely or turn it into a construct that is only allowed for perf optimizations if we decide to do this.
2024-01-05Auto merge of #119192 - michaelwoerister:mcp533-push, r=cjgillotbors-13/+13
Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives This PR replaces almost all of the remaining `FxHashMap`s in query results with either `FxIndexMap` or `UnordMap`. The only case that is missing is the `EffectiveVisibilities` struct which turned out to not be straightforward to transform. Once that is done too, we can remove the `HashStable` implementation from `HashMap`. The first commit adds the `StableCompare` trait which is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableCompare` implementation can be provided to offer a lightweight way for stable sorting. The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`. The rest of the commits are rather mechanical and don't overlap, so they are best reviewed individually. Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-01-05Stabilize THIR unsafeckMatthew Jasper-5/+4
2024-01-04Make iteration order of collect_return_position_impl_trait_in_trait_tys ↵Michael Woerister-4/+4
query stable
2024-01-04Make iteration order of supported_target_features query stableMichael Woerister-1/+1
2024-01-04Make iteration order of trimmed_def_paths query stableMichael Woerister-1/+1
2024-01-04Make iteration order of named_variable_map, late_bound_vars_map, and ↵Michael Woerister-2/+2
resolve_bound_vars queries stable
2024-01-04Make iteration order of wasm_import_module_map query stableMichael Woerister-1/+1
2024-01-04Make iteration order of upstream_monomorphizations query stableMichael Woerister-2/+2
2024-01-04Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives.Michael Woerister-2/+2
2024-01-02Merge check_for_entry_fn fully into check_mod_type_wfOli Scherer-4/+0
2024-01-02Reorder `check_item_type` diagnostics so they occur next to the ↵Oli Scherer-2/+2
corresponding `check_well_formed` diagnostics
2023-12-31Avoid specialization for AttrId deserializationbjorn3-0/+4
2023-12-31Remove almost all uses of specialization from the metadata encoding codebjorn3-93/+65
2023-12-31Avoid specialization for the Span Encodable and Decodable implsbjorn3-32/+33
2023-12-26Auto merge of #119146 - nnethercote:rm-DiagCtxt-api-duplication, ↵bors-1/+1
r=compiler-errors Remove `DiagCtxt` API duplication `DiagCtxt` defines the internal API for creating and emitting diagnostics: methods like `struct_err`, `struct_span_warn`, `note`, `create_fatal`, `emit_bug`. There are over 50 methods. Some of these methods are then duplicated across several other types: `Session`, `ParseSess`, `Parser`, `ExtCtxt`, and `MirBorrowckCtxt`. `Session` duplicates the most, though half the ones it does are unused. Each duplicated method just calls forward to the corresponding method in `DiagCtxt`. So this duplication exists to (in the best case) shorten chains like `ecx.tcx.sess.parse_sess.dcx.emit_err()` to `ecx.emit_err()`. This API duplication is ugly and has been bugging me for a while. And it's inconsistent: there's no real logic about which methods are duplicated, and the use of `#[rustc_lint_diagnostic]` and `#[track_caller]` attributes vary across the duplicates. This PR removes the duplicated API methods and makes all diagnostic creation and emission go through `DiagCtxt`. It also adds `dcx` getter methods to several types to shorten chains. This approach scales *much* better than API duplication; indeed, the PR adds `dcx()` to numerous types that didn't have API duplication: `TyCtxt`, `LoweringCtxt`, `ConstCx`, `FnCtxt`, `TypeErrCtxt`, `InferCtxt`, `CrateLoader`, `CheckAttrVisitor`, and `Resolver`. These result in a lot of changes from `foo.tcx.sess.emit_err()` to `foo.dcx().emit_err()`. (You could do this with more types, but it gets into diminishing returns territory for types that don't emit many diagnostics.) After all these changes, some call sites are more verbose, some are less verbose, and many are the same. The total number of lines is reduced, mostly because of the removed API duplication. And consistency is increased, because calls to `emit_err` and friends are always preceded with `.dcx()` or `.dcx`. r? `@compiler-errors`
2023-12-24Auto merge of #119139 - michaelwoerister:cleanup-stable-source-file-id, ↵bors-22/+15
r=cjgillot Unify SourceFile::name_hash and StableSourceFileId This PR adapts the existing `StableSourceFileId` type so that it can be used instead of the `name_hash` field of `SourceFile`. This simplifies a few things that were kind of duplicated before. The PR should also fix issues https://github.com/rust-lang/rust/issues/112700 and https://github.com/rust-lang/rust/issues/115835, but I was not able to reproduce these issues in a regression test. As far as I can tell, the root cause of these issues is that the id of the originating crate is not hashed in the `HashStable` impl of `Span` and thus cache entries that should have been considered invalidated were loaded. After this PR, the `stable_id` field of `SourceFile` includes information about the originating crate, so that ICE should not occur anymore.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-19Unify SourceFile::name_hash and StableSourceFileIdMichael Woerister-22/+15
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-2/+2
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-13global param_env canonicalization cacheAli MJ Al-Nasrawy-1/+3
2023-12-07ctfe interpreter: extend provenance so that it can track whether a pointer ↵Ralf Jung-0/+1
is immutable
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-4/+4
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-26Auto merge of #117301 - saethlin:finish-rmeta-encoding, r=WaffleLapkinbors-2/+1
Call FileEncoder::finish in rmeta encoding Fixes https://github.com/rust-lang/rust/issues/117254 The bug here was that rmeta encoding never called FileEncoder::finish. Now it does. Most of the changes here are needed to support that, since rmeta encoding wants to finish _then_ access the File in the encoder, so finish can't move out. I tried adding a `cfg(debug_assertions)` exploding Drop impl to FileEncoder that checked for finish being called before dropping, but fatal errors cause unwinding so this isn't really possible. If we encounter a fatal error with a dirty FileEncoder, the Drop impl ICEs even though the implementation is correct. If we try to paper over that by wrapping FileEncoder in ManuallyDrop then that just erases the fact that Drop automatically checks that we call finish on all paths. I also changed the name of DepGraph::encode to DepGraph::finish_encoding, because that's what it does and it makes the fact that it is the path to FileEncoder::finish less confusing. r? `@WaffleLapkin`
2023-11-25rustc: Make `def_kind` mandatory for all `DefId`sVadim Petrochenkov-18/+1
2023-11-23Move WorkerLocal out of QueryArenasMark Rousskov-4/+4
This cuts librustc_driver.so code size by ~85 kilobytes.
2023-11-22Call FileEncoder::finish in rmeta encodingBen Kimock-2/+1
2023-11-22Allow defining opaques in check_coroutine_obligationsMichael Goulet-1/+1
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-8/+3
`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-21Auto merge of #118107 - matthiaskrgr:rollup-k5bfkfr, r=matthiaskrgrbors-1/+11
Rollup of 8 pull requests Successful merges: - #117327 (Add documentation for some queries) - #117835 (Note about object lifetime defaults in does not live long enough error) - #117851 (Uplift `InferConst` to `rustc_type_ir`) - #117973 (test: Add test for async-move in 2015 Rust proc macro) - #117992 (Don't require intercrate mode for negative coherence) - #118010 (Typeck break expr even if break is illegal) - #118026 (Don't consider regions in `deref_into_dyn_supertrait` lint) - #118089 (intercrate_ambiguity_causes: handle self ty infer + reservation impls) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-20Unify defined_lib_features and lib_features queriesMichael Goulet-5/+2
2023-11-19Add documentation for some queriesNilstrieb-1/+11
2023-11-08Rollup merge of #116399 - WaffleLapkin:erase_small_things, r=cjgillotMatthias Krüger-6/+16
Small changes w/ `query::Erase<_>` r? `@cjgillot` cc `@Zoxc`
2023-11-07Add an explanation for `transmute_unchecked`Maybe Waffle-0/+9
2023-10-31Turn const_caller_location from a query to a hookOli Scherer-4/+0
2023-10-26Stash and cancel cycle errors for auto trait leakage in opaquesMichael Goulet-0/+1
2023-10-25Rollup merge of #117136 - compiler-errors:defid-list, r=oli-obkMatthias Krüger-1/+1
Intern `LocalDefId` list from `opaque_types_defined_by` query r? oli-obk
2023-10-24Intern LocalDefId list from opaque queryMichael Goulet-1/+1
2023-10-23Auto merge of #116849 - oli-obk:error_shenanigans, r=cjgillotbors-6/+62
Avoid a `track_errors` by bubbling up most errors from `check_well_formed` I believe `track_errors` is mostly papering over issues that a sufficiently convoluted query graph can hit. I made this change, while the actual change I want to do is to stop bailing out early on errors, and instead use this new `ErrorGuaranteed` to invoke `check_well_formed` for individual items before doing all the `typeck` logic on them. This works towards resolving https://github.com/rust-lang/rust/issues/97477 and various other ICEs, as well as allowing us to use parallel rustc more (which is currently rather limited/bottlenecked due to the very sequential nature in which we do `rustc_hir_analysis::check_crate`) cc `@SparrowLii` `@Zoxc` for the new `try_par_for_each_in` function
2023-10-23Allow `ensure` queries to return `Result<(), ErrorGuaranteed>`Oli Scherer-4/+60
2023-10-21coverage: Change query `codegened_and_inlined_items` to a plain functionZalathar-6/+0
This query has a name that sounds general-purpose, but in fact it has coverage-specific semantics, and (fortunately) is only used by coverage code. Because it is only ever called once (from one designated CGU), it doesn't need to be a query, and we can change it to a regular function instead.
2023-10-20s/generator/coroutine/Oli Scherer-9/+9
2023-10-20s/Generator/Coroutine/Oli Scherer-4/+4