2022-02-17 19:07:33 +00:00
|
|
|
//! Defines the various compiler queries.
|
|
|
|
//!
|
|
|
|
//! For more information on the query system, see
|
|
|
|
//! ["Queries: demand-driven compilation"](https://rustc-dev-guide.rust-lang.org/query.html).
|
|
|
|
//! This chapter includes instructions for adding new queries.
|
|
|
|
|
2023-05-15 04:24:45 +00:00
|
|
|
#![allow(unused_parens)]
|
|
|
|
|
|
|
|
use crate::dep_graph;
|
|
|
|
use crate::infer::canonical::{self, Canonical};
|
|
|
|
use crate::lint::LintExpectation;
|
|
|
|
use crate::metadata::ModChild;
|
|
|
|
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
|
2023-05-16 19:03:28 +00:00
|
|
|
use crate::middle::debugger_visualizer::DebuggerVisualizerFile;
|
2023-05-15 04:24:45 +00:00
|
|
|
use crate::middle::exported_symbols::{ExportedSymbol, SymbolExportInfo};
|
|
|
|
use crate::middle::lib_features::LibFeatures;
|
|
|
|
use crate::middle::privacy::EffectiveVisibilities;
|
|
|
|
use crate::middle::resolve_bound_vars::{ObjectLifetimeDefault, ResolveBoundVars, ResolvedArg};
|
|
|
|
use crate::middle::stability::{self, DeprecationEntry};
|
|
|
|
use crate::mir;
|
|
|
|
use crate::mir::interpret::GlobalId;
|
|
|
|
use crate::mir::interpret::{
|
2023-10-09 08:02:46 +00:00
|
|
|
EvalStaticInitializerRawResult, EvalToAllocationRawResult, EvalToConstValueResult,
|
|
|
|
EvalToValTreeResult,
|
2023-05-15 04:24:45 +00:00
|
|
|
};
|
|
|
|
use crate::mir::interpret::{LitToConstError, LitToConstInput};
|
|
|
|
use crate::mir::mono::CodegenUnit;
|
|
|
|
use crate::query::erase::{erase, restore, Erase};
|
2023-10-18 15:53:06 +00:00
|
|
|
use crate::query::plumbing::{
|
|
|
|
query_ensure, query_ensure_error_guaranteed, query_get_at, CyclePlaceholder, DynamicQuery,
|
|
|
|
};
|
2023-05-15 04:24:45 +00:00
|
|
|
use crate::thir;
|
|
|
|
use crate::traits::query::{
|
2024-02-20 09:34:51 +00:00
|
|
|
CanonicalAliasGoal, CanonicalPredicateGoal, CanonicalTyGoal,
|
2023-05-15 04:24:45 +00:00
|
|
|
CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal,
|
|
|
|
CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, NoSolution,
|
|
|
|
};
|
|
|
|
use crate::traits::query::{
|
|
|
|
DropckConstraint, DropckOutlivesResult, MethodAutoderefStepsResult, NormalizationResult,
|
|
|
|
OutlivesBound,
|
|
|
|
};
|
|
|
|
use crate::traits::specialization_graph;
|
2023-05-23 13:21:22 +00:00
|
|
|
use crate::traits::{
|
2023-07-03 15:19:08 +00:00
|
|
|
CodegenObligationError, EvaluationResult, ImplSource, ObjectSafetyViolation, ObligationCause,
|
|
|
|
OverflowError, WellFormedLoc,
|
2023-05-23 13:21:22 +00:00
|
|
|
};
|
2023-05-15 04:24:45 +00:00
|
|
|
use crate::ty::fast_reject::SimplifiedType;
|
|
|
|
use crate::ty::layout::ValidityRequirement;
|
|
|
|
use crate::ty::util::AlwaysRequiresDrop;
|
|
|
|
use crate::ty::TyCtxtFeed;
|
|
|
|
use crate::ty::{
|
|
|
|
self, print::describe_as_module, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt,
|
|
|
|
UnusedGenericParams,
|
|
|
|
};
|
2023-07-11 21:35:29 +00:00
|
|
|
use crate::ty::{GenericArg, GenericArgsRef};
|
2023-05-15 04:24:45 +00:00
|
|
|
use rustc_arena::TypedArena;
|
|
|
|
use rustc_ast as ast;
|
2023-03-10 21:39:14 +00:00
|
|
|
use rustc_ast::expand::{allocator::AllocatorKind, StrippedCfgItem};
|
2023-05-15 04:24:45 +00:00
|
|
|
use rustc_attr as attr;
|
|
|
|
use rustc_data_structures::fingerprint::Fingerprint;
|
2023-12-21 13:21:01 +00:00
|
|
|
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
2023-05-15 04:24:45 +00:00
|
|
|
use rustc_data_structures::steal::Steal;
|
|
|
|
use rustc_data_structures::svh::Svh;
|
|
|
|
use rustc_data_structures::sync::Lrc;
|
2023-12-21 09:52:27 +00:00
|
|
|
use rustc_data_structures::unord::{UnordMap, UnordSet};
|
2023-05-15 04:24:45 +00:00
|
|
|
use rustc_errors::ErrorGuaranteed;
|
|
|
|
use rustc_hir as hir;
|
|
|
|
use rustc_hir::def::{DefKind, DocLinkResMap};
|
|
|
|
use rustc_hir::def_id::{
|
2023-04-26 18:53:51 +00:00
|
|
|
CrateNum, DefId, DefIdMap, DefIdSet, LocalDefId, LocalDefIdMap, LocalDefIdSet, LocalModDefId,
|
2023-05-15 04:24:45 +00:00
|
|
|
};
|
|
|
|
use rustc_hir::lang_items::{LangItem, LanguageItems};
|
2023-12-18 20:02:21 +00:00
|
|
|
use rustc_hir::{Crate, ItemLocalId, ItemLocalMap, TraitCandidate};
|
2023-05-15 04:24:45 +00:00
|
|
|
use rustc_index::IndexVec;
|
|
|
|
use rustc_query_system::ich::StableHashingContext;
|
|
|
|
use rustc_query_system::query::{try_get_cached, CacheSelector, QueryCache, QueryMode, QueryState};
|
|
|
|
use rustc_session::config::{EntryFnType, OptLevel, OutputFilenames, SymbolManglingVersion};
|
|
|
|
use rustc_session::cstore::{CrateDepKind, CrateSource};
|
|
|
|
use rustc_session::cstore::{ExternCrate, ForeignModule, LinkagePreference, NativeLib};
|
|
|
|
use rustc_session::lint::LintExpectationId;
|
|
|
|
use rustc_session::Limits;
|
2022-10-10 18:03:19 +00:00
|
|
|
use rustc_span::def_id::LOCAL_CRATE;
|
2023-05-15 04:24:45 +00:00
|
|
|
use rustc_span::symbol::Symbol;
|
|
|
|
use rustc_span::{Span, DUMMY_SP};
|
|
|
|
use rustc_target::abi;
|
|
|
|
use rustc_target::spec::PanicStrategy;
|
|
|
|
use std::mem;
|
|
|
|
use std::ops::Deref;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::sync::Arc;
|
2022-10-10 18:03:19 +00:00
|
|
|
|
2023-02-07 07:32:30 +00:00
|
|
|
pub mod erase;
|
2022-10-31 22:54:09 +00:00
|
|
|
mod keys;
|
2023-03-13 22:22:59 +00:00
|
|
|
pub use keys::{AsLocalKey, Key, LocalCrate};
|
2023-05-15 23:53:21 +00:00
|
|
|
pub mod on_disk_cache;
|
|
|
|
#[macro_use]
|
|
|
|
pub mod plumbing;
|
|
|
|
pub use plumbing::{IntoQueryParam, TyCtxtAt, TyCtxtEnsure, TyCtxtEnsureWithValue};
|
2022-10-31 22:54:09 +00:00
|
|
|
|
2018-12-03 00:14:35 +00:00
|
|
|
// Each of these queries corresponds to a function pointer field in the
|
|
|
|
// `Providers` struct for requesting a value of that type, and a method
|
|
|
|
// on `tcx: TyCtxt` (and `tcx.at(span)`) for doing that request in a way
|
|
|
|
// which memoizes and does dep-graph tracking, wrapping around the actual
|
|
|
|
// `Providers` that the driver creates (using several `rustc_*` crates).
|
|
|
|
//
|
|
|
|
// The result type of each query must implement `Clone`, and additionally
|
|
|
|
// `ty::query::values::Value`, which produces an appropriate placeholder
|
|
|
|
// (error) value if the query resulted in a query cycle.
|
|
|
|
// Queries marked with `fatal_cycle` do not need the latter implementation,
|
|
|
|
// as they will raise an fatal error on query cycles instead.
|
|
|
|
rustc_queries! {
|
2024-02-12 04:26:59 +00:00
|
|
|
/// This exists purely for testing the interactions between delayed bugs and incremental.
|
|
|
|
query trigger_delayed_bug(key: DefId) {
|
|
|
|
desc { "triggering a delayed bug for testing incremental" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-11-03 15:44:19 +00:00
|
|
|
|
2023-11-19 16:26:24 +00:00
|
|
|
/// Collects the list of all tools registered using `#![register_tool]`.
|
2023-03-06 10:56:23 +00:00
|
|
|
query registered_tools(_: ()) -> &'tcx ty::RegisteredTools {
|
|
|
|
arena_cache
|
|
|
|
desc { "compute registered tools for crate" }
|
|
|
|
}
|
|
|
|
|
2024-01-27 13:55:15 +00:00
|
|
|
query early_lint_checks(_: ()) {
|
2023-03-06 10:56:53 +00:00
|
|
|
desc { "perform lints prior to macro expansion" }
|
|
|
|
}
|
|
|
|
|
2022-10-25 10:45:02 +00:00
|
|
|
query resolutions(_: ()) -> &'tcx ty::ResolverGlobalCtxt {
|
2022-12-05 16:19:14 +00:00
|
|
|
feedable
|
2021-04-04 12:40:35 +00:00
|
|
|
no_hash
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting the resolver outputs" }
|
2021-04-04 12:40:35 +00:00
|
|
|
}
|
|
|
|
|
2022-12-05 16:43:06 +00:00
|
|
|
query resolver_for_lowering(_: ()) -> &'tcx Steal<(ty::ResolverAstLowering, Lrc<ast::Crate>)> {
|
2023-02-16 14:07:42 +00:00
|
|
|
eval_always
|
2021-07-13 16:45:20 +00:00
|
|
|
no_hash
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting the resolver for lowering" }
|
2021-07-13 16:45:20 +00:00
|
|
|
}
|
|
|
|
|
2021-04-27 17:24:33 +00:00
|
|
|
/// Return the span for a definition.
|
|
|
|
/// Contrary to `def_span` below, this query returns the full absolute span of the definition.
|
|
|
|
/// This span is meant for dep-tracking rather than diagnostics. It should not be used outside
|
|
|
|
/// of rustc_middle::hir::source_map.
|
|
|
|
query source_span(key: LocalDefId) -> Span {
|
2022-12-07 14:31:50 +00:00
|
|
|
// Accesses untracked data
|
|
|
|
eval_always
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting the source span" }
|
2021-04-27 17:24:33 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Represents crate as a whole (as distinct from the top-level crate module).
|
|
|
|
/// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`),
|
|
|
|
/// we will have to assume that any change means that you need to be recompiled.
|
|
|
|
/// This is because the `hir_crate` query gives you access to all other items.
|
|
|
|
/// To avoid this fate, do not call `tcx.hir().krate()`; instead,
|
|
|
|
/// prefer wrappers like `tcx.visit_all_items_in_krate()`.
|
2023-02-07 11:23:31 +00:00
|
|
|
query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting the crate HIR" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-02-06 11:16:51 +00:00
|
|
|
|
2022-04-03 19:50:33 +00:00
|
|
|
/// All items in the crate.
|
2023-02-07 11:23:31 +00:00
|
|
|
query hir_crate_items(_: ()) -> &'tcx rustc_middle::hir::ModuleItems {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-04-03 19:50:33 +00:00
|
|
|
eval_always
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting HIR crate items" }
|
2022-04-03 19:50:33 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// The items in a module.
|
|
|
|
///
|
|
|
|
/// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`.
|
|
|
|
/// Avoid calling this query directly.
|
2023-04-26 18:53:51 +00:00
|
|
|
query hir_module_items(key: LocalModDefId) -> &'tcx rustc_middle::hir::ModuleItems {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "getting HIR module items in `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { true }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-02-07 17:25:36 +00:00
|
|
|
|
2022-12-15 16:20:27 +00:00
|
|
|
/// Gives access to the HIR ID for the given `LocalDefId` owner `key` if any.
|
2022-01-28 17:58:27 +00:00
|
|
|
///
|
2023-04-10 20:02:52 +00:00
|
|
|
/// Definitions that were generated with no HIR, would be fed to return `None`.
|
2022-12-15 16:20:27 +00:00
|
|
|
query opt_local_def_id_to_hir_id(key: LocalDefId) -> Option<hir::HirId>{
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "getting HIR ID of `{}`", tcx.def_path_str(key) }
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2022-01-28 17:58:27 +00:00
|
|
|
}
|
|
|
|
|
2021-03-06 10:25:41 +00:00
|
|
|
/// Gives access to the HIR node's parent for the HIR owner `key`.
|
|
|
|
///
|
|
|
|
/// This can be conveniently accessed by methods on `tcx.hir()`.
|
|
|
|
/// Avoid calling this query directly.
|
2022-09-20 05:11:23 +00:00
|
|
|
query hir_owner_parent(key: hir::OwnerId) -> hir::HirId {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "getting HIR parent of `{}`", tcx.def_path_str(key) }
|
2021-03-06 10:25:41 +00:00
|
|
|
}
|
|
|
|
|
2024-01-25 16:16:38 +00:00
|
|
|
/// Gives access to the HIR nodes and bodies inside `key` if it's a HIR owner.
|
2021-01-31 20:40:03 +00:00
|
|
|
///
|
|
|
|
/// This can be conveniently accessed by methods on `tcx.hir()`.
|
|
|
|
/// Avoid calling this query directly.
|
2024-01-25 16:16:38 +00:00
|
|
|
query opt_hir_owner_nodes(key: LocalDefId) -> Option<&'tcx hir::OwnerNodes<'tcx>> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "getting HIR owner items in `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-02-07 10:14:47 +00:00
|
|
|
|
2020-11-24 17:12:42 +00:00
|
|
|
/// Gives access to the HIR attributes inside the HIR owner `key`.
|
|
|
|
///
|
|
|
|
/// This can be conveniently accessed by methods on `tcx.hir()`.
|
|
|
|
/// Avoid calling this query directly.
|
2022-09-20 05:11:23 +00:00
|
|
|
query hir_attrs(key: hir::OwnerId) -> &'tcx hir::AttributeMap<'tcx> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "getting HIR owner attributes in `{}`", tcx.def_path_str(key) }
|
2020-11-24 17:12:42 +00:00
|
|
|
}
|
|
|
|
|
2021-03-03 06:38:02 +00:00
|
|
|
/// Given the def_id of a const-generic parameter, computes the associated default const
|
2021-03-20 22:34:58 +00:00
|
|
|
/// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`.
|
2023-01-10 19:27:41 +00:00
|
|
|
query const_param_default(param: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "computing const default for a given parameter `{}`", tcx.def_path_str(param) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { param.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-03-03 06:38:02 +00:00
|
|
|
}
|
|
|
|
|
2022-03-31 19:03:52 +00:00
|
|
|
/// Returns the [`Ty`][rustc_middle::ty::Ty] of the given [`DefId`]. If the [`DefId`] points
|
|
|
|
/// to an alias, it will "skip" this alias to return the aliased type.
|
|
|
|
///
|
|
|
|
/// [`DefId`]: rustc_hir::def_id::DefId
|
2023-02-07 08:29:48 +00:00
|
|
|
query type_of(key: DefId) -> ty::EarlyBinder<Ty<'tcx>> {
|
2021-07-21 01:06:39 +00:00
|
|
|
desc { |tcx|
|
|
|
|
"{action} `{path}`",
|
|
|
|
action = {
|
|
|
|
use rustc_hir::def::DefKind;
|
|
|
|
match tcx.def_kind(key) {
|
2023-09-26 02:15:32 +00:00
|
|
|
DefKind::TyAlias => "expanding type alias",
|
2021-07-21 01:06:39 +00:00
|
|
|
DefKind::TraitAlias => "expanding trait alias",
|
|
|
|
_ => "computing type of",
|
|
|
|
}
|
|
|
|
},
|
|
|
|
path = tcx.def_path_str(key),
|
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2018-12-03 00:14:35 +00:00
|
|
|
|
2023-08-27 22:02:54 +00:00
|
|
|
/// Specialized instance of `type_of` that detects cycles that are due to
|
|
|
|
/// revealing opaque because of an auto trait bound. Unless `CyclePlaceholder` needs
|
|
|
|
/// to be handled separately, call `type_of` instead.
|
|
|
|
query type_of_opaque(key: DefId) -> Result<ty::EarlyBinder<Ty<'tcx>>, CyclePlaceholder> {
|
|
|
|
desc { |tcx|
|
|
|
|
"computing type of opaque `{path}`",
|
|
|
|
path = tcx.def_path_str(key),
|
|
|
|
}
|
2023-10-26 17:30:53 +00:00
|
|
|
cycle_stash
|
2023-08-27 22:02:54 +00:00
|
|
|
}
|
|
|
|
|
2023-09-26 02:15:32 +00:00
|
|
|
query type_alias_is_lazy(key: DefId) -> bool {
|
|
|
|
desc { |tcx|
|
|
|
|
"computing whether `{path}` is a lazy type alias",
|
|
|
|
path = tcx.def_path_str(key),
|
|
|
|
}
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2022-12-28 04:16:36 +00:00
|
|
|
query collect_return_position_impl_trait_in_trait_tys(key: DefId)
|
2023-12-21 13:21:01 +00:00
|
|
|
-> Result<&'tcx DefIdMap<ty::EarlyBinder<Ty<'tcx>>>, ErrorGuaranteed>
|
2022-09-02 21:02:59 +00:00
|
|
|
{
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process" }
|
2022-09-09 15:34:11 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2022-09-02 21:02:59 +00:00
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2023-01-18 18:03:06 +00:00
|
|
|
query is_type_alias_impl_trait(key: DefId) -> bool
|
|
|
|
{
|
|
|
|
desc { "determine whether the opaque is a type-alias impl trait" }
|
|
|
|
separate_provide_extern
|
2023-03-13 22:02:28 +00:00
|
|
|
feedable
|
2023-01-18 18:03:06 +00:00
|
|
|
}
|
|
|
|
|
2023-02-07 11:23:31 +00:00
|
|
|
query unsizing_params_for_adt(key: DefId) -> &'tcx rustc_index::bit_set::BitSet<u32>
|
2023-01-21 05:43:37 +00:00
|
|
|
{
|
|
|
|
arena_cache
|
|
|
|
desc { |tcx|
|
|
|
|
"determining what parameters of `{}` can participate in unsizing",
|
|
|
|
tcx.def_path_str(key),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-19 16:26:24 +00:00
|
|
|
/// The root query triggering all analysis passes like typeck or borrowck.
|
2022-01-23 18:34:26 +00:00
|
|
|
query analysis(key: ()) -> Result<(), ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "running analysis passes on this crate" }
|
|
|
|
}
|
2020-02-25 23:26:38 +00:00
|
|
|
|
2022-03-28 22:10:45 +00:00
|
|
|
/// This query checks the fulfillment of collected lint expectations.
|
|
|
|
/// All lint emitting queries have to be done before this is executed
|
|
|
|
/// to ensure that all expectations can be fulfilled.
|
|
|
|
///
|
|
|
|
/// This is an extra query to enable other drivers (like rustdoc) to
|
2022-04-05 16:23:38 +00:00
|
|
|
/// only execute a small subset of the `analysis` query, while allowing
|
2022-03-28 22:10:45 +00:00
|
|
|
/// lints to be expected. In rustc, this query will be executed as part of
|
2022-04-05 16:23:38 +00:00
|
|
|
/// the `analysis` query and doesn't have to be called a second time.
|
2022-03-28 22:10:45 +00:00
|
|
|
///
|
|
|
|
/// Tools can additionally pass in a tool filter. That will restrict the
|
|
|
|
/// expectations to only trigger for lints starting with the listed tool
|
|
|
|
/// name. This is useful for cases were not all linting code from rustc
|
2022-04-05 16:23:38 +00:00
|
|
|
/// was called. With the default `None` all registered lints will also
|
2022-03-28 22:10:45 +00:00
|
|
|
/// be checked for expectation fulfillment.
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_expectations(key: Option<Symbol>) {
|
2022-03-28 22:10:45 +00:00
|
|
|
eval_always
|
|
|
|
desc { "checking lint expectations (RFC 2383)" }
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
|
|
|
|
/// associated generics.
|
2023-02-07 11:23:31 +00:00
|
|
|
query generics_of(key: DefId) -> &'tcx ty::Generics {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) }
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-17 06:00:46 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
|
|
|
|
/// predicates (where-clauses) that must be proven true in order
|
|
|
|
/// to reference it. This is almost always the "predicates query"
|
|
|
|
/// that you want.
|
|
|
|
///
|
|
|
|
/// `predicates_of` builds on `predicates_defined_on` -- in fact,
|
|
|
|
/// it is almost always the same as that query, except for the
|
|
|
|
/// case of traits. For traits, `predicates_of` contains
|
|
|
|
/// an additional `Self: Trait<...>` predicate that users don't
|
|
|
|
/// actually write. This reflects the fact that to invoke the
|
|
|
|
/// trait (e.g., via `Default::default`) you must supply types
|
|
|
|
/// that actually implement the trait. (However, this extra
|
|
|
|
/// predicate gets in the way of some checks, which are intended
|
|
|
|
/// to operate over only the actual where-clauses written by the
|
|
|
|
/// user.)
|
|
|
|
query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
|
|
|
|
desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
|
|
|
|
cache_on_disk_if { key.is_local() }
|
|
|
|
}
|
2019-03-17 06:00:46 +00:00
|
|
|
|
2023-04-18 14:09:48 +00:00
|
|
|
query opaque_types_defined_by(
|
|
|
|
key: LocalDefId
|
2023-10-18 19:28:46 +00:00
|
|
|
) -> &'tcx ty::List<LocalDefId> {
|
2023-04-18 14:09:48 +00:00
|
|
|
desc {
|
|
|
|
|tcx| "computing the opaque types defined by `{}`",
|
|
|
|
tcx.def_path_str(key.to_def_id())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 11:12:30 +00:00
|
|
|
query impl_trait_in_assoc_types_defined_by(
|
|
|
|
key: LocalDefId
|
|
|
|
) -> &'tcx ty::List<LocalDefId> {
|
|
|
|
desc {
|
|
|
|
|tcx| "computing the opaque types defined by `{}`",
|
|
|
|
tcx.def_path_str(key.to_def_id())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns the list of bounds that can be used for
|
|
|
|
/// `SelectionCandidate::ProjectionCandidate(_)` and
|
|
|
|
/// `ProjectionTyCandidate::TraitDef`.
|
|
|
|
/// Specifically this is the bounds written on the trait's type
|
|
|
|
/// definition, or those after the `impl` keyword
|
|
|
|
///
|
|
|
|
/// ```ignore (incomplete)
|
|
|
|
/// type X: Bound + 'lt
|
|
|
|
/// // ^^^^^^^^^^^
|
|
|
|
/// impl Debug + Display
|
|
|
|
/// // ^^^^^^^^^^^^^^^
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// `key` is the `DefId` of the associated type or opaque type.
|
|
|
|
///
|
|
|
|
/// Bounds from the parent (e.g. with nested impl trait) are not included.
|
2023-06-19 20:46:46 +00:00
|
|
|
query explicit_item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx [(ty::Clause<'tcx>, Span)]> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-06-24 18:13:44 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Elaborated version of the predicates from `explicit_item_bounds`.
|
|
|
|
///
|
|
|
|
/// For example:
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// trait MyTrait {
|
|
|
|
/// type MyAType: Eq + ?Sized;
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// `explicit_item_bounds` returns `[<Self as MyTrait>::MyAType: Eq]`,
|
|
|
|
/// and `item_bounds` returns
|
|
|
|
/// ```text
|
|
|
|
/// [
|
|
|
|
/// <Self as Trait>::MyAType: Eq,
|
|
|
|
/// <Self as Trait>::MyAType: PartialEq<<Self as Trait>::MyAType>
|
|
|
|
/// ]
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// Bounds from the parent (e.g. with nested impl trait) are not included.
|
2023-06-19 20:46:46 +00:00
|
|
|
query item_bounds(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<ty::Clause<'tcx>>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
|
|
|
|
}
|
2020-05-30 16:19:31 +00:00
|
|
|
|
2022-11-05 16:54:15 +00:00
|
|
|
/// Look up all native libraries this crate depends on.
|
|
|
|
/// These are assembled from the following places:
|
|
|
|
/// - `extern` blocks (depending on their `link` attributes)
|
|
|
|
/// - the `libs` (`-l`) option
|
2023-02-07 11:23:31 +00:00
|
|
|
query native_libraries(_: CrateNum) -> &'tcx Vec<NativeLib> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "looking up the native libraries of a linked crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-20 16:22:16 +00:00
|
|
|
|
2023-02-07 11:23:31 +00:00
|
|
|
query shallow_lint_levels_on(key: hir::OwnerId) -> &'tcx rustc_middle::lint::ShallowLintLevelMap {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "looking up lint levels for `{}`", tcx.def_path_str(key) }
|
2022-07-22 16:48:36 +00:00
|
|
|
}
|
|
|
|
|
2023-02-07 11:23:31 +00:00
|
|
|
query lint_expectations(_: ()) -> &'tcx Vec<(LintExpectationId, LintExpectation)> {
|
2022-07-22 16:48:36 +00:00
|
|
|
arena_cache
|
|
|
|
desc { "computing `#[expect]`ed lints in this crate" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-02-11 13:38:16 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query expn_that_defined(key: DefId) -> rustc_span::ExpnId {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "getting the expansion that defined `{}`", tcx.def_path_str(key) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2018-12-03 00:14:35 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query is_panic_runtime(_: CrateNum) -> bool {
|
|
|
|
fatal_cycle
|
|
|
|
desc { "checking if the crate is_panic_runtime" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-20 15:06:09 +00:00
|
|
|
|
2022-08-15 19:11:11 +00:00
|
|
|
/// Checks whether a type is representable or infinitely sized
|
|
|
|
query representability(_: LocalDefId) -> rustc_middle::ty::Representability {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { "checking if `{}` is representable", tcx.def_path_str(key) }
|
2022-08-15 19:11:11 +00:00
|
|
|
// infinitely sized types will cause a cycle
|
|
|
|
cycle_delay_bug
|
|
|
|
// we don't want recursive representability calls to be forced with
|
|
|
|
// incremental compilation because, if a cycle occurs, we need the
|
|
|
|
// entire cycle to be in memory for diagnostics
|
|
|
|
anon
|
|
|
|
}
|
|
|
|
|
|
|
|
/// An implementation detail for the `representability` query
|
|
|
|
query representability_adt_ty(_: Ty<'tcx>) -> rustc_middle::ty::Representability {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "checking if `{}` is representable", key }
|
2022-08-15 19:11:11 +00:00
|
|
|
cycle_delay_bug
|
|
|
|
anon
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Set of param indexes for type params that are in the type's representation
|
2023-02-07 11:23:31 +00:00
|
|
|
query params_in_repr(key: DefId) -> &'tcx rustc_index::bit_set::BitSet<u32> {
|
2022-08-15 19:11:11 +00:00
|
|
|
desc { "finding type parameters in the representation" }
|
|
|
|
arena_cache
|
|
|
|
no_hash
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2021-05-22 13:40:26 +00:00
|
|
|
/// Fetch the THIR for a given body. If typeck for that body failed, returns an empty `Thir`.
|
2022-05-08 13:53:19 +00:00
|
|
|
query thir_body(key: LocalDefId) -> Result<(&'tcx Steal<thir::Thir<'tcx>>, thir::ExprId), ErrorGuaranteed> {
|
2021-05-27 14:31:47 +00:00
|
|
|
// Perf tests revealed that hashing THIR is inefficient (see #85729).
|
2021-05-26 20:34:42 +00:00
|
|
|
no_hash
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "building THIR for `{}`", tcx.def_path_str(key) }
|
2021-04-04 16:42:17 +00:00
|
|
|
}
|
2021-07-24 21:18:15 +00:00
|
|
|
|
|
|
|
/// Create a THIR tree for debugging.
|
2022-05-08 13:53:19 +00:00
|
|
|
query thir_tree(key: LocalDefId) -> &'tcx String {
|
2021-07-24 21:18:15 +00:00
|
|
|
no_hash
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key) }
|
2021-07-24 21:18:15 +00:00
|
|
|
}
|
2021-04-04 16:42:17 +00:00
|
|
|
|
2023-01-26 22:35:24 +00:00
|
|
|
/// Create a list-like THIR representation for debugging.
|
2022-05-08 13:53:19 +00:00
|
|
|
query thir_flat(key: LocalDefId) -> &'tcx String {
|
2023-01-26 22:35:24 +00:00
|
|
|
no_hash
|
|
|
|
arena_cache
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "constructing flat THIR representation for `{}`", tcx.def_path_str(key) }
|
2023-01-26 22:35:24 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Set of all the `DefId`s in this crate that have MIR associated with
|
|
|
|
/// them. This includes all the body owners, but also things like struct
|
|
|
|
/// constructors.
|
2023-02-07 11:23:31 +00:00
|
|
|
query mir_keys(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexSet<LocalDefId> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "getting a list of all mir_keys" }
|
|
|
|
}
|
2019-03-20 15:06:09 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps DefId's that have an associated `mir::Body` to the result
|
|
|
|
/// of the MIR const-checking pass. This is the set of qualifs in
|
|
|
|
/// the final value of a `const`.
|
|
|
|
query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
|
|
|
|
desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
|
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-20 15:06:09 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Fetch the MIR for a given `DefId` right after it's built - this includes
|
|
|
|
/// unreachable code.
|
2022-05-08 13:53:19 +00:00
|
|
|
query mir_built(key: LocalDefId) -> &'tcx Steal<mir::Body<'tcx>> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-20 15:06:09 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Fetch the MIR for a given `DefId` up till the point where it is
|
|
|
|
/// ready for const qualification.
|
|
|
|
///
|
|
|
|
/// See the README for the `mir` module for details.
|
2022-05-08 13:53:19 +00:00
|
|
|
query mir_const(key: LocalDefId) -> &'tcx Steal<mir::Body<'tcx>> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "preparing `{}` for borrow checking", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
no_hash
|
|
|
|
}
|
2019-03-20 15:06:09 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Try to build an abstract representation of the given constant.
|
2021-09-07 00:56:29 +00:00
|
|
|
query thir_abstract_const(
|
2021-01-31 20:40:03 +00:00
|
|
|
key: DefId
|
2023-05-09 22:02:52 +00:00
|
|
|
) -> Result<Option<ty::EarlyBinder<ty::Const<'tcx>>>, ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc {
|
2022-10-17 19:30:41 +00:00
|
|
|
|tcx| "building an abstract representation for `{}`", tcx.def_path_str(key),
|
2020-09-10 07:06:30 +00:00
|
|
|
}
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-09-10 07:06:30 +00:00
|
|
|
|
2022-05-08 13:53:19 +00:00
|
|
|
query mir_drops_elaborated_and_const_checked(key: LocalDefId) -> &'tcx Steal<mir::Body<'tcx>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
no_hash
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-05-03 04:16:17 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query mir_for_ctfe(
|
|
|
|
key: DefId
|
|
|
|
) -> &'tcx mir::Body<'tcx> {
|
|
|
|
desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) }
|
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-10-26 19:00:40 +00:00
|
|
|
|
2022-05-08 13:53:19 +00:00
|
|
|
query mir_promoted(key: LocalDefId) -> (
|
|
|
|
&'tcx Steal<mir::Body<'tcx>>,
|
|
|
|
&'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
|
|
|
|
) {
|
2021-01-31 20:40:03 +00:00
|
|
|
no_hash
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "promoting constants in MIR for `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-20 15:06:09 +00:00
|
|
|
|
2023-02-25 22:51:57 +00:00
|
|
|
query closure_typeinfo(key: LocalDefId) -> ty::ClosureTypeInfo<'tcx> {
|
2021-07-09 14:40:51 +00:00
|
|
|
desc {
|
2022-10-25 17:59:18 +00:00
|
|
|
|tcx| "finding symbols for captures of closure `{}`",
|
2023-02-16 09:25:11 +00:00
|
|
|
tcx.def_path_str(key)
|
2021-07-09 14:40:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-19 21:46:28 +00:00
|
|
|
/// Returns names of captured upvars for closures and coroutines.
|
2023-06-18 07:55:04 +00:00
|
|
|
///
|
|
|
|
/// Here are some examples:
|
|
|
|
/// - `name__field1__field2` when the upvar is captured by value.
|
|
|
|
/// - `_ref__name__field` when the upvar is captured by reference.
|
|
|
|
///
|
2023-10-19 21:46:28 +00:00
|
|
|
/// For coroutines this only contains upvars that are shared by all states.
|
2023-06-18 07:55:04 +00:00
|
|
|
query closure_saved_names_of_captured_variables(def_id: DefId) -> &'tcx IndexVec<abi::FieldIdx, Symbol> {
|
|
|
|
arena_cache
|
|
|
|
desc { |tcx| "computing debuginfo for closure `{}`", tcx.def_path_str(def_id) }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2023-10-19 21:46:28 +00:00
|
|
|
query mir_coroutine_witnesses(key: DefId) -> &'tcx Option<mir::CoroutineLayout<'tcx>> {
|
2022-07-26 18:37:25 +00:00
|
|
|
arena_cache
|
2023-10-19 21:46:28 +00:00
|
|
|
desc { |tcx| "coroutine witness types for `{}`", tcx.def_path_str(key) }
|
2022-07-26 18:37:25 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2023-11-22 03:43:59 +00:00
|
|
|
query check_coroutine_obligations(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
|
2023-10-19 21:46:28 +00:00
|
|
|
desc { |tcx| "verify auto trait bounds for coroutine interior type `{}`", tcx.def_path_str(key) }
|
2022-10-01 13:57:22 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// MIR after our optimization passes have run. This is MIR that is ready
|
|
|
|
/// for codegen. This is also the only query that can fetch non-local MIR, at present.
|
|
|
|
query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> {
|
|
|
|
desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) }
|
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-10-26 19:00:40 +00:00
|
|
|
|
2023-09-13 02:15:40 +00:00
|
|
|
/// Summarizes coverage IDs inserted by the `InstrumentCoverage` MIR pass
|
|
|
|
/// (for compiler option `-Cinstrument-coverage`), after MIR optimizations
|
|
|
|
/// have had a chance to potentially remove some of them.
|
|
|
|
query coverage_ids_info(key: ty::InstanceDef<'tcx>) -> &'tcx mir::CoverageIdsInfo {
|
|
|
|
desc { |tcx| "retrieving coverage IDs info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-06-22 21:11:55 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own
|
|
|
|
/// `DefId`. This function returns all promoteds in the specified body. The body references
|
|
|
|
/// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because
|
|
|
|
/// after inlining a body may refer to promoteds from other bodies. In that case you still
|
|
|
|
/// need to use the `DefId` of the original body.
|
|
|
|
query promoted_mir(key: DefId) -> &'tcx IndexVec<mir::Promoted, mir::Body<'tcx>> {
|
|
|
|
desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) }
|
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-20 15:53:55 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Erases regions from `ty` to yield a new type.
|
|
|
|
/// Normally you would just use `tcx.erase_regions(value)`,
|
|
|
|
/// however, which uses this query as a kind of cache.
|
|
|
|
query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> {
|
|
|
|
// This query is not expected to have input -- as a result, it
|
|
|
|
// is not a good candidates for "replay" because it is essentially a
|
|
|
|
// pure function of its input (and hence the expectation is that
|
|
|
|
// no caller would be green **apart** from just these
|
|
|
|
// queries). Making it anonymous avoids hashing the result, which
|
|
|
|
// may save a bit of time.
|
|
|
|
anon
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "erasing regions from `{}`", ty }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-20 15:53:55 +00:00
|
|
|
|
2023-12-21 10:13:03 +00:00
|
|
|
query wasm_import_module_map(_: CrateNum) -> &'tcx DefIdMap<String> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting wasm import module map" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps from the `DefId` of an item (trait/struct/enum/fn) to the
|
|
|
|
/// predicates (where-clauses) directly defined on it. This is
|
|
|
|
/// equal to the `explicit_predicates_of` predicates plus the
|
|
|
|
/// `inferred_outlives_of` predicates.
|
|
|
|
query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> {
|
|
|
|
desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns everything that looks like a predicate written explicitly
|
|
|
|
/// by the user on a trait item.
|
|
|
|
///
|
|
|
|
/// Traits are unusual, because predicates on associated types are
|
|
|
|
/// converted into bounds on that type for backwards compatibility:
|
|
|
|
///
|
|
|
|
/// trait X where Self::U: Copy { type U; }
|
|
|
|
///
|
|
|
|
/// becomes
|
|
|
|
///
|
|
|
|
/// trait X { type U: Copy; }
|
|
|
|
///
|
|
|
|
/// `explicit_predicates_of` and `explicit_item_bounds` will then take
|
|
|
|
/// the appropriate subsets of the predicates here.
|
|
|
|
query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-07-04 11:15:04 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns the predicates written explicitly by the user.
|
|
|
|
query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
|
|
|
|
desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns the inferred outlives predicates (e.g., for `struct
|
|
|
|
/// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`).
|
2023-06-20 03:25:40 +00:00
|
|
|
query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Clause<'tcx>, Span)] {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps from the `DefId` of a trait to the list of
|
|
|
|
/// super-predicates. This is a subset of the full list of
|
|
|
|
/// predicates. We store these in a separate map because we must
|
|
|
|
/// evaluate them even during type conversion, often before the
|
|
|
|
/// full predicates are available (note that supertraits have
|
|
|
|
/// additional acyclicity requirements).
|
|
|
|
query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
|
2020-12-03 23:10:55 +00:00
|
|
|
desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2020-12-03 23:10:55 +00:00
|
|
|
}
|
|
|
|
|
2023-02-02 20:37:02 +00:00
|
|
|
query implied_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
|
|
|
|
desc { |tcx| "computing the implied predicates of `{}`", tcx.def_path_str(key) }
|
|
|
|
cache_on_disk_if { key.is_local() }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2020-12-03 23:10:55 +00:00
|
|
|
/// The `Option<Ident>` is the name of an associated type. If it is `None`, then this query
|
|
|
|
/// returns the full set of predicates. If `Some<Ident>`, then the query returns only the
|
|
|
|
/// subset of super-predicates that reference traits that define the given associated type.
|
|
|
|
/// This is used to avoid cycles in resolving types like `T::Item`.
|
2023-05-03 20:13:32 +00:00
|
|
|
query super_predicates_that_define_assoc_item(key: (DefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
|
2023-02-02 18:50:25 +00:00
|
|
|
desc { |tcx| "computing the super traits of `{}` with associated type name `{}`",
|
2020-12-03 23:10:55 +00:00
|
|
|
tcx.def_path_str(key.0),
|
2023-02-02 18:50:25 +00:00
|
|
|
key.1
|
2020-12-03 23:10:55 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-11-13 17:01:16 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// To avoid cycles within the predicates of a single item we compute
|
|
|
|
/// per-type-parameter predicates for resolving `T::AssocTy`.
|
2023-03-13 19:06:41 +00:00
|
|
|
query type_param_predicates(key: (LocalDefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> {
|
2022-04-08 21:06:20 +00:00
|
|
|
desc { |tcx| "computing the bounds for type parameter `{}`", tcx.hir().ty_param_name(key.1) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-02-07 11:23:31 +00:00
|
|
|
query trait_def(key: DefId) -> &'tcx ty::TraitDef {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) }
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-03-04 20:28:41 +00:00
|
|
|
query adt_def(key: DefId) -> ty::AdtDef<'tcx> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) }
|
2021-12-16 23:32:00 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query adt_destructor(key: DefId) -> Option<ty::Destructor> {
|
|
|
|
desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-08-01 00:52:16 +00:00
|
|
|
query adt_sized_constraint(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query adt_dtorck_constraint(
|
|
|
|
key: DefId
|
2022-03-24 18:21:41 +00:00
|
|
|
) -> Result<&'tcx DropckConstraint<'tcx>, NoSolution> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate
|
|
|
|
/// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might
|
|
|
|
/// not have the feature gate active).
|
|
|
|
///
|
|
|
|
/// **Do not call this function manually.** It is only meant to cache the base data for the
|
2022-06-15 10:54:43 +00:00
|
|
|
/// `is_const_fn` function. Consider using `is_const_fn` or `is_const_fn_raw` instead.
|
|
|
|
query constness(key: DefId) -> hir::Constness {
|
|
|
|
desc { |tcx| "checking if item is const: `{}`", tcx.def_path_str(key) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-09-14 22:38:07 +00:00
|
|
|
query asyncness(key: DefId) -> ty::Asyncness {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-09-19 03:02:08 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns `true` if calls to the function may be promoted.
|
|
|
|
///
|
|
|
|
/// This is either because the function is e.g., a tuple-struct or tuple-variant
|
|
|
|
/// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should
|
|
|
|
/// be removed in the future in favour of some form of check which figures out whether the
|
|
|
|
/// function does not inspect the bits of any of its arguments (so is essentially just a
|
|
|
|
/// constructor function).
|
|
|
|
query is_promotable_const_fn(key: DefId) -> bool {
|
|
|
|
desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-10-19 21:46:28 +00:00
|
|
|
/// Returns `Some(coroutine_kind)` if the node pointed to by `def_id` is a coroutine.
|
|
|
|
query coroutine_kind(def_id: DefId) -> Option<hir::CoroutineKind> {
|
|
|
|
desc { |tcx| "looking up coroutine kind of `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-01-26 01:09:23 +00:00
|
|
|
|
2024-01-24 22:27:25 +00:00
|
|
|
query coroutine_for_closure(def_id: DefId) -> DefId {
|
2024-01-25 03:50:23 +00:00
|
|
|
desc { |_tcx| "Given a coroutine-closure def id, return the def id of the coroutine returned by it" }
|
2024-01-24 22:27:25 +00:00
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2023-08-02 23:03:31 +00:00
|
|
|
/// Gets a map with the variance of every item; use `variances_of` instead.
|
2023-02-07 11:23:31 +00:00
|
|
|
query crate_variances(_: ()) -> &'tcx ty::CrateVariancesMap<'tcx> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "computing the variances for items in this crate" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps from the `DefId` of a type or region parameter to its (inferred) variance.
|
|
|
|
query variances_of(def_id: DefId) -> &'tcx [ty::Variance] {
|
|
|
|
desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps from thee `DefId` of a type to its (inferred) outlives.
|
2023-02-07 11:23:31 +00:00
|
|
|
query inferred_outlives_crate(_: ()) -> &'tcx ty::CratePredicatesMap<'tcx> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "computing the inferred outlives predicates for items in this crate" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-04-10 13:44:54 +00:00
|
|
|
/// Maps from an impl/trait or struct/variant `DefId`
|
|
|
|
/// to a list of the `DefId`s of its associated items or fields.
|
2021-01-31 20:40:03 +00:00
|
|
|
query associated_item_def_ids(key: DefId) -> &'tcx [DefId] {
|
2023-04-10 13:44:54 +00:00
|
|
|
desc { |tcx| "collecting associated items or fields of `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps from a trait item to the trait item "descriptor".
|
2023-02-03 16:29:46 +00:00
|
|
|
query associated_item(key: DefId) -> ty::AssocItem {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-02-05 00:43:03 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Collects the associated items defined on a trait or impl.
|
2023-02-06 08:57:34 +00:00
|
|
|
query associated_items(key: DefId) -> &'tcx ty::AssocItems {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-11-18 22:29:07 +00:00
|
|
|
/// Maps from associated items on a trait to the corresponding associated
|
|
|
|
/// item on the impl specified by `impl_id`.
|
|
|
|
///
|
|
|
|
/// For example, with the following code
|
|
|
|
///
|
|
|
|
/// ```
|
|
|
|
/// struct Type {}
|
|
|
|
/// // DefId
|
|
|
|
/// trait Trait { // trait_id
|
|
|
|
/// fn f(); // trait_f
|
|
|
|
/// fn g() {} // trait_g
|
|
|
|
/// }
|
|
|
|
///
|
|
|
|
/// impl Trait for Type { // impl_id
|
|
|
|
/// fn f() {} // impl_f
|
|
|
|
/// fn g() {} // impl_g
|
|
|
|
/// }
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
|
|
|
|
///`{ trait_f: impl_f, trait_g: impl_g }`
|
2023-02-21 10:35:19 +00:00
|
|
|
query impl_item_implementor_ids(impl_id: DefId) -> &'tcx DefIdMap<DefId> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "comparing impl items against trait for `{}`", tcx.def_path_str(impl_id) }
|
2021-11-18 22:29:07 +00:00
|
|
|
}
|
|
|
|
|
2023-02-17 19:03:45 +00:00
|
|
|
/// Given `fn_def_id` of a trait or of an impl that implements a given trait:
|
|
|
|
/// if `fn_def_id` is the def id of a function defined inside a trait, then it creates and returns
|
|
|
|
/// the associated items that correspond to each impl trait in return position for that trait.
|
|
|
|
/// if `fn_def_id` is the def id of a function defined inside an impl that implements a trait, then it
|
|
|
|
/// creates and returns the associated items that correspond to each impl trait in return position
|
|
|
|
/// of the implemented trait.
|
2023-03-17 03:45:14 +00:00
|
|
|
query associated_types_for_impl_traits_in_associated_fn(fn_def_id: DefId) -> &'tcx [DefId] {
|
2022-10-26 19:38:32 +00:00
|
|
|
desc { |tcx| "creating associated items for impl trait in trait returned by `{}`", tcx.def_path_str(fn_def_id) }
|
|
|
|
cache_on_disk_if { fn_def_id.is_local() }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2022-12-16 20:15:34 +00:00
|
|
|
/// Given an impl trait in trait `opaque_ty_def_id`, create and return the corresponding
|
|
|
|
/// associated item.
|
2023-03-17 03:45:14 +00:00
|
|
|
query associated_type_for_impl_trait_in_trait(opaque_ty_def_id: LocalDefId) -> LocalDefId {
|
2022-12-16 20:15:34 +00:00
|
|
|
desc { |tcx| "creates the associated item corresponding to the opaque type `{}`", tcx.def_path_str(opaque_ty_def_id.to_def_id()) }
|
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
|
|
|
|
2024-02-10 21:26:48 +00:00
|
|
|
/// Given an `impl_id`, return the trait it implements along with some header information.
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Return `None` if this is an inherent impl.
|
2024-02-10 21:46:44 +00:00
|
|
|
query impl_trait_header(impl_id: DefId) -> Option<ty::EarlyBinder<ty::ImplTraitHeader<'tcx>>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { impl_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-02-14 22:55:31 +00:00
|
|
|
query issue33140_self_ty(key: DefId) -> Option<ty::EarlyBinder<ty::Ty<'tcx>>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Maps a `DefId` of a type to a list of its inherent impls.
|
|
|
|
/// Contains implementations of methods that are inherent to a type.
|
|
|
|
/// Methods in these implementations don't need to be exported.
|
2024-01-12 14:29:54 +00:00
|
|
|
query inherent_impls(key: DefId) -> Result<&'tcx [DefId], ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2024-01-12 14:29:54 +00:00
|
|
|
query incoherent_impls(key: SimplifiedType) -> Result<&'tcx [DefId], ErrorGuaranteed> {
|
2022-03-15 15:30:30 +00:00
|
|
|
desc { |tcx| "collecting all inherent impls for `{:?}`", key }
|
|
|
|
}
|
|
|
|
|
2023-12-07 11:56:48 +00:00
|
|
|
/// The result of unsafety-checking this `LocalDefId` with the old checker.
|
|
|
|
query mir_unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-12-07 11:56:48 +00:00
|
|
|
/// Unsafety-check this `LocalDefId`.
|
|
|
|
query check_unsafety(key: LocalDefId) {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key) }
|
2021-03-14 19:10:22 +00:00
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-08-17 10:22:32 +00:00
|
|
|
/// Returns the types assumed to be well formed while "inside" of the given item.
|
|
|
|
///
|
|
|
|
/// Note that we've liberated the late bound regions of function signatures, so
|
|
|
|
/// this can not be used to check whether these types are well formed.
|
2023-06-27 21:13:39 +00:00
|
|
|
query assumed_wf_types(key: LocalDefId) -> &'tcx [(Ty<'tcx>, Span)] {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) }
|
2022-08-17 10:22:32 +00:00
|
|
|
}
|
|
|
|
|
2023-07-17 18:12:49 +00:00
|
|
|
/// We need to store the assumed_wf_types for an RPITIT so that impls of foreign
|
|
|
|
/// traits with return-position impl trait in traits can inherit the right wf types.
|
|
|
|
query assumed_wf_types_for_rpitit(key: DefId) -> &'tcx [(Ty<'tcx>, Span)] {
|
|
|
|
desc { |tcx| "computing the implied bounds of `{}`", tcx.def_path_str(key) }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2021-10-29 15:15:45 +00:00
|
|
|
/// Computes the signature of the function.
|
2023-01-18 23:52:47 +00:00
|
|
|
query fn_sig(key: DefId) -> ty::EarlyBinder<ty::PolyFnSig<'tcx>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2022-08-10 20:53:06 +00:00
|
|
|
cycle_delay_bug
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-10-29 15:15:45 +00:00
|
|
|
/// Performs lint checking for the module.
|
2024-01-27 13:55:15 +00:00
|
|
|
query lint_mod(key: LocalModDefId) {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "linting {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_unused_traits(_: ()) {
|
2022-01-30 16:14:54 +00:00
|
|
|
desc { "checking unused trait imports in crate" }
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Checks the attributes in the module.
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_mod_attrs(key: LocalModDefId) {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
2020-11-25 00:00:00 +00:00
|
|
|
|
2021-10-29 15:15:45 +00:00
|
|
|
/// Checks for uses of unstable APIs in the module.
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_mod_unstable_api_usage(key: LocalModDefId) {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`).
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_mod_const_bodies(key: LocalModDefId) {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Checks the loops in the module.
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_mod_loops(key: LocalModDefId) {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_mod_naked_functions(key: LocalModDefId) {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_mod_privacy(key: LocalModDefId) {
|
2023-04-26 18:53:51 +00:00
|
|
|
desc { |tcx| "checking privacy in {}", describe_as_module(key.to_local_def_id(), tcx) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-02-16 09:34:53 +00:00
|
|
|
query check_liveness(key: LocalDefId) {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "checking liveness of variables in `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-01-29 20:10:41 +00:00
|
|
|
/// Return the live symbols in the crate for dead code check.
|
|
|
|
///
|
|
|
|
/// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone) and
|
|
|
|
/// their respective impl (i.e., part of the derive macro)
|
2023-02-07 11:23:31 +00:00
|
|
|
query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx (
|
2023-02-21 11:19:54 +00:00
|
|
|
LocalDefIdSet,
|
|
|
|
LocalDefIdMap<Vec<(DefId, DefId)>>
|
2022-01-29 20:10:41 +00:00
|
|
|
) {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "finding live symbols in crate" }
|
2022-01-29 20:10:41 +00:00
|
|
|
}
|
|
|
|
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_mod_deathness(key: LocalModDefId) {
|
2022-01-29 20:10:41 +00:00
|
|
|
desc { |tcx| "checking deathness of variables in {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
|
|
|
|
2024-01-11 22:13:39 +00:00
|
|
|
query check_mod_impl_wf(key: LocalModDefId) -> Result<(), ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) }
|
2024-01-11 22:13:39 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-10-18 08:47:17 +00:00
|
|
|
query check_mod_type_wf(key: LocalModDefId) -> Result<(), ErrorGuaranteed> {
|
2021-05-10 10:18:55 +00:00
|
|
|
desc { |tcx| "checking that types are well-formed in {}", describe_as_module(key, tcx) }
|
2023-10-18 15:53:06 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-05-10 10:18:55 +00:00
|
|
|
}
|
|
|
|
|
2024-01-27 13:55:15 +00:00
|
|
|
query collect_mod_item_types(key: LocalModDefId) {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) }
|
|
|
|
}
|
2020-12-29 16:21:52 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Caches `CoerceUnsized` kinds for impls on custom types.
|
2024-01-23 15:23:22 +00:00
|
|
|
query coerce_unsized_info(key: DefId) -> Result<ty::adjustment::CoerceUnsizedInfo, ErrorGuaranteed> {
|
2021-05-30 15:24:54 +00:00
|
|
|
desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2024-01-23 15:23:22 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-05-30 15:24:54 +00:00
|
|
|
}
|
2020-12-29 16:21:52 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) }
|
2023-04-30 19:34:13 +00:00
|
|
|
cache_on_disk_if(tcx) { !tcx.is_typeck_child(key.to_def_id()) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "type-checking `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-01-05 15:46:44 +00:00
|
|
|
|
2022-10-27 13:23:26 +00:00
|
|
|
query used_trait_imports(key: LocalDefId) -> &'tcx UnordSet<LocalDefId> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "finding used_trait_imports `{}`", tcx.def_path_str(key) }
|
2021-01-31 20:40:03 +00:00
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
2020-07-01 09:41:38 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query has_typeck_results(def_id: DefId) -> bool {
|
|
|
|
desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) }
|
|
|
|
}
|
2020-01-11 02:22:36 +00:00
|
|
|
|
2024-01-23 15:23:22 +00:00
|
|
|
query coherent_trait(def_id: DefId) -> Result<(), ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) }
|
2024-01-23 15:23:22 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Borrow-checks the function body. If this is a closure, returns
|
|
|
|
/// additional requirements that the closure's creator must verify.
|
|
|
|
query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key) }
|
2021-11-06 20:01:35 +00:00
|
|
|
cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Gets a complete map from all types to their inherent impls.
|
|
|
|
/// Not meant to be used directly outside of coherence.
|
2024-01-12 14:29:54 +00:00
|
|
|
query crate_inherent_impls(k: ()) -> Result<&'tcx CrateInherentImpls, ErrorGuaranteed> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "finding all inherent impls defined in crate" }
|
2024-01-12 14:29:54 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Checks all types in the crate for overlap in their inherent impls. Reports errors.
|
|
|
|
/// Not meant to be used directly outside of coherence.
|
2024-01-12 08:57:07 +00:00
|
|
|
query crate_inherent_impls_overlap_check(_: ()) -> Result<(), ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "check for overlap between inherent impls defined in this crate" }
|
2024-01-12 08:57:07 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-10-21 13:36:35 +00:00
|
|
|
/// Checks whether all impls in the crate pass the overlap check, returning
|
|
|
|
/// which impls fail it. If all impls are correct, the returned slice is empty.
|
2021-05-09 18:53:13 +00:00
|
|
|
query orphan_check_impl(key: LocalDefId) -> Result<(), ErrorGuaranteed> {
|
|
|
|
desc { |tcx|
|
|
|
|
"checking whether impl `{}` follows the orphan rules",
|
2023-02-16 09:25:11 +00:00
|
|
|
tcx.def_path_str(key),
|
2021-10-21 13:36:35 +00:00
|
|
|
}
|
2024-01-23 15:23:22 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-10-21 13:36:35 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Check whether the function has any recursion that could cause the inliner to trigger
|
|
|
|
/// a cycle. Returns the call stack causing the cycle. The call stack does not contain the
|
|
|
|
/// current function, just all intermediate functions.
|
|
|
|
query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool {
|
|
|
|
fatal_cycle
|
|
|
|
desc { |tcx|
|
|
|
|
"computing if `{}` (transitively) calls `{}`",
|
|
|
|
key.0,
|
2023-02-16 09:25:11 +00:00
|
|
|
tcx.def_path_str(key.1),
|
2019-03-29 01:50:31 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Obtain all the calls into other local functions
|
2023-07-11 21:35:29 +00:00
|
|
|
query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, GenericArgsRef<'tcx>)] {
|
2021-01-31 20:40:03 +00:00
|
|
|
fatal_cycle
|
|
|
|
desc { |tcx|
|
|
|
|
"computing all local function calls in `{}`",
|
|
|
|
tcx.def_path_str(key.def_id()),
|
2020-05-31 15:11:51 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2021-01-02 18:45:11 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Evaluates a constant and returns the computed allocation.
|
|
|
|
///
|
2023-10-09 08:02:46 +00:00
|
|
|
/// **Do not use this** directly, use the `eval_to_const_value` or `eval_to_valtree` instead.
|
2021-01-31 20:40:03 +00:00
|
|
|
query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
|
|
|
|
-> EvalToAllocationRawResult<'tcx> {
|
|
|
|
desc { |tcx|
|
|
|
|
"const-evaluating + checking `{}`",
|
|
|
|
key.value.display(tcx)
|
2019-03-29 01:50:31 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
2021-01-02 18:45:11 +00:00
|
|
|
|
2023-10-09 08:02:46 +00:00
|
|
|
/// Evaluate a static's initializer, returning the allocation of the initializer's memory.
|
2023-10-10 08:52:21 +00:00
|
|
|
query eval_static_initializer(key: DefId) -> EvalStaticInitializerRawResult<'tcx> {
|
2023-10-09 08:02:46 +00:00
|
|
|
desc { |tcx|
|
|
|
|
"evaluating initializer of static `{}`",
|
|
|
|
tcx.def_path_str(key)
|
|
|
|
}
|
|
|
|
cache_on_disk_if { key.is_local() }
|
2023-10-09 12:20:26 +00:00
|
|
|
separate_provide_extern
|
2023-10-09 08:02:46 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Evaluates const items or anonymous constants
|
|
|
|
/// (such as enum variant explicit discriminants or array lengths)
|
|
|
|
/// into a representation suitable for the type system and const generics.
|
|
|
|
///
|
|
|
|
/// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`,
|
|
|
|
/// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`.
|
|
|
|
query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>)
|
|
|
|
-> EvalToConstValueResult<'tcx> {
|
|
|
|
desc { |tcx|
|
|
|
|
"simplifying constant for the type system `{}`",
|
|
|
|
key.value.display(tcx)
|
|
|
|
}
|
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
2021-01-02 18:45:11 +00:00
|
|
|
|
2022-04-12 16:14:28 +00:00
|
|
|
/// Evaluate a constant and convert it to a type level constant or
|
2021-02-22 14:09:24 +00:00
|
|
|
/// return `None` if that is not possible.
|
2022-04-12 16:14:28 +00:00
|
|
|
query eval_to_valtree(
|
|
|
|
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>
|
|
|
|
) -> EvalToValTreeResult<'tcx> {
|
2022-06-02 17:42:29 +00:00
|
|
|
desc { "evaluating type-level constant" }
|
2021-02-22 14:09:24 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 14:37:24 +00:00
|
|
|
/// Converts a type level constant value into `ConstValue`
|
2023-09-16 07:36:22 +00:00
|
|
|
query valtree_to_const_val(key: (Ty<'tcx>, ty::ValTree<'tcx>)) -> mir::ConstValue<'tcx> {
|
2022-06-02 17:42:29 +00:00
|
|
|
desc { "converting type-level constant value to mir constant value"}
|
2022-04-21 14:37:24 +00:00
|
|
|
}
|
|
|
|
|
2022-06-29 08:30:47 +00:00
|
|
|
/// Destructures array, ADT or tuple constants into the constants
|
|
|
|
/// of their fields.
|
2022-06-28 20:35:48 +00:00
|
|
|
query destructure_const(key: ty::Const<'tcx>) -> ty::DestructuredConst<'tcx> {
|
2022-06-02 17:42:29 +00:00
|
|
|
desc { "destructuring type level constant"}
|
2022-04-12 16:14:28 +00:00
|
|
|
}
|
|
|
|
|
2022-03-11 11:07:53 +00:00
|
|
|
// FIXME get rid of this with valtrees
|
2021-01-31 20:40:03 +00:00
|
|
|
query lit_to_const(
|
|
|
|
key: LitToConstInput<'tcx>
|
2022-02-02 03:24:45 +00:00
|
|
|
) -> Result<ty::Const<'tcx>, LitToConstError> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "converting literal to const" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-04-30 15:31:36 +00:00
|
|
|
query check_match(key: LocalDefId) -> Result<(), rustc_errors::ErrorGuaranteed> {
|
2023-02-16 09:34:53 +00:00
|
|
|
desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) }
|
2023-02-26 20:48:50 +00:00
|
|
|
cache_on_disk_if { true }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-09-22 13:19:53 +00:00
|
|
|
/// Performs part of the privacy check and computes effective visibilities.
|
|
|
|
query effective_visibilities(_: ()) -> &'tcx EffectiveVisibilities {
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
2022-09-22 13:19:53 +00:00
|
|
|
desc { "checking effective visibilities" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2024-01-27 13:55:15 +00:00
|
|
|
query check_private_in_public(_: ()) {
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "checking for private elements in public interfaces" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-02-21 11:07:17 +00:00
|
|
|
query reachable_set(_: ()) -> &'tcx LocalDefIdSet {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "reachability" }
|
2023-09-10 00:00:00 +00:00
|
|
|
cache_on_disk_if { true }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-05-25 05:52:32 +00:00
|
|
|
/// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body;
|
|
|
|
/// in the case of closures, this will be redirected to the enclosing function.
|
|
|
|
query region_scope_tree(def_id: DefId) -> &'tcx crate::middle::region::ScopeTree {
|
|
|
|
desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) }
|
|
|
|
}
|
|
|
|
|
2021-10-29 15:15:45 +00:00
|
|
|
/// Generates a MIR body for the shim.
|
2023-02-07 11:23:31 +00:00
|
|
|
query mir_shims(key: ty::InstanceDef<'tcx>) -> &'tcx mir::Body<'tcx> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// The `symbol_name` query provides the symbol name for calling a
|
|
|
|
/// given instance from the local crate. In particular, it will also
|
|
|
|
/// look up the correct symbol name of instances from upstream crates.
|
|
|
|
query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> {
|
|
|
|
desc { "computing the symbol for `{}`", key }
|
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
2020-12-23 15:24:29 +00:00
|
|
|
|
2023-11-23 21:49:02 +00:00
|
|
|
query def_kind(def_id: DefId) -> DefKind {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-12-23 15:24:29 +00:00
|
|
|
|
2021-10-29 15:15:45 +00:00
|
|
|
/// Gets the span for the definition.
|
2021-01-31 20:40:03 +00:00
|
|
|
query def_span(def_id: DefId) -> Span {
|
|
|
|
desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2022-12-01 10:33:28 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-10-29 15:15:45 +00:00
|
|
|
/// Gets the span for the identifier of the definition.
|
2021-01-31 20:40:03 +00:00
|
|
|
query def_ident_span(def_id: DefId) -> Option<Span> {
|
|
|
|
desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-02-19 14:36:11 +00:00
|
|
|
query lookup_stability(def_id: DefId) -> Option<attr::Stability> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-04-11 04:50:02 +00:00
|
|
|
|
2022-02-19 14:36:11 +00:00
|
|
|
query lookup_const_stability(def_id: DefId) -> Option<attr::ConstStability> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-04-27 14:14:19 +00:00
|
|
|
query lookup_default_body_stability(def_id: DefId) -> Option<attr::DefaultBodyStability> {
|
|
|
|
desc { |tcx| "looking up default body stability of `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-24 18:32:37 +00:00
|
|
|
query should_inherit_track_caller(def_id: DefId) -> bool {
|
|
|
|
desc { |tcx| "computing should_inherit_track_caller of `{}`", tcx.def_path_str(def_id) }
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query lookup_deprecation_entry(def_id: DefId) -> Option<DeprecationEntry> {
|
|
|
|
desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-05-13 20:40:22 +00:00
|
|
|
|
2022-03-12 22:27:51 +00:00
|
|
|
/// Determines whether an item is annotated with `doc(hidden)`.
|
|
|
|
query is_doc_hidden(def_id: DefId) -> bool {
|
|
|
|
desc { |tcx| "checking whether `{}` is `doc(hidden)`", tcx.def_path_str(def_id) }
|
2023-01-20 20:59:19 +00:00
|
|
|
separate_provide_extern
|
2022-03-12 22:27:51 +00:00
|
|
|
}
|
|
|
|
|
2022-09-28 00:06:38 +00:00
|
|
|
/// Determines whether an item is annotated with `doc(notable_trait)`.
|
|
|
|
query is_doc_notable_trait(def_id: DefId) -> bool {
|
|
|
|
desc { |tcx| "checking whether `{}` is `doc(notable_trait)`", tcx.def_path_str(def_id) }
|
|
|
|
}
|
|
|
|
|
2022-04-01 13:04:47 +00:00
|
|
|
/// Returns the attributes on the item at `def_id`.
|
|
|
|
///
|
|
|
|
/// Do not use this directly, use `tcx.get_attrs` instead.
|
2021-01-31 20:40:03 +00:00
|
|
|
query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] {
|
|
|
|
desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-01-30 20:28:16 +00:00
|
|
|
|
2023-02-07 11:23:31 +00:00
|
|
|
query codegen_fn_attrs(def_id: DefId) -> &'tcx CodegenFnAttrs {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) }
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-04-27 12:50:50 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2022-04-27 08:22:08 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-02-21 14:15:16 +00:00
|
|
|
query asm_target_features(def_id: DefId) -> &'tcx FxIndexSet<Symbol> {
|
2022-02-17 18:16:04 +00:00
|
|
|
desc { |tcx| "computing target features for inline asm of `{}`", tcx.def_path_str(def_id) }
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] {
|
|
|
|
desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
/// Gets the rendered value of the specified constant or associated constant.
|
|
|
|
/// Used by rustdoc.
|
2023-02-07 11:23:31 +00:00
|
|
|
query rendered_const(def_id: DefId) -> &'tcx String {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-08-18 02:13:37 +00:00
|
|
|
desc { |tcx| "rendering constant initializer of `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query impl_parent(def_id: DefId) -> Option<DefId> {
|
|
|
|
desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-09-16 20:34:57 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query is_ctfe_mir_available(key: DefId) -> bool {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "checking if item has CTFE MIR available: `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query is_mir_available(key: DefId) -> bool {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "checking if item has MIR available: `{}`", tcx.def_path_str(key) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { key.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-09-01 22:04:28 +00:00
|
|
|
query own_existential_vtable_entries(
|
2022-10-19 01:27:32 +00:00
|
|
|
key: DefId
|
2021-09-01 22:04:28 +00:00
|
|
|
) -> &'tcx [DefId] {
|
2022-10-19 01:27:32 +00:00
|
|
|
desc { |tcx| "finding all existential vtable entries for trait `{}`", tcx.def_path_str(key) }
|
2021-09-01 22:04:28 +00:00
|
|
|
}
|
|
|
|
|
2021-06-14 10:02:53 +00:00
|
|
|
query vtable_entries(key: ty::PolyTraitRef<'tcx>)
|
|
|
|
-> &'tcx [ty::VtblEntry<'tcx>] {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "finding all vtable entries for trait `{}`", tcx.def_path_str(key.def_id()) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-10-10 18:03:19 +00:00
|
|
|
query vtable_trait_upcasting_coercion_new_vptr_slot(key: (Ty<'tcx>, Ty<'tcx>)) -> Option<usize> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "finding the slot within vtable for trait object `{}` vtable ptr during trait upcasting coercion from `{}` vtable",
|
2021-08-18 04:45:18 +00:00
|
|
|
key.1, key.0 }
|
2021-07-31 14:46:23 +00:00
|
|
|
}
|
|
|
|
|
2021-10-07 09:29:01 +00:00
|
|
|
query vtable_allocation(key: (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>)) -> mir::interpret::AllocId {
|
|
|
|
desc { |tcx| "vtable const allocation for <{} as {}>",
|
|
|
|
key.0,
|
2023-07-25 20:00:13 +00:00
|
|
|
key.1.map(|trait_ref| format!("{trait_ref}")).unwrap_or("_".to_owned())
|
2021-10-07 09:29:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-09 11:36:27 +00:00
|
|
|
query codegen_select_candidate(
|
2023-07-04 01:18:31 +00:00
|
|
|
key: (ty::ParamEnv<'tcx>, ty::TraitRef<'tcx>)
|
2023-05-23 13:21:22 +00:00
|
|
|
) -> Result<&'tcx ImplSource<'tcx, ()>, CodegenObligationError> {
|
2021-01-31 20:40:03 +00:00
|
|
|
cache_on_disk_if { true }
|
2022-09-09 11:36:27 +00:00
|
|
|
desc { |tcx| "computing candidate for `{}`", key.1 }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Return all `impl` blocks in the current crate.
|
2022-01-25 23:40:10 +00:00
|
|
|
query all_local_trait_impls(_: ()) -> &'tcx rustc_data_structures::fx::FxIndexMap<DefId, Vec<LocalDefId>> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "finding local trait impls" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Given a trait `trait_id`, return all known `impl` blocks.
|
2023-02-07 11:23:31 +00:00
|
|
|
query trait_impls_of(trait_id: DefId) -> &'tcx ty::trait_def::TraitImpls {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "finding trait impls of `{}`", tcx.def_path_str(trait_id) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2024-01-11 10:05:12 +00:00
|
|
|
query specialization_graph_of(trait_id: DefId) -> Result<&'tcx specialization_graph::Graph, ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
|
|
|
|
cache_on_disk_if { true }
|
2024-01-23 15:23:22 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-05-23 13:21:22 +00:00
|
|
|
query object_safety_violations(trait_id: DefId) -> &'tcx [ObjectSafetyViolation] {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "determining object safety of trait `{}`", tcx.def_path_str(trait_id) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-01-28 15:07:21 +00:00
|
|
|
query check_is_object_safe(trait_id: DefId) -> bool {
|
|
|
|
desc { |tcx| "checking if trait `{}` is object safe", tcx.def_path_str(trait_id) }
|
2022-12-29 09:53:25 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
|
|
|
|
/// Gets the ParameterEnvironment for a given item; this environment
|
|
|
|
/// will be in "user-facing" mode, meaning that it is suitable for
|
|
|
|
/// type-checking etc, and it does not normalize specializable
|
|
|
|
/// associated types. This is almost always what you want,
|
|
|
|
/// unless you are doing MIR optimizations, in which case you
|
|
|
|
/// might want to use `reveal_all()` method to change modes.
|
|
|
|
query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
|
|
|
|
desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
|
2023-03-03 15:38:36 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-02-25 05:41:38 +00:00
|
|
|
/// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`,
|
|
|
|
/// as this method is more efficient.
|
|
|
|
query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> {
|
|
|
|
desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
|
|
|
|
/// `ty.is_copy()`, etc, since that will prune the environment where possible.
|
|
|
|
query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
|
|
|
desc { "computing whether `{}` is `Copy`", env.value }
|
|
|
|
}
|
Overhaul `TyS` and `Ty`.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
means we can move a lot of methods away from `TyS`, leaving `TyS` as a
barely-used type, which is appropriate given that it's not meant to
be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
than via `TyS`, which wasn't obvious at all.
Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs
Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
`Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
(pointer-based, for the `Equal` case) and partly on `TyS`
(contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
or `&`. They seem to be unavoidable.
2022-01-25 03:13:38 +00:00
|
|
|
/// Query backing `Ty::is_sized`.
|
2021-01-31 20:40:03 +00:00
|
|
|
query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
|
|
|
desc { "computing whether `{}` is `Sized`", env.value }
|
|
|
|
}
|
Overhaul `TyS` and `Ty`.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
means we can move a lot of methods away from `TyS`, leaving `TyS` as a
barely-used type, which is appropriate given that it's not meant to
be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
than via `TyS`, which wasn't obvious at all.
Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs
Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
`Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
(pointer-based, for the `Equal` case) and partly on `TyS`
(contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
or `&`. They seem to be unavoidable.
2022-01-25 03:13:38 +00:00
|
|
|
/// Query backing `Ty::is_freeze`.
|
2021-01-31 20:40:03 +00:00
|
|
|
query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
|
|
|
desc { "computing whether `{}` is freeze", env.value }
|
|
|
|
}
|
Overhaul `TyS` and `Ty`.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
means we can move a lot of methods away from `TyS`, leaving `TyS` as a
barely-used type, which is appropriate given that it's not meant to
be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
than via `TyS`, which wasn't obvious at all.
Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs
Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
`Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
(pointer-based, for the `Equal` case) and partly on `TyS`
(contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
or `&`. They seem to be unavoidable.
2022-01-25 03:13:38 +00:00
|
|
|
/// Query backing `Ty::is_unpin`.
|
2021-03-18 21:44:36 +00:00
|
|
|
query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
|
|
|
desc { "computing whether `{}` is `Unpin`", env.value }
|
|
|
|
}
|
Overhaul `TyS` and `Ty`.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
means we can move a lot of methods away from `TyS`, leaving `TyS` as a
barely-used type, which is appropriate given that it's not meant to
be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
than via `TyS`, which wasn't obvious at all.
Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs
Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
`Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
(pointer-based, for the `Equal` case) and partly on `TyS`
(contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
or `&`. They seem to be unavoidable.
2022-01-25 03:13:38 +00:00
|
|
|
/// Query backing `Ty::needs_drop`.
|
2021-01-31 20:40:03 +00:00
|
|
|
query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
|
|
|
desc { "computing whether `{}` needs drop", env.value }
|
|
|
|
}
|
Overhaul `TyS` and `Ty`.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
means we can move a lot of methods away from `TyS`, leaving `TyS` as a
barely-used type, which is appropriate given that it's not meant to
be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
than via `TyS`, which wasn't obvious at all.
Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs
Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
`Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
(pointer-based, for the `Equal` case) and partly on `TyS`
(contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
or `&`. They seem to be unavoidable.
2022-01-25 03:13:38 +00:00
|
|
|
/// Query backing `Ty::has_significant_drop_raw`.
|
2021-04-13 07:43:11 +00:00
|
|
|
query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
|
|
|
|
desc { "computing whether `{}` has a significant drop", env.value }
|
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
|
Overhaul `TyS` and `Ty`.
Specifically, change `Ty` from this:
```
pub type Ty<'tcx> = &'tcx TyS<'tcx>;
```
to this
```
pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>);
```
There are two benefits to this.
- It's now a first class type, so we can define methods on it. This
means we can move a lot of methods away from `TyS`, leaving `TyS` as a
barely-used type, which is appropriate given that it's not meant to
be used directly.
- The uniqueness requirement is now explicit, via the `Interned` type.
E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather
than via `TyS`, which wasn't obvious at all.
Much of this commit is boring churn. The interesting changes are in
these files:
- compiler/rustc_middle/src/arena.rs
- compiler/rustc_middle/src/mir/visit.rs
- compiler/rustc_middle/src/ty/context.rs
- compiler/rustc_middle/src/ty/mod.rs
Specifically:
- Most mentions of `TyS` are removed. It's very much a dumb struct now;
`Ty` has all the smarts.
- `TyS` now has `crate` visibility instead of `pub`.
- `TyS::make_for_test` is removed in favour of the static `BOOL_TY`,
which just works better with the new structure.
- The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls
of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned`
(pointer-based, for the `Equal` case) and partly on `TyS`
(contents-based, for the other cases).
- There are many tedious sigil adjustments, i.e. adding or removing `*`
or `&`. They seem to be unavoidable.
2022-01-25 03:13:38 +00:00
|
|
|
/// Query backing `Ty::is_structural_eq_shallow`.
|
2021-01-31 20:40:03 +00:00
|
|
|
///
|
|
|
|
/// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types
|
|
|
|
/// correctly.
|
2023-09-26 07:39:41 +00:00
|
|
|
query has_structural_eq_impl(ty: Ty<'tcx>) -> bool {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc {
|
2023-09-26 07:39:41 +00:00
|
|
|
"computing whether `{}` implements `StructuralPartialEq`",
|
2021-01-31 20:40:03 +00:00
|
|
|
ty
|
2019-03-29 01:50:31 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// A list of types where the ADT requires drop if and only if any of
|
|
|
|
/// those types require drop. If the ADT is known to always need drop
|
|
|
|
/// then `Err(AlwaysRequiresDrop)` is returned.
|
|
|
|
query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
|
|
|
|
desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) }
|
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
|
|
|
|
2021-04-13 07:43:11 +00:00
|
|
|
/// A list of types where the ADT requires drop if and only if any of those types
|
|
|
|
/// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
|
|
|
|
/// is considered to not be significant. A drop is significant if it is implemented
|
|
|
|
/// by the user or does anything that will have any observable behavior (other than
|
|
|
|
/// freeing up memory). If the ADT is known to have a significant destructor then
|
|
|
|
/// `Err(AlwaysRequiresDrop)` is returned.
|
|
|
|
query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
|
|
|
|
desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
|
|
|
|
cache_on_disk_if { false }
|
|
|
|
}
|
|
|
|
|
2021-08-24 18:29:30 +00:00
|
|
|
/// Computes the layout of a type. Note that this implicitly
|
|
|
|
/// executes in "reveal all" mode, and will normalize the input type.
|
|
|
|
query layout_of(
|
|
|
|
key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
|
2023-04-30 21:05:27 +00:00
|
|
|
) -> Result<ty::layout::TyAndLayout<'tcx>, &'tcx ty::layout::LayoutError<'tcx>> {
|
2022-08-24 01:42:12 +00:00
|
|
|
depth_limit
|
2021-08-24 18:29:30 +00:00
|
|
|
desc { "computing layout of `{}`", key.value }
|
2023-11-08 06:56:06 +00:00
|
|
|
// we emit our own error during query cycle handling
|
|
|
|
cycle_delay_bug
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
2021-09-01 21:29:15 +00:00
|
|
|
/// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
|
|
|
|
///
|
|
|
|
/// NB: this doesn't handle virtual calls - those should use `fn_abi_of_instance`
|
|
|
|
/// instead, where the instance is an `InstanceDef::Virtual`.
|
|
|
|
query fn_abi_of_fn_ptr(
|
|
|
|
key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
|
2023-04-30 21:14:53 +00:00
|
|
|
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
|
2021-09-01 21:29:15 +00:00
|
|
|
desc { "computing call ABI of `{}` function pointers", key.value.0 }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
|
|
|
|
/// direct calls to an `fn`.
|
|
|
|
///
|
|
|
|
/// NB: that includes virtual calls, which are represented by "direct calls"
|
|
|
|
/// to an `InstanceDef::Virtual` instance (of `<dyn Trait as Trait>::fn`).
|
|
|
|
query fn_abi_of_instance(
|
|
|
|
key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
|
2023-04-30 21:14:53 +00:00
|
|
|
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, &'tcx ty::layout::FnAbiError<'tcx>> {
|
2021-09-01 21:29:15 +00:00
|
|
|
desc { "computing call ABI of `{}`", key.value.0 }
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query dylib_dependency_formats(_: CrateNum)
|
|
|
|
-> &'tcx [(CrateNum, LinkagePreference)] {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting dylib dependency formats of crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
2023-02-07 11:23:31 +00:00
|
|
|
query dependency_formats(_: ()) -> &'tcx Lrc<crate::middle::dependency_format::Dependencies> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting the linkage format of all dependencies" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
query is_compiler_builtins(_: CrateNum) -> bool {
|
|
|
|
fatal_cycle
|
|
|
|
desc { "checking if the crate is_compiler_builtins" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query has_global_allocator(_: CrateNum) -> bool {
|
2021-04-16 20:28:54 +00:00
|
|
|
// This query depends on untracked global state in CStore
|
|
|
|
eval_always
|
2021-01-31 20:40:03 +00:00
|
|
|
fatal_cycle
|
|
|
|
desc { "checking if the crate has_global_allocator" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-04-24 22:08:35 +00:00
|
|
|
query has_alloc_error_handler(_: CrateNum) -> bool {
|
|
|
|
// This query depends on untracked global state in CStore
|
|
|
|
eval_always
|
|
|
|
fatal_cycle
|
|
|
|
desc { "checking if the crate has_alloc_error_handler" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
query has_panic_handler(_: CrateNum) -> bool {
|
|
|
|
fatal_cycle
|
|
|
|
desc { "checking if the crate has_panic_handler" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query is_profiler_runtime(_: CrateNum) -> bool {
|
|
|
|
fatal_cycle
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "checking if a crate is `#![profiler_runtime]`" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-05-18 02:51:52 +00:00
|
|
|
query has_ffi_unwind_calls(key: LocalDefId) -> bool {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "checking if `{}` contains FFI-unwind calls", tcx.def_path_str(key) }
|
2022-05-18 02:51:52 +00:00
|
|
|
cache_on_disk_if { true }
|
|
|
|
}
|
2022-06-08 20:32:17 +00:00
|
|
|
query required_panic_strategy(_: CrateNum) -> Option<PanicStrategy> {
|
2021-01-31 20:40:03 +00:00
|
|
|
fatal_cycle
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting a crate's required panic strategy" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2021-09-09 12:31:19 +00:00
|
|
|
query panic_in_drop_strategy(_: CrateNum) -> PanicStrategy {
|
|
|
|
fatal_cycle
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting a crate's configured panic-in-drop strategy" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-09-09 12:31:19 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
query is_no_builtins(_: CrateNum) -> bool {
|
|
|
|
fatal_cycle
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting whether a crate has `#![no_builtins]`" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion {
|
|
|
|
fatal_cycle
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting a crate's symbol mangling version" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> {
|
|
|
|
eval_always
|
|
|
|
desc { "getting crate's ExternCrateData" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
query specializes(_: (DefId, DefId)) -> bool {
|
|
|
|
desc { "computing whether impls specialize one another" }
|
|
|
|
}
|
2022-09-20 05:11:23 +00:00
|
|
|
query in_scope_traits_map(_: hir::OwnerId)
|
2023-12-18 20:02:21 +00:00
|
|
|
-> Option<&'tcx ItemLocalMap<Box<[TraitCandidate]>>> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting traits in scope at a block" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
2023-06-01 06:14:06 +00:00
|
|
|
/// Returns whether the impl or associated function has the `default` keyword.
|
|
|
|
query defaultness(def_id: DefId) -> hir::Defaultness {
|
|
|
|
desc { |tcx| "looking up whether `{}` has `default`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
2023-10-18 08:47:17 +00:00
|
|
|
query check_well_formed(key: hir::OwnerId) -> Result<(), ErrorGuaranteed> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key) }
|
2023-10-18 15:53:06 +00:00
|
|
|
ensure_forwards_result_if_red
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The `DefId`s of all non-generic functions and statics in the given crate
|
|
|
|
// that can be reached from outside the crate.
|
|
|
|
//
|
|
|
|
// We expect this items to be available for being linked to.
|
|
|
|
//
|
|
|
|
// This query can also be called for `LOCAL_CRATE`. In this case it will
|
|
|
|
// compute which items will be reachable to other crates, taking into account
|
|
|
|
// the kind of crate that is currently compiled. Crates with only a
|
|
|
|
// C interface have fewer reachable things.
|
|
|
|
//
|
|
|
|
// Does not include external symbols that don't have a corresponding DefId,
|
|
|
|
// like the compiler-generated `main` function and so on.
|
|
|
|
query reachable_non_generics(_: CrateNum)
|
2023-02-07 11:23:31 +00:00
|
|
|
-> &'tcx DefIdMap<SymbolExportInfo> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "looking up the exported symbols of a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query is_reachable_non_generic(def_id: DefId) -> bool {
|
|
|
|
desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) }
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { def_id.is_local() }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2021-05-11 09:35:50 +00:00
|
|
|
query is_unreachable_local_definition(def_id: LocalDefId) -> bool {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx|
|
|
|
|
"checking whether `{}` is reachable from outside the crate",
|
2023-02-16 09:25:11 +00:00
|
|
|
tcx.def_path_str(def_id),
|
2020-05-31 15:11:51 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// The entire set of monomorphizations the local crate can safely link
|
|
|
|
/// to because they are exported from upstream crates. Do not depend on
|
|
|
|
/// this directly, as its value changes anytime a monomorphization gets
|
|
|
|
/// added or removed in any upstream crate. Instead use the narrower
|
|
|
|
/// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even
|
|
|
|
/// better, `Instance::upstream_monomorphization()`.
|
2023-12-21 10:12:01 +00:00
|
|
|
query upstream_monomorphizations(_: ()) -> &'tcx DefIdMap<UnordMap<GenericArgsRef<'tcx>, CrateNum>> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-05-11 12:39:04 +00:00
|
|
|
desc { "collecting available upstream monomorphizations" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns the set of upstream monomorphizations available for the
|
|
|
|
/// generic function identified by the given `def_id`. The query makes
|
|
|
|
/// sure to make a stable selection if the same monomorphization is
|
|
|
|
/// available in multiple upstream crates.
|
|
|
|
///
|
|
|
|
/// You likely want to call `Instance::upstream_monomorphization()`
|
|
|
|
/// instead of invoking this query directly.
|
|
|
|
query upstream_monomorphizations_for(def_id: DefId)
|
2023-12-21 10:12:01 +00:00
|
|
|
-> Option<&'tcx UnordMap<GenericArgsRef<'tcx>, CrateNum>>
|
2022-01-31 18:55:34 +00:00
|
|
|
{
|
|
|
|
desc { |tcx|
|
|
|
|
"collecting available upstream monomorphizations for `{}`",
|
|
|
|
tcx.def_path_str(def_id),
|
2020-05-31 15:11:51 +00:00
|
|
|
}
|
2022-01-31 18:55:34 +00:00
|
|
|
separate_provide_extern
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns the upstream crate that exports drop-glue for the given
|
2023-07-11 21:35:29 +00:00
|
|
|
/// type (`args` is expected to be a single-item list containing the
|
2021-01-31 20:40:03 +00:00
|
|
|
/// type one wants drop-glue for).
|
|
|
|
///
|
|
|
|
/// This is a subset of `upstream_monomorphizations_for` in order to
|
|
|
|
/// increase dep-tracking granularity. Otherwise adding or removing any
|
|
|
|
/// type with drop-glue in any upstream crate would invalidate all
|
|
|
|
/// functions calling drop-glue of an upstream type.
|
|
|
|
///
|
|
|
|
/// You likely want to call `Instance::upstream_monomorphization()`
|
|
|
|
/// instead of invoking this query directly.
|
|
|
|
///
|
|
|
|
/// NOTE: This query could easily be extended to also support other
|
|
|
|
/// common functions that have are large set of monomorphizations
|
|
|
|
/// (like `Clone::clone` for example).
|
2023-07-11 21:35:29 +00:00
|
|
|
query upstream_drop_glue_for(args: GenericArgsRef<'tcx>) -> Option<CrateNum> {
|
|
|
|
desc { "available upstream drop-glue for `{:?}`", args }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-11-05 16:54:15 +00:00
|
|
|
/// Returns a list of all `extern` blocks of a crate.
|
2023-07-15 10:17:37 +00:00
|
|
|
query foreign_modules(_: CrateNum) -> &'tcx FxIndexMap<DefId, ForeignModule> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "looking up the foreign modules of a linked crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-07-15 08:38:50 +00:00
|
|
|
/// Lint against `extern fn` declarations having incompatible types.
|
|
|
|
query clashing_extern_declarations(_: ()) {
|
|
|
|
desc { "checking `extern fn` declarations are compatible" }
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Identifies the entry-point (e.g., the `main` function) for a given
|
|
|
|
/// crate, returning `None` if there is no entry point (such as for library crates).
|
2021-05-11 10:00:59 +00:00
|
|
|
query entry_fn(_: ()) -> Option<(DefId, EntryFnType)> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "looking up the entry function of a crate" }
|
|
|
|
}
|
2022-11-05 16:54:15 +00:00
|
|
|
|
|
|
|
/// Finds the `rustc_proc_macro_decls` item of a crate.
|
2021-05-11 10:12:52 +00:00
|
|
|
query proc_macro_decls_static(_: ()) -> Option<LocalDefId> {
|
2022-11-05 16:54:15 +00:00
|
|
|
desc { "looking up the proc macro declarations for a crate" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-11-05 16:54:15 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
// The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
|
|
|
|
// Changing the name should cause a compiler error, but in case that changes, be aware.
|
|
|
|
query crate_hash(_: CrateNum) -> Svh {
|
|
|
|
eval_always
|
|
|
|
desc { "looking up the hash a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-11-05 16:54:15 +00:00
|
|
|
|
|
|
|
/// Gets the hash for the host proc macro. Used to support -Z dual-proc-macro.
|
2021-01-31 20:40:03 +00:00
|
|
|
query crate_host_hash(_: CrateNum) -> Option<Svh> {
|
|
|
|
eval_always
|
|
|
|
desc { "looking up the hash of a host version of a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-11-05 16:54:15 +00:00
|
|
|
|
|
|
|
/// Gets the extra data to put in each output filename for a crate.
|
|
|
|
/// For example, compiling the `foo` crate with `extra-filename=-a` creates a `libfoo-b.rlib` file.
|
2023-02-07 11:23:31 +00:00
|
|
|
query extra_filename(_: CrateNum) -> &'tcx String {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "looking up the extra filename for a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-11-05 16:54:15 +00:00
|
|
|
|
|
|
|
/// Gets the paths where the crate came from in the file system.
|
2023-02-07 11:23:31 +00:00
|
|
|
query crate_extern_paths(_: CrateNum) -> &'tcx Vec<PathBuf> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "looking up the paths for extern crates" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Given a crate and a trait, look up all impls of that trait in the crate.
|
|
|
|
/// Return `(impl_id, self_ty)`.
|
2022-01-06 04:02:00 +00:00
|
|
|
query implementations_of_trait(_: (CrateNum, DefId)) -> &'tcx [(DefId, Option<SimplifiedType>)] {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "looking up implementations of a trait in a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-12-23 15:24:29 +00:00
|
|
|
|
2022-03-15 15:30:30 +00:00
|
|
|
/// Collects all incoherent impls for the given crate and type.
|
|
|
|
///
|
|
|
|
/// Do not call this directly, but instead use the `incoherent_impls` query.
|
|
|
|
/// This query is only used to get the data necessary for that query.
|
2024-01-12 14:29:54 +00:00
|
|
|
query crate_incoherent_impls(key: (CrateNum, SimplifiedType)) -> Result<&'tcx [DefId], ErrorGuaranteed> {
|
2022-03-15 15:30:30 +00:00
|
|
|
desc { |tcx| "collecting all impls for a type in a crate" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2022-11-05 16:54:15 +00:00
|
|
|
/// Get the corresponding native library from the `native_libraries` query
|
2022-07-12 20:52:35 +00:00
|
|
|
query native_library(def_id: DefId) -> Option<&'tcx NativeLib> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { |tcx| "getting the native library for `{}`", tcx.def_path_str(def_id) }
|
2022-07-12 20:52:35 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-03-12 17:38:42 +00:00
|
|
|
/// Does lifetime resolution on items. Importantly, we can't resolve
|
|
|
|
/// lifetimes directly on things like trait methods, because of trait params.
|
2023-03-03 03:10:46 +00:00
|
|
|
/// See `rustc_resolve::late::lifetimes` for details.
|
2023-02-06 18:38:52 +00:00
|
|
|
query resolve_bound_vars(_: hir::OwnerId) -> &'tcx ResolveBoundVars {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "resolving lifetimes" }
|
|
|
|
}
|
2023-02-06 18:38:52 +00:00
|
|
|
query named_variable_map(_: hir::OwnerId) ->
|
2023-12-21 10:30:01 +00:00
|
|
|
Option<&'tcx FxIndexMap<ItemLocalId, ResolvedArg>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "looking up a named region" }
|
|
|
|
}
|
2022-11-05 15:33:58 +00:00
|
|
|
query is_late_bound_map(_: hir::OwnerId) -> Option<&'tcx FxIndexSet<ItemLocalId>> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "testing if a region is late bound" }
|
|
|
|
}
|
2022-08-30 20:47:58 +00:00
|
|
|
/// For a given item's generic parameter, gets the default lifetimes to be used
|
2021-04-19 12:57:08 +00:00
|
|
|
/// for each parameter if a trait object were to be passed for that parameter.
|
2022-08-30 20:47:58 +00:00
|
|
|
/// For example, for `T` in `struct Foo<'a, T>`, this would be `'static`.
|
|
|
|
/// For `T` in `struct Foo<'a, T: 'a>`, this would instead be `'a`.
|
|
|
|
/// This query will panic if passed something that is not a type parameter.
|
|
|
|
query object_lifetime_default(key: DefId) -> ObjectLifetimeDefault {
|
|
|
|
desc { "looking up lifetime defaults for generic parameter `{}`", tcx.def_path_str(key) }
|
2022-05-29 18:15:34 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-09-20 05:11:23 +00:00
|
|
|
query late_bound_vars_map(_: hir::OwnerId)
|
2023-12-21 10:30:01 +00:00
|
|
|
-> Option<&'tcx FxIndexMap<ItemLocalId, Vec<ty::BoundVariableKind>>> {
|
2020-10-26 18:18:31 +00:00
|
|
|
desc { "looking up late bound vars" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-09-13 15:27:56 +00:00
|
|
|
/// Computes the visibility of the provided `def_id`.
|
|
|
|
///
|
|
|
|
/// If the item from the `def_id` doesn't have a visibility, it will panic. For example
|
|
|
|
/// a generic type parameter will panic if you call this method on it:
|
|
|
|
///
|
|
|
|
/// ```
|
2022-11-20 02:10:45 +00:00
|
|
|
/// use std::fmt::Debug;
|
|
|
|
///
|
2022-09-13 15:27:56 +00:00
|
|
|
/// pub trait Foo<T: Debug> {}
|
|
|
|
/// ```
|
|
|
|
///
|
|
|
|
/// In here, if you call `visibility` on `T`, it'll panic.
|
2022-08-27 21:10:06 +00:00
|
|
|
query visibility(def_id: DefId) -> ty::Visibility<DefId> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-02-28 16:05:37 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2020-12-03 00:25:04 +00:00
|
|
|
|
2022-10-04 14:22:39 +00:00
|
|
|
query inhabited_predicate_adt(key: DefId) -> ty::inhabitedness::InhabitedPredicate<'tcx> {
|
|
|
|
desc { "computing the uninhabited predicate of `{:?}`", key }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Do not call this query directly: invoke `Ty::inhabited_predicate` instead.
|
|
|
|
query inhabited_predicate_type(key: Ty<'tcx>) -> ty::inhabitedness::InhabitedPredicate<'tcx> {
|
|
|
|
desc { "computing the uninhabited predicate of `{}`", key }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query dep_kind(_: CrateNum) -> CrateDepKind {
|
|
|
|
eval_always
|
|
|
|
desc { "fetching what a dependency looks like" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2021-10-29 15:15:45 +00:00
|
|
|
|
|
|
|
/// Gets the name of the crate.
|
2021-01-31 20:40:03 +00:00
|
|
|
query crate_name(_: CrateNum) -> Symbol {
|
2022-12-05 16:37:44 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "fetching what a crate is named" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2021-12-21 03:24:43 +00:00
|
|
|
query module_children(def_id: DefId) -> &'tcx [ModChild] {
|
|
|
|
desc { |tcx| "collecting child items of module `{}`", tcx.def_path_str(def_id) }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
|
|
|
query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option<CrateNum> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-09-23 05:38:49 +00:00
|
|
|
query lib_features(_: CrateNum) -> &'tcx LibFeatures {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "calculating the lib features defined in a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2023-09-23 05:38:49 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-12-21 09:52:27 +00:00
|
|
|
query stability_implications(_: CrateNum) -> &'tcx UnordMap<Symbol, Symbol> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-07-13 14:10:19 +00:00
|
|
|
desc { "calculating the implications between `#[unstable]` features defined in a crate" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
2022-05-13 13:50:21 +00:00
|
|
|
/// Whether the function is an intrinsic
|
2024-02-19 17:35:12 +00:00
|
|
|
query intrinsic(def_id: DefId) -> Option<rustc_middle::ty::IntrinsicDef> {
|
2024-01-30 14:20:22 +00:00
|
|
|
desc { |tcx| "fetch intrinsic name if `{}` is an intrinsic", tcx.def_path_str(def_id) }
|
2022-05-13 13:50:21 +00:00
|
|
|
separate_provide_extern
|
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns the lang items defined in another crate by loading it from metadata.
|
2023-02-07 11:23:31 +00:00
|
|
|
query get_lang_items(_: ()) -> &'tcx LanguageItems {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "calculating the lang items map" }
|
|
|
|
}
|
2019-05-19 18:16:04 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns all diagnostic items defined in all crates.
|
2023-02-07 11:23:31 +00:00
|
|
|
query all_diagnostic_items(_: ()) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "calculating the diagnostic items map" }
|
|
|
|
}
|
2019-05-19 18:16:04 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns the lang items defined in another crate by loading it from metadata.
|
2022-10-26 21:18:29 +00:00
|
|
|
query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, LangItem)] {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "calculating the lang items defined in a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-05-19 18:16:04 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Returns the diagnostic items defined in a crate.
|
2023-02-07 11:23:31 +00:00
|
|
|
query diagnostic_items(_: CrateNum) -> &'tcx rustc_hir::diagnostic_items::DiagnosticItems {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "calculating the diagnostic items map in a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-05-19 18:16:04 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] {
|
|
|
|
desc { "calculating the missing lang items in a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-11-19 16:26:24 +00:00
|
|
|
|
|
|
|
/// The visible parent map is a map from every item to a visible parent.
|
|
|
|
/// It prefers the shortest visible path to an item.
|
|
|
|
/// Used for diagnostics, for example path trimming.
|
|
|
|
/// The parents are modules, enums or traits.
|
2023-02-07 11:23:31 +00:00
|
|
|
query visible_parent_map(_: ()) -> &'tcx DefIdMap<DefId> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "calculating the visible parent map" }
|
|
|
|
}
|
2023-11-19 16:26:24 +00:00
|
|
|
/// Collects the "trimmed", shortest accessible paths to all items for diagnostics.
|
|
|
|
/// See the [provider docs](`rustc_middle::ty::print::trimmed_def_paths`) for more info.
|
2023-12-21 11:27:04 +00:00
|
|
|
query trimmed_def_paths(_: ()) -> &'tcx DefIdMap<Symbol> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "calculating trimmed def paths" }
|
|
|
|
}
|
|
|
|
query missing_extern_crate_item(_: CrateNum) -> bool {
|
|
|
|
eval_always
|
|
|
|
desc { "seeing if we're missing an `extern crate` item for this crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-02-07 11:23:31 +00:00
|
|
|
query used_crate_source(_: CrateNum) -> &'tcx Lrc<CrateSource> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "looking at the source for a crate" }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-05-16 16:50:05 +00:00
|
|
|
|
2022-04-26 01:02:43 +00:00
|
|
|
/// Returns the debugger visualizers defined for this crate.
|
2023-05-16 16:50:05 +00:00
|
|
|
/// NOTE: This query has to be marked `eval_always` because it reads data
|
|
|
|
/// directly from disk that is not tracked anywhere else. I.e. it
|
|
|
|
/// represents a genuine input to the query system.
|
2023-05-16 19:03:28 +00:00
|
|
|
query debugger_visualizers(_: CrateNum) -> &'tcx Vec<DebuggerVisualizerFile> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2022-04-26 01:02:43 +00:00
|
|
|
desc { "looking up the debugger visualizers for this crate" }
|
|
|
|
separate_provide_extern
|
2023-05-16 16:50:05 +00:00
|
|
|
eval_always
|
2022-04-26 01:02:43 +00:00
|
|
|
}
|
2023-05-16 16:50:05 +00:00
|
|
|
|
2021-05-11 12:50:54 +00:00
|
|
|
query postorder_cnums(_: ()) -> &'tcx [CrateNum] {
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "generating a postorder list of CrateNums" }
|
|
|
|
}
|
2021-05-11 20:06:07 +00:00
|
|
|
/// Returns whether or not the crate with CrateNum 'cnum'
|
|
|
|
/// is marked as a private dependency
|
|
|
|
query is_private_dep(c: CrateNum) -> bool {
|
|
|
|
eval_always
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "checking whether crate `{}` is a private dependency", c }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-05-11 20:06:07 +00:00
|
|
|
}
|
2021-05-11 20:05:54 +00:00
|
|
|
query allocator_kind(_: ()) -> Option<AllocatorKind> {
|
|
|
|
eval_always
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting the allocator kind for the current crate" }
|
2021-05-11 20:05:54 +00:00
|
|
|
}
|
2023-04-24 22:08:35 +00:00
|
|
|
query alloc_error_handler_kind(_: ()) -> Option<AllocatorKind> {
|
|
|
|
eval_always
|
|
|
|
desc { "alloc error handler kind for the current crate" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap<hir::HirId, hir::Upvar>> {
|
|
|
|
desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) }
|
|
|
|
}
|
2022-05-31 23:59:28 +00:00
|
|
|
query maybe_unused_trait_imports(_: ()) -> &'tcx FxIndexSet<LocalDefId> {
|
|
|
|
desc { "fetching potentially unused trait imports" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2023-02-21 14:18:10 +00:00
|
|
|
query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx UnordSet<Symbol> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "finding names imported by glob use for `{}`", tcx.def_path_str(def_id) }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-02-07 11:23:31 +00:00
|
|
|
query stability_index(_: ()) -> &'tcx stability::Index {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "calculating the stability index for the local crate" }
|
|
|
|
}
|
2021-06-07 09:03:17 +00:00
|
|
|
query crates(_: ()) -> &'tcx [CrateNum] {
|
2021-07-12 19:20:16 +00:00
|
|
|
eval_always
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "fetching all foreign CrateNum instances" }
|
|
|
|
}
|
2024-02-14 18:40:45 +00:00
|
|
|
// Crates that are loaded non-speculatively (not for diagnostics or doc links).
|
|
|
|
// FIXME: This is currently only used for collecting lang items, but should be used instead of
|
|
|
|
// `crates` in most other cases too.
|
|
|
|
query used_crates(_: ()) -> &'tcx [CrateNum] {
|
|
|
|
eval_always
|
|
|
|
desc { "fetching `CrateNum`s for all crates loaded non-speculatively" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-12-24 03:09:32 +00:00
|
|
|
/// A list of all traits in a crate, used by rustdoc and error reporting.
|
2023-05-23 13:21:22 +00:00
|
|
|
query traits(_: CrateNum) -> &'tcx [DefId] {
|
2021-12-24 03:09:32 +00:00
|
|
|
desc { "fetching all traits in a crate" }
|
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-02-05 19:05:46 +00:00
|
|
|
query trait_impls_in_crate(_: CrateNum) -> &'tcx [DefId] {
|
|
|
|
desc { "fetching all trait impls in a crate" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// The list of symbols exported from the given crate.
|
|
|
|
///
|
|
|
|
/// - All names contained in `exported_symbols(cnum)` are guaranteed to
|
|
|
|
/// correspond to a publicly visible symbol in `cnum` machine code.
|
|
|
|
/// - The `exported_symbols` sets of different crates do not intersect.
|
2022-03-28 17:53:01 +00:00
|
|
|
query exported_symbols(cnum: CrateNum) -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportInfo)] {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "collecting exported symbols for crate `{}`", cnum}
|
2022-03-28 17:53:01 +00:00
|
|
|
cache_on_disk_if { *cnum == LOCAL_CRATE }
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-05-11 12:39:04 +00:00
|
|
|
query collect_and_partition_mono_items(_: ()) -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) {
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "collect_and_partition_mono_items" }
|
|
|
|
}
|
2022-10-17 19:30:41 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query is_codegened_item(def_id: DefId) -> bool {
|
|
|
|
desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) }
|
|
|
|
}
|
2021-03-13 00:00:00 +00:00
|
|
|
|
2022-10-17 19:30:41 +00:00
|
|
|
query codegen_unit(sym: Symbol) -> &'tcx CodegenUnit<'tcx> {
|
|
|
|
desc { "getting codegen unit `{sym}`" }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-10-17 19:30:41 +00:00
|
|
|
|
2022-12-01 17:57:53 +00:00
|
|
|
query unused_generic_params(key: ty::InstanceDef<'tcx>) -> UnusedGenericParams {
|
2021-10-01 17:08:06 +00:00
|
|
|
cache_on_disk_if { key.def_id().is_local() }
|
2021-01-31 20:40:03 +00:00
|
|
|
desc {
|
|
|
|
|tcx| "determining which generic parameters are unused by `{}`",
|
2021-10-01 17:08:06 +00:00
|
|
|
tcx.def_path_str(key.def_id())
|
2019-03-29 01:50:31 +00:00
|
|
|
}
|
2021-05-30 15:24:54 +00:00
|
|
|
separate_provide_extern
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2022-10-17 19:30:41 +00:00
|
|
|
|
2021-05-11 12:39:04 +00:00
|
|
|
query backend_optimization_level(_: ()) -> OptLevel {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "optimization level used by backend" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2022-02-01 17:46:04 +00:00
|
|
|
/// Return the filenames where output artefacts shall be stored.
|
|
|
|
///
|
|
|
|
/// This query returns an `&Arc` because codegen backends need the value even after the `TyCtxt`
|
|
|
|
/// has been destroyed.
|
2023-02-07 11:23:31 +00:00
|
|
|
query output_filenames(_: ()) -> &'tcx Arc<OutputFilenames> {
|
2022-12-05 17:00:26 +00:00
|
|
|
feedable
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "getting output filenames" }
|
2023-01-23 10:25:51 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2024-02-20 09:34:51 +00:00
|
|
|
/// <div class="warning">
|
|
|
|
///
|
|
|
|
/// Do not call this query directly: Invoke `normalize` instead.
|
|
|
|
///
|
|
|
|
/// </div>
|
|
|
|
query normalize_canonicalized_projection_ty(
|
|
|
|
goal: CanonicalAliasGoal<'tcx>
|
2021-01-31 20:40:03 +00:00
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "normalizing `{}`", goal.value.value }
|
2023-03-21 00:46:52 +00:00
|
|
|
}
|
|
|
|
|
2024-02-20 09:34:51 +00:00
|
|
|
/// <div class="warning">
|
|
|
|
///
|
|
|
|
/// Do not call this query directly: Invoke `normalize` instead.
|
|
|
|
///
|
|
|
|
/// </div>
|
|
|
|
query normalize_canonicalized_weak_ty(
|
|
|
|
goal: CanonicalAliasGoal<'tcx>
|
2023-03-07 12:03:11 +00:00
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
|
|
|
desc { "normalizing `{}`", goal.value.value }
|
|
|
|
}
|
|
|
|
|
2024-02-20 09:34:51 +00:00
|
|
|
/// <div class="warning">
|
|
|
|
///
|
|
|
|
/// Do not call this query directly: Invoke `normalize` instead.
|
|
|
|
///
|
|
|
|
/// </div>
|
|
|
|
query normalize_canonicalized_inherent_projection_ty(
|
|
|
|
goal: CanonicalAliasGoal<'tcx>
|
2023-03-21 00:46:52 +00:00
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
|
|
|
desc { "normalizing `{}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-11-26 16:41:22 +00:00
|
|
|
/// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
|
|
|
|
query try_normalize_generic_arg_after_erasing_regions(
|
|
|
|
goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
|
|
|
|
) -> Result<GenericArg<'tcx>, NoSolution> {
|
2021-11-26 22:41:22 +00:00
|
|
|
desc { "normalizing `{}`", goal.value }
|
2021-11-26 16:41:22 +00:00
|
|
|
}
|
|
|
|
|
2023-12-11 01:13:21 +00:00
|
|
|
query implied_outlives_bounds_compat(
|
2021-01-31 20:40:03 +00:00
|
|
|
goal: CanonicalTyGoal<'tcx>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "computing implied outlives bounds for `{}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-12-11 01:13:21 +00:00
|
|
|
query implied_outlives_bounds(
|
|
|
|
goal: CanonicalTyGoal<'tcx>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec<OutlivesBound<'tcx>>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
|
|
|
desc { "computing implied outlives bounds v2 for `{}`", goal.value.value }
|
|
|
|
}
|
|
|
|
|
2022-06-28 20:56:32 +00:00
|
|
|
/// Do not call this query directly:
|
|
|
|
/// invoke `DropckOutlives::new(dropped_ty)).fully_perform(typeck.infcx)` instead.
|
2021-01-31 20:40:03 +00:00
|
|
|
query dropck_outlives(
|
|
|
|
goal: CanonicalTyGoal<'tcx>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "computing dropck types for `{}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
|
|
|
|
/// `infcx.predicate_must_hold()` instead.
|
|
|
|
query evaluate_obligation(
|
|
|
|
goal: CanonicalPredicateGoal<'tcx>
|
2023-05-23 13:21:22 +00:00
|
|
|
) -> Result<EvaluationResult, OverflowError> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "evaluating trait selection obligation `{}`", goal.value.value }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `Eq` type-op
|
|
|
|
query type_op_ascribe_user_type(
|
|
|
|
goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `Eq` type-op
|
|
|
|
query type_op_eq(
|
|
|
|
goal: CanonicalTypeOpEqGoal<'tcx>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "evaluating `type_op_eq` `{:?}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `Subtype` type-op
|
|
|
|
query type_op_subtype(
|
|
|
|
goal: CanonicalTypeOpSubtypeGoal<'tcx>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "evaluating `type_op_subtype` `{:?}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `ProvePredicate` type-op
|
|
|
|
query type_op_prove_predicate(
|
|
|
|
goal: CanonicalTypeOpProvePredicateGoal<'tcx>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "evaluating `type_op_prove_predicate` `{:?}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `Normalize` type-op
|
|
|
|
query type_op_normalize_ty(
|
|
|
|
goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "normalizing `{}`", goal.value.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `Normalize` type-op
|
2023-06-22 18:17:13 +00:00
|
|
|
query type_op_normalize_clause(
|
|
|
|
goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Clause<'tcx>>
|
2021-01-31 20:40:03 +00:00
|
|
|
) -> Result<
|
2023-06-22 18:17:13 +00:00
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Clause<'tcx>>>,
|
2021-01-31 20:40:03 +00:00
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "normalizing `{:?}`", goal.value.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `Normalize` type-op
|
|
|
|
query type_op_normalize_poly_fn_sig(
|
|
|
|
goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "normalizing `{:?}`", goal.value.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Do not call this query directly: part of the `Normalize` type-op
|
|
|
|
query type_op_normalize_fn_sig(
|
|
|
|
goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>
|
|
|
|
) -> Result<
|
|
|
|
&'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>,
|
|
|
|
NoSolution,
|
|
|
|
> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "normalizing `{:?}`", goal.value.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2024-02-12 06:39:32 +00:00
|
|
|
query instantiate_and_check_impossible_predicates(key: (DefId, GenericArgsRef<'tcx>)) -> bool {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { |tcx|
|
2024-02-12 06:39:32 +00:00
|
|
|
"checking impossible instantiated predicates: `{}`",
|
2021-01-31 20:40:03 +00:00
|
|
|
tcx.def_path_str(key.0)
|
2019-03-29 01:50:31 +00:00
|
|
|
}
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-07-22 10:20:17 +00:00
|
|
|
query is_impossible_associated_item(key: (DefId, DefId)) -> bool {
|
2022-08-07 05:47:32 +00:00
|
|
|
desc { |tcx|
|
2023-07-22 10:20:17 +00:00
|
|
|
"checking if `{}` is impossible to reference within `{}`",
|
2022-08-07 05:47:32 +00:00
|
|
|
tcx.def_path_str(key.1),
|
|
|
|
tcx.def_path_str(key.0),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
query method_autoderef_steps(
|
|
|
|
goal: CanonicalTyGoal<'tcx>
|
|
|
|
) -> MethodAutoderefStepsResult<'tcx> {
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "computing autoderef types for `{}`", goal.value.value }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2023-12-21 11:30:36 +00:00
|
|
|
query supported_target_features(_: CrateNum) -> &'tcx UnordMap<String, Option<Symbol>> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-01-31 20:40:03 +00:00
|
|
|
eval_always
|
|
|
|
desc { "looking up supported target features" }
|
|
|
|
}
|
2019-03-29 01:50:31 +00:00
|
|
|
|
2021-05-11 11:50:41 +00:00
|
|
|
query features_query(_: ()) -> &'tcx rustc_feature::Features {
|
2022-12-05 17:52:17 +00:00
|
|
|
feedable
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "looking up enabled feature gates" }
|
|
|
|
}
|
2020-04-05 05:21:36 +00:00
|
|
|
|
2023-03-14 12:53:04 +00:00
|
|
|
query crate_for_resolver((): ()) -> &'tcx Steal<(rustc_ast::Crate, rustc_ast::AttrVec)> {
|
2023-02-16 14:07:42 +00:00
|
|
|
feedable
|
|
|
|
no_hash
|
|
|
|
desc { "the ast before macro expansion and name resolution" }
|
|
|
|
}
|
|
|
|
|
2021-01-31 20:40:03 +00:00
|
|
|
/// Attempt to resolve the given `DefId` to an `Instance`, for the
|
2023-07-11 21:35:29 +00:00
|
|
|
/// given generics args (`GenericArgsRef`), returning one of:
|
2021-01-31 20:40:03 +00:00
|
|
|
/// * `Ok(Some(instance))` on success
|
2023-07-11 21:35:29 +00:00
|
|
|
/// * `Ok(None)` when the `GenericArgsRef` are still too generic,
|
2021-01-31 20:40:03 +00:00
|
|
|
/// and therefore don't allow finding the final `Instance`
|
2022-01-23 18:34:26 +00:00
|
|
|
/// * `Err(ErrorGuaranteed)` when the `Instance` resolution process
|
2021-01-31 20:40:03 +00:00
|
|
|
/// couldn't complete due to errors elsewhere - this is distinct
|
|
|
|
/// from `Ok(None)` to avoid misleading diagnostics when an error
|
|
|
|
/// has already been/will be emitted, for the original cause
|
|
|
|
query resolve_instance(
|
2023-07-11 21:35:29 +00:00
|
|
|
key: ty::ParamEnvAnd<'tcx, (DefId, GenericArgsRef<'tcx>)>
|
2022-01-23 18:34:26 +00:00
|
|
|
) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
|
2021-01-31 20:40:03 +00:00
|
|
|
desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
|
|
|
|
}
|
2020-07-02 21:56:17 +00:00
|
|
|
|
2023-06-22 18:17:13 +00:00
|
|
|
query reveal_opaque_types_in_bounds(key: &'tcx ty::List<ty::Clause<'tcx>>) -> &'tcx ty::List<ty::Clause<'tcx>> {
|
2022-11-25 19:30:37 +00:00
|
|
|
desc { "revealing opaque types in `{:?}`", key }
|
2021-01-31 20:40:03 +00:00
|
|
|
}
|
2021-02-23 23:35:48 +00:00
|
|
|
|
2021-07-04 18:02:51 +00:00
|
|
|
query limits(key: ()) -> Limits {
|
|
|
|
desc { "looking up limits" }
|
2021-06-25 23:48:26 +00:00
|
|
|
}
|
Add initial implementation of HIR-based WF checking for diagnostics
During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).
This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.
This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.
The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.
Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).
2021-04-04 20:55:39 +00:00
|
|
|
|
|
|
|
/// Performs an HIR-based well-formed check on the item with the given `HirId`. If
|
2021-08-22 16:15:49 +00:00
|
|
|
/// we get an `Unimplemented` error that matches the provided `Predicate`, return
|
Add initial implementation of HIR-based WF checking for diagnostics
During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).
This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.
This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.
The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.
Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).
2021-04-04 20:55:39 +00:00
|
|
|
/// the cause of the newly created obligation.
|
|
|
|
///
|
|
|
|
/// This is only used by error-reporting code to get a better cause (in particular, a better
|
|
|
|
/// span) for an *existing* error. Therefore, it is best-effort, and may never handle
|
|
|
|
/// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
|
|
|
|
/// because the `ty::Ty`-based wfcheck is always run.
|
2023-02-07 11:23:31 +00:00
|
|
|
query diagnostic_hir_wf_check(
|
2023-05-23 13:21:22 +00:00
|
|
|
key: (ty::Predicate<'tcx>, WellFormedLoc)
|
|
|
|
) -> &'tcx Option<ObligationCause<'tcx>> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
Add initial implementation of HIR-based WF checking for diagnostics
During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).
This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.
This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.
The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.
Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).
2021-04-04 20:55:39 +00:00
|
|
|
eval_always
|
|
|
|
no_hash
|
2022-10-17 19:30:41 +00:00
|
|
|
desc { "performing HIR wf-checking for predicate `{:?}` at item `{:?}`", key.0, key.1 }
|
Add initial implementation of HIR-based WF checking for diagnostics
During well-formed checking, we walk through all types 'nested' in
generic arguments. For example, WF-checking `Option<MyStruct<u8>>`
will cause us to check `MyStruct<u8>` and `u8`. However, this is done
on a `rustc_middle::ty::Ty`, which has no span information. As a result,
any errors that occur will have a very general span (e.g. the
definintion of an associated item).
This becomes a problem when macros are involved. In general, an
associated type like `type MyType = Option<MyStruct<u8>>;` may
have completely different spans for each nested type in the HIR. Using
the span of the entire associated item might end up pointing to a macro
invocation, even though a user-provided span is available in one of the
nested types.
This PR adds a framework for HIR-based well formed checking. This check
is only run during error reporting, and is used to obtain a more precise
span for an existing error. This is accomplished by individually
checking each 'nested' type in the HIR for the type, allowing us to
find the most-specific type (and span) that produces a given error.
The majority of the changes are to the error-reporting code. However,
some of the general trait code is modified to pass through more
information.
Since this has no soundness implications, I've implemented a minimal
version to begin with, which can be extended over time. In particular,
this only works for HIR items with a corresponding `DefId` (e.g. it will
not work for WF-checking performed within function bodies).
2021-04-04 20:55:39 +00:00
|
|
|
}
|
2021-09-24 15:02:02 +00:00
|
|
|
|
|
|
|
/// The list of backend features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
|
|
|
|
/// `--target` and similar).
|
2023-02-07 11:23:31 +00:00
|
|
|
query global_backend_features(_: ()) -> &'tcx Vec<String> {
|
2022-09-02 02:17:35 +00:00
|
|
|
arena_cache
|
2021-09-24 15:02:02 +00:00
|
|
|
eval_always
|
|
|
|
desc { "computing the backend features for CLI flags" }
|
|
|
|
}
|
2022-03-05 10:04:32 +00:00
|
|
|
|
2023-04-30 21:05:27 +00:00
|
|
|
query check_validity_requirement(key: (ValidityRequirement, ty::ParamEnvAnd<'tcx, Ty<'tcx>>)) -> Result<bool, &'tcx ty::layout::LayoutError<'tcx>> {
|
2023-02-26 21:50:19 +00:00
|
|
|
desc { "checking validity requirement for `{}`: {}", key.1.value, key.0 }
|
2022-07-14 21:42:47 +00:00
|
|
|
}
|
2022-09-30 16:47:39 +00:00
|
|
|
|
2022-12-24 21:12:38 +00:00
|
|
|
query compare_impl_const(
|
2022-09-30 17:53:32 +00:00
|
|
|
key: (LocalDefId, DefId)
|
2022-09-30 16:47:39 +00:00
|
|
|
) -> Result<(), ErrorGuaranteed> {
|
2023-02-16 09:25:11 +00:00
|
|
|
desc { |tcx| "checking assoc const `{}` has the same type as trait item", tcx.def_path_str(key.0) }
|
2022-09-30 16:47:39 +00:00
|
|
|
}
|
Introduce deduced parameter attributes, and use them for deducing `readonly` on
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-18 02:42:15 +00:00
|
|
|
|
|
|
|
query deduced_param_attrs(def_id: DefId) -> &'tcx [ty::DeducedParamAttrs] {
|
|
|
|
desc { |tcx| "deducing parameter attributes for {}", tcx.def_path_str(def_id) }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
2022-02-01 12:30:32 +00:00
|
|
|
|
|
|
|
query doc_link_resolutions(def_id: DefId) -> &'tcx DocLinkResMap {
|
|
|
|
eval_always
|
|
|
|
desc { "resolutions for documentation links for a module" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
|
|
|
|
|
|
|
query doc_link_traits_in_scope(def_id: DefId) -> &'tcx [DefId] {
|
|
|
|
eval_always
|
|
|
|
desc { "traits in scope for documentation links for a module" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
2023-02-11 23:05:11 +00:00
|
|
|
|
|
|
|
/// Used in `super_combine_consts` to ICE if the type of the two consts are definitely not going to end up being
|
2023-03-15 18:25:48 +00:00
|
|
|
/// equal to eachother. This might return `Ok` even if the types are not equal, but will never return `Err` if
|
2023-02-11 23:05:11 +00:00
|
|
|
/// the types might be equal.
|
2023-12-04 20:42:41 +00:00
|
|
|
query check_tys_might_be_eq(
|
|
|
|
arg: Canonical<'tcx, ty::ParamEnvAnd<'tcx, (Ty<'tcx>, Ty<'tcx>)>>
|
|
|
|
) -> Result<(), NoSolution> {
|
2023-02-11 23:05:11 +00:00
|
|
|
desc { "check whether two const param are definitely not equal to eachother"}
|
|
|
|
}
|
2023-03-10 21:39:14 +00:00
|
|
|
|
|
|
|
/// Get all item paths that were stripped by a `#[cfg]` in a particular crate.
|
|
|
|
/// Should not be called for the local crate before the resolver outputs are created, as it
|
|
|
|
/// is only fed there.
|
|
|
|
query stripped_cfg_items(cnum: CrateNum) -> &'tcx [StrippedCfgItem] {
|
|
|
|
feedable
|
|
|
|
desc { "getting cfg-ed out item names" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
2023-06-05 15:57:21 +00:00
|
|
|
|
|
|
|
query generics_require_sized_self(def_id: DefId) -> bool {
|
|
|
|
desc { "check whether the item has a `where Self: Sized` bound" }
|
|
|
|
}
|
2023-10-07 00:29:42 +00:00
|
|
|
|
|
|
|
query cross_crate_inlinable(def_id: DefId) -> bool {
|
|
|
|
desc { "whether the item should be made inlinable across crates" }
|
|
|
|
separate_provide_extern
|
|
|
|
}
|
2024-01-04 13:45:06 +00:00
|
|
|
|
|
|
|
query find_field((def_id, ident): (DefId, rustc_span::symbol::Ident)) -> Option<rustc_target::abi::FieldIdx> {
|
|
|
|
desc { |tcx| "find the index of maybe nested field `{ident}` in `{}`", tcx.def_path_str(def_id) }
|
|
|
|
}
|
2018-12-03 00:14:35 +00:00
|
|
|
}
|
2023-05-15 04:24:45 +00:00
|
|
|
|
|
|
|
rustc_query_append! { define_callbacks! }
|
|
|
|
rustc_feedable_queries! { define_feedable! }
|