Skip to content

Commit eba0d16

Browse files
authored
Merge pull request rust-lang#19413 from ShoyuVanilla/issue-19399
fix: Properly calculate the layouts of tuple ptrs whose last fields are DST
2 parents 9134ee9 + 9a6f889 commit eba0d16

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/layout.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,15 @@ fn struct_tail_erasing_lifetimes(db: &dyn HirDatabase, pointee: Ty) -> Ty {
388388
None => pointee,
389389
}
390390
}
391+
TyKind::Tuple(_, subst) => {
392+
if let Some(last_field_ty) =
393+
subst.iter(Interner).last().and_then(|arg| arg.ty(Interner))
394+
{
395+
struct_tail_erasing_lifetimes(db, last_field_ty.clone())
396+
} else {
397+
pointee
398+
}
399+
}
391400
_ => pointee,
392401
}
393402
}

src/tools/rust-analyzer/crates/hir-ty/src/layout/tests.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,16 @@ fn tuple() {
468468
}
469469
}
470470

471+
#[test]
472+
fn tuple_ptr_with_dst_tail() {
473+
size_and_align!(
474+
struct Goal(*const ([u8],));
475+
);
476+
size_and_align!(
477+
struct Goal(*const (u128, [u8]));
478+
);
479+
}
480+
471481
#[test]
472482
fn non_zero_and_non_null() {
473483
size_and_align! {

0 commit comments

Comments
 (0)