diff options
| author | Marcus Klaas <mail@marcusklaas.nl> | 2015-11-22 16:07:38 +0100 |
|---|---|---|
| committer | Marcus Klaas <mail@marcusklaas.nl> | 2015-11-22 16:07:38 +0100 |
| commit | 840012b5e02db35a121bc69b91c77cde05f63ae7 (patch) | |
| tree | 563e1b039e5c25902b90646fc209a841399094b6 /src/utils.rs | |
| parent | 559f00ba9951b29c73339d94bcaeb5efa94b332a (diff) | |
Format bare function types
Fix https://github.com/rust-lang-nursery/rustfmt/issues/616. Fix https://github.com/rust-lang-nursery/rustfmt/issues/276. Close https://github.com/rust-lang-nursery/rustfmt/issues/350.
Diffstat (limited to 'src/utils.rs')
| -rw-r--r-- | src/utils.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/utils.rs b/src/utils.rs index 37dfb756972..6170b0c5ee0 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -12,6 +12,7 @@ use std::cmp::Ordering; use syntax::ast::{self, Visibility, Attribute, MetaItem, MetaItem_}; use syntax::codemap::{CodeMap, Span, BytePos}; +use syntax::abi; use Indent; use comment::FindUncommented; @@ -46,6 +47,14 @@ pub fn format_visibility(vis: Visibility) -> &'static str { } #[inline] +pub fn format_unsafety(unsafety: ast::Unsafety) -> &'static str { + match unsafety { + ast::Unsafety::Unsafe => "unsafe ", + ast::Unsafety::Normal => "", + } +} + +#[inline] pub fn format_mutability(mutability: ast::Mutability) -> &'static str { match mutability { ast::Mutability::MutMutable => "mut ", @@ -53,6 +62,12 @@ pub fn format_mutability(mutability: ast::Mutability) -> &'static str { } } +#[inline] +// FIXME(#451): include "C"? +pub fn format_abi(abi: abi::Abi) -> String { + format!("extern {} ", abi) +} + // The width of the first line in s. #[inline] pub fn first_line_width(s: &str) -> usize { |
