1
Fork 0

Rollup merge of #139811 - yotamofek:pr/newtype_cleanups, r=oli-obk

Use `newtype_index!`-generated types more idiomatically

Continuation of sorts of #139674
Shouldn't affect anything, just makes some code simpler
This commit is contained in:
Matthias Krüger 2025-04-14 21:55:40 +02:00 committed by GitHub
commit 04d10520f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 61 additions and 87 deletions

View file

@ -531,12 +531,12 @@ fn write_mir_intro<'tcx>(
// construct a scope tree and write it out
let mut scope_tree: FxHashMap<SourceScope, Vec<SourceScope>> = Default::default();
for (index, scope_data) in body.source_scopes.iter().enumerate() {
for (index, scope_data) in body.source_scopes.iter_enumerated() {
if let Some(parent) = scope_data.parent_scope {
scope_tree.entry(parent).or_default().push(SourceScope::new(index));
scope_tree.entry(parent).or_default().push(index);
} else {
// Only the argument scope has no parent, because it's the root.
assert_eq!(index, OUTERMOST_SOURCE_SCOPE.index());
assert_eq!(index, OUTERMOST_SOURCE_SCOPE);
}
}

View file

@ -278,7 +278,7 @@ impl<'tcx> TyCtxt<'tcx> {
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
let shift_bv = |bv: ty::BoundVar| ty::BoundVar::from_usize(bv.as_usize() + bound_vars);
let shift_bv = |bv: ty::BoundVar| bv + bound_vars;
self.replace_escaping_bound_vars_uncached(
value,
FnMutDelegate {

View file

@ -231,9 +231,7 @@ impl MaxUniverse {
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxUniverse {
fn visit_ty(&mut self, t: Ty<'tcx>) {
if let ty::Placeholder(placeholder) = t.kind() {
self.max_universe = ty::UniverseIndex::from_u32(
self.max_universe.as_u32().max(placeholder.universe.as_u32()),
);
self.max_universe = self.max_universe.max(placeholder.universe);
}
t.super_visit_with(self)
@ -241,9 +239,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxUniverse {
fn visit_const(&mut self, c: ty::consts::Const<'tcx>) {
if let ty::ConstKind::Placeholder(placeholder) = c.kind() {
self.max_universe = ty::UniverseIndex::from_u32(
self.max_universe.as_u32().max(placeholder.universe.as_u32()),
);
self.max_universe = self.max_universe.max(placeholder.universe);
}
c.super_visit_with(self)
@ -251,9 +247,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for MaxUniverse {
fn visit_region(&mut self, r: ty::Region<'tcx>) {
if let ty::RePlaceholder(placeholder) = r.kind() {
self.max_universe = ty::UniverseIndex::from_u32(
self.max_universe.as_u32().max(placeholder.universe.as_u32()),
);
self.max_universe = self.max_universe.max(placeholder.universe);
}
}
}