Skip to content

Commit 2b5cd0f

Browse files
committed
Thread target type through, make CoerceChange type change happen in some visitors
1 parent 84a16f0 commit 2b5cd0f

30 files changed

Lines changed: 50 additions & 50 deletions

File tree

compiler/rustc_borrowck/src/borrow_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'tcx> {
302302
};
303303

304304
self.local_map.entry(borrowed_place.local).or_default().insert(idx);
305-
} else if let &mir::Rvalue::Reborrow(mutability, borrowed_place) = rvalue {
305+
} else if let &mir::Rvalue::Reborrow(mutability, borrowed_place, _target) = rvalue {
306306
let borrowed_place_ty = borrowed_place.ty(self.body, self.tcx).ty;
307307
let &ty::Adt(reborrowed_adt, _reborrowed_args) = borrowed_place_ty.kind() else {
308308
unreachable!()

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
549549
) {
550550
match &stmt.kind {
551551
mir::StatementKind::Assign(box (lhs, rhs)) => {
552-
if let mir::Rvalue::Ref(_, _, place) | mir::Rvalue::Reborrow(_, place) = rhs {
552+
if let mir::Rvalue::Ref(_, _, place) | mir::Rvalue::Reborrow(_, place, _) = rhs {
553553
if place.ignore_borrow(
554554
self.tcx,
555555
self.body,

compiler/rustc_borrowck/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
15091509
);
15101510
}
15111511

1512-
&Rvalue::Reborrow(mutability, place) => {
1512+
&Rvalue::Reborrow(mutability, place, _target) => {
15131513
let access_kind = (
15141514
Deep,
15151515
if mutability == Mutability::Mut {

compiler/rustc_borrowck/src/polonius/legacy/loan_invalidations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl<'a, 'tcx> LoanInvalidationsGenerator<'a, 'tcx> {
275275
self.access_place(location, place, access_kind, LocalMutationIsAllowed::No);
276276
}
277277

278-
&Rvalue::Reborrow(mutability, place) => {
278+
&Rvalue::Reborrow(mutability, place, _target) => {
279279
let access_kind = (
280280
Deep,
281281
if mutability == Mutability::Mut {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
551551

552552
impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
553553
fn visit_assign(&mut self, place: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) {
554-
// check rvalue is Reborrow
555-
if let Rvalue::Reborrow(mutability, rvalue) = rvalue {
554+
if let Rvalue::Reborrow(mutability, rvalue, _) = rvalue {
555+
// check rvalue is Reborrow
556556
self.add_generic_reborrow_constraint(*mutability, location, place, rvalue);
557557
} else {
558558
// rest of the cases
@@ -637,11 +637,11 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
637637
debug!(?rv_ty);
638638
let rv_ty = self.normalize(rv_ty, location);
639639
debug!("normalized rv_ty: {:?}", rv_ty);
640-
// Note: we've checked Reborrow/CoerceShared type matches
641-
// separately in fn visit_assign.
642-
if !matches!(rv, Rvalue::Reborrow(_, _))
643-
&& let Err(terr) =
644-
self.sub_types(rv_ty, place_ty, location.to_locations(), category)
640+
if let Rvalue::Reborrow(mutability, rvalue, _) = rv {
641+
// check rvalue is Reborrow
642+
self.add_generic_reborrow_constraint(*mutability, location, place, rvalue);
643+
} else if let Err(terr) =
644+
self.sub_types(rv_ty, place_ty, location.to_locations(), category)
645645
{
646646
span_mirbug!(
647647
self,

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
514514
// Generic shared reborrowing is not (necessarily) a simple memcpy, but currently the
515515
// coherence check places such restrictions on the CoerceShared trait as to guarantee
516516
// that it is.
517-
mir::Rvalue::Reborrow(_, place) => self.codegen_operand(bx, &mir::Operand::Copy(place)),
517+
mir::Rvalue::Reborrow(_, place, _) => {
518+
self.codegen_operand(bx, &mir::Operand::Copy(place))
519+
}
518520

519521
mir::Rvalue::RawPtr(kind, place) => {
520522
let mk_ptr = move |tcx: TyCtxt<'tcx>, ty: Ty<'tcx>| {

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ where
255255
in_place::<Q, _>(cx, in_local, place.as_ref())
256256
}
257257

258-
Rvalue::Reborrow(_, place) => in_place::<Q, _>(cx, in_local, place.as_ref()),
258+
Rvalue::Reborrow(_, place, _) => in_place::<Q, _>(cx, in_local, place.as_ref()),
259259

260260
Rvalue::WrapUnsafeBinder(op, _) => in_operand::<Q, _>(cx, in_local, op),
261261

compiler/rustc_const_eval/src/check_consts/resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ where
191191
}
192192
}
193193

194-
mir::Rvalue::Reborrow(mutability, borrowed_place) => {
194+
mir::Rvalue::Reborrow(mutability, borrowed_place, _target) => {
195195
if !borrowed_place.is_indirect() && mutability.is_mut() {
196196
let place_ty = borrowed_place.ty(self.ccx.body, self.ccx.tcx).ty;
197197
if Q::in_any_value_of_ty(self.ccx, place_ty) {

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
270270
self.copy_op_allow_transmute(&op, &dest)?;
271271
}
272272

273-
Reborrow(_, place) => {
273+
Reborrow(_, place, _) => {
274274
let op = self.eval_place_to_op(place, Some(dest.layout))?;
275275
self.copy_op(&op, &dest)?;
276276
}

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
12511251
with_no_trimmed_paths!(write!(fmt, "wrap_binder!({op:?}; {ty})"))
12521252
}
12531253

1254-
Reborrow(mutability, ref place) => {
1254+
Reborrow(mutability, ref place, _) => {
12551255
if mutability.is_mut() {
12561256
write!(fmt, "reborrow {place:?}")
12571257
} else {

0 commit comments

Comments
 (0)