Skip to content

Commit 0720743

Browse files
authored
Rollup merge of #111661 - clubby789:offset-of-erase-regions, r=compiler-errors
Erase regions of type in `offset_of!` Fixes #111657
2 parents 71fdb95 + 35cf572 commit 0720743

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

compiler/rustc_mir_build/src/build/expr/as_rvalue.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
481481
}))))
482482
}
483483

484-
ExprKind::OffsetOf { container, fields } => {
485-
block.and(Rvalue::NullaryOp(NullOp::OffsetOf(fields), container))
486-
}
484+
ExprKind::OffsetOf { container, fields } => block.and(Rvalue::NullaryOp(
485+
NullOp::OffsetOf(fields),
486+
this.tcx.erase_regions(container),
487+
)),
487488

488489
ExprKind::Literal { .. }
489490
| ExprKind::NamedConst { .. }

tests/ui/offset-of/offset-of-arg-count.rs

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ fn main() {
1212
offset_of!(S, f.,); //~ ERROR expected identifier
1313
offset_of!(S, f..); //~ ERROR no rules expected the token
1414
offset_of!(S, f..,); //~ ERROR no rules expected the token
15+
offset_of!(Lt<'static>, bar); // issue #111657
16+
1517
}
1618

1719
struct S { f: u8, }
20+
struct Lt<'a> {
21+
bar: &'a (),
22+
}

0 commit comments

Comments
 (0)