Skip to content

Commit 19f7c94

Browse files
authored
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
2 parents c5faf3a + 1287ccc commit 19f7c94

6 files changed

Lines changed: 18 additions & 32 deletions

File tree

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,16 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
353353
})
354354
}
355355

356-
fn dump_feature_usage_metrics(tcxt: TyCtxt<'_>, metrics_dir: &Path) {
357-
let hash = tcxt.crate_hash(LOCAL_CRATE);
358-
let crate_name = tcxt.crate_name(LOCAL_CRATE);
356+
fn dump_feature_usage_metrics(tcx: TyCtxt<'_>, metrics_dir: &Path) {
357+
let hash = tcx.crate_hash(LOCAL_CRATE);
358+
let crate_name = tcx.crate_name(LOCAL_CRATE);
359359
let metrics_file_name = format!("unstable_feature_usage_metrics-{crate_name}-{hash}.json");
360360
let metrics_path = metrics_dir.join(metrics_file_name);
361-
if let Err(error) = tcxt.features().dump_feature_usage_metrics(metrics_path) {
361+
if let Err(error) = tcx.features().dump_feature_usage_metrics(metrics_path) {
362362
// FIXME(yaahc): once metrics can be enabled by default we will want "failure to emit
363363
// default metrics" to only produce a warning when metrics are enabled by default and emit
364364
// an error only when the user manually enables metrics
365-
tcxt.dcx().emit_err(UnstableFeatureUsage { error });
365+
tcx.dcx().emit_err(UnstableFeatureUsage { error });
366366
}
367367
}
368368

compiler/rustc_middle/src/dep_graph/graph.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl DepGraph {
292292

293293
pub fn with_anon_task<'tcx, OP, R>(
294294
&self,
295-
cx: TyCtxt<'tcx>,
295+
tcx: TyCtxt<'tcx>,
296296
dep_kind: DepKind,
297297
op: OP,
298298
) -> (R, DepNodeIndex)
@@ -301,7 +301,7 @@ impl DepGraph {
301301
{
302302
match self.data() {
303303
Some(data) => {
304-
let (result, index) = data.with_anon_task_inner(cx, dep_kind, op);
304+
let (result, index) = data.with_anon_task_inner(tcx, dep_kind, op);
305305
self.read_index(index);
306306
(result, index)
307307
}
@@ -379,14 +379,14 @@ impl DepGraphData {
379379
/// how to make that work with `anon` in `execute_job_incr`, though.
380380
pub fn with_anon_task_inner<'tcx, OP, R>(
381381
&self,
382-
cx: TyCtxt<'tcx>,
382+
tcx: TyCtxt<'tcx>,
383383
dep_kind: DepKind,
384384
op: OP,
385385
) -> (R, DepNodeIndex)
386386
where
387387
OP: FnOnce() -> R,
388388
{
389-
debug_assert!(!cx.is_eval_always(dep_kind));
389+
debug_assert!(!tcx.is_eval_always(dep_kind));
390390

391391
// Large numbers of reads are common enough here that pre-sizing `read_set`
392392
// to 128 actually helps perf on some benchmarks.
@@ -865,7 +865,7 @@ impl DepGraph {
865865
dep_node_debug.borrow_mut().insert(dep_node, debug_str);
866866
}
867867

868-
pub fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
868+
pub(crate) fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String> {
869869
self.data.as_ref()?.dep_node_debug.borrow().get(&dep_node).cloned()
870870
}
871871

@@ -1103,7 +1103,7 @@ impl DepGraph {
11031103
}
11041104
}
11051105

1106-
pub fn finish_encoding(&self) -> FileEncodeResult {
1106+
pub(crate) fn finish_encoding(&self) -> FileEncodeResult {
11071107
if let Some(data) = &self.data { data.current.encoder.finish(&data.current) } else { Ok(0) }
11081108
}
11091109

compiler/rustc_middle/src/query/erase.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_span::{ErrorGuaranteed, Spanned};
1515
use crate::mir::interpret::EvalToValTreeResult;
1616
use crate::mir::mono::{MonoItem, NormalizationErrorInMono};
1717
use crate::traits::solve;
18-
use crate::ty::adjustment::CoerceUnsizedInfo;
1918
use crate::ty::{self, Ty, TyCtxt};
2019
use crate::{mir, traits};
2120

@@ -160,10 +159,6 @@ impl Erasable for Result<Option<ty::Instance<'_>>, rustc_errors::ErrorGuaranteed
160159
[u8; size_of::<Result<Option<ty::Instance<'static>>, rustc_errors::ErrorGuaranteed>>()];
161160
}
162161

163-
impl Erasable for Result<CoerceUnsizedInfo, rustc_errors::ErrorGuaranteed> {
164-
type Storage = [u8; size_of::<Result<CoerceUnsizedInfo, rustc_errors::ErrorGuaranteed>>()];
165-
}
166-
167162
impl Erasable
168163
for Result<Option<ty::EarlyBinder<'_, ty::Const<'_>>>, rustc_errors::ErrorGuaranteed>
169164
{
@@ -194,10 +189,6 @@ impl Erasable for Result<mir::ConstAlloc<'_>, mir::interpret::ErrorHandled> {
194189
[u8; size_of::<Result<mir::ConstAlloc<'static>, mir::interpret::ErrorHandled>>()];
195190
}
196191

197-
impl Erasable for Result<mir::ConstValue, mir::interpret::ErrorHandled> {
198-
type Storage = [u8; size_of::<Result<mir::ConstValue, mir::interpret::ErrorHandled>>()];
199-
}
200-
201192
impl Erasable for Option<(mir::ConstValue, Ty<'_>)> {
202193
type Storage = [u8; size_of::<Option<(mir::ConstValue, Ty<'_>)>>()];
203194
}
@@ -337,6 +328,8 @@ impl_erasable_for_simple_types! {
337328
Result<(), rustc_errors::ErrorGuaranteed>,
338329
Result<(), rustc_middle::traits::query::NoSolution>,
339330
Result<rustc_middle::traits::EvaluationResult, rustc_middle::traits::OverflowError>,
331+
Result<rustc_middle::ty::adjustment::CoerceUnsizedInfo, rustc_errors::ErrorGuaranteed>,
332+
Result<mir::ConstValue, mir::interpret::ErrorHandled>,
340333
rustc_abi::ReprOptions,
341334
rustc_ast::expand::allocator::AllocatorKind,
342335
rustc_hir::DefaultBodyStability,

compiler/rustc_middle/src/query/plumbing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ macro_rules! define_callbacks {
322322
non_queries { $($_:tt)* }
323323
) => {
324324
$(
325-
#[allow(unused_lifetimes)]
326325
pub mod $name {
327326
use super::*;
328327
use $crate::query::erase::{self, Erased};

src/doc/rustc-dev-guide/src/query.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,6 @@ pub fn provide(providers: &mut rustc_middle::util::Providers) {
168168
}
169169
```
170170

171-
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
172-
173-
- This function takes a mutable reference to the `query::Providers` struct and sets the fields to point to the correct provider functions.
174-
- You can also assign queries individually, e.g. `providers.type_of = type_of;`.
175-
- You can assign fields individually for each provider type (local, external, and hooks).
176-
177171
#### Adding a new provider
178172

179173
Suppose you want to add a new query called `fubar`.

src/librustdoc/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -954,15 +954,15 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
954954
})
955955
}
956956

957-
fn dump_feature_usage_metrics(tcxt: TyCtxt<'_>, metrics_dir: &Path) {
958-
let hash = tcxt.crate_hash(LOCAL_CRATE);
959-
let crate_name = tcxt.crate_name(LOCAL_CRATE);
957+
fn dump_feature_usage_metrics(tcx: TyCtxt<'_>, metrics_dir: &Path) {
958+
let hash = tcx.crate_hash(LOCAL_CRATE);
959+
let crate_name = tcx.crate_name(LOCAL_CRATE);
960960
let metrics_file_name = format!("unstable_feature_usage_metrics-{crate_name}-{hash}.json");
961961
let metrics_path = metrics_dir.join(metrics_file_name);
962-
if let Err(error) = tcxt.features().dump_feature_usage_metrics(metrics_path) {
962+
if let Err(error) = tcx.features().dump_feature_usage_metrics(metrics_path) {
963963
// FIXME(yaahc): once metrics can be enabled by default we will want "failure to emit
964964
// default metrics" to only produce a warning when metrics are enabled by default and emit
965965
// an error only when the user manually enables metrics
966-
tcxt.dcx().err(format!("cannot emit feature usage metrics: {error}"));
966+
tcx.dcx().err(format!("cannot emit feature usage metrics: {error}"));
967967
}
968968
}

0 commit comments

Comments
 (0)