diff options
| author | bors <bors@rust-lang.org> | 2023-02-19 05:35:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-19 05:35:03 +0000 |
| commit | 73f40197ecabf77ed59028af61739404eb60dd2e (patch) | |
| tree | d85c5175b2c1b33af686cef847865a64be4eea77 /compiler/rustc_codegen_llvm/src | |
| parent | fcdbd1c07f0b6c8e7d8bbd727c6ca69a1af8c7e9 (diff) | |
| parent | 7f798c2b216db0bb7ebeb9dd863fbdf7668094c5 (diff) | |
| download | rust-73f40197ecabf77ed59028af61739404eb60dd2e.tar.gz rust-73f40197ecabf77ed59028af61739404eb60dd2e.zip | |
Auto merge of #107772 - compiler-errors:dyn-star-backend-is-ptr, r=eholk
Make `dyn*`'s value backend type a pointer One tweak on top of Ralf's commit should fix using `usize` as a `dyn*`-coercible type, and should fix when we're using various other pointer types when LLVM opaque pointers is disabled. r? `@eholk` but feel free to reassign cc https://github.com/rust-lang/rust/pull/107728#issuecomment-1421231823 `@RalfJung`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/type_of.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index cc8ff947fc3..9cda24bab87 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -329,7 +329,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { ) -> &'a Type { // HACK(eddyb) special-case fat pointers until LLVM removes // pointee types, to avoid bitcasting every `OperandRef::deref`. - match self.ty.kind() { + match *self.ty.kind() { ty::Ref(..) | ty::RawPtr(_) => { return self.field(cx, index).llvm_type(cx); } @@ -339,6 +339,11 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty()); return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate); } + // `dyn* Trait` has the same ABI as `*mut dyn Trait` + ty::Dynamic(bounds, region, ty::DynStar) => { + let ptr_ty = cx.tcx.mk_mut_ptr(cx.tcx.mk_dynamic(bounds, region, ty::Dyn)); + return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate); + } _ => {} } |
