diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 8fec629161eac..bdaed5bb42ee1 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -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 }); } } diff --git a/compiler/rustc_middle/src/dep_graph/graph.rs b/compiler/rustc_middle/src/dep_graph/graph.rs index 963d5f1a53bdd..d410d9a48cd10 100644 --- a/compiler/rustc_middle/src/dep_graph/graph.rs +++ b/compiler/rustc_middle/src/dep_graph/graph.rs @@ -292,7 +292,7 @@ impl DepGraph { 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 @@ impl DepGraph { { 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 @@ impl DepGraphData { /// 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 @@ impl DepGraph { dep_node_debug.borrow_mut().insert(dep_node, debug_str); } - pub fn dep_node_debug_str(&self, dep_node: DepNode) -> Option { + pub(crate) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option { self.data.as_ref()?.dep_node_debug.borrow().get(&dep_node).cloned() } @@ -1103,7 +1103,7 @@ impl DepGraph { } } - 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) } } diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index 4d4833b4943e4..da56b0827966a 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -17,7 +17,6 @@ use crate::mir::interpret::EvalToValTreeResult; use crate::mir::mono::{MonoItem, NormalizationErrorInMono}; use crate::query::plumbing::CyclePlaceholder; use crate::traits::solve; -use crate::ty::adjustment::CoerceUnsizedInfo; use crate::ty::{self, Ty, TyCtxt}; use crate::{mir, traits}; @@ -162,10 +161,6 @@ impl Erasable for Result>, rustc_errors::ErrorGuaranteed [u8; size_of::>, rustc_errors::ErrorGuaranteed>>()]; } -impl Erasable for Result { - type Storage = [u8; size_of::>()]; -} - impl Erasable for Result>>, rustc_errors::ErrorGuaranteed> { @@ -196,10 +191,6 @@ impl Erasable for Result, mir::interpret::ErrorHandled> { [u8; size_of::, mir::interpret::ErrorHandled>>()]; } -impl Erasable for Result { - type Storage = [u8; size_of::>()]; -} - impl Erasable for Option<(mir::ConstValue, Ty<'_>)> { type Storage = [u8; size_of::)>>()]; } @@ -343,6 +334,8 @@ impl_erasable_for_simple_types! { Result<(), rustc_errors::ErrorGuaranteed>, Result<(), rustc_middle::traits::query::NoSolution>, Result, + Result, + Result, rustc_abi::ReprOptions, rustc_ast::expand::allocator::AllocatorKind, rustc_hir::DefaultBodyStability, diff --git a/compiler/rustc_middle/src/query/plumbing.rs b/compiler/rustc_middle/src/query/plumbing.rs index ad0b6f7c335ef..8df7d4ff661e6 100644 --- a/compiler/rustc_middle/src/query/plumbing.rs +++ b/compiler/rustc_middle/src/query/plumbing.rs @@ -320,7 +320,6 @@ macro_rules! define_callbacks { non_queries { $($_:tt)* } ) => { $( - #[allow(unused_lifetimes)] pub mod $name { use super::*; use $crate::query::erase::{self, Erased}; diff --git a/src/doc/rustc-dev-guide/src/query.md b/src/doc/rustc-dev-guide/src/query.md index 5ab2ab428e811..437dd8daa70b4 100644 --- a/src/doc/rustc-dev-guide/src/query.md +++ b/src/doc/rustc-dev-guide/src/query.md @@ -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`. diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 55075001e0fef..8c1069dd6d397 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -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}")); } }