Skip to content

Commit 1d43fbb

Browse files
committedJun 12, 2024
Auto merge of rust-lang#126332 - GuillaumeGomez:rollup-bu1q4pz, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - rust-lang#126039 (Promote `arm64ec-pc-windows-msvc` to tier 2) - rust-lang#126075 (Remove `DebugWithInfcx` machinery) - rust-lang#126228 (Provide correct parent for nested anon const) - rust-lang#126232 (interpret: dyn trait metadata check: equate traits in a proper way) - rust-lang#126242 (Simplify provider api to improve llvm ir) - rust-lang#126294 (coverage: Replace the old span refiner with a single function) - rust-lang#126295 (No uninitalized report in a pre-returned match arm) - rust-lang#126312 (Update `rustc-perf` submodule) - rust-lang#126322 (Follow up to splitting core's PanicInfo and std's PanicInfo) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0285dab + 5d22e7a commit 1d43fbb

Some content is hidden

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

51 files changed

+561
-851
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+17-4
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
557557
// for the branching codepaths that aren't covered, to point at them.
558558
let map = self.infcx.tcx.hir();
559559
let body = map.body_owned_by(self.mir_def_id());
560-
561-
let mut visitor = ConditionVisitor { spans: &spans, name: &name, errors: vec![] };
560+
let mut visitor =
561+
ConditionVisitor { tcx: self.infcx.tcx, spans: &spans, name: &name, errors: vec![] };
562562
visitor.visit_body(&body);
563563

564564
let mut show_assign_sugg = false;
@@ -4372,13 +4372,14 @@ impl<'hir> Visitor<'hir> for BreakFinder {
43724372

43734373
/// Given a set of spans representing statements initializing the relevant binding, visit all the
43744374
/// function expressions looking for branching code paths that *do not* initialize the binding.
4375-
struct ConditionVisitor<'b> {
4375+
struct ConditionVisitor<'b, 'tcx> {
4376+
tcx: TyCtxt<'tcx>,
43764377
spans: &'b [Span],
43774378
name: &'b str,
43784379
errors: Vec<(Span, String)>,
43794380
}
43804381

4381-
impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
4382+
impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
43824383
fn visit_expr(&mut self, ex: &'v hir::Expr<'v>) {
43834384
match ex.kind {
43844385
hir::ExprKind::If(cond, body, None) => {
@@ -4464,6 +4465,12 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
44644465
),
44654466
));
44664467
} else if let Some(guard) = &arm.guard {
4468+
if matches!(
4469+
self.tcx.hir_node(arm.body.hir_id),
4470+
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Ret(_), .. })
4471+
) {
4472+
continue;
4473+
}
44674474
self.errors.push((
44684475
arm.pat.span.to(guard.span),
44694476
format!(
@@ -4473,6 +4480,12 @@ impl<'b, 'v> Visitor<'v> for ConditionVisitor<'b> {
44734480
),
44744481
));
44754482
} else {
4483+
if matches!(
4484+
self.tcx.hir_node(arm.body.hir_id),
4485+
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Ret(_), .. })
4486+
) {
4487+
continue;
4488+
}
44764489
self.errors.push((
44774490
arm.pat.span,
44784491
format!(

‎compiler/rustc_const_eval/src/interpret/cast.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
387387
match (&src_pointee_ty.kind(), &dest_pointee_ty.kind()) {
388388
(&ty::Array(_, length), &ty::Slice(_)) => {
389389
let ptr = self.read_pointer(src)?;
390-
// u64 cast is from usize to u64, which is always good
391390
let val = Immediate::new_slice(
392391
ptr,
393392
length.eval_target_usize(*self.tcx, self.param_env),
@@ -405,13 +404,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
405404
let (old_data, old_vptr) = val.to_scalar_pair();
406405
let old_data = old_data.to_pointer(self)?;
407406
let old_vptr = old_vptr.to_pointer(self)?;
408-
let (ty, old_trait) = self.get_ptr_vtable(old_vptr)?;
409-
if old_trait != data_a.principal() {
410-
throw_ub!(InvalidVTableTrait {
411-
expected_trait: data_a,
412-
vtable_trait: old_trait,
413-
});
414-
}
407+
let ty = self.get_ptr_vtable_ty(old_vptr, Some(data_a))?;
415408
let new_vptr = self.get_vtable_ptr(ty, data_b.principal())?;
416409
self.write_immediate(Immediate::new_dyn_trait(old_data, new_vptr, self), dest)
417410
}

0 commit comments

Comments
 (0)