Skip to content

Commit a161ab0

Browse files
committed
Auto merge of #113637 - Mark-Simulacrum:bootstrap-bump, r=ozkanonur
Bump bootstrap to 1.72 beta
2 parents 1b3e686 + e8b0b17 commit a161ab0

File tree

181 files changed

+1804
-1442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+1804
-1442
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ cf2dff2b1e3fa55fa5415d524200070d0d7aacfe
1616
b39a1d6f1a30ba29f25d7141038b9a5bf0126e36
1717
# reorder fluent message files
1818
f97fddab91fbf290ea5b691fe355d6f915220b6e
19+
# format let-else
20+
cc907f80b95c6ec530c5ee1b05b044a468f07eca

compiler/rustc_ast/src/token.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1111
use rustc_data_structures::sync::Lrc;
1212
use rustc_macros::HashStable_Generic;
1313
use rustc_span::symbol::{kw, sym};
14-
#[cfg_attr(not(bootstrap), allow(hidden_glob_reexports))]
14+
#[allow(hidden_glob_reexports)]
1515
use rustc_span::symbol::{Ident, Symbol};
1616
use rustc_span::{self, edition::Edition, Span, DUMMY_SP};
1717
use std::borrow::Cow;

compiler/rustc_ast_lowering/src/asm.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
352352

353353
let idx2 = *o.get();
354354
let (ref op2, op_sp2) = operands[idx2];
355-
let Some(asm::InlineAsmRegOrRegClass::Reg(reg2)) = op2.reg() else {
355+
let Some(asm::InlineAsmRegOrRegClass::Reg(reg2)) = op2.reg()
356+
else {
356357
unreachable!();
357358
};
358359

@@ -368,7 +369,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
368369
assert!(!*late);
369370
let out_op_sp = if input { op_sp2 } else { op_sp };
370371
Some(out_op_sp)
371-
},
372+
}
372373
_ => None,
373374
};
374375

@@ -377,7 +378,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
377378
op_span2: op_sp2,
378379
reg1_name: reg.name(),
379380
reg2_name: reg2.name(),
380-
in_out
381+
in_out,
381382
});
382383
}
383384
Entry::Vacant(v) => {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+40-24
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
714714
_ => None,
715715
};
716716

