Auto merge of #78334 - jonas-schievink:rollup-z0gzbmm, r=jonas-schievink
Rollup of 12 pull requests Successful merges: - #75115 (`#[deny(unsafe_op_in_unsafe_fn)]` in sys/cloudabi) - #76614 (change the order of type arguments on ControlFlow) - #77610 (revise Hermit's mutex interface to support the behaviour of StaticMutex) - #77830 (Simplify query proc-macros) - #77930 (Do not ICE with TraitPredicates containing [type error]) - #78069 (Fix const core::panic!(non_literal_str).) - #78072 (Cleanup constant matching in exhaustiveness checking) - #78119 (Throw core::panic!("message") as &str instead of String.) - #78191 (Introduce a temporary for discriminant value in MatchBranchSimplification) - #78272 (const_evaluatable_checked: deal with unused nodes + div) - #78318 (TyCtxt: generate single impl block with `slice_interners` macro) - #78327 (resolve: Relax macro resolution consistency check to account for any errors) Failed merges: r? `@ghost`
This commit is contained in:
commit
f58ffc9381
66 changed files with 1421 additions and 823 deletions
|
@ -2036,13 +2036,13 @@ direct_interners! {
|
|||
|
||||
macro_rules! slice_interners {
|
||||
($($field:ident: $method:ident($ty:ty)),+ $(,)?) => (
|
||||
$(impl<'tcx> TyCtxt<'tcx> {
|
||||
pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
|
||||
impl<'tcx> TyCtxt<'tcx> {
|
||||
$(pub fn $method(self, v: &[$ty]) -> &'tcx List<$ty> {
|
||||
self.interners.$field.intern_ref(v, || {
|
||||
Interned(List::from_arena(&*self.arena, v))
|
||||
}).0
|
||||
}
|
||||
})+
|
||||
})+
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ use crate::ty::util::AlwaysRequiresDrop;
|
|||
use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt};
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::profiling::ProfileCategory::*;
|
||||
use rustc_data_structures::stable_hasher::StableVec;
|
||||
use rustc_data_structures::svh::Svh;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
@ -169,26 +168,71 @@ pub fn force_from_dep_node<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> bool
|
|||
return false;
|
||||
}
|
||||
|
||||
rustc_dep_node_force!([dep_node, tcx]
|
||||
// These are inputs that are expected to be pre-allocated and that
|
||||
// should therefore always be red or green already.
|
||||
DepKind::CrateMetadata |
|
||||
macro_rules! force_from_dep_node {
|
||||
($($(#[$attr:meta])* [$($modifiers:tt)*] $name:ident($K:ty),)*) => {
|
||||
match dep_node.kind {
|
||||
// These are inputs that are expected to be pre-allocated and that
|
||||
// should therefore always be red or green already.
|
||||
DepKind::CrateMetadata |
|
||||
|
||||
// These are anonymous nodes.
|
||||
DepKind::TraitSelect |
|
||||
// These are anonymous nodes.
|
||||
DepKind::TraitSelect |
|
||||
|
||||
// We don't have enough information to reconstruct the query key of
|
||||
// these.
|
||||
DepKind::CompileCodegenUnit => {
|
||||
bug!("force_from_dep_node: encountered {:?}", dep_node)
|
||||
// We don't have enough information to reconstruct the query key of
|
||||
// these.
|
||||
DepKind::CompileCodegenUnit |
|
||||
|
||||
// Forcing this makes no sense.
|
||||
DepKind::Null => {
|
||||
bug!("force_from_dep_node: encountered {:?}", dep_node)
|
||||
}
|
||||
|
||||
$(DepKind::$name => {
|
||||
debug_assert!(<$K as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key());
|
||||
|
||||
if let Some(key) = <$K as DepNodeParams<TyCtxt<'_>>>::recover(tcx, dep_node) {
|
||||
force_query::<queries::$name<'_>, _>(
|
||||
tcx,
|
||||
key,
|
||||
DUMMY_SP,
|
||||
*dep_node
|
||||
);
|
||||
return true;
|
||||
}
|
||||
})*
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
rustc_dep_node_append! { [force_from_dep_node!][] }
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
pub(crate) fn try_load_from_on_disk_cache<'tcx>(tcx: TyCtxt<'tcx>, dep_node: &DepNode) {
|
||||
rustc_dep_node_try_load_from_on_disk_cache!(dep_node, tcx)
|
||||
macro_rules! try_load_from_on_disk_cache {
|
||||
($($name:ident,)*) => {
|
||||
match dep_node.kind {
|
||||
$(DepKind::$name => {
|
||||
if <query_keys::$name<'tcx> as DepNodeParams<TyCtxt<'_>>>::can_reconstruct_query_key() {
|
||||
debug_assert!(tcx.dep_graph
|
||||
.node_color(dep_node)
|
||||
.map(|c| c.is_green())
|
||||
.unwrap_or(false));
|
||||
|
||||
let key = <query_keys::$name<'tcx> as DepNodeParams<TyCtxt<'_>>>::recover(tcx, dep_node).unwrap();
|
||||
if queries::$name::cache_on_disk(tcx, &key, None) {
|
||||
let _ = tcx.$name(key);
|
||||
}
|
||||
}
|
||||
})*
|
||||
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rustc_cached_queries!(try_load_from_on_disk_cache!);
|
||||
}
|
||||
|
||||
mod sealed {
|
||||
|
|
|
@ -242,25 +242,15 @@ macro_rules! hash_result {
|
|||
};
|
||||
}
|
||||
|
||||
macro_rules! define_queries {
|
||||
(<$tcx:tt> $($category:tt {
|
||||
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*
|
||||
},)*) => {
|
||||
define_queries_inner! { <$tcx>
|
||||
$($( $(#[$attr])* category<$category> [$($modifiers)*] fn $name: $node($($K)*) -> $V,)*)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! query_helper_param_ty {
|
||||
(DefId) => { impl IntoQueryParam<DefId> };
|
||||
($K:ty) => { $K };
|
||||
}
|
||||
|
||||
macro_rules! define_queries_inner {
|
||||
macro_rules! define_queries {
|
||||
(<$tcx:tt>
|
||||
$($(#[$attr:meta])* category<$category:tt>
|
||||
[$($modifiers:tt)*] fn $name:ident: $node:ident($($K:tt)*) -> $V:ty,)*) => {
|
||||
$($(#[$attr:meta])*
|
||||
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
|
||||
|
||||
use std::mem;
|
||||
use crate::{
|
||||
|
@ -268,7 +258,6 @@ macro_rules! define_queries_inner {
|
|||
rustc_data_structures::stable_hasher::StableHasher,
|
||||
ich::StableHashingContext
|
||||
};
|
||||
use rustc_data_structures::profiling::ProfileCategory;
|
||||
|
||||
define_queries_struct! {
|
||||
tcx: $tcx,
|
||||
|
@ -362,13 +351,12 @@ macro_rules! define_queries_inner {
|
|||
as QueryStorage
|
||||
>::Stored;
|
||||
const NAME: &'static str = stringify!($name);
|
||||
const CATEGORY: ProfileCategory = $category;
|
||||
}
|
||||
|
||||
impl<$tcx> QueryAccessors<TyCtxt<$tcx>> for queries::$name<$tcx> {
|
||||
const ANON: bool = is_anon!([$($modifiers)*]);
|
||||
const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);
|
||||
const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$node;
|
||||
const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$name;
|
||||
|
||||
type Cache = query_storage!([$($modifiers)*][$($K)*, $V]);
|
||||
|
||||
|
|
|
@ -120,13 +120,13 @@ pub fn print_stats(tcx: TyCtxt<'_>) {
|
|||
}
|
||||
|
||||
macro_rules! print_stats {
|
||||
(<$tcx:tt> $($category:tt {
|
||||
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*
|
||||
},)*) => {
|
||||
(<$tcx:tt>
|
||||
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($K:ty) -> $V:ty,)*
|
||||
) => {
|
||||
fn query_stats(tcx: TyCtxt<'_>) -> Vec<QueryStats> {
|
||||
let mut queries = Vec::new();
|
||||
|
||||
$($(
|
||||
$(
|
||||
queries.push(stats::<
|
||||
crate::dep_graph::DepKind,
|
||||
<TyCtxt<'_> as QueryContext>::Query,
|
||||
|
@ -135,7 +135,7 @@ macro_rules! print_stats {
|
|||
stringify!($name),
|
||||
&tcx.queries.$name,
|
||||
));
|
||||
)*)*
|
||||
)*
|
||||
|
||||
queries
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue