Skip to content

Commit 12353c1

Browse files
compiler-errorseholk
authored andcommitted
Use principal of cast target as dyn-star trait ref in codegen
1 parent ef7062d commit 12353c1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_middle::mir;
1212
use rustc_middle::mir::Operand;
1313
use rustc_middle::ty::cast::{CastTy, IntTy};
1414
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf};
15-
use rustc_middle::ty::TraitObjectRepresentation;
1615
use rustc_middle::ty::{self, adjustment::PointerCast, Instance, Ty, TyCtxt};
1716
use rustc_span::source_map::{Span, DUMMY_SP};
1817

@@ -279,12 +278,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
279278
OperandValue::Immediate(v) => v,
280279
OperandValue::Pair(_, _) => todo!(),
281280
};
282-
// FIXME: find the real vtable!
283-
let trait_ref = if let ty::Dynamic(data, _, TraitObjectRepresentation::Sized) = cast.ty.kind() {
284-
data.principal()
285-
} else {
286-
bug!("Only valid to do a DynStar cast into a DynStar type")
287-
};
281+
let trait_ref =
282+
if let ty::Dynamic(data, _, ty::TraitObjectRepresentation::Sized) = cast.ty.kind() {
283+
data.principal()
284+
} else {
285+
bug!("Only valid to do a DynStar cast into a DynStar type")
286+
};
288287
let vtable = get_vtable(bx.cx(), source.ty(self.mir, bx.tcx()), trait_ref);
289288
OperandValue::Pair(data, vtable)
290289
}

0 commit comments

Comments
 (0)