Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
}

Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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<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()
}

Expand Down Expand Up @@ -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) }
}

Expand Down
11 changes: 2 additions & 9 deletions compiler/rustc_middle/src/query/erase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -162,10 +161,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>
{
Expand Down Expand Up @@ -196,10 +191,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<'_>)>>()];
}
Expand Down Expand Up @@ -343,6 +334,8 @@ impl_erasable_for_simple_types! {
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,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 0 additions & 6 deletions src/doc/rustc-dev-guide/src/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
10 changes: 5 additions & 5 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}"));
}
}
Loading