Skip to content

Commit e457330

Browse files
committed
Require Deref to CodegenCx for HasCodegen
1 parent f47505e commit e457330

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/librustc_codegen_llvm/builder.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef};
2929
use rustc_codegen_ssa::mir::place::PlaceRef;
3030
use std::borrow::Cow;
3131
use std::ffi::CStr;
32-
use std::ops::Range;
32+
use std::ops::{Deref, Range};
3333
use std::ptr;
3434

3535
// All Builders must have an llfn associated with them
@@ -84,6 +84,13 @@ impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
8484
}
8585
}
8686

87+
impl Deref for Builder<'_, 'll, 'tcx> {
88+
type Target = CodegenCx<'ll, 'tcx>;
89+
90+
fn deref(&self) -> &Self::Target {
91+
self.cx
92+
}
93+
}
8794

8895
impl HasCodegen<'tcx> for Builder<'_, 'll, 'tcx> {
8996
type CodegenCx = CodegenCx<'ll, 'tcx>;

src/librustc_codegen_ssa/traits/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
8585
{
8686
}
8787

88-
pub trait HasCodegen<'tcx>: Backend<'tcx> {
88+
pub trait HasCodegen<'tcx>:
89+
Backend<'tcx> + ::std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>
90+
{
8991
type CodegenCx: CodegenMethods<'tcx>
9092
+ BackendTypes<
9193
Value = Self::Value,

0 commit comments

Comments
 (0)