diff options
author | clubby789 <jamie@hill-daniel.co.uk> | 2023-05-16 21:36:42 +0000 |
---|---|---|
committer | clubby789 <jamie@hill-daniel.co.uk> | 2023-05-16 21:36:42 +0000 |
commit | 35cf5726e3a7a16d97243bc6c23ff8173e2119de (patch) | |
tree | f920301557dbc18babc0f82cd76182ae94d72a1e | |
parent | b652d9a0fd5c5a7eeacd1ae8299166941c221230 (diff) | |
download | rust-35cf5726e3a7a16d97243bc6c23ff8173e2119de.tar.gz |
Erase regions of type in `offset_of!`
-rw-r--r-- | compiler/rustc_mir_build/src/build/expr/as_rvalue.rs | 7 | ||||
-rw-r--r-- | tests/ui/offset-of/offset-of-arg-count.rs | 5 |
2 files changed, 9 insertions, 3 deletions
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 c385b00692f..0105a265ffb 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 5e66e33f8a2..92a205f14d9 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 (), +} |