mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Print safety correctly in extern static items
This commit is contained in:
parent
4f2f477fde
commit
4e1b3ab0e7
@ -38,7 +38,6 @@ impl<'a> State<'a> {
|
|||||||
self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs);
|
self.print_fn_full(sig, ident, generics, vis, *defaultness, body.as_deref(), attrs);
|
||||||
}
|
}
|
||||||
ast::ForeignItemKind::Static(box ast::StaticItem { ty, mutability, expr, safety }) => {
|
ast::ForeignItemKind::Static(box ast::StaticItem { ty, mutability, expr, safety }) => {
|
||||||
self.print_safety(*safety);
|
|
||||||
self.print_item_const(
|
self.print_item_const(
|
||||||
ident,
|
ident,
|
||||||
Some(*mutability),
|
Some(*mutability),
|
||||||
@ -46,6 +45,7 @@ impl<'a> State<'a> {
|
|||||||
ty,
|
ty,
|
||||||
expr.as_deref(),
|
expr.as_deref(),
|
||||||
vis,
|
vis,
|
||||||
|
*safety,
|
||||||
ast::Defaultness::Final,
|
ast::Defaultness::Final,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -84,10 +84,12 @@ impl<'a> State<'a> {
|
|||||||
ty: &ast::Ty,
|
ty: &ast::Ty,
|
||||||
body: Option<&ast::Expr>,
|
body: Option<&ast::Expr>,
|
||||||
vis: &ast::Visibility,
|
vis: &ast::Visibility,
|
||||||
|
safety: ast::Safety,
|
||||||
defaultness: ast::Defaultness,
|
defaultness: ast::Defaultness,
|
||||||
) {
|
) {
|
||||||
self.head("");
|
self.head("");
|
||||||
self.print_visibility(vis);
|
self.print_visibility(vis);
|
||||||
|
self.print_safety(safety);
|
||||||
self.print_defaultness(defaultness);
|
self.print_defaultness(defaultness);
|
||||||
let leading = match mutbl {
|
let leading = match mutbl {
|
||||||
None => "const",
|
None => "const",
|
||||||
@ -181,6 +183,7 @@ impl<'a> State<'a> {
|
|||||||
ty,
|
ty,
|
||||||
body.as_deref(),
|
body.as_deref(),
|
||||||
&item.vis,
|
&item.vis,
|
||||||
|
ast::Safety::Default,
|
||||||
ast::Defaultness::Final,
|
ast::Defaultness::Final,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -192,6 +195,7 @@ impl<'a> State<'a> {
|
|||||||
ty,
|
ty,
|
||||||
expr.as_deref(),
|
expr.as_deref(),
|
||||||
&item.vis,
|
&item.vis,
|
||||||
|
ast::Safety::Default,
|
||||||
*defaultness,
|
*defaultness,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -549,6 +553,7 @@ impl<'a> State<'a> {
|
|||||||
ty,
|
ty,
|
||||||
expr.as_deref(),
|
expr.as_deref(),
|
||||||
vis,
|
vis,
|
||||||
|
ast::Safety::Default,
|
||||||
*defaultness,
|
*defaultness,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
6
tests/ui/unpretty/extern-static.rs
Normal file
6
tests/ui/unpretty/extern-static.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
//@ compile-flags: -Zunpretty=normal
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
unsafe extern "C" {
|
||||||
|
pub unsafe static STATIC: ();
|
||||||
|
}
|
6
tests/ui/unpretty/extern-static.stdout
Normal file
6
tests/ui/unpretty/extern-static.stdout
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
//@ compile-flags: -Zunpretty=normal
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
unsafe extern "C" {
|
||||||
|
pub unsafe static STATIC: ();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user