From 187c4cf2572f2bf43a2ee8cee9e459d9ecbc429a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 24 Nov 2018 16:30:29 +0100 Subject: [PATCH] Use BackendTypes instead of Backend or HasCodegen in a few places --- src/librustc_codegen_ssa/traits/abi.rs | 4 ++-- src/librustc_codegen_ssa/traits/asm.rs | 9 ++++----- src/librustc_codegen_ssa/traits/debuginfo.rs | 7 +++---- src/librustc_codegen_ssa/traits/declare.rs | 6 +++--- src/librustc_codegen_ssa/traits/intrinsic.rs | 4 ++-- src/librustc_codegen_ssa/traits/misc.rs | 4 ++-- src/librustc_codegen_ssa/traits/type_.rs | 2 ++ 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/librustc_codegen_ssa/traits/abi.rs b/src/librustc_codegen_ssa/traits/abi.rs index f35eb84813f..c659a99e1c9 100644 --- a/src/librustc_codegen_ssa/traits/abi.rs +++ b/src/librustc_codegen_ssa/traits/abi.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::HasCodegen; +use super::BackendTypes; use rustc::ty::{FnSig, Instance, Ty}; use rustc_target::abi::call::FnType; @@ -18,6 +18,6 @@ pub trait AbiMethods<'tcx> { fn fn_type_of_instance(&self, instance: &Instance<'tcx>) -> FnType<'tcx, Ty<'tcx>>; } -pub trait AbiBuilderMethods<'tcx>: HasCodegen<'tcx> { +pub trait AbiBuilderMethods<'tcx>: BackendTypes { fn apply_attrs_callsite(&mut self, ty: &FnType<'tcx, Ty<'tcx>>, callsite: Self::Value); } diff --git a/src/librustc_codegen_ssa/traits/asm.rs b/src/librustc_codegen_ssa/traits/asm.rs index 93e4869e937..0e56fe46a31 100644 --- a/src/librustc_codegen_ssa/traits/asm.rs +++ b/src/librustc_codegen_ssa/traits/asm.rs @@ -8,13 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::Backend; -use super::HasCodegen; +use super::BackendTypes; use mir::place::PlaceRef; use rustc::hir::{GlobalAsm, InlineAsm}; -pub trait AsmBuilderMethods<'tcx>: HasCodegen<'tcx> { - // Take an inline assembly expression and splat it out via LLVM +pub trait AsmBuilderMethods<'tcx>: BackendTypes { + /// Take an inline assembly expression and splat it out via LLVM fn codegen_inline_asm( &mut self, ia: &InlineAsm, @@ -23,6 +22,6 @@ pub trait AsmBuilderMethods<'tcx>: HasCodegen<'tcx> { ) -> bool; } -pub trait AsmMethods<'tcx>: Backend<'tcx> { +pub trait AsmMethods<'tcx> { fn codegen_global_asm(&self, ga: &GlobalAsm); } diff --git a/src/librustc_codegen_ssa/traits/debuginfo.rs b/src/librustc_codegen_ssa/traits/debuginfo.rs index 643776fcd64..c4becf37059 100644 --- a/src/librustc_codegen_ssa/traits/debuginfo.rs +++ b/src/librustc_codegen_ssa/traits/debuginfo.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::Backend; -use super::HasCodegen; +use super::BackendTypes; use debuginfo::{FunctionDebugContext, MirDebugScope, VariableAccess, VariableKind}; use rustc::hir::def_id::CrateNum; use rustc::mir; @@ -19,7 +18,7 @@ use rustc_mir::monomorphize::Instance; use syntax::ast::Name; use syntax_pos::{SourceFile, Span}; -pub trait DebugInfoMethods<'tcx>: Backend<'tcx> { +pub trait DebugInfoMethods<'tcx>: BackendTypes { fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value); /// Creates the function-specific debug context. @@ -51,7 +50,7 @@ pub trait DebugInfoMethods<'tcx>: Backend<'tcx> { fn debuginfo_upvar_decls_ops_sequence(&self, byte_offset_of_var_in_env: u64) -> [i64; 4]; } -pub trait DebugInfoBuilderMethods<'tcx>: HasCodegen<'tcx> { +pub trait DebugInfoBuilderMethods<'tcx>: BackendTypes { fn declare_local( &mut self, dbg_context: &FunctionDebugContext, diff --git a/src/librustc_codegen_ssa/traits/declare.rs b/src/librustc_codegen_ssa/traits/declare.rs index 38ef52e3c8e..f9a29652843 100644 --- a/src/librustc_codegen_ssa/traits/declare.rs +++ b/src/librustc_codegen_ssa/traits/declare.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::Backend; +use super::BackendTypes; use rustc::hir::def_id::DefId; use rustc::mir::mono::{Linkage, Visibility}; use rustc::ty; use rustc_mir::monomorphize::Instance; -pub trait DeclareMethods<'tcx>: Backend<'tcx> { +pub trait DeclareMethods<'tcx>: BackendTypes { /// Declare a global value. /// /// If there’s a value with the same name already declared, the function will @@ -71,7 +71,7 @@ pub trait DeclareMethods<'tcx>: Backend<'tcx> { fn get_defined_value(&self, name: &str) -> Option; } -pub trait PreDefineMethods<'tcx>: Backend<'tcx> { +pub trait PreDefineMethods<'tcx>: BackendTypes { fn predefine_static( &self, def_id: DefId, diff --git a/src/librustc_codegen_ssa/traits/intrinsic.rs b/src/librustc_codegen_ssa/traits/intrinsic.rs index 3e64644b205..539c781e283 100644 --- a/src/librustc_codegen_ssa/traits/intrinsic.rs +++ b/src/librustc_codegen_ssa/traits/intrinsic.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::HasCodegen; +use super::BackendTypes; use mir::operand::OperandRef; use rustc::ty::Ty; use rustc_target::abi::call::FnType; @@ -21,7 +21,7 @@ pub enum OverflowOp { Mul, } -pub trait IntrinsicCallMethods<'tcx>: HasCodegen<'tcx> { +pub trait IntrinsicCallMethods<'tcx>: BackendTypes { /// Remember to add all intrinsics here, in librustc_typeck/check/mod.rs, /// and in libcore/intrinsics.rs; if you need access to any llvm intrinsics, /// add them to librustc_codegen_llvm/context.rs diff --git a/src/librustc_codegen_ssa/traits/misc.rs b/src/librustc_codegen_ssa/traits/misc.rs index ab4f2f724cd..d8871dd3a58 100644 --- a/src/librustc_codegen_ssa/traits/misc.rs +++ b/src/librustc_codegen_ssa/traits/misc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use super::Backend; +use super::BackendTypes; use libc::c_uint; use rustc::mir::mono::Stats; use rustc::session::Session; @@ -18,7 +18,7 @@ use rustc_mir::monomorphize::partitioning::CodegenUnit; use std::cell::RefCell; use std::sync::Arc; -pub trait MiscMethods<'tcx>: Backend<'tcx> { +pub trait MiscMethods<'tcx>: BackendTypes { fn vtables( &self, ) -> &RefCell, ty::PolyExistentialTraitRef<'tcx>), Self::Value>>; diff --git a/src/librustc_codegen_ssa/traits/type_.rs b/src/librustc_codegen_ssa/traits/type_.rs index bc6b70ad02f..1d31bdfa9f0 100644 --- a/src/librustc_codegen_ssa/traits/type_.rs +++ b/src/librustc_codegen_ssa/traits/type_.rs @@ -20,6 +20,8 @@ use rustc_target::abi::call::{ArgType, CastTarget, FnType, Reg}; use std::cell::RefCell; use syntax::ast; +// This depends on `Backend` and not `BackendTypes`, because consumers will probably want to use +// `LayoutOf` or `HasTyCtxt`. This way, they don't have to add a constraint on it themselves. pub trait BaseTypeMethods<'tcx>: Backend<'tcx> { fn type_void(&self) -> Self::Type; fn type_metadata(&self) -> Self::Type;