Rollup merge of #124524 - spastorino:make-foreign-static-use-struct, r=oli-obk

Add StaticForeignItem and use it on ForeignItemKind

This is in preparation for unsafe extern blocks that adds a safe variant for functions inside extern blocks.

r? `@oli-obk`
cc `@compiler-errors`
This commit is contained in:
Matthias Krüger 2024-04-30 06:43:42 +02:00 committed by GitHub
commit 27d320d1b6

View File

@ -3325,11 +3325,11 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
.map(|(s, _, _)| format!("{};", s))
}
}
ast::ForeignItemKind::Static(ref ty, mutability, _) => {
ast::ForeignItemKind::Static(ref static_foreign_item) => {
// FIXME(#21): we're dropping potential comments in between the
// function kw here.
let vis = format_visibility(context, &self.vis);
let mut_str = format_mutability(mutability);
let mut_str = format_mutability(static_foreign_item.mutability);
let prefix = format!(
"{}static {}{}:",
vis,
@ -3340,7 +3340,7 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
rewrite_assign_rhs(
context,
prefix,
&**ty,
&static_foreign_item.ty,
&RhsAssignKind::Ty,
shape.sub_width(1)?,
)