diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index c385b00692ff4..0105a265ffbab 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -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 { .. } diff --git a/tests/ui/offset-of/offset-of-arg-count.rs b/tests/ui/offset-of/offset-of-arg-count.rs index 5e66e33f8a273..92a205f14d9d1 100644 --- a/tests/ui/offset-of/offset-of-arg-count.rs +++ b/tests/ui/offset-of/offset-of-arg-count.rs @@ -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 (), +}