1
Fork 0

offset_of

This commit is contained in:
DrMeepster 2022-09-11 00:37:49 -07:00
parent b92a41c676
commit 511e457c4b
71 changed files with 841 additions and 38 deletions

View file

@ -1551,6 +1551,24 @@ impl<'a> State<'a> {
self.word("asm!");
self.print_inline_asm(asm);
}
hir::ExprKind::OffsetOf(container, ref fields) => {
self.word("offset_of!(");
self.print_type(container);
self.word(",");
self.space();
let (&first, rest) =
fields.split_first().expect("offset_of! should have at least 1 field");
self.print_ident(first);
for &field in rest {
self.word(".");
self.print_ident(field);
}
self.word(")");
}
hir::ExprKind::Yield(expr, _) => {
self.word_space("yield");
self.print_expr_maybe_paren(expr, parser::PREC_JUMP);