Unnamed repository; edit this file 'description' to name the repository.
remove explicit deref of AbiAlign for most methods
Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference.
Jubilee Young 7 months ago
parent 7291893 · commit a805c9b
-rw-r--r--crates/hir-ty/src/layout/tests.rs4
-rw-r--r--crates/hir-ty/src/mir/eval.rs6
-rw-r--r--crates/hir-ty/src/mir/eval/shim.rs4
-rw-r--r--crates/hir/src/lib.rs2
4 files changed, 8 insertions, 8 deletions
diff --git a/crates/hir-ty/src/layout/tests.rs b/crates/hir-ty/src/layout/tests.rs
index 523ddad946..8be5eaca63 100644
--- a/crates/hir-ty/src/layout/tests.rs
+++ b/crates/hir-ty/src/layout/tests.rs
@@ -150,7 +150,7 @@ fn check_size_and_align(
) {
let l = eval_goal(ra_fixture, minicore).unwrap();
assert_eq!(l.size.bytes(), size, "size mismatch");
- assert_eq!(l.align.abi.bytes(), align, "align mismatch");
+ assert_eq!(l.align.bytes(), align, "align mismatch");
}
#[track_caller]
@@ -162,7 +162,7 @@ fn check_size_and_align_expr(
) {
let l = eval_expr(ra_fixture, minicore).unwrap();
assert_eq!(l.size.bytes(), size, "size mismatch");
- assert_eq!(l.align.abi.bytes(), align, "align mismatch");
+ assert_eq!(l.align.bytes(), align, "align mismatch");
}
#[track_caller]
diff --git a/crates/hir-ty/src/mir/eval.rs b/crates/hir-ty/src/mir/eval.rs
index 3e658cb93e..fc7d97fff4 100644
--- a/crates/hir-ty/src/mir/eval.rs
+++ b/crates/hir-ty/src/mir/eval.rs
@@ -2085,7 +2085,7 @@ impl<'db> Evaluator<'db> {
if let Some(layout) = self.layout_cache.borrow().get(&ty.to_nextsolver(interner)) {
return Ok(layout
.is_sized()
- .then(|| (layout.size.bytes_usize(), layout.align.abi.bytes() as usize)));
+ .then(|| (layout.size.bytes_usize(), layout.align.bytes() as usize)));
}
if let DefWithBodyId::VariantId(f) = locals.body.owner
&& let Some((AdtId::EnumId(e), _)) = ty.as_adt()
@@ -2104,7 +2104,7 @@ impl<'db> Evaluator<'db> {
let layout = layout?;
Ok(layout
.is_sized()
- .then(|| (layout.size.bytes_usize(), layout.align.abi.bytes() as usize)))
+ .then(|| (layout.size.bytes_usize(), layout.align.bytes() as usize)))
}
/// A version of `self.size_of` which returns error if the type is unsized. `what` argument should
@@ -2797,7 +2797,7 @@ impl<'db> Evaluator<'db> {
)?;
// FIXME: there is some leak here
let size = layout.size.bytes_usize();
- let addr = self.heap_allocate(size, layout.align.abi.bytes() as usize)?;
+ let addr = self.heap_allocate(size, layout.align.bytes() as usize)?;
self.write_memory(addr, &result)?;
IntervalAndTy { interval: Interval { addr, size }, ty }
};
diff --git a/crates/hir-ty/src/mir/eval/shim.rs b/crates/hir-ty/src/mir/eval/shim.rs
index f67778b0f1..3848049304 100644
--- a/crates/hir-ty/src/mir/eval/shim.rs
+++ b/crates/hir-ty/src/mir/eval/shim.rs
@@ -767,7 +767,7 @@ impl Evaluator<'_> {
"align_of generic arg is not provided".into(),
));
};
- let align = self.layout(ty.to_nextsolver(interner))?.align.abi.bytes();
+ let align = self.layout(ty.to_nextsolver(interner))?.align.bytes();
destination.write_from_bytes(self, &align.to_le_bytes()[0..destination.size])
}
"size_of_val" => {
@@ -1431,7 +1431,7 @@ impl Evaluator<'_> {
field_types.iter().next_back().unwrap().1.clone().substitute(Interner, subst);
let sized_part_size =
layout.fields.offset(field_types.iter().count() - 1).bytes_usize();
- let sized_part_align = layout.align.abi.bytes() as usize;
+ let sized_part_align = layout.align.bytes() as usize;
let (unsized_part_size, unsized_part_align) =
self.size_align_of_unsized(&last_field_ty, metadata, locals)?;
let align = sized_part_align.max(unsized_part_align) as isize;
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 027a386abe..17767955d4 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -6094,7 +6094,7 @@ impl Layout {
}
pub fn align(&self) -> u64 {
- self.0.align.abi.bytes()
+ self.0.align.bytes()
}
pub fn niches(&self) -> Option<u128> {