diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-07-11 10:25:41 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-07-11 10:25:41 +0000 |
| commit | 984db78d771ec67d781e954da759dbea8667197a (patch) | |
| tree | 2402121e683c95d820a3f40616463bc20a2ba8d8 | |
| parent | 423915590b08896ecc845b8b22910cb98c4c7e36 (diff) | |
| download | rust-984db78d771ec67d781e954da759dbea8667197a.tar.gz rust-984db78d771ec67d781e954da759dbea8667197a.zip | |
Hide niches in SIMD types, too
| -rw-r--r-- | compiler/rustc_middle/src/ty/layout.rs | 7 | ||||
| -rw-r--r-- | src/test/ui/layout/unsafe-cell-hides-niche.rs | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 8cbc0169bc7..1ed41db099c 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1092,12 +1092,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { hide_niches(a); hide_niches(b); } - Abi::Vector { element, count: _ } => { - // Until we support types other than floats and integers in SIMD, - // `element` must already be a full for its range, so there's nothing to - // do here. - assert!(element.is_always_valid(dl)); - } + Abi::Vector { element, count: _ } => hide_niches(element), Abi::Aggregate { sized: _ } => {} } st.largest_niche = None; diff --git a/src/test/ui/layout/unsafe-cell-hides-niche.rs b/src/test/ui/layout/unsafe-cell-hides-niche.rs index 2d3bb1d23c0..bb2156a5da7 100644 --- a/src/test/ui/layout/unsafe-cell-hides-niche.rs +++ b/src/test/ui/layout/unsafe-cell-hides-niche.rs @@ -5,6 +5,8 @@ // run-pass +#![feature(repr_simd)] + use std::cell::{UnsafeCell, RefCell, Cell}; use std::mem::size_of; use std::num::NonZeroU32 as N32; @@ -47,4 +49,10 @@ fn main() { trait Trait {} assert_eq!(size_of::< UnsafeCell<&dyn Trait> >(), 16); assert_eq!(size_of::<Option<UnsafeCell<&dyn Trait>>>(), 24); // (✗ niche opt) + + #[repr(simd)] + pub struct Vec4<T>([T; 4]); + + assert_eq!(size_of::< UnsafeCell<Vec4<N32>> >(), 16); + assert_eq!(size_of::<Option<UnsafeCell<Vec4<N32>>>>(), 32); // (✗ niche opt) } |
