use config::lists::*;
use syntax::ast::{self, FunctionRetTy, Mutability};
-use syntax::codemap::{self, BytePos, Span};
+use syntax::source_map::{self, BytePos, Span};
use syntax::symbol::keywords;
-use codemap::SpanUtils;
use config::{IndentStyle, TypeDensity};
use expr::{rewrite_assign_rhs, rewrite_tuple, rewrite_unary_prefix, ToExpr};
use lists::{definitive_tactic, itemize_list, write_list, ListFormatting, Separator};
use pairs::{rewrite_pair, PairParts};
use rewrite::{Rewrite, RewriteContext};
use shape::Shape;
+use source_map::SpanUtils;
use spanned::Spanned;
use utils::{
colon_spaces, extra_offset, first_line_width, format_abi, format_mutability,
ast::GenericArgs::Parenthesized(ref data) => {
let output = match data.output {
Some(ref ty) => FunctionRetTy::Ty(ty.clone()),
- None => FunctionRetTy::Default(codemap::DUMMY_SP),
+ None => FunctionRetTy::Default(source_map::DUMMY_SP),
};
result.push_str(&format_function_type(
data.inputs.iter().map(|x| &**x),
<I as Iterator>::Item: Deref,
<I::Item as Deref>::Target: Rewrite + Spanned + 'a,
{
+ debug!("format_function_type {:#?}", shape);
+
// Code for handling variadics is somewhat duplicated for items, but they
// are different enough to need some serious refactoring to share code.
enum ArgumentKind<T>
shape.block().indent.to_string_with_newline(context.config),
)
};
- if last_line_width(&args) + first_line_width(&output) <= shape.width {
+ if output.is_empty() || last_line_width(&args) + first_line_width(&output) <= shape.width {
Some(format!("{}{}", args, output))
} else {
Some(format!(
}
let span = mk_sp(self.get(0)?.span().lo(), self.last()?.span().hi());
- let has_paren = context.snippet(span).starts_with("(");
+ let has_paren = context.snippet(span).starts_with('(');
let bounds_shape = if has_paren {
shape.offset_left(1)?.sub_width(1)?
} else {
context: &RewriteContext,
shape: Shape,
) -> Option<String> {
+ debug!("rewrite_bare_fn {:#?}", shape);
+
let mut result = String::with_capacity(128);
if let Some(ref lifetime_str) = rewrite_lifetime_param(context, shape, &bare_fn.generic_params)
result.push_str("fn");
- let func_ty_shape = shape.offset_left(result.len())?;
+ let func_ty_shape = if context.use_block_indent() {
+ shape.offset_left(result.len())?
+ } else {
+ shape.visual_indent(result.len()).sub_width(result.len())?
+ };
let rewrite = format_function_type(
bare_fn.decl.inputs.iter(),