diff options
| author | bors <bors@rust-lang.org> | 2023-04-22 00:10:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-04-22 00:10:44 +0000 |
| commit | 80a2ec49a4ffb7a351c41c8db14711297324b587 (patch) | |
| tree | 32a089a87caf1bc9e30b08dcf2ce8d8e50bfc73a /compiler/rustc_ty_utils | |
| parent | 0fd50f3e019dddc47d1d6dbe35c4c1542098d9c5 (diff) | |
| parent | 99abe44135e84de2029186384c3ffbd1ad860cca (diff) | |
| download | rust-80a2ec49a4ffb7a351c41c8db14711297324b587.tar.gz rust-80a2ec49a4ffb7a351c41c8db14711297324b587.zip | |
Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
Diffstat (limited to 'compiler/rustc_ty_utils')
| -rw-r--r-- | compiler/rustc_ty_utils/src/consts.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs index e650792f4d5..b08a92570ed 100644 --- a/compiler/rustc_ty_utils/src/consts.rs +++ b/compiler/rustc_ty_utils/src/consts.rs @@ -256,6 +256,7 @@ fn recurse_build<'tcx>( ExprKind::VarRef { .. } | ExprKind::UpvarRef { .. } | ExprKind::StaticRef { .. } + | ExprKind::OffsetOf { .. } | ExprKind::ThreadLocalRef(_) => { error(GenericConstantTooComplexSub::OperationNotSupported(node.span))? } @@ -347,6 +348,7 @@ impl<'a, 'tcx> IsThirPolymorphic<'a, 'tcx> { | thir::ExprKind::ZstLiteral { .. } | thir::ExprKind::StaticRef { .. } | thir::ExprKind::InlineAsm(_) + | thir::ExprKind::OffsetOf { .. } | thir::ExprKind::ThreadLocalRef(_) | thir::ExprKind::Yield { .. } => false, } |
