Rollup merge of #111661 - clubby789:offset-of-erase-regions, r=compiler-errors

Erase regions of type in `offset_of!`

Fixes #111657
This commit is contained in:
Dylan DPC 2023-05-17 11:13:58 +05:30 committed by GitHub
commit 0720743836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -481,9 +481,10 @@ pub(crate) fn as_rvalue(
}))))
}
ExprKind::OffsetOf { container, fields } => {
block.and(Rvalue::NullaryOp(NullOp::OffsetOf(fields), container))
}
ExprKind::OffsetOf { container, fields } => block.and(Rvalue::NullaryOp(
NullOp::OffsetOf(fields),
this.tcx.erase_regions(container),
)),
ExprKind::Literal { .. }
| ExprKind::NamedConst { .. }

View File

@ -12,6 +12,11 @@ fn main() {
offset_of!(S, f.,); //~ ERROR expected identifier
offset_of!(S, f..); //~ ERROR no rules expected the token
offset_of!(S, f..,); //~ ERROR no rules expected the token
offset_of!(Lt<'static>, bar); // issue #111657
}
struct S { f: u8, }
struct Lt<'a> {
bar: &'a (),
}