Skip to content

Commit b0c72aa

Browse files
committed
minor refactor
1 parent 6c3e762 commit b0c72aa

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/librustc_codegen_llvm/debuginfo/metadata.rs

+8-13
Original file line numberDiff line numberDiff line change
@@ -654,12 +654,11 @@ pub fn type_metadata(
654654
// type is going to see *somthing* weird - the only
655655
// question is what exactly it will see
656656
let mem_pos = cx.mem_pos_of(t);
657-
let (size, align) = (mem_pos.size, mem_pos.align);
658657
llvm::LLVMRustDIBuilderCreateBasicType(
659658
DIB(cx),
660659
SmallCStr::new("<recur_type>").as_ptr(),
661-
size.bits(),
662-
align.bits() as u32,
660+
mem_pos.size.bits(),
661+
mem_pos.align.bits() as u32,
663662
DW_ATE_unsigned)
664663
}
665664
};
@@ -853,14 +852,13 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType {
853852
};
854853

855854
let mem_pos = cx.mem_pos_of(t);
856-
let (size, align) = (mem_pos.size, mem_pos.align);
857855
let name = SmallCStr::new(name);
858856
let ty_metadata = unsafe {
859857
llvm::LLVMRustDIBuilderCreateBasicType(
860858
DIB(cx),
861859
name.as_ptr(),
862-
size.bits(),
863-
align.bits() as u32,
860+
mem_pos.size.bits(),
861+
mem_pos.align.bits() as u32,
864862
encoding)
865863
};
866864

@@ -1923,8 +1921,6 @@ fn prepare_enum_metadata(
19231921
} => {
19241922
let discr_type = discr.value.to_ty(cx.tcx);
19251923
let mem_pos = cx.mem_pos_of(discr_type);
1926-
let (size, align) = (mem_pos.size, mem_pos.align);
1927-
19281924

19291925
let discr_metadata = basic_type_metadata(cx, discr_type);
19301926
unsafe {
@@ -1934,8 +1930,8 @@ fn prepare_enum_metadata(
19341930
discriminator_name,
19351931
file_metadata,
19361932
UNKNOWN_LINE_NUMBER,
1937-
size.bits(),
1938-
align.bits() as u32,
1933+
mem_pos.size.bits(),
1934+
mem_pos.align.bits() as u32,
19391935
layout.fields.offset(discr_index).bits(),
19401936
DIFlags::FlagArtificial,
19411937
discr_metadata))
@@ -2137,7 +2133,6 @@ fn create_struct_stub(
21372133
containing_scope: Option<&'ll DIScope>,
21382134
) -> &'ll DICompositeType {
21392135
let struct_mem_pos = cx.mem_pos_of(struct_type);
2140-
let (struct_size, struct_align) = (struct_mem_pos.size, struct_mem_pos.align);
21412136

21422137
let name = SmallCStr::new(struct_type_name);
21432138
let unique_type_id = SmallCStr::new(
@@ -2155,8 +2150,8 @@ fn create_struct_stub(
21552150
name.as_ptr(),
21562151
unknown_file_metadata(cx),
21572152
UNKNOWN_LINE_NUMBER,
2158-
struct_size.bits(),
2159-
struct_align.bits() as u32,
2153+
struct_mem_pos.size.bits(),
2154+
struct_mem_pos.align.bits() as u32,
21602155
DIFlags::FlagZero,
21612156
None,
21622157
empty_array,

src/librustc_codegen_ssa/mir/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
399399
// as this will yield the lowest alignment.
400400
let layout = self.layout.field(bx, 0);
401401
let offset = if let Some(llindex) = bx.const_to_opt_uint(llindex) {
402-
layout.pref_pos.size.checked_mul(llindex, bx).unwrap_or(layout.pref_pos.size)
402+
layout.pref_pos.checked_mul(llindex, bx).unwrap_or(layout.pref_pos).size
403403
} else {
404404
layout.pref_pos.size
405405
};

0 commit comments

Comments
 (0)