717-
let Some(borrow_level) = borrow_level else { return false; };
717+
let Some(borrow_level) = borrow_level else {
718+
return false;
719+
};
718720
let sugg = move_sites
719721
.iter()
720722
.map(|move_site| {
@@ -763,7 +765,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
763765
.typeck_root_def_id(self.mir_def_id().to_def_id())
764766
.as_local()
765767
.and_then(|def_id| tcx.hir().get_generics(def_id))
766-
else { return; };
768+
else {
769+
return;
770+
};
767771
// Try to find predicates on *generic params* that would allow copying `ty`
768772
let ocx = ObligationCtxt::new(&self.infcx);
769773
let copy_did = tcx.require_lang_item(LangItem::Copy, Some(span));
@@ -1220,18 +1224,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
12201224
return;
12211225
};
12221226
let inner_param_uses = find_all_local_uses::find(self.body, inner_param.local);
1223-
let Some((inner_call_loc, inner_call_term)) = inner_param_uses.into_iter().find_map(|loc| {
1224-
let Either::Right(term) = self.body.stmt_at(loc) else {
1225-
debug!("{:?} is a statement, so it can't be a call", loc);
1226-
return None;
1227-
};
1228-
let TerminatorKind::Call { args, .. } = &term.kind else {
1229-
debug!("not a call: {:?}", term);
1230-
return None;
1231-
};
1232-
debug!("checking call args for uses of inner_param: {:?}", args);
1233-
args.contains(&Operand::Move(inner_param)).then_some((loc, term))
1234-
}) else {
1227+
let Some((inner_call_loc, inner_call_term)) =
1228+
inner_param_uses.into_iter().find_map(|loc| {
1229+
let Either::Right(term) = self.body.stmt_at(loc) else {
1230+
debug!("{:?} is a statement, so it can't be a call", loc);
1231+
return None;
1232+
};
1233+
let TerminatorKind::Call { args, .. } = &term.kind else {
1234+
debug!("not a call: {:?}", term);
1235+
return None;
1236+
};
1237+
debug!("checking call args for uses of inner_param: {:?}", args);
1238+
args.contains(&Operand::Move(inner_param)).then_some((loc, term))
1239+
})
1240+
else {
12351241
debug!("no uses of inner_param found as a by-move call arg");
12361242
return;
12371243
};
@@ -1442,21 +1448,24 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
14421448
}
14431449

14441450
// Get closure's arguments
1445-
let ty::Closure(_, substs) = typeck_results.expr_ty(closure_expr).kind() else { /* hir::Closure can be a generator too */ return };
1451+
let ty::Closure(_, substs) = typeck_results.expr_ty(closure_expr).kind() else {
1452+
/* hir::Closure can be a generator too */
1453+
return;
1454+
};
14461455
let sig = substs.as_closure().sig();
14471456
let tupled_params =
14481457
tcx.erase_late_bound_regions(sig.inputs().iter().next().unwrap().map_bound(|&b| b));
14491458
let ty::Tuple(params) = tupled_params.kind() else { return };
14501459

14511460
// Find the first argument with a matching type, get its name
1452-
let Some((_, this_name)) = params
1453-
.iter()
1454-
.zip(hir.body_param_names(closure.body))
1455-
.find(|(param_ty, name)|{
1461+
let Some((_, this_name)) =
1462+
params.iter().zip(hir.body_param_names(closure.body)).find(|(param_ty, name)| {
14561463
// FIXME: also support deref for stuff like `Rc` arguments
14571464
param_ty.peel_refs() == local_ty && name != &Ident::empty()
14581465
})
1459-
else { return };
1466+
else {
1467+
return;
1468+
};
14601469

14611470
let spans;
14621471
if let Some((_path_expr, qpath)) = finder.error_path
@@ -2899,7 +2908,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
28992908
{
29002909
let def_id = def_id.expect_local();
29012910
for operand in operands {
2902-
let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand else {
2911+
let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) =
2912+
operand
2913+
else {
29032914
continue;
29042915
};
29052916
debug!(
@@ -2908,7 +2919,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
29082919
);
29092920

29102921
// Find the local from the operand.
2911-
let Some(assigned_from_local) = assigned_from.local_or_deref_local() else {
2922+
let Some(assigned_from_local) =
2923+
assigned_from.local_or_deref_local()
2924+
else {
29122925
continue;
29132926
};
29142927

@@ -2961,7 +2974,9 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
29612974
);
29622975

29632976
// Find the local from the rvalue.
2964-
let Some(assigned_from_local) = assigned_from.local_or_deref_local() else { continue };
2977+
let Some(assigned_from_local) = assigned_from.local_or_deref_local() else {
2978+
continue;
2979+
};
29652980
debug!(
29662981
"annotate_argument_and_return_for_borrow: \
29672982
assigned_from_local={:?}",
@@ -3009,7 +3024,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
30093024
assigned_to, args
30103025
);
30113026
for operand in args {
3012-
let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand else {
3027+
let (Operand::Copy(assigned_from) | Operand::Move(assigned_from)) = operand
3028+
else {
30133029
continue;
30143030
};
30153031
debug!(

compiler/rustc_borrowck/src/diagnostics/mod.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -847,14 +847,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
847847
kind: TerminatorKind::Call { fn_span, call_source, .. }, ..
848848
}) = &self.body[location.block].terminator
849849
{
850-
let Some((method_did, method_substs)) =
851-
rustc_middle::util::find_self_call(
852-
self.infcx.tcx,
853-
&self.body,
854-
target_temp,
855-
location.block,
856-
)
857-
else {
850+
let Some((method_did, method_substs)) = rustc_middle::util::find_self_call(
851+
self.infcx.tcx,
852+
&self.body,
853+
target_temp,
854+
location.block,
855+
) else {
858856
return normal_ret;
859857
};
860858

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
184184
}
185185
// Error with the pattern
186186
LookupResult::Exact(_) => {
187-
let LookupResult::Parent(Some(mpi)) = self.move_data.rev_lookup.find(move_from.as_ref()) else {
187+
let LookupResult::Parent(Some(mpi)) =
188+
self.move_data.rev_lookup.find(move_from.as_ref())
189+
else {
188190
// move_from should be a projection from match_place.
189191
unreachable!("Probably not unreachable...");
190192
};
@@ -494,8 +496,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
494496
if let LocalInfo::User(BindingForm::Var(VarBindingForm { pat_span, .. })) =
495497
*bind_to.local_info()
496498
{
497-
let Ok(pat_snippet) =
498-
self.infcx.tcx.sess.source_map().span_to_snippet(pat_span) else { continue; };
499+
let Ok(pat_snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(pat_span)
500+
else {
501+
continue;
502+
};
499503
let Some(stripped) = pat_snippet.strip_prefix('&') else {
500504
suggestions.push((
501505
bind_to.source_info.span.shrink_to_lo(),

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
648648
let def_id = self.body.source.def_id();
649649
let hir_id = hir_map.local_def_id_to_hir_id(def_id.as_local().unwrap());
650650
let node = hir_map.find(hir_id);
651-
let Some(hir::Node::Item(item)) = node else { return; };
652-
let hir::ItemKind::Fn(.., body_id) = item.kind else { return; };
651+
let Some(hir::Node::Item(item)) = node else {
652+
return;
653+
};
654+
let hir::ItemKind::Fn(.., body_id) = item.kind else {
655+
return;
656+
};
653657
let body = self.infcx.tcx.hir().body(body_id);
654658

655659
let mut v = V { assign_span: span, err, ty, suggested: false };

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+25-15
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
224224
let mut hrtb_bounds = vec![];
225225
gat_id_and_generics.iter().flatten().for_each(|(gat_hir_id, generics)| {
226226
for pred in generics.predicates {
227-
let BoundPredicate(
228-
WhereBoundPredicate {
229-
bound_generic_params,
230-
bounds,
231-
..
232-
}) = pred else { continue; };
227+
let BoundPredicate(WhereBoundPredicate { bound_generic_params, bounds, .. }) = pred
228+
else {
229+
continue;
230+
};
233231
if bound_generic_params
234232
.iter()
235233
.rfind(|bgp| hir.local_def_id_to_hir_id(bgp.def_id) == *gat_hir_id)
@@ -813,7 +811,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
813811
return;
814812
}
815813
let suitable_region = self.infcx.tcx.is_suitable_region(f);
816-
let Some(suitable_region) = suitable_region else { return; };
814+
let Some(suitable_region) = suitable_region else {
815+
return;
816+
};
817817

818818
let fn_returns = self.infcx.tcx.return_type_impl_or_dyn_traits(suitable_region.def_id);
819819

@@ -848,7 +848,10 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
848848
let Some((alias_tys, alias_span, lt_addition_span)) = self
849849
.infcx
850850
.tcx
851-
.return_type_impl_or_dyn_traits_with_type_alias(suitable_region.def_id) else { return; };
851+
.return_type_impl_or_dyn_traits_with_type_alias(suitable_region.def_id)
852+
else {
853+
return;
854+
};
852855

853856
// in case the return type of the method is a type alias
854857
let mut spans_suggs: Vec<_> = Vec::new();
@@ -932,8 +935,13 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
932935
let mut visitor = TraitObjectVisitor(FxIndexSet::default());
933936
visitor.visit_ty(param.param_ty);
934937

935-
let Some((ident, self_ty)) =
936-
NiceRegionError::get_impl_ident_and_self_ty_from_trait(tcx, instance.def_id(), &visitor.0) else { return; };
938+
let Some((ident, self_ty)) = NiceRegionError::get_impl_ident_and_self_ty_from_trait(
939+
tcx,
940+
instance.def_id(),
941+
&visitor.0,
942+
) else {
943+
return;
944+
};
937945

938946
self.suggest_constrain_dyn_trait_in_impl(diag, &visitor.0, ident, self_ty);
939947
}
@@ -981,23 +989,25 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
981989
sup: RegionVid,
982990
) {
983991
let (Some(sub), Some(sup)) = (self.to_error_region(sub), self.to_error_region(sup)) else {
984-
return
992+
return;
985993
};
986994

987995
let Some((ty_sub, _)) = self
988996
.infcx
989997
.tcx
990998
.is_suitable_region(sub)
991-
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sub, &anon_reg.boundregion)) else {
992-
return
999+
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sub, &anon_reg.boundregion))
1000+
else {
1001+
return;
9931002
};
9941003

9951004
let Some((ty_sup, _)) = self
9961005
.infcx
9971006
.tcx
9981007
.is_suitable_region(sup)
999-
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sup, &anon_reg.boundregion)) else {
1000-
return
1008+
.and_then(|anon_reg| find_anon_type(self.infcx.tcx, sup, &anon_reg.boundregion))
1009+
else {
1010+
return;
10011011
};
10021012

10031013
suggest_adding_lifetime_params(self.infcx.tcx, sub, ty_sup, ty_sub, diag);

compiler/rustc_borrowck/src/diagnostics/region_name.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
325325
// Can't have BrEnv in functions, constants or generators.
326326
bug!("BrEnv outside of closure.");
327327
};
328-
let hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. })
329-
= tcx.hir().expect_expr(self.mir_hir_id()).kind
328+
let hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }) =
329+
tcx.hir().expect_expr(self.mir_hir_id()).kind
330330
else {
331331
bug!("Closure is not defined by a closure expr");
332332
};

compiler/rustc_borrowck/src/region_infer/mod.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -2058,10 +2058,17 @@ impl<'tcx> RegionInferenceContext<'tcx> {
20582058
let mut extra_info = vec![];
20592059
for constraint in path.iter() {
20602060
let outlived = constraint.sub;
2061-
let Some(origin) = self.var_infos.get(outlived) else { continue; };
2062-
let RegionVariableOrigin::Nll(NllRegionVariableOrigin::Placeholder(p)) = origin.origin else { continue; };
2061+
let Some(origin) = self.var_infos.get(outlived) else {
2062+
continue;
2063+
};
2064+
let RegionVariableOrigin::Nll(NllRegionVariableOrigin::Placeholder(p)) = origin.origin
2065+
else {
2066+
continue;
2067+
};
20632068
debug!(?constraint, ?p);
2064-
let ConstraintCategory::Predicate(span) = constraint.category else { continue; };
2069+
let ConstraintCategory::Predicate(span) = constraint.category else {
2070+
continue;
2071+
};
20652072
extra_info.push(ExtraConstraintInfo::PlaceholderFromPredicate(span));
20662073
// We only want to point to one
20672074
break;

compiler/rustc_borrowck/src/type_check/mod.rs

+8-20
Original file line numberDiff line numberDiff line change
@@ -2039,28 +2039,16 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20392039
}
20402040

20412041
CastKind::PointerCoercion(PointerCoercion::MutToConstPointer) => {
2042-
let ty::RawPtr(ty::TypeAndMut {
2043-
ty: ty_from,
2044-
mutbl: hir::Mutability::Mut,
2045-
}) = op.ty(body, tcx).kind() else {
2046-
span_mirbug!(
2047-
self,
2048-
rvalue,
2049-
"unexpected base type for cast {:?}",
2050-
ty,
2051-
);
2042+
let ty::RawPtr(ty::TypeAndMut { ty: ty_from, mutbl: hir::Mutability::Mut }) =
2043+
op.ty(body, tcx).kind()
2044+
else {
2045+
span_mirbug!(self, rvalue, "unexpected base type for cast {:?}", ty,);
20522046
return;
20532047
};
2054-
let ty::RawPtr(ty::TypeAndMut {
2055-
ty: ty_to,
2056-
mutbl: hir::Mutability::Not,
2057-
}) = ty.kind() else {
2058-
span_mirbug!(
2059-
self,
2060-
rvalue,
2061-
"unexpected target type for cast {:?}",
2062-
ty,
2063-
);
2048+
let ty::RawPtr(ty::TypeAndMut { ty: ty_to, mutbl: hir::Mutability::Not }) =
2049+
ty.kind()
2050+
else {
2051+
span_mirbug!(self, rvalue, "unexpected target type for cast {:?}", ty,);
20642052
return;
20652053
};
20662054
if let Err(terr) = self.sub_types(

compiler/rustc_borrowck/src/universal_regions.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,9 @@ fn for_each_late_bound_region_in_item<'tcx>(
929929
}
930930

931931
for bound_var in tcx.late_bound_vars(tcx.hir().local_def_id_to_hir_id(mir_def_id)) {
932-
let ty::BoundVariableKind::Region(bound_region) = bound_var else { continue; };
932+
let ty::BoundVariableKind::Region(bound_region) = bound_var else {
933+
continue;
934+
};
933935
let liberated_region = ty::Region::new_free(tcx, mir_def_id.to_def_id(), bound_region);
934936
f(liberated_region);
935937
}

0 commit comments

Comments
 (0)