Ensure that queries only return Copy types.

This commit is contained in:
Camille GILLOT 2022-01-31 19:55:34 +01:00
parent bf242bb119
commit 6c2ee885e6
31 changed files with 141 additions and 96 deletions

View file

@ -215,7 +215,8 @@ rustc_queries! {
desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) }
}
query native_libraries(_: CrateNum) -> Lrc<Vec<NativeLib>> {
query native_libraries(_: CrateNum) -> Vec<NativeLib> {
storage(ArenaCacheSelector<'tcx>)
desc { "looking up the native libraries of a linked crate" }
separate_provide_extern
}
@ -254,6 +255,7 @@ rustc_queries! {
/// Create a THIR tree for debugging.
query thir_tree(key: ty::WithOptConstParam<LocalDefId>) -> String {
no_hash
storage(ArenaCacheSelector<'tcx>)
desc { |tcx| "constructing THIR tree for `{}`", tcx.def_path_str(key.did.to_def_id()) }
}
@ -368,6 +370,7 @@ rustc_queries! {
query symbols_for_closure_captures(
key: (LocalDefId, DefId)
) -> Vec<rustc_span::Symbol> {
storage(ArenaCacheSelector<'tcx>)
desc {
|tcx| "symbols for captures of closure `{}` in `{}`",
tcx.def_path_str(key.1),
@ -538,7 +541,7 @@ rustc_queries! {
query adt_dtorck_constraint(
key: DefId
) -> Result<DtorckConstraint<'tcx>, NoSolution> {
) -> Result<&'tcx DtorckConstraint<'tcx>, NoSolution> {
desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) }
}
@ -646,8 +649,8 @@ rustc_queries! {
/// The map returned for `tcx.impl_item_implementor_ids(impl_id)` would be
///`{ trait_f: impl_f, trait_g: impl_g }`
query impl_item_implementor_ids(impl_id: DefId) -> FxHashMap<DefId, DefId> {
desc { |tcx| "comparing impl items against trait for {}", tcx.def_path_str(impl_id) }
storage(ArenaCacheSelector<'tcx>)
desc { |tcx| "comparing impl items against trait for {}", tcx.def_path_str(impl_id) }
}
/// Given an `impl_id`, return the trait it implements.
@ -1042,6 +1045,7 @@ rustc_queries! {
/// Gets the rendered value of the specified constant or associated constant.
/// Used by rustdoc.
query rendered_const(def_id: DefId) -> String {
storage(ArenaCacheSelector<'tcx>)
desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) }
separate_provide_extern
}
@ -1091,7 +1095,7 @@ rustc_queries! {
query codegen_fulfill_obligation(
key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
) -> Result<ImplSource<'tcx, ()>, ErrorReported> {
) -> Result<&'tcx ImplSource<'tcx, ()>, ErrorReported> {
cache_on_disk_if { true }
desc { |tcx|
"checking if `{}` fulfills its obligations",
@ -1213,7 +1217,8 @@ rustc_queries! {
/// 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>>)>
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
) -> Result<abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
storage(ArenaCacheSelector<'tcx>)
desc { "computing call ABI of `{}` function pointers", key.value.0 }
remap_env_constness
}
@ -1225,7 +1230,8 @@ rustc_queries! {
/// 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>>)>
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
) -> Result<abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
storage(ArenaCacheSelector<'tcx>)
desc { "computing call ABI of `{}`", key.value.0 }
remap_env_constness
}
@ -1237,6 +1243,7 @@ rustc_queries! {
}
query dependency_formats(_: ()) -> Lrc<crate::middle::dependency_format::Dependencies> {
storage(ArenaCacheSelector<'tcx>)
desc { "get the linkage format of all dependencies" }
}
@ -1369,13 +1376,15 @@ rustc_queries! {
/// You likely want to call `Instance::upstream_monomorphization()`
/// instead of invoking this query directly.
query upstream_monomorphizations_for(def_id: DefId)
-> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>> {
desc { |tcx|
"collecting available upstream monomorphizations for `{}`",
tcx.def_path_str(def_id),
}
separate_provide_extern
-> Option<&'tcx FxHashMap<SubstsRef<'tcx>, CrateNum>>
{
storage(ArenaCacheSelector<'tcx>)
desc { |tcx|
"collecting available upstream monomorphizations for `{}`",
tcx.def_path_str(def_id),
}
separate_provide_extern
}
/// Returns the upstream crate that exports drop-glue for the given
/// type (`substs` is expected to be a single-item list containing the
@ -1396,7 +1405,8 @@ rustc_queries! {
desc { "available upstream drop-glue for `{:?}`", substs }
}
query foreign_modules(_: CrateNum) -> Lrc<FxHashMap<DefId, ForeignModule>> {
query foreign_modules(_: CrateNum) -> FxHashMap<DefId, ForeignModule> {
storage(ArenaCacheSelector<'tcx>)
desc { "looking up the foreign modules of a linked crate" }
separate_provide_extern
}
@ -1422,11 +1432,13 @@ rustc_queries! {
separate_provide_extern
}
query extra_filename(_: CrateNum) -> String {
storage(ArenaCacheSelector<'tcx>)
eval_always
desc { "looking up the extra filename for a crate" }
separate_provide_extern
}
query crate_extern_paths(_: CrateNum) -> Vec<PathBuf> {
storage(ArenaCacheSelector<'tcx>)
eval_always
desc { "looking up the paths for extern crates" }
separate_provide_extern
@ -1480,6 +1492,7 @@ rustc_queries! {
/// For `struct Foo<'a, T: 'a, U>`, this would instead be `['a, 'static]`.
query object_lifetime_defaults_map(_: LocalDefId)
-> Option<Vec<ObjectLifetimeDefault>> {
storage(ArenaCacheSelector<'tcx>)
desc { "looking up lifetime defaults for a region on an item" }
}
query late_bound_vars_map(_: LocalDefId)
@ -1488,6 +1501,7 @@ rustc_queries! {
}
query lifetime_scope_map(_: LocalDefId) -> Option<FxHashMap<ItemLocalId, LifetimeScopeForPath>> {
storage(ArenaCacheSelector<'tcx>)
desc { "finds the lifetime scope for an HirId of a PathSegment" }
}
@ -1502,6 +1516,7 @@ rustc_queries! {
query type_uninhabited_from(
key: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
) -> ty::inhabitedness::DefIdForest {
storage(ArenaCacheSelector<'tcx>)
desc { "computing the inhabitedness of `{:?}`", key }
remap_env_constness
}
@ -1566,7 +1581,8 @@ rustc_queries! {
desc { "calculating the missing lang items in a crate" }
separate_provide_extern
}
query visible_parent_map(_: ()) -> Lrc<DefIdMap<DefId>> {
query visible_parent_map(_: ()) -> DefIdMap<DefId> {
storage(ArenaCacheSelector<'tcx>)
desc { "calculating the visible parent map" }
}
query trimmed_def_paths(_: ()) -> FxHashMap<DefId, Symbol> {
@ -1579,6 +1595,7 @@ rustc_queries! {
separate_provide_extern
}
query used_crate_source(_: CrateNum) -> Lrc<CrateSource> {
storage(ArenaCacheSelector<'tcx>)
eval_always
desc { "looking at the source for a crate" }
separate_provide_extern
@ -1669,7 +1686,7 @@ rustc_queries! {
desc { "optimization level used by backend" }
}
query output_filenames(_: ()) -> Arc<OutputFilenames> {
query output_filenames(_: ()) -> &'tcx Arc<OutputFilenames> {
eval_always
desc { "output_filenames" }
}
@ -1911,6 +1928,7 @@ rustc_queries! {
/// all of the cases that the normal `ty::Ty`-based wfcheck does. This is fine,
/// because the `ty::Ty`-based wfcheck is always run.
query diagnostic_hir_wf_check(key: (ty::Predicate<'tcx>, traits::WellFormedLoc)) -> Option<traits::ObligationCause<'tcx>> {
storage(ArenaCacheSelector<'tcx>)
eval_always
no_hash
desc { "performing HIR wf-checking for predicate {:?} at item {:?}", key.0, key.1 }