Skip to content

Commit 6a19a87

Browse files
committedMay 10, 2024
Auto merge of #124972 - matthiaskrgr:rollup-3fablim, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #124615 (coverage: Further simplify extraction of mapping info from MIR) - #124778 (Fix parse error message for meta items) - #124797 (Refactor float `Primitive`s to a separate `Float` type) - #124888 (Migrate `run-make/rustdoc-output-path` to rmake) - #124957 (Make `Ty::builtin_deref` just return a `Ty`) r? `@ghost` `@rustbot` modify labels: rollup
·
1.88.01.80.0
2 parents 66f8770 + 9a9ec90 commit 6a19a87

File tree

82 files changed

+467
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+467
-401
lines changed
 

‎compiler/rustc_abi/src/lib.rs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,41 @@ impl Integer {
926926
}
927927
}
928928

929+
/// Floating-point types.
930+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
931+
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
932+
pub enum Float {
933+
F16,
934+
F32,
935+
F64,
936+
F128,
937+
}
938+
939+
impl Float {
940+
pub fn size(self) -> Size {
941+
use Float::*;
942+
943+
match self {
944+
F16 => Size::from_bits(16),
945+
F32 => Size::from_bits(32),
946+
F64 => Size::from_bits(64),
947+
F128 => Size::from_bits(128),
948+
}
949+
}
950+
951+
pub fn align<C: HasDataLayout>(self, cx: &C) -> AbiAndPrefAlign {
952+
use Float::*;
953+
let dl = cx.data_layout();
954+
955+
match self {
956+
F16 => dl.f16_align,
957+
F32 => dl.f32_align,
958+
F64 => dl.f64_align,
959+
F128 => dl.f128_align,
960+
}
961+
}
962+
}
963+
929964
/// Fundamental unit of memory access and layout.
930965
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
931966
#[cfg_attr(feature = "nightly", derive(HashStable_Generic))]
@@ -938,10 +973,7 @@ pub enum Primitive {
938973
/// a negative integer passed by zero-extension will appear positive in
939974
/// the callee, and most operations on it will produce the wrong values.
940975
Int(Integer, bool),
941-
F16,
942-
F32,
943-
F64,
944-
F128,
976+
Float(Float),
945977
Pointer(AddressSpace),
946978
}
947979

@@ -952,10 +984,7 @@ impl Primitive {
952984

953985
match self {
954986
Int(i, _) => i.size(),
955-
F16 => Size::from_bits(16),
956-
F32 => Size::from_bits(32),
957-
F64 => Size::from_bits(64),
958-
F128 => Size::from_bits(128),
987+
Float(f) => f.size(),
959988
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
960989
// different address spaces can have different sizes
961990
// (but TargetDataLayout doesn't currently parse that part of the DL string)
@@ -969,10 +998,7 @@ impl Primitive {
969998

970999
match self {
9711000
Int(i, _) => i.align(dl),
972-
F16 => dl.f16_align,
973-
F32 => dl.f32_align,
974-
F64 => dl.f64_align,
975-
F128 => dl.f128_align,
1001+
Float(f) => f.align(dl),
9761002
// FIXME(erikdesjardins): ignoring address space is technically wrong, pointers in
9771003
// different address spaces can have different alignments
9781004
// (but TargetDataLayout doesn't currently parse that part of the DL string)

‎compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,10 +1483,9 @@ fn suggest_ampmut<'tcx>(
14831483
} else {
14841484
// otherwise, suggest that the user annotates the binding; we provide the
14851485
// type of the local.
1486-
let ty_mut = decl_ty.builtin_deref(true).unwrap();
1487-
assert_eq!(ty_mut.mutbl, hir::Mutability::Not);
1486+
let ty = decl_ty.builtin_deref(true).unwrap();
14881487

1489-
(false, span, format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty_mut.ty))
1488+
(false, span, format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty))
14901489
}
14911490
}
14921491

0 commit comments

Comments
 (0)
Please sign in to comment.