Skip to content

Commit 7c017c3

Browse files
committed
abi layout: type annotate layout_of
1 parent c0aab38 commit 7c017c3

File tree

1 file changed

+12
-5
lines changed
  • crates/rustc_codegen_spirv/src

1 file changed

+12
-5
lines changed

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use rustc_index::Idx;
1818
use rustc_middle::query::Providers;
1919
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
2020
use rustc_middle::ty::{
21-
self, Const, CoroutineArgs, CoroutineArgsExt as _, FloatTy, IntTy, PolyFnSig, Ty, TyCtxt,
22-
TyKind, UintTy,
21+
self, AdtDef, Const, CoroutineArgs, CoroutineArgsExt as _, FloatTy, IntTy, PolyFnSig, Ty,
22+
TyCtxt, TyKind, UintTy,
2323
};
2424
use rustc_middle::ty::{GenericArgsRef, ScalarInt};
2525
use rustc_middle::{bug, span_bug};
@@ -164,7 +164,12 @@ pub(crate) fn provide(providers: &mut Providers) {
164164
}
165165
}
166166

167-
providers.layout_of = |tcx, key| {
167+
providers.layout_of = layout_of;
168+
169+
fn layout_of<'tcx>(
170+
tcx: TyCtxt<'tcx>,
171+
key: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>,
172+
) -> Result<TyAndLayout<'tcx>, &'tcx ty::layout::LayoutError<'tcx>> {
168173
// HACK(eddyb) to special-case any types at all, they must be normalized,
169174
// but when normalization would be needed, `layout_of`'s default provider
170175
// recurses (supposedly for caching reasons), i.e. its calls `layout_of`
@@ -174,7 +179,9 @@ pub(crate) fn provide(providers: &mut Providers) {
174179

175180
// HACK(eddyb) bypassing upstream `#[repr(simd)]` changes (see also
176181
// the later comment above `check_well_formed`, for more details).
177-
let reimplement_old_style_repr_simd = match ty.kind() {
182+
let reimplement_old_style_repr_simd: Option<(&AdtDef<'tcx>, Ty<'tcx>, u64)> = match ty
183+
.kind()
184+
{
178185
ty::Adt(def, args) if def.repr().simd() && !def.repr().packed() && def.is_struct() => {
179186
Some(def.non_enum_variant()).and_then(|v| {
180187
let (count, e_ty) = v
@@ -268,7 +275,7 @@ pub(crate) fn provide(providers: &mut Providers) {
268275
}
269276

270277
Ok(TyAndLayout { ty, layout })
271-
};
278+
}
272279

273280
// HACK(eddyb) work around https://github.com/rust-lang/rust/pull/129403
274281
// banning "struct-style" `#[repr(simd)]` (in favor of "array-newtype-style"),

0 commit comments

Comments
 (0)