summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_mir_build/src/build/mod.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:35 +0000
commitd1b2d29528b7794b41e66fc2136e395a02f8529b (patch)
treea4a17504b260206dec3cf55b2dca82929a348ac2 /compiler/rustc_mir_build/src/build/mod.rs
parentReleasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz
rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_mir_build/src/build/mod.rs')
-rw-r--r--compiler/rustc_mir_build/src/build/mod.rs45
1 files changed, 25 insertions, 20 deletions
diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs
index d828e71c7..2a23a69b5 100644
--- a/compiler/rustc_mir_build/src/build/mod.rs
+++ b/compiler/rustc_mir_build/src/build/mod.rs
@@ -10,6 +10,7 @@ use rustc_hir as hir;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{GeneratorKind, Node};
+use rustc_index::bit_set::GrowableBitSet;
use rustc_index::{Idx, IndexSlice, IndexVec};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
@@ -93,8 +94,7 @@ fn mir_build(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> {
|| body.basic_blocks.has_free_regions()
|| body.var_debug_info.has_free_regions()
|| body.yield_ty().has_free_regions()),
- "Unexpected free regions in MIR: {:?}",
- body,
+ "Unexpected free regions in MIR: {body:?}",
);
body
@@ -215,6 +215,14 @@ struct Builder<'a, 'tcx> {
unit_temp: Option<Place<'tcx>>,
var_debug_info: Vec<VarDebugInfo<'tcx>>,
+
+ // A cache for `maybe_lint_level_roots_bounded`. That function is called
+ // repeatedly, and each time it effectively traces a path through a tree
+ // structure from a node towards the root, doing an attribute check on each
+ // node along the way. This cache records which nodes trace all the way to
+ // the root (most of them do) and saves us from retracing many sub-paths
+ // many times, and rechecking many nodes.
+ lint_level_roots_cache: GrowableBitSet<hir::ItemLocalId>,
}
type CaptureMap<'tcx> = SortedIndexMultiMap<usize, hir::HirId, Capture<'tcx>>;
@@ -473,7 +481,7 @@ fn construct_fn<'tcx>(
let (yield_ty, return_ty) = if generator_kind.is_some() {
let gen_ty = arguments[thir::UPVAR_ENV_PARAM].ty;
let gen_sig = match gen_ty.kind() {
- ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(),
+ ty::Generator(_, gen_args, ..) => gen_args.as_generator().sig(),
_ => {
span_bug!(span, "generator w/o generator type: {:?}", gen_ty)
}
@@ -562,7 +570,7 @@ fn construct_const<'a, 'tcx>(
// Figure out what primary body this item has.
let (span, const_ty_span) = match tcx.hir().get(hir_id) {
Node::Item(hir::Item {
- kind: hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _),
+ kind: hir::ItemKind::Static(ty, _, _) | hir::ItemKind::Const(ty, _, _),
span,
..
})
@@ -618,11 +626,9 @@ fn construct_error(tcx: TyCtxt<'_>, def: LocalDefId, err: ErrorGuaranteed) -> Bo
let num_params = match body_owner_kind {
hir::BodyOwnerKind::Fn => tcx.fn_sig(def).skip_binder().inputs().skip_binder().len(),
hir::BodyOwnerKind::Closure => {
- let ty = tcx.type_of(def).subst_identity();
+ let ty = tcx.type_of(def).instantiate_identity();
match ty.kind() {
- ty::Closure(_, substs) => {
- 1 + substs.as_closure().sig().inputs().skip_binder().len()
- }
+ ty::Closure(_, args) => 1 + args.as_closure().sig().inputs().skip_binder().len(),
ty::Generator(..) => 2,
_ => bug!("expected closure or generator, found {ty:?}"),
}
@@ -725,6 +731,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
var_indices: Default::default(),
unit_temp: None,
var_debug_info: vec![],
+ lint_level_roots_cache: GrowableBitSet::new_empty(),
};
assert_eq!(builder.cfg.start_new_block(), START_BLOCK);
@@ -768,9 +775,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
closure_ty = *ty;
}
- let upvar_substs = match closure_ty.kind() {
- ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs),
- ty::Generator(_, substs, _) => ty::UpvarSubsts::Generator(substs),
+ let upvar_args = match closure_ty.kind() {
+ ty::Closure(_, args) => ty::UpvarArgs::Closure(args),
+ ty::Generator(_, args, _) => ty::UpvarArgs::Generator(args),
_ => return,
};
@@ -779,7 +786,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// with the closure's DefId. Here, we run through that vec of UpvarIds for
// the given closure and use the necessary information to create upvar
// debuginfo and to fill `self.upvars`.
- let capture_tys = upvar_substs.upvar_tys();
+ let capture_tys = upvar_args.upvar_tys();
let tcx = self.tcx;
self.upvars = tcx
@@ -813,7 +820,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
};
self.var_debug_info.push(VarDebugInfo {
name,
- references: 0,
source_info: SourceInfo::outermost(captured_place.var_ident.span),
value: VarDebugInfoContents::Place(use_place),
argument_index: None,
@@ -844,7 +850,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.var_debug_info.push(VarDebugInfo {
name,
source_info,
- references: 0,
value: VarDebugInfoContents::Place(arg_local.into()),
argument_index: Some(argument_index as u16 + 1),
});
@@ -969,9 +974,9 @@ pub(crate) fn parse_float_into_scalar(
match float_ty {
ty::FloatTy::F32 => {
let Ok(rust_f) = num.parse::<f32>() else { return None };
- let mut f = num.parse::<Single>().unwrap_or_else(|e| {
- panic!("apfloat::ieee::Single failed to parse `{}`: {:?}", num, e)
- });
+ let mut f = num
+ .parse::<Single>()
+ .unwrap_or_else(|e| panic!("apfloat::ieee::Single failed to parse `{num}`: {e:?}"));
assert!(
u128::from(rust_f.to_bits()) == f.to_bits(),
@@ -992,9 +997,9 @@ pub(crate) fn parse_float_into_scalar(
}
ty::FloatTy::F64 => {
let Ok(rust_f) = num.parse::<f64>() else { return None };
- let mut f = num.parse::<Double>().unwrap_or_else(|e| {
- panic!("apfloat::ieee::Double failed to parse `{}`: {:?}", num, e)
- });
+ let mut f = num
+ .parse::<Double>()
+ .unwrap_or_else(|e| panic!("apfloat::ieee::Double failed to parse `{num}`: {e:?}"));
assert!(
u128::from(rust_f.to_bits()) == f.to_bits(),