mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #153691 - nnethercote:misc-tweaks, r=yaahc
Miscellaneous tweaks A hodge-podge of small changes that didn't fit anywhere else. r? @yaahc
This commit is contained in:
@@ -353,16 +353,16 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
|
||||
})
|
||||
}
|
||||
|
||||
fn dump_feature_usage_metrics(tcxt: TyCtxt<'_>, metrics_dir: &Path) {
|
||||
let hash = tcxt.crate_hash(LOCAL_CRATE);
|
||||
let crate_name = tcxt.crate_name(LOCAL_CRATE);
|
||||
fn dump_feature_usage_metrics(tcx: TyCtxt<'_>, metrics_dir: &Path) {
|
||||
let hash = tcx.crate_hash(LOCAL_CRATE);
|
||||
let crate_name = tcx.crate_name(LOCAL_CRATE);
|
||||
let metrics_file_name = format!("unstable_feature_usage_metrics-{crate_name}-{hash}.json");
|
||||
let metrics_path = metrics_dir.join(metrics_file_name);
|
||||
if let Err(error) = tcxt.features().dump_feature_usage_metrics(metrics_path) {
|
||||
if let Err(error) = tcx.features().dump_feature_usage_metrics(metrics_path) {
|
||||
// FIXME(yaahc): once metrics can be enabled by default we will want "failure to emit
|
||||
// default metrics" to only produce a warning when metrics are enabled by default and emit
|
||||
// an error only when the user manually enables metrics
|
||||
tcxt.dcx().emit_err(UnstableFeatureUsage { error });
|
||||
tcx.dcx().emit_err(UnstableFeatureUsage { error });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ pub fn with_task<'tcx, A: Debug, R>(
|
||||
|
||||
pub fn with_anon_task<'tcx, OP, R>(
|
||||
&self,
|
||||
cx: TyCtxt<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
dep_kind: DepKind,
|
||||
op: OP,
|
||||
) -> (R, DepNodeIndex)
|
||||
@@ -301,7 +301,7 @@ pub fn with_anon_task<'tcx, OP, R>(
|
||||
{
|
||||
match self.data() {
|
||||
Some(data) => {
|
||||
let (result, index) = data.with_anon_task_inner(cx, dep_kind, op);
|
||||
let (result, index) = data.with_anon_task_inner(tcx, dep_kind, op);
|
||||
self.read_index(index);
|
||||
(result, index)
|
||||
}
|
||||
@@ -379,14 +379,14 @@ pub fn with_task<'tcx, A: Debug, R>(
|
||||
/// how to make that work with `anon` in `execute_job_incr`, though.
|
||||
pub fn with_anon_task_inner<'tcx, OP, R>(
|
||||
&self,
|
||||
cx: TyCtxt<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
dep_kind: DepKind,
|
||||
op: OP,
|
||||
) -> (R, DepNodeIndex)
|
||||
where
|
||||
OP: FnOnce() -> R,
|
||||
{
|
||||
debug_assert!(!cx.is_eval_always(dep_kind));
|
||||
debug_assert!(!tcx.is_eval_always(dep_kind));
|
||||
|
||||
// Large numbers of reads are common enough here that pre-sizing `read_set`
|
||||
// to 128 actually helps perf on some benchmarks.
|
||||
@@ -865,7 +865,7 @@ pub(crate) fn register_dep_node_debug_str<F>(&self, dep_node: DepNode, debug_str
|
||||
dep_node_debug.borrow_mut().insert(dep_node, debug_str);
|
||||
}
|
||||
|
||||
pub fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
|
||||
pub(crate) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
|
||||
self.data.as_ref()?.dep_node_debug.borrow().get(&dep_node).cloned()
|
||||
}
|
||||
|
||||
@@ -1103,7 +1103,7 @@ pub fn exec_cache_promotions<'tcx>(&self, tcx: TyCtxt<'tcx>) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn finish_encoding(&self) -> FileEncodeResult {
|
||||
pub(crate) fn finish_encoding(&self) -> FileEncodeResult {
|
||||
if let Some(data) = &self.data { data.current.encoder.finish(&data.current) } else { Ok(0) }
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
use crate::mir::interpret::EvalToValTreeResult;
|
||||
use crate::mir::mono::{MonoItem, NormalizationErrorInMono};
|
||||
use crate::traits::solve;
|
||||
use crate::ty::adjustment::CoerceUnsizedInfo;
|
||||
use crate::ty::{self, Ty, TyCtxt};
|
||||
use crate::{mir, traits};
|
||||
|
||||
@@ -160,10 +159,6 @@ impl Erasable for Result<Option<ty::Instance<'_>>, rustc_errors::ErrorGuaranteed
|
||||
[u8; size_of::<Result<Option<ty::Instance<'static>>, rustc_errors::ErrorGuaranteed>>()];
|
||||
}
|
||||
|
||||
impl Erasable for Result<CoerceUnsizedInfo, rustc_errors::ErrorGuaranteed> {
|
||||
type Storage = [u8; size_of::<Result<CoerceUnsizedInfo, rustc_errors::ErrorGuaranteed>>()];
|
||||
}
|
||||
|
||||
impl Erasable
|
||||
for Result<Option<ty::EarlyBinder<'_, ty::Const<'_>>>, rustc_errors::ErrorGuaranteed>
|
||||
{
|
||||
@@ -194,10 +189,6 @@ impl Erasable for Result<mir::ConstAlloc<'_>, mir::interpret::ErrorHandled> {
|
||||
[u8; size_of::<Result<mir::ConstAlloc<'static>, mir::interpret::ErrorHandled>>()];
|
||||
}
|
||||
|
||||
impl Erasable for Result<mir::ConstValue, mir::interpret::ErrorHandled> {
|
||||
type Storage = [u8; size_of::<Result<mir::ConstValue, mir::interpret::ErrorHandled>>()];
|
||||
}
|
||||
|
||||
impl Erasable for Option<(mir::ConstValue, Ty<'_>)> {
|
||||
type Storage = [u8; size_of::<Option<(mir::ConstValue, Ty<'_>)>>()];
|
||||
}
|
||||
@@ -337,6 +328,8 @@ impl Erasable for $ty {
|
||||
Result<(), rustc_errors::ErrorGuaranteed>,
|
||||
Result<(), rustc_middle::traits::query::NoSolution>,
|
||||
Result<rustc_middle::traits::EvaluationResult, rustc_middle::traits::OverflowError>,
|
||||
Result<rustc_middle::ty::adjustment::CoerceUnsizedInfo, rustc_errors::ErrorGuaranteed>,
|
||||
Result<mir::ConstValue, mir::interpret::ErrorHandled>,
|
||||
rustc_abi::ReprOptions,
|
||||
rustc_ast::expand::allocator::AllocatorKind,
|
||||
rustc_hir::DefaultBodyStability,
|
||||
|
||||
@@ -322,7 +322,6 @@ fn $name:ident($($K:tt)*) -> $V:ty
|
||||
non_queries { $($_:tt)* }
|
||||
) => {
|
||||
$(
|
||||
#[allow(unused_lifetimes)]
|
||||
pub mod $name {
|
||||
use super::*;
|
||||
use $crate::query::erase::{self, Erased};
|
||||
|
||||
@@ -168,12 +168,6 @@ pub fn provide(providers: &mut rustc_middle::util::Providers) {
|
||||
}
|
||||
```
|
||||
|
||||
Note that `util::Providers` implements `DerefMut` to `query::Providers` so callers of the `provide` functions can pass in a `util::Providers` and it will just work for provider functions that accept `query::Providers` too
|
||||
|
||||
- This function takes a mutable reference to the `query::Providers` struct and sets the fields to point to the correct provider functions.
|
||||
- You can also assign queries individually, e.g. `providers.type_of = type_of;`.
|
||||
- You can assign fields individually for each provider type (local, external, and hooks).
|
||||
|
||||
#### Adding a new provider
|
||||
|
||||
Suppose you want to add a new query called `fubar`.
|
||||
|
||||
@@ -954,15 +954,15 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
|
||||
})
|
||||
}
|
||||
|
||||
fn dump_feature_usage_metrics(tcxt: TyCtxt<'_>, metrics_dir: &Path) {
|
||||
let hash = tcxt.crate_hash(LOCAL_CRATE);
|
||||
let crate_name = tcxt.crate_name(LOCAL_CRATE);
|
||||
fn dump_feature_usage_metrics(tcx: TyCtxt<'_>, metrics_dir: &Path) {
|
||||
let hash = tcx.crate_hash(LOCAL_CRATE);
|
||||
let crate_name = tcx.crate_name(LOCAL_CRATE);
|
||||
let metrics_file_name = format!("unstable_feature_usage_metrics-{crate_name}-{hash}.json");
|
||||
let metrics_path = metrics_dir.join(metrics_file_name);
|
||||
if let Err(error) = tcxt.features().dump_feature_usage_metrics(metrics_path) {
|
||||
if let Err(error) = tcx.features().dump_feature_usage_metrics(metrics_path) {
|
||||
// FIXME(yaahc): once metrics can be enabled by default we will want "failure to emit
|
||||
// default metrics" to only produce a warning when metrics are enabled by default and emit
|
||||
// an error only when the user manually enables metrics
|
||||
tcxt.dcx().err(format!("cannot emit feature usage metrics: {error}"));
|
||||
tcx.dcx().err(format!("cannot emit feature usage metrics: {error}"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user