Skip to content

Commit b3b6e4d

Browse files
committed
Some refactorings
1 parent 0c1dc62 commit b3b6e4d

File tree

7 files changed

+26
-31
lines changed

7 files changed

+26
-31
lines changed

src/librustc_codegen_llvm/builder.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ impl BackendTypes for Builder<'_, 'll, 'tcx> {
5858
type Value = <CodegenCx<'ll, 'tcx> as BackendTypes>::Value;
5959
type BasicBlock = <CodegenCx<'ll, 'tcx> as BackendTypes>::BasicBlock;
6060
type Type = <CodegenCx<'ll, 'tcx> as BackendTypes>::Type;
61-
type Context = <CodegenCx<'ll, 'tcx> as BackendTypes>::Context;
6261
type Funclet = <CodegenCx<'ll, 'tcx> as BackendTypes>::Funclet;
6362

6463
type DIScope = <CodegenCx<'ll, 'tcx> as BackendTypes>::DIScope;

src/librustc_codegen_llvm/common.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ impl BackendTypes for CodegenCx<'ll, 'tcx> {
9898
type Value = &'ll Value;
9999
type BasicBlock = &'ll BasicBlock;
100100
type Type = &'ll Type;
101-
type Context = &'ll llvm::Context;
102101
type Funclet = Funclet<'ll>;
103102

104103
type DIScope = &'ll llvm::debuginfo::DIScope;

src/librustc_codegen_llvm/type_.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,22 @@ impl fmt::Debug for Type {
4747
}
4848
}
4949

50+
impl CodegenCx<'ll, 'tcx> {
51+
crate fn type_named_struct(&self, name: &str) -> &'ll Type {
52+
let name = SmallCStr::new(name);
53+
unsafe {
54+
llvm::LLVMStructCreateNamed(self.llcx, name.as_ptr())
55+
}
56+
}
57+
58+
crate fn set_struct_body(&self, ty: &'ll Type, els: &[&'ll Type], packed: bool) {
59+
unsafe {
60+
llvm::LLVMStructSetBody(ty, els.as_ptr(),
61+
els.len() as c_uint, packed as Bool)
62+
}
63+
}
64+
}
65+
5066
impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
5167
fn type_void(&self) -> &'ll Type {
5268
unsafe {
@@ -160,13 +176,6 @@ impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
160176
}
161177
}
162178

163-
fn type_named_struct(&self, name: &str) -> &'ll Type {
164-
let name = SmallCStr::new(name);
165-
unsafe {
166-
llvm::LLVMStructCreateNamed(self.llcx, name.as_ptr())
167-
}
168-
}
169-
170179

171180
fn type_array(&self, ty: &'ll Type, len: u64) -> &'ll Type {
172181
unsafe {
@@ -186,13 +195,6 @@ impl BaseTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
186195
}
187196
}
188197

189-
fn set_struct_body(&self, ty: &'ll Type, els: &[&'ll Type], packed: bool) {
190-
unsafe {
191-
llvm::LLVMStructSetBody(ty, els.as_ptr(),
192-
els.len() as c_uint, packed as Bool)
193-
}
194-
}
195-
196198
fn type_ptr_to(&self, ty: &'ll Type) -> &'ll Type {
197199
assert_ne!(self.type_kind(ty), TypeKind::Function,
198200
"don't call ptr_to on function types, use ptr_to_llvm_type on FnType instead");

src/librustc_codegen_ssa/debuginfo.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,21 @@ impl<D> FunctionDebugContext<D> {
2323
match *self {
2424
FunctionDebugContext::RegularContext(ref data) => data,
2525
FunctionDebugContext::DebugInfoDisabled => {
26-
span_bug!(span, "{}", FunctionDebugContext::<D>::debuginfo_disabled_message());
26+
span_bug!(
27+
span,
28+
"debuginfo: Error trying to access FunctionDebugContext \
29+
although debug info is disabled!",
30+
);
2731
}
2832
FunctionDebugContext::FunctionWithoutDebugInfo => {
29-
span_bug!(span, "{}", FunctionDebugContext::<D>::should_be_ignored_message());
33+
span_bug!(
34+
span,
35+
"debuginfo: Error trying to access FunctionDebugContext \
36+
for function that should be ignored by debug info!",
37+
);
3038
}
3139
}
3240
}
33-
34-
fn debuginfo_disabled_message() -> &'static str {
35-
"debuginfo: Error trying to access FunctionDebugContext although debug info is disabled!"
36-
}
37-
38-
fn should_be_ignored_message() -> &'static str {
39-
"debuginfo: Error trying to access FunctionDebugContext for function that should be \
40-
ignored by debug info!"
41-
}
4241
}
4342

4443
/// Enables emitting source locations for the given functions.

src/librustc_codegen_ssa/traits/backend.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub trait BackendTypes {
2626
type Value: CodegenObject;
2727
type BasicBlock: Copy;
2828
type Type: CodegenObject;
29-
type Context;
3029
type Funclet;
3130

3231
type DIScope: Copy;

src/librustc_codegen_ssa/traits/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ pub trait HasCodegen<'tcx>: Backend<'tcx> {
9292
Value = Self::Value,
9393
BasicBlock = Self::BasicBlock,
9494
Type = Self::Type,
95-
Context = Self::Context,
9695
Funclet = Self::Funclet,
9796
DIScope = Self::DIScope,
9897
>;

src/librustc_codegen_ssa/traits/type_.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ pub trait BaseTypeMethods<'tcx>: Backend<'tcx> {
4141
fn type_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
4242
fn type_variadic_func(&self, args: &[Self::Type], ret: Self::Type) -> Self::Type;
4343
fn type_struct(&self, els: &[Self::Type], packed: bool) -> Self::Type;
44-
fn type_named_struct(&self, name: &str) -> Self::Type;
4544
fn type_array(&self, ty: Self::Type, len: u64) -> Self::Type;
4645
fn type_vector(&self, ty: Self::Type, len: u64) -> Self::Type;
4746
fn type_kind(&self, ty: Self::Type) -> TypeKind;
48-
fn set_struct_body(&self, ty: Self::Type, els: &[Self::Type], packed: bool);
4947
fn type_ptr_to(&self, ty: Self::Type) -> Self::Type;
5048
fn element_type(&self, ty: Self::Type) -> Self::Type;
5149

0 commit comments

Comments
 (0)