1
Fork 0

Require Deref to CodegenCx for HasCodegen

This commit is contained in:
bjorn3 2018-11-27 18:35:35 +01:00
parent f47505e867
commit e45733048e
2 changed files with 11 additions and 2 deletions

View file

@ -29,7 +29,7 @@ use rustc_codegen_ssa::mir::operand::{OperandValue, OperandRef};
use rustc_codegen_ssa::mir::place::PlaceRef;
use std::borrow::Cow;
use std::ffi::CStr;
use std::ops::Range;
use std::ops::{Deref, Range};
use std::ptr;
// All Builders must have an llfn associated with them
@ -84,6 +84,13 @@ impl ty::layout::LayoutOf for Builder<'_, '_, 'tcx> {
}
}
impl Deref for Builder<'_, 'll, 'tcx> {
type Target = CodegenCx<'ll, 'tcx>;
fn deref(&self) -> &Self::Target {
self.cx
}
}
impl HasCodegen<'tcx> for Builder<'_, 'll, 'tcx> {
type CodegenCx = CodegenCx<'ll, 'tcx>;

View file

@ -85,7 +85,9 @@ impl<'tcx, T> CodegenMethods<'tcx> for T where
{
}
pub trait HasCodegen<'tcx>: Backend<'tcx> {
pub trait HasCodegen<'tcx>:
Backend<'tcx> + ::std::ops::Deref<Target = <Self as HasCodegen<'tcx>>::CodegenCx>
{
type CodegenCx: CodegenMethods<'tcx>
+ BackendTypes<
Value = Self::Value,