summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_target/src/abi/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_target/src/abi/mod.rs')
-rw-r--r--compiler/rustc_target/src/abi/mod.rs50
1 files changed, 3 insertions, 47 deletions
diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs
index 88a0a1f8e..8d2e92cc7 100644
--- a/compiler/rustc_target/src/abi/mod.rs
+++ b/compiler/rustc_target/src/abi/mod.rs
@@ -3,10 +3,8 @@ pub use Primitive::*;
use crate::json::{Json, ToJson};
-use std::fmt;
use std::ops::Deref;
-use rustc_data_structures::intern::Interned;
use rustc_macros::HashStable_Generic;
pub mod call;
@@ -19,48 +17,6 @@ impl ToJson for Endian {
}
}
-rustc_index::newtype_index! {
- #[derive(HashStable_Generic)]
- pub struct VariantIdx {}
-}
-
-#[derive(Copy, Clone, PartialEq, Eq, Hash, HashStable_Generic)]
-#[rustc_pass_by_value]
-pub struct Layout<'a>(pub Interned<'a, LayoutS<VariantIdx>>);
-
-impl<'a> fmt::Debug for Layout<'a> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- // See comment on `<LayoutS as Debug>::fmt` above.
- self.0.0.fmt(f)
- }
-}
-
-impl<'a> Layout<'a> {
- pub fn fields(self) -> &'a FieldsShape {
- &self.0.0.fields
- }
-
- pub fn variants(self) -> &'a Variants<VariantIdx> {
- &self.0.0.variants
- }
-
- pub fn abi(self) -> Abi {
- self.0.0.abi
- }
-
- pub fn largest_niche(self) -> Option<Niche> {
- self.0.0.largest_niche
- }
-
- pub fn align(self) -> AbiAndPrefAlign {
- self.0.0.align
- }
-
- pub fn size(self) -> Size {
- self.0.0.size
- }
-}
-
/// The layout of a type, alongside the type itself.
/// Provides various type traversal APIs (e.g., recursing into fields).
///
@@ -75,8 +31,8 @@ pub struct TyAndLayout<'a, Ty> {
}
impl<'a, Ty> Deref for TyAndLayout<'a, Ty> {
- type Target = &'a LayoutS<VariantIdx>;
- fn deref(&self) -> &&'a LayoutS<VariantIdx> {
+ type Target = &'a LayoutS;
+ fn deref(&self) -> &&'a LayoutS {
&self.layout.0.0
}
}
@@ -129,7 +85,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
C: HasDataLayout,
{
match self.abi {
- Abi::Scalar(scalar) => scalar.primitive().is_float(),
+ Abi::Scalar(scalar) => matches!(scalar.primitive(), F32 | F64),
Abi::Aggregate { .. } => {
if self.fields.count() == 1 && self.fields.offset(0).bytes() == 0 {
self.field(cx, 0).is_single_fp_element(cx)