Skip to content

Commit 675cba0

Browse files
authored
Rollup merge of #118081 - nnethercote:rustc_ty_utils, r=compiler-errors
`rustc_ty_utils` cleanups Minor improvements I found while looking at this code. r? ``@lcnr``
2 parents 187d44b + 9e6ee72 commit 675cba0

File tree

11 files changed

+23
-33
lines changed

11 files changed

+23
-33
lines changed

compiler/rustc_ty_utils/src/abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_target::spec::abi::Abi as SpecAbi;
1616

1717
use std::iter;
1818

19-
pub fn provide(providers: &mut Providers) {
19+
pub(crate) fn provide(providers: &mut Providers) {
2020
*providers = Providers { fn_abi_of_fn_ptr, fn_abi_of_instance, ..*providers };
2121
}
2222

compiler/rustc_ty_utils/src/assoc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::query::Providers;
88
use rustc_middle::ty::{self, GenericArgs, ImplTraitInTraitData, Ty, TyCtxt};
99
use rustc_span::symbol::kw;
1010

11-
pub fn provide(providers: &mut Providers) {
11+
pub(crate) fn provide(providers: &mut Providers) {
1212
*providers = Providers {
1313
associated_item,
1414
associated_item_def_ids,

compiler/rustc_ty_utils/src/consts.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::errors::{GenericConstantTooComplex, GenericConstantTooComplexSub};
1717

1818
/// Destructures array, ADT or tuple constants into the constants
1919
/// of their fields.
20-
pub(crate) fn destructure_const<'tcx>(
20+
fn destructure_const<'tcx>(
2121
tcx: TyCtxt<'tcx>,
2222
const_: ty::Const<'tcx>,
2323
) -> ty::DestructuredConst<'tcx> {
@@ -396,7 +396,7 @@ impl<'a, 'tcx> visit::Visitor<'a, 'tcx> for IsThirPolymorphic<'a, 'tcx> {
396396
}
397397

398398
/// Builds an abstract const, do not use this directly, but use `AbstractConst::new` instead.
399-
pub fn thir_abstract_const(
399+
fn thir_abstract_const(
400400
tcx: TyCtxt<'_>,
401401
def: LocalDefId,
402402
) -> Result<Option<ty::EarlyBinder<ty::Const<'_>>>, ErrorGuaranteed> {
@@ -428,6 +428,6 @@ pub fn thir_abstract_const(
428428
Ok(Some(ty::EarlyBinder::bind(recurse_build(tcx, body, body_id, root_span)?)))
429429
}
430430

431-
pub fn provide(providers: &mut Providers) {
431+
pub(crate) fn provide(providers: &mut Providers) {
432432
*providers = Providers { destructure_const, thir_abstract_const, ..*providers };
433433
}

compiler/rustc_ty_utils/src/implied_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
77
use rustc_span::Span;
88
use std::iter;
99

10-
pub fn provide(providers: &mut Providers) {
10+
pub(crate) fn provide(providers: &mut Providers) {
1111
*providers = Providers {
1212
assumed_wf_types,
1313
assumed_wf_types_for_rpitit: |tcx, def_id| {

compiler/rustc_ty_utils/src/instance.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,6 @@ fn resolve_associated_item<'tcx>(
328328
})
329329
}
330330

331-
pub fn provide(providers: &mut Providers) {
331+
pub(crate) fn provide(providers: &mut Providers) {
332332
*providers = Providers { resolve_instance, ..*providers };
333333
}

compiler/rustc_ty_utils/src/layout.rs

+6-16
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::errors::{
2424
};
2525
use crate::layout_sanity_check::sanity_check_layout;
2626

27-
pub fn provide(providers: &mut Providers) {
27+
pub(crate) fn provide(providers: &mut Providers) {
2828
*providers = Providers { layout_of, ..*providers };
2929
}
3030

@@ -65,7 +65,11 @@ fn layout_of<'tcx>(
6565
let layout = layout_of_uncached(&cx, ty)?;
6666
let layout = TyAndLayout { ty, layout };
6767

68-
record_layout_for_printing(&cx, layout);
68+
// If we are running with `-Zprint-type-sizes`, maybe record layouts
69+
// for dumping later.
70+
if cx.tcx.sess.opts.unstable_opts.print_type_sizes {
71+
record_layout_for_printing(&cx, layout);
72+
}
6973

7074
sanity_check_layout(&cx, &layout);
7175

@@ -911,21 +915,7 @@ fn coroutine_layout<'tcx>(
911915
Ok(layout)
912916
}
913917

914-
/// This is invoked by the `layout_of` query to record the final
915-
/// layout of each type.
916-
#[inline(always)]
917918
fn record_layout_for_printing<'tcx>(cx: &LayoutCx<'tcx, TyCtxt<'tcx>>, layout: TyAndLayout<'tcx>) {
918-
// If we are running with `-Zprint-type-sizes`, maybe record layouts
919-
// for dumping later.
920-
if cx.tcx.sess.opts.unstable_opts.print_type_sizes {
921-
record_layout_for_printing_outlined(cx, layout)
922-
}
923-
}
924-
925-
fn record_layout_for_printing_outlined<'tcx>(
926-
cx: &LayoutCx<'tcx, TyCtxt<'tcx>>,
927-
layout: TyAndLayout<'tcx>,
928-
) {
929919
// Ignore layouts that are done with non-empty environments or
930920
// non-monomorphic layouts, as the user only wants to see the stuff
931921
// resulting from the final codegen session.

compiler/rustc_ty_utils/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
#![allow(internal_features)]
1111
#![feature(assert_matches)]
1212
#![feature(associated_type_defaults)]
13+
#![feature(box_patterns)]
14+
#![feature(if_let_guard)]
1315
#![feature(iterator_try_collect)]
1416
#![feature(let_chains)]
15-
#![feature(if_let_guard)]
1617
#![feature(never_type)]
17-
#![feature(box_patterns)]
1818
#![recursion_limit = "256"]
1919
#![deny(rustc::untranslatable_diagnostic)]
2020
#![deny(rustc::diagnostic_outside_of_impl)]
@@ -34,13 +34,13 @@ mod common_traits;
3434
mod consts;
3535
mod errors;
3636
mod implied_bounds;
37-
pub mod instance;
37+
mod instance;
3838
mod layout;
3939
mod layout_sanity_check;
4040
mod needs_drop;
4141
mod opaque_types;
42-
pub mod representability;
43-
pub mod sig_types;
42+
mod representability;
43+
mod sig_types;
4444
mod structural_match;
4545
mod ty;
4646

compiler/rustc_ty_utils/src/representability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_middle::query::Providers;
66
use rustc_middle::ty::{self, Representability, Ty, TyCtxt};
77
use rustc_span::def_id::LocalDefId;
88

9-
pub fn provide(providers: &mut Providers) {
9+
pub(crate) fn provide(providers: &mut Providers) {
1010
*providers =
1111
Providers { representability, representability_adt_ty, params_in_repr, ..*providers };
1212
}

compiler/rustc_ty_utils/src/sig_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_middle::ty::TyCtxt;
88
use rustc_span::Span;
99
use rustc_type_ir::visit::TypeVisitable;
1010

11-
pub trait SpannedTypeVisitor<'tcx> {
11+
pub(crate) trait SpannedTypeVisitor<'tcx> {
1212
type BreakTy = !;
1313
fn visit(
1414
&mut self,
@@ -17,7 +17,7 @@ pub trait SpannedTypeVisitor<'tcx> {
1717
) -> ControlFlow<Self::BreakTy>;
1818
}
1919

20-
pub fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
20+
pub(crate) fn walk_types<'tcx, V: SpannedTypeVisitor<'tcx>>(
2121
tcx: TyCtxt<'tcx>,
2222
item: LocalDefId,
2323
visitor: &mut V,

compiler/rustc_ty_utils/src/structural_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ fn has_structural_eq_impls<'tcx>(tcx: TyCtxt<'tcx>, adt_ty: Ty<'tcx>) -> bool {
3939
ocx.select_all_or_error().is_empty()
4040
}
4141

42-
pub fn provide(providers: &mut Providers) {
42+
pub(crate) fn provide(providers: &mut Providers) {
4343
providers.has_structural_eq_impls = has_structural_eq_impls;
4444
}

compiler/rustc_ty_utils/src/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ fn unsizing_params_for_adt<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> BitSet<u32
351351
unsizing_params
352352
}
353353

354-
pub fn provide(providers: &mut Providers) {
354+
pub(crate) fn provide(providers: &mut Providers) {
355355
*providers = Providers {
356356
asyncness,
357357
adt_sized_constraint,

0 commit comments

Comments
 (0)