summary refs log tree commit diff
path: root/compiler/rustc_middle/src/query
AgeCommit message (Collapse)AuthorLines
2023-01-19Encode whether foreign opaques are TAITs or notMichael Goulet-0/+6
2023-01-17change item_bounds query to return EarlyBinder; remove bound_item_bounds queryKyle Matsuda-1/+1
2023-01-14change impl_trait_ref query to return EarlyBinder; remove ↵Kyle Matsuda-1/+1
bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata
2023-01-14change const_param_default query to return EarlyBinder; remove ↵Kyle Matsuda-1/+1
bound_const_param_default query; add EarlyBinder to const_param_default in metadata
2023-01-12Feed the `features_query` instead of grabbing it from the session lazilyOli Scherer-1/+1
2023-01-12Remove `output_filenames` field from TyCtxt and feed the query insteadOli Scherer-1/+1
2023-01-12Remove `untracked_crate` field and instead pass it along with the resolver.Oli Scherer-1/+1
2023-01-12Feed `crate_name` queryOli Scherer-1/+1
2023-01-12Feed `resolutions` query instead of it being a thin wrapper around an ↵Oli Scherer-1/+1
untracked field
2023-01-09Use newtype for unused generic parametersNilstrieb-1/+1
2022-12-28better names and a commentMichael Goulet-1/+1
2022-12-24Rename some compare_method functionsMichael Goulet-1/+1
2022-12-17Rollup merge of #105493 - WaffleLapkin:unchoke-r-a, r=NilstriebMatthias Krüger-1/+105
Help rust-analyzer normalize query return types See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/rustc.20query.20types.20are.20not.20normalized.20since.20recently/near/312686086), since https://github.com/rust-lang/rust/pull/103808, rust analyzer doesn't normalize return types of queries. This is because r-a doesn't support associated type defaults (yet). The easiest fix is to not use associated type defaults (duh), which this PR does. r? `@cjgillot`
2022-12-16Add a comment warning against using associated type defaults <3Maybe Waffle-0/+8
2022-12-09Move the untracked cstore and source_span into a structOli Scherer-0/+2
2022-12-09Help rust-analyzer normalize query return typesMaybe Waffle-1/+97
2022-12-05feed resolver_for_lowering instead of storing it in a fieldOli Scherer-1/+1
2022-12-01Fill in `def_span` when creating def ids.Oli Scherer-0/+1
This makes sure that ICEing because of def ids created outside of ast lowering will be able to produce a query backtrace and not cause a double panic because of trying to call the `def_span` query
2022-11-29Make inferred_outlives_crate return ClauseSantiago Pastorino-1/+1
2022-11-26Rollup merge of #104909 - ↵Guillaume Gomez-2/+2
compiler-errors:normalize_opaque_types-is-misleading, r=fee1-dead Rename `normalize_opaque_types` to `reveal_opaque_types_in_bounds` 1. The query name is a bit misleading, since it doesn't do any associated type normalization, and 2. since it only takes a predicate list, it sounds a bit more powerful than it actually is.
2022-11-25Rename normalize_opaque_types to reveal_opaque_types_in_boundsMichael Goulet-2/+2
2022-11-25Add empty ConstKind::Abstractkadmin-11/+2
Initial pass at expr/abstract const/s Address comments Switch to using a list instead of &[ty::Const], rm `AbstractConst` Remove try_unify_abstract_consts Update comments Add edits Recurse more More edits Prevent equating associated consts Move failing test to ui Changes this test from incremental to ui, and mark it as failing and a known bug. Does not cause the compiler to ICE, so should be ok.
2022-11-24Auto merge of #103808 - cjgillot:vec-cache, r=TaKO8Kibors-0/+597
Use an IndexVec to cache queries with index-like key Revival of an old idea. Let's see if it has more effect. r? `@ghost`
2022-11-20Factor out conservative_is_privately_uninhabitedCameron Steffen-11/+0
2022-11-20Fix doctest errors related to rustc_middlereez12g-0/+2
2022-11-11Resolve lifetimes independently for each item-like.Camille GILLOT-10/+1
2022-11-05Add internal descriptions to a few queriesNilstrieb-1/+17
2022-11-01Use Key impl to select cache.Camille GILLOT-1/+10
2022-11-01Move keys module.Camille GILLOT-0/+588
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-0/+11
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-29Encode LangItem directlyCameron Steffen-1/+1
2022-10-29Auto merge of #102698 - michaelwoerister:unord-collections, r=lncrbors-1/+1
Introduce UnordMap, UnordSet, and UnordBag (MCP 533) This is the start of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533). I followed `@eddyb's` suggestion of naming the collection types `Unord(Map/Set/Bag)` which is a bit easier to type than `Unordered(Map/Set/Bag)` r? `@eddyb`
2022-10-27Introduce UnordMap, UnordSet, and UnordBag (see MCP 533)Michael Woerister-1/+1
MCP 533: https://github.com/rust-lang/compiler-team/issues/533 Also, as an example, substitute UnordMap for FxHashMap in used_trait_imports query result.
2022-10-26privacy: Rename "accessibility levels" to "effective visibilities"Vadim Petrochenkov-3/+3
And a couple of other naming tweaks Related to https://github.com/rust-lang/rust/issues/48054
2022-10-25rustc_middle: Rearrange resolver outputs structures slightlyVadim Petrochenkov-1/+1
2022-10-23Auto merge of #102660 - camsteffen:uninhabited-perf, r=oli-obkbors-8/+7
Remove ParamEnv from uninhabited query
2022-10-22Introduce InhabitedPredicateCameron Steffen-8/+7
2022-10-22Auto merge of #103196 - Nilstrieb:no-meta-query, r=cjgillotbors-10/+0
Get rid of native_library projection queries They don't seem particularly useful as I don't expect native libraries to change frequently. Maybe they do provide significant value of keeping incremental compilation green though, I'm not sure.
2022-10-21Introduce deduced parameter attributes, and use them for deducing `readonly` onPatrick Walton-0/+5
indirect immutable freeze by-value function parameters. Right now, `rustc` only examines function signatures and the platform ABI when determining the LLVM attributes to apply to parameters. This results in missed optimizations, because there are some attributes that can be determined via analysis of the MIR making up the function body. In particular, `readonly` could be applied to most indirectly-passed by-value function arguments (specifically, those that are freeze and are observed not to be mutated), but it currently is not. This patch introduces the machinery that allows `rustc` to determine those attributes. It consists of a query, `deduced_param_attrs`, that, when evaluated, analyzes the MIR of the function to determine supplementary attributes. The results of this query for each function are written into the crate metadata so that the deduced parameter attributes can be applied to cross-crate functions. In this patch, we simply check the parameter for mutations to determine whether the `readonly` attribute should be applied to parameters that are indirect immutable freeze by-value. More attributes could conceivably be deduced in the future: `nocapture` and `noalias` come to mind. Adding `readonly` to indirect function parameters where applicable enables some potential optimizations in LLVM that are discussed in [issue 103103] and [PR 103070] around avoiding stack-to-stack memory copies that appear in functions like `core::fmt::Write::write_fmt` and `core::panicking::assert_failed`. These functions pass a large structure unchanged by value to a subfunction that also doesn't mutate it. Since the structure in this case is passed as an indirect parameter, it's a pointer from LLVM's perspective. As a result, the intermediate copy of the structure that our codegen emits could be optimized away by LLVM's MemCpyOptimizer if it knew that the pointer is `readonly nocapture noalias` in both the caller and callee. We already pass `nocapture noalias`, but we're missing `readonly`, as we can't determine whether a by-value parameter is mutated by examining the signature in Rust. I didn't have much success with having LLVM infer the `readonly` attribute, even with fat LTO; it seems that deducing it at the MIR level is necessary. No large benefits should be expected from this optimization *now*; LLVM needs some changes (discussed in [PR 103070]) to more aggressively use the `noalias nocapture readonly` combination in its alias analysis. I have some LLVM patches for these optimizations and have had them looked over. With all the patches applied locally, I enabled LLVM to remove all the `memcpy`s from the following code: ```rust fn main() { println!("Hello {}", 3); } ``` which is a significant codegen improvement over the status quo. I expect that if this optimization kicks in in multiple places even for such a simple program, then it will apply to Rust code all over the place. [issue 103103]: https://github.com/rust-lang/rust/issues/103103 [PR 103070]: https://github.com/rust-lang/rust/pull/103070
2022-10-19Don't call `own_existential_vtable_entries` on unresolved trait refMichael Goulet-2/+2
2022-10-19Get rid of native_library projection queriesnils-10/+0
They don't seem particularly useful as I don't expect native libraries to change frequently.
2022-10-18Clean up query descriptionsnils-89/+92
Use the same tense everywhere and prefer display over debug, as these descriptions are user facing.
2022-10-17rm `try_normalize_mir_const_after_erasing_regions`lcnr-8/+0
2022-10-14Get rid of `rustc_query_description!`Nilstrieb-1/+4
Queries can provide an arbitrary expression for their description and their caching behavior. Before, these expressions where stored in a `rustc_query_description` macro emitted by the `rustc_queries` macro, and then used in `rustc_query_impl` to fill out the methods for the `QueryDescription` trait. Instead, we now emit two new modules from `rustc_queries` containing the functions with the expressions. `rustc_query_impl` calls these functions now instead of invoking the macro. Since we are now defining some of the functions in `rustc_middle::query`, we now need all the imports for the key types there as well.
2022-10-10Check representability in adt_sized_constraintCameron Steffen-9/+1
2022-10-07Rewrite representabilityCameron Steffen-0/+26
2022-10-06Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnrMatthias Krüger-0/+6
make `compare_const_impl` a query and use it in `instance.rs` Fixes #88365 the bug in #88365 was caused by some `instance.rs` code using the `PartialEq` impl on `Ty` to check that the type of the associated const in an impl is the same as the type of the associated const in the trait definition. This was wrong for two reasons: - the check typeck does is that the impl type is a subtype of the trait definition's type (see `mismatched_impl_ty_2.rs` which [was ICEing](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f6d60ebe6745011f0d52ab2bc712025d) before this PR on stable) - it assumes that if two types are equal then the `PartialEq` impl will reflect that which isnt true for higher ranked types or type level constants when `feature(generic_const_exprs)` is enabled (see `mismatched_impl_ty_3.rs` for higher ranked types which was [ICEing on stable](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d7af131a655ed515b035624626c62c71)) r? `@lcnr`
2022-10-01Compute by owner instead of HirId.Camille GILLOT-2/+3
2022-10-01Move lint level computation to rustc_middle::lint.Camille GILLOT-1/+1
2022-10-01Compute `lint_levels` by definitionDeadbeef-3/+7