Move some supertraits outward.
Specifically, put them where they are genuinely required, i.e. the outermost place they can be.
This commit is contained in:
parent
85a4d2af90
commit
540fcc617a
@ -280,7 +280,7 @@ pub fn immediate(self) -> V {
|
||||
///
|
||||
/// If you don't need the type, see [`OperandValue::pointer_parts`]
|
||||
/// or [`OperandValue::deref`].
|
||||
pub fn deref<Cx: LayoutTypeMethods<'tcx>>(self, cx: &Cx) -> PlaceRef<'tcx, V> {
|
||||
pub fn deref<Cx: CodegenMethods<'tcx>>(self, cx: &Cx) -> PlaceRef<'tcx, V> {
|
||||
if self.layout.ty.is_box() {
|
||||
// Derefer should have removed all Box derefs
|
||||
bug!("dereferencing {:?} in codegen", self.layout.ty);
|
||||
|
@ -27,6 +27,11 @@
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use rustc_middle::ty::layout::FnAbiOf;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_target::abi::call::FnAbi;
|
||||
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
|
||||
|
||||
pub use self::abi::AbiBuilderMethods;
|
||||
pub use self::asm::{AsmBuilderMethods, AsmMethods, GlobalAsmOperandRef, InlineAsmOperandRef};
|
||||
pub use self::backend::{BackendTypes, CodegenBackend, ExtraBackendMethods};
|
||||
@ -46,7 +51,9 @@
|
||||
|
||||
pub trait CodegenObject = Copy + PartialEq + fmt::Debug;
|
||||
|
||||
pub trait CodegenMethods<'tcx> = TypeMethods<'tcx>
|
||||
pub trait CodegenMethods<'tcx> = LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
|
||||
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
|
||||
+ TypeMethods<'tcx>
|
||||
+ ConstMethods<'tcx>
|
||||
+ StaticMethods
|
||||
+ DebugInfoMethods<'tcx>
|
||||
|
@ -1,5 +1,5 @@
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, LayoutOf, TyAndLayout};
|
||||
use rustc_middle::ty::layout::{HasTyCtxt, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_target::abi::call::{ArgAbi, CastTarget, FnAbi, Reg};
|
||||
use rustc_target::abi::{AddressSpace, Float, Integer};
|
||||
@ -9,7 +9,7 @@
|
||||
use crate::common::TypeKind;
|
||||
use crate::mir::place::PlaceRef;
|
||||
|
||||
pub trait BaseTypeMethods<'tcx>: BackendTypes + HasTyCtxt<'tcx> {
|
||||
pub trait BaseTypeMethods<'tcx>: BackendTypes {
|
||||
fn type_i8(&self) -> Self::Type;
|
||||
fn type_i16(&self) -> Self::Type;
|
||||
fn type_i32(&self) -> Self::Type;
|
||||
@ -40,7 +40,9 @@ pub trait BaseTypeMethods<'tcx>: BackendTypes + HasTyCtxt<'tcx> {
|
||||
fn val_ty(&self, v: Self::Value) -> Self::Type;
|
||||
}
|
||||
|
||||
pub trait DerivedTypeMethods<'tcx>: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {
|
||||
pub trait DerivedTypeMethods<'tcx>:
|
||||
BaseTypeMethods<'tcx> + MiscMethods<'tcx> + HasTyCtxt<'tcx>
|
||||
{
|
||||
fn type_int(&self) -> Self::Type {
|
||||
match &self.sess().target.c_int_width[..] {
|
||||
"16" => self.type_i16(),
|
||||
@ -98,13 +100,12 @@ fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T> DerivedTypeMethods<'tcx> for T where Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> {}
|
||||
|
||||
pub trait LayoutTypeMethods<'tcx>:
|
||||
BackendTypes
|
||||
+ LayoutOf<'tcx, LayoutOfResult = TyAndLayout<'tcx>>
|
||||
+ FnAbiOf<'tcx, FnAbiOfResult = &'tcx FnAbi<'tcx, Ty<'tcx>>>
|
||||
impl<'tcx, T> DerivedTypeMethods<'tcx> for T where
|
||||
Self: BaseTypeMethods<'tcx> + MiscMethods<'tcx> + HasTyCtxt<'tcx>
|
||||
{
|
||||
}
|
||||
|
||||
pub trait LayoutTypeMethods<'tcx>: BackendTypes {
|
||||
/// The backend type used for a rust type when it's in memory,
|
||||
/// such as when it's stack-allocated or when it's being loaded or stored.
|
||||
fn backend_type(&self, layout: TyAndLayout<'tcx>) -> Self::Type;
|
||||
|
Loading…
Reference in New Issue
Block a user