Skip to content

Commit

Permalink
Rollup merge of #111661 - clubby789:offset-of-erase-regions, r=compil…
Browse files Browse the repository at this point in the history
…er-errors

Erase regions of type in `offset_of!`

Fixes #111657
  • Loading branch information
Dylan-DPC authored May 17, 2023
2 parents 71fdb95 + 35cf572 commit 0720743
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/rustc_mir_build/src/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}))))
}

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 { .. }
Expand Down
5 changes: 5 additions & 0 deletions tests/ui/offset-of/offset-of-arg-count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (),
}

0 comments on commit 0720743

Please sign in to comment.