mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-12 20:16:49 +00:00
Format visibility for statics and consts
This commit is contained in:
parent
8a9bbd9d7c
commit
7e0456b852
@ -1118,13 +1118,18 @@ impl<'a> FmtVisitor<'a> {
|
||||
}
|
||||
|
||||
pub fn rewrite_static(prefix: &str,
|
||||
vis: ast::Visibility,
|
||||
ident: ast::Ident,
|
||||
ty: &ast::Ty,
|
||||
mutability: ast::Mutability,
|
||||
expr: &ast::Expr,
|
||||
context: &RewriteContext)
|
||||
-> Option<String> {
|
||||
let prefix = format!("{} {}{}: ", prefix, format_mutability(mutability), ident);
|
||||
let prefix = format!("{}{} {}{}: ",
|
||||
format_visibility(vis),
|
||||
prefix,
|
||||
format_mutability(mutability),
|
||||
ident);
|
||||
// 2 = " =".len()
|
||||
let ty_str = try_opt!(ty.rewrite(context,
|
||||
context.config.max_width - context.block_indent.width() -
|
||||
|
@ -219,6 +219,7 @@ impl<'a, 'v> visit::Visitor<'v> for FmtVisitor<'a> {
|
||||
}
|
||||
ast::Item_::ItemStatic(ref ty, mutability, ref expr) => {
|
||||
let rewrite = rewrite_static("static",
|
||||
item.vis,
|
||||
item.ident,
|
||||
ty,
|
||||
mutability,
|
||||
@ -228,6 +229,7 @@ impl<'a, 'v> visit::Visitor<'v> for FmtVisitor<'a> {
|
||||
}
|
||||
ast::Item_::ItemConst(ref ty, ref expr) => {
|
||||
let rewrite = rewrite_static("const",
|
||||
item.vis,
|
||||
item.ident,
|
||||
ty,
|
||||
ast::Mutability::MutImmutable,
|
||||
|
@ -1,10 +1,14 @@
|
||||
pub const FILE_GENERIC_READ: DWORD =
|
||||
const FILE_GENERIC_READ: DWORD =
|
||||
STANDARD_RIGHTS_READ | FILE_READ_DATA |
|
||||
FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE;
|
||||
|
||||
pub static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo",
|
||||
static boolnames: &'static[&'static str] = &["bw", "am", "xsb", "xhp", "xenl", "eo",
|
||||
"gn", "hc", "km", "hs", "in", "db", "da", "mir", "msgr", "os", "eslok", "xt", "hz", "ul", "xon",
|
||||
"nxon", "mc5i", "chts", "nrrmc", "npc", "ndscr", "ccc", "bce", "hls", "xhpa", "crxm", "daisy",
|
||||
"xvpa", "sam", "cpix", "lpix", "OTbs", "OTns", "OTnc", "OTMT", "OTNL", "OTpt", "OTxr"];
|
||||
|
||||
static mut name: SomeType = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
pub static count : u8 = 10 ;
|
||||
|
||||
pub const test: &Type = &val;
|
||||
|
@ -11,3 +11,7 @@ static boolnames: &'static [&'static str] = &["bw", "am", "xsb", "xhp", "xenl",
|
||||
|
||||
static mut name: SomeType =
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
|
||||
|
||||
pub static count: u8 = 10;
|
||||
|
||||
pub const test: &Type = &val;
|
||||
|
Loading…
Reference in New Issue
Block a user