fn_args_layout = "Block"
array_layout = "Block"
+control_style = "Rfc"
where_style = "Rfc"
generics_indent = "Block"
fn_call_style = "Block"
}
}
+const CONFIG_FILE_NAMES: [&'static str; 2] = [".rustfmt.toml", "rustfmt.toml"];
+
/// Try to find a project file in the given directory and its parents. Returns the path of a the
/// nearest project file if one exists, or `None` if no project file was found.
fn lookup_project_file(dir: &Path) -> FmtResult<Option<PathBuf>> {
current = try!(fs::canonicalize(current));
- const CONFIG_FILE_NAMES: [&'static str; 2] = [".rustfmt.toml", "rustfmt.toml"];
-
loop {
for config_file_name in &CONFIG_FILE_NAMES {
let config_file = current.join(config_file_name);
}
}
+fn open_config_file(file_path: &Path) -> FmtResult<(Config, Option<PathBuf>)> {
+ let mut file = try!(File::open(&file_path));
+ let mut toml = String::new();
+ try!(file.read_to_string(&mut toml));
+ match Config::from_toml(&toml) {
+ Ok(cfg) => Ok((cfg, Some(file_path.to_path_buf()))),
+ Err(err) => Err(FmtError::from(err)),
+ }
+}
+
/// Resolve the config for input in `dir`.
///
/// Returns the `Config` to use, and the path of the project file if there was
if path.is_none() {
return Ok((Config::default(), None));
}
- let path = path.unwrap();
- let mut file = try!(File::open(&path));
- let mut toml = String::new();
- try!(file.read_to_string(&mut toml));
- match Config::from_toml(&toml) {
- Ok(cfg) => Ok((cfg, Some(path))),
- Err(err) => Err(FmtError::from(err)),
- }
+ open_config_file(&path.unwrap())
}
/// read the given config file path recursively if present else read the project file path
-> FmtResult<(Config, Option<PathBuf>)> {
if let Some(config_file) = config_path {
- let (toml, path) = try!(resolve_config(config_file.as_ref()));
+ let (toml, path) = try!(open_config_file(config_file.as_ref()));
if path.is_some() {
return Ok((toml, path));
}
let mut path = None;
// Load the config path file if provided
if let Some(config_file) = config_path {
- let (cfg_tmp, path_tmp) = resolve_config(config_file.as_ref())?;
+ let (cfg_tmp, path_tmp) = open_config_file(config_file.as_ref())?;
config = cfg_tmp;
path = path_tmp;
};
}
fn print_usage(opts: &Options, reason: &str) {
- let reason = format!("{}\nusage: {} [options] <file>...",
+ let reason = format!("{}\n\nusage: {} [options] <file>...",
reason,
env::args_os().next().unwrap().to_string_lossy());
println!("{}", opts.usage(&reason));
return Ok(Operation::Version);
}
+ let config_path_not_found = |path: &str| -> FmtResult<Operation> {
+ Err(FmtError::from(format!("Error: unable to find a config file for the given path: `{}`",
+ path)))
+ };
+
// Read the config_path and convert to parent dir if a file is provided.
- let config_path: Option<PathBuf> = matches
- .opt_str("config-path")
- .map(PathBuf::from)
- .and_then(|dir| {
- if dir.is_file() {
- return dir.parent().map(|v| v.into());
- }
- Some(dir)
- });
+ // If a config file cannot be found from the given path, return error.
+ let config_path: Option<PathBuf> = match matches.opt_str("config-path").map(PathBuf::from) {
+ Some(ref path) if !path.exists() => return config_path_not_found(path.to_str().unwrap()),
+ Some(ref path) if path.is_dir() => {
+ let mut config_file_path = None;
+ for config_file_name in &CONFIG_FILE_NAMES {
+ let temp_path = path.join(config_file_name);
+ if temp_path.is_file() {
+ config_file_path = Some(temp_path);
+ }
+ }
+ if config_file_path.is_some() {
+ config_file_path
+ } else {
+ return config_path_not_found(path.to_str().unwrap());
+ }
+ }
+ path @ _ => path,
+ };
// if no file argument is supplied, read from stdin
if matches.free.is_empty() {
}
pub fn from_toml(toml: &str) -> Result<Config, String> {
- let parsed: toml::Value = toml.parse().expect("Could not parse TOML");
+ let parsed: toml::Value =
+ toml.parse().map_err(|e| format!("Could not parse TOML: {}", e))?;
let mut err: String = String::new();
- for (key, _) in parsed.as_table().expect("Parsed config was not table") {
- match &**key {
- $(
- stringify!($i) => (),
- )+
- _ => {
- let msg = &format!("Warning: Unknown configuration option `{}`\n", key);
- err.push_str(msg)
+ {
+ let table = parsed
+ .as_table()
+ .ok_or(String::from("Parsed config was not table"))?;
+ for (key, _) in table {
+ match &**key {
+ $(
+ stringify!($i) => (),
+ )+
+ _ => {
+ let msg =
+ &format!("Warning: Unknown configuration option `{}`\n",
+ key);
+ err.push_str(msg)
+ }
}
}
}
newline_style: NewlineStyle, NewlineStyle::Unix, "Unix or Windows line endings";
fn_brace_style: BraceStyle, BraceStyle::SameLineWhere, "Brace style for functions";
item_brace_style: BraceStyle, BraceStyle::SameLineWhere, "Brace style for structs and enums";
+ control_style: Style, Style::Default, "Indent style for control flow statements";
control_brace_style: ControlBraceStyle, ControlBraceStyle::AlwaysSameLine,
"Brace style for control flow constructs";
impl_empty_single_line: bool, true, "Put empty-body implementations on a single line";
semicolon_for_stmt, trimmed_last_line_width, left_most_sub_expr, stmt_expr,
colon_spaces};
use visitor::FmtVisitor;
-use config::{Config, IndentStyle, MultilineStyle, ControlBraceStyle};
+use config::{Config, IndentStyle, MultilineStyle, ControlBraceStyle, Style};
use comment::{FindUncommented, rewrite_comment, contains_comment, recover_comment_removed};
use types::{rewrite_path, PathContext};
use items::{span_lo_for_arg, span_hi_for_arg};
.max_width
.checked_sub(shape.used_width() + prefix.len() +
infix.len()));
- let rhs_shape = try_opt!(shape.sub_width(suffix.len() + prefix.len()))
- .visual_indent(prefix.len());
+ let rhs_shape = match context.config.control_style {
+ Style::Default => {
+ try_opt!(shape.sub_width(suffix.len() + prefix.len())).visual_indent(prefix.len())
+ }
+ Style::Rfc => try_opt!(shape.block_left(context.config.tab_spaces)),
+ };
let rhs_result = try_opt!(rhs.rewrite(context, rhs_shape));
let lhs_result = try_opt!(lhs.rewrite(context,
// We need braces, but we might still prefer a one-liner.
let stmt = &block.stmts[0];
// 4 = braces and spaces.
- let mut rewrite = stmt.rewrite(context, try_opt!(body_shape.sub_width(4)));
-
- // Checks if rewrite succeeded and fits on a single line.
- rewrite = and_one_line(rewrite);
-
- if let Some(rewrite) = rewrite {
- return Some(format!("{} {{ {} }}", prefix, rewrite));
+ if let Some(body_shape) = body_shape.sub_width(4) {
+ // Checks if rewrite succeeded and fits on a single line.
+ if let Some(rewrite) = and_one_line(stmt.rewrite(context, body_shape)) {
+ return Some(format!("{} {{ {} }}", prefix, rewrite));
+ }
}
}
// The body of the closure is big enough to be block indented, that
// means we must re-format.
- let block_shape = Shape {
- width: context.config.max_width - shape.block().indent.width(),
- ..shape.block()
- };
+ let block_shape = shape.block().with_max_width(context.config);
let block_str = try_opt!(block.rewrite(&context, block_shape));
Some(format!("{} {}",
prefix,
let pat_expr_string = match self.cond {
Some(cond) => {
- let mut cond_shape = try_opt!(constr_shape.shrink_left(add_offset));
+ let mut cond_shape = match context.config.control_style {
+ Style::Default => try_opt!(constr_shape.shrink_left(add_offset)),
+ Style::Rfc => constr_shape,
+ };
if context.config.control_brace_style != ControlBraceStyle::AlwaysNextLine {
// 2 = " {".len()
cond_shape = try_opt!(cond_shape.sub_width(2));
None => String::new(),
};
+ let force_newline_brace = context.config.control_style == Style::Rfc &&
+ pat_expr_string.contains('\n');
+
// Try to format if-else on single line.
if self.allow_single_line && context.config.single_line_if_else_max_width > 0 {
let trial = self.rewrite_single_line(&pat_expr_string, context, shape.width);
&shape.indent.block_only().to_string(context.config);
let block_sep = if self.cond.is_none() && between_kwd_cond_comment.is_some() {
""
- } else if context.config.control_brace_style ==
- ControlBraceStyle::AlwaysNextLine {
+ } else if context.config.control_brace_style == ControlBraceStyle::AlwaysNextLine ||
+ force_newline_brace {
alt_block_sep.as_str()
} else {
" "
result.push('\n');
result.push_str(&arm_indent_str);
- let arm_str = arm.rewrite(&context,
- Shape {
- width: context.config.max_width - arm_shape.indent.width(),
- ..arm_shape
- });
+ let arm_str = arm.rewrite(&context, arm_shape.with_max_width(context.config));
if let Some(ref arm_str) = arm_str {
result.push_str(arm_str);
} else {
let pats_str = try_opt!(write_list(items, &fmt));
let guard_shape = if pats_str.contains('\n') {
- Shape {
- width: context.config.max_width - shape.indent.width(),
- ..shape
- }
+ shape.with_max_width(context.config)
} else {
shape
};
connector: &str,
shape: Shape)
-> Option<String> {
- debug!("rewrite_pat_expr {:?} {:?}", shape, pat);
+ debug!("rewrite_pat_expr {:?} {:?} {:?}", shape, pat, expr);
let mut result = match pat {
Some(pat) => {
let matcher = if matcher.is_empty() {
let prefix = format!("{}static {}{}: ", vis, mut_str, item.ident);
let offset = self.block_indent + prefix.len();
// 1 = ;
- let width = self.config.max_width - offset.width() - 1;
- let rewrite = ty.rewrite(&self.get_context(), Shape::legacy(width, offset));
+ let shape = Shape::indented(offset, self.config).sub_width(1).unwrap();
+ let rewrite = ty.rewrite(&self.get_context(), shape);
match rewrite {
Some(result) => {
let suffix = if semicolon_for_expr(e) { ";" } else { "" };
e.rewrite(&self.get_context(),
- Shape::legacy(self.config.max_width -
- self.block_indent.width(),
- self.block_indent))
+ Shape::indented(self.block_indent, self.config))
.map(|s| s + suffix)
.or_else(|| Some(self.snippet(e.span)))
}
None => {
stmt.rewrite(&self.get_context(),
- Shape::legacy(self.config.max_width -
- self.block_indent.width(),
- self.block_indent))
+ Shape::indented(self.block_indent, self.config))
}
}
} else {
body_lo,
body_hi);
- let budget = self.config.max_width - self.block_indent.width() - 2;
+ let shape = Shape::indented(self.block_indent, self.config)
+ .sub_width(2)
+ .unwrap();
let fmt = ListFormatting {
tactic: DefinitiveListTactic::Vertical,
separator: ",",
trailing_separator: self.config.trailing_comma,
- shape: Shape::legacy(budget, self.block_indent),
+ shape: shape,
ends_with_newline: true,
config: self.config,
};
.node
.attrs
.rewrite(&self.get_context(),
- Shape::legacy(self.config.max_width -
- indent.width(),
- indent)));
+ Shape::indented(indent, self.config)));
if !result.is_empty() {
result.push('\n');
result.push_str(&indent.to_string(self.config));
wrap_str(tag,
self.config.max_width,
- Shape::legacy(self.config.max_width - indent.width(), indent))
+ Shape::indented(indent, self.config))
}
};
None => self_ty.span.lo,
};
let generics_indent = offset + last_line_width(&result);
- let shape = try_opt!(generics_shape(context.config, generics_indent));
+ let shape = Shape::indented(generics_indent, context.config);
let generics_str = try_opt!(rewrite_generics(context, generics, shape, mk_sp(lo, hi)));
result.push_str(&generics_str);
// Can't fit the self type on what's left of the line, so start a new one.
let indent = offset.block_indent(context.config);
result.push_str(&format!("\n{}", indent.to_string(context.config)));
- let budget = try_opt!(context.config.max_width.checked_sub(indent.width()));
- result.push_str(&*try_opt!(self_ty.rewrite(context, Shape::legacy(budget, indent))));
+ result.push_str(&*try_opt!(self_ty.rewrite(context,
+ Shape::indented(indent, context.config))));
Some(result)
} else {
unreachable!();
let body_lo = context.codemap.span_after(item.span, "{");
let generics_indent = offset + last_line_width(&result);
- let shape = try_opt!(generics_shape(context.config, generics_indent));
+ let shape = Shape::indented(generics_indent, context.config);
let generics_str =
try_opt!(rewrite_generics(context, generics, shape, mk_sp(item.span.lo, body_lo)));
result.push_str(&generics_str);
let where_clause_str = match generics {
Some(generics) => {
let generics_indent = offset + last_line_width(&header_str);
- let shape = try_opt!(generics_shape(context.config, generics_indent));
+ let shape = Shape::indented(generics_indent, context.config);
let generics_str =
try_opt!(rewrite_generics(context, generics, shape, mk_sp(span.lo, body_lo)));
result.push_str(&generics_str);
let generics_indent = indent + result.len();
let generics_span = mk_sp(context.codemap.span_after(span, "type"), ty.span.lo);
- let shape = try_opt!(try_opt!(generics_shape(context.config, generics_indent))
+ let shape = try_opt!(Shape::indented(generics_indent, context.config)
.sub_width(" =".len()));
let generics_str = try_opt!(rewrite_generics(context, generics, shape, generics_span));
let name = self.ident;
let vis = format_visibility(&self.vis);
- let mut attr_str = try_opt!(self.attrs
- .rewrite(context,
- Shape::legacy(context.config.max_width -
- shape.indent.width(),
- shape.indent)));
+ let mut attr_str =
+ try_opt!(self.attrs
+ .rewrite(context, Shape::indented(shape.indent, context.config)));
if !attr_str.is_empty() {
attr_str.push('\n');
attr_str.push_str(&shape.indent.to_string(context.config));
let type_offset = shape.indent.block_indent(context.config);
let rewrite_type_in_next_line = || {
- let budget = try_opt!(context.config.max_width.checked_sub(type_offset.width()));
- self.ty.rewrite(context, Shape::legacy(budget, type_offset))
+ self.ty
+ .rewrite(context, Shape::indented(type_offset, context.config))
};
let last_line_width = last_line_width(&result) + type_annotation_spacing.1.len();
// Generics.
let generics_indent = indent + last_line_width(&result);
let generics_span = mk_sp(span.lo, span_for_return(&fd.output).lo);
- let shape = try_opt!(generics_shape(context.config, generics_indent));
+ let shape = Shape::indented(generics_indent, context.config);
let generics_str = try_opt!(rewrite_generics(context, generics, shape, generics_span));
result.push_str(&generics_str);
// Note that the width and indent don't really matter, we'll re-layout the
// return type later anyway.
let ret_str = try_opt!(fd.output
- .rewrite(&context,
- Shape::legacy(context.config.max_width -
- indent.width(),
- indent)));
+ .rewrite(&context, Shape::indented(indent, context.config)));
let multi_line_ret_str = ret_str.contains('\n');
let ret_str_len = if multi_line_ret_str { 0 } else { ret_str.len() };
if multi_line_ret_str || ret_should_indent {
// Now that we know the proper indent and width, we need to
// re-layout the return type.
- let budget = try_opt!(context.config.max_width.checked_sub(ret_indent.width()));
let ret_str = try_opt!(fd.output
- .rewrite(context, Shape::legacy(budget, ret_indent)));
+ .rewrite(context,
+ Shape::indented(ret_indent, context.config)));
result.push_str(&ret_str);
} else {
result.push_str(&ret_str);
}
}
- let budget = try_opt!(context.config.max_width.checked_sub(indent.block_indent));
let where_clause_str = try_opt!(rewrite_where_clause(context,
where_clause,
context.config.fn_brace_style,
- Shape::legacy(budget, indent),
+ Shape::indented(indent, context.config),
Density::Tall,
"{",
!has_braces,
offset: Indent,
span: Span)
-> Option<String> {
- let shape = try_opt!(generics_shape(context.config, offset));
+ let shape = Shape::indented(offset, context.config);
let mut result = try_opt!(rewrite_generics(context, generics, shape, span));
if !generics.where_clause.predicates.is_empty() || result.contains('\n') {
Some(result)
}
-
-fn generics_shape(config: &Config, indent: Indent) -> Option<Shape> {
- Some(Shape::legacy(try_opt!(config.max_width.checked_sub(indent.width())),
- indent))
-}
}
impl Shape {
- pub fn indented(indent: Indent, config: &Config) -> Shape {
- Shape {
- width: config.max_width,
- indent: indent,
- offset: indent.width(),
- }
- }
-
/// `indent` is the indentation of the first line. The next lines
/// should begin with at least `indent` spaces (except backwards
/// indentation). The first line should not begin with indentation.
}
}
+ pub fn indented(indent: Indent, config: &Config) -> Shape {
+ Shape {
+ width: config.max_width.checked_sub(indent.width()).unwrap_or(0),
+ indent: indent,
+ offset: indent.alignment,
+ }
+ }
+
+ pub fn with_max_width(&self, config: &Config) -> Shape {
+ Shape {
+ width: config
+ .max_width
+ .checked_sub(self.indent.width())
+ .unwrap_or(0),
+ ..*self
+ }
+ }
+
pub fn offset(width: usize, indent: Indent, offset: usize) -> Shape {
Shape {
width: width,
}
}
+ pub fn block_left(&self, width: usize) -> Option<Shape> {
+ self.block_indent(width).sub_width(width)
+ }
+
pub fn add_offset(&self, extra_width: usize) -> Shape {
Shape {
- width: self.width,
- indent: self.indent,
offset: self.offset + extra_width,
+ ..*self
}
}
pub fn block(&self) -> Shape {
Shape {
- width: self.width,
indent: self.indent.block_only(),
- offset: self.offset,
+ ..*self
}
}
pub fn sub_width(&self, width: usize) -> Option<Shape> {
Some(Shape {
width: try_opt!(self.width.checked_sub(width)),
- indent: self.indent,
- offset: self.offset,
+ ..*self
})
}
}
pub fn offset_left(&self, width: usize) -> Option<Shape> {
- Some(Shape {
- width: try_opt!(self.width.checked_sub(width)),
- indent: self.indent,
- offset: self.offset + width,
- })
+ self.add_offset(width).sub_width(width)
}
pub fn used_width(&self) -> usize {
fn shape_visual_indent() {
let config = Config::default();
let indent = Indent::new(4, 8);
- let shape = Shape::indented(indent, &config);
+ let shape = Shape::legacy(config.max_width, indent);
let shape = shape.visual_indent(20);
assert_eq!(config.max_width, shape.width);
assert_eq!(4, shape.indent.block_indent);
- assert_eq!(32, shape.indent.alignment);
- assert_eq!(32, shape.offset);
+ assert_eq!(28, shape.indent.alignment);
+ assert_eq!(28, shape.offset);
}
#[test]
fn shape_block_indent_without_alignment() {
let config = Config::default();
let indent = Indent::new(4, 0);
- let shape = Shape::indented(indent, &config);
+ let shape = Shape::legacy(config.max_width, indent);
let shape = shape.block_indent(20);
assert_eq!(config.max_width, shape.width);
fn shape_block_indent_with_alignment() {
let config = Config::default();
let indent = Indent::new(4, 8);
- let shape = Shape::indented(indent, &config);
+ let shape = Shape::legacy(config.max_width, indent);
let shape = shape.block_indent(20);
assert_eq!(config.max_width, shape.width);
ast::StmtKind::Local(..) |
ast::StmtKind::Expr(..) |
ast::StmtKind::Semi(..) => {
- let rewrite = stmt.rewrite(&self.get_context(),
- Shape::legacy(self.config.max_width -
- self.block_indent.width(),
- self.block_indent));
+ let rewrite =
+ stmt.rewrite(&self.get_context(),
+ Shape::indented(self.block_indent, self.config));
if rewrite.is_none() {
self.failed = true;
}
codemap: parse_session.codemap(),
buffer: StringBuffer::new(),
last_pos: BytePos(0),
- block_indent: Indent {
- block_indent: 0,
- alignment: 0,
- },
+ block_indent: Indent::empty(),
config: config,
failed: false,
}
let rewrite = outers
.rewrite(&self.get_context(),
- Shape::legacy(self.config.max_width - self.block_indent.width(),
- self.block_indent))
+ Shape::indented(self.block_indent, self.config))
.unwrap();
self.buffer.push_str(&rewrite);
let last = outers.last().unwrap();
ctx.create_device_local_buffer(buffer)
});
}
+
+fn issue470() {
+ {{{
+ let explicit_arg_decls =
+ explicit_arguments.into_iter()
+ .enumerate()
+ .map(|(index, (ty, pattern))| {
+ let lvalue = Lvalue::Arg(index as u32);
+ block = this.pattern(block,
+ argument_extent,
+ hair::PatternRef::Hair(pattern),
+ &lvalue);
+ ArgDecl { ty: ty }
+ });
+ }}}
+}
+
+// #1509
+impl Foo {
+ pub fn bar(&self) {
+ Some(SomeType {
+ push_closure_out_to_100_chars: iter(otherwise_it_works_ok.into_iter().map(|f| {
+ Ok(f)
+ })),
+ })
+ }
+}
funk(); //dontchangeme
// or me
+
+ // #1388
+ const EXCEPTION_PATHS: &'static [&'static str] =
+ &[// std crates
+ "src/libstd/sys/", // Platform-specific code for std lives here.
+ "src/bootstrap"];
}
/// test123
// rustfmt-array_layout: Block
// rustfmt-fn_call_style: Block
+// rustfmt-control_style: Rfc
// Test expressions with block formatting.
fn arrays() {
Some(p) => baz!(one_item_macro_as_expression_which_is_also_loooooooooooooooong),
};
}
+
+fn issue_1450() {
+ if selfstate
+ .compare_exchandsfasdsdfgsdgsdfgsdfgsdfgsdfgsdfgfsfdsage_weak(
+ STATE_PARKED,
+ STATE_UNPARKED,
+ Release,
+ Relaxed,
+ Release,
+ Relaxed,
+ )
+ .is_ok() {
+ return;
+ }
+}
+
+fn foo() {
+ if real_total <= limit && !pre_line_comments &&
+ !items.into_iter().any(|item| item.as_ref().is_multiline()) {
+ DefinitiveListTactic::Horizontal
+ }
+}
--- /dev/null
+// rustfmt-max_width: 120
+// rustfmt-comment_width: 110
+
+impl Struct {
+ fn fun() {
+ let result = match <R::RequestResult as serde::Deserialize>::deserialize(&json) {
+ Ok(v) => v,
+ Err(e) => {
+ match <R::ErrorResult as serde::Deserialize>::deserialize(&json) {
+ Ok(v) => return Err(Error::with_json(v)),
+ Err(e2) => return Err(Error::with_json(e)),
+ }
+ }
+ };
+ }
+}
}
struct Foo<C=()>(String);
+
+// #1364
+fn foo() {
+ convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
+ convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
+ convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
+ convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
+}
fn test() {
a?
}
+
+fn issue1291() {
+ try!(fs::create_dir_all(&gitfiledir).chain_err(|| {
+ format!("failed to create the {} submodule directory for the workarea",
+ name)
+ }));
+}
ctx.create_device_local_buffer(buffer)
});
}
+
+fn issue470() {
+ {
+ {
+ {
+ let explicit_arg_decls = explicit_arguments
+ .into_iter()
+ .enumerate()
+ .map(|(index, (ty, pattern))| {
+ let lvalue = Lvalue::Arg(index as u32);
+ block = this.pattern(block,
+ argument_extent,
+ hair::PatternRef::Hair(pattern),
+ &lvalue);
+ ArgDecl { ty: ty }
+ });
+ }
+ }
+ }
+}
+
+// #1509
+impl Foo {
+ pub fn bar(&self) {
+ Some(SomeType {
+ push_closure_out_to_100_chars: iter(otherwise_it_works_ok.into_iter().map(|f| {
+ Ok(f)
+ })),
+ })
+ }
+}
funk(); // dontchangeme
// or me
+
+ // #1388
+ const EXCEPTION_PATHS: &'static [&'static str] =
+ &[// std crates
+ "src/libstd/sys/", // Platform-specific code for std lives here.
+ "src/bootstrap"];
}
/// test123
// rustfmt-array_layout: Block
// rustfmt-fn_call_style: Block
+// rustfmt-control_style: Rfc
// Test expressions with block formatting.
fn arrays() {
Some(p) => baz!(one_item_macro_as_expression_which_is_also_loooooooooooooooong),
};
}
+
+fn issue_1450() {
+ if selfstate
+ .compare_exchandsfasdsdfgsdgsdfgsdfgsdfgsdfgsdfgfsfdsage_weak(
+ STATE_PARKED,
+ STATE_UNPARKED,
+ Release,
+ Relaxed,
+ Release,
+ Relaxed,
+ )
+ .is_ok()
+ {
+ return;
+ }
+}
+
+fn foo() {
+ if real_total <= limit && !pre_line_comments &&
+ !items.into_iter().any(|item| item.as_ref().is_multiline())
+ {
+ DefinitiveListTactic::Horizontal
+ }
+}
--- /dev/null
+// rustfmt-max_width: 120
+// rustfmt-comment_width: 110
+
+impl Struct {
+ fn fun() {
+ let result = match <R::RequestResult as serde::Deserialize>::deserialize(&json) {
+ Ok(v) => v,
+ Err(e) => {
+ match <R::ErrorResult as serde::Deserialize>::deserialize(&json) {
+ Ok(v) => return Err(Error::with_json(v)),
+ Err(e2) => return Err(Error::with_json(e)),
+ }
+ }
+ };
+ }
+}
}
struct Foo<C = ()>(String);
+
+// #1364
+fn foo() {
+ convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
+ convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
+ convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
+ convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
+}
fn test() {
a?
}
+
+fn issue1291() {
+ fs::create_dir_all(&gitfiledir)
+ .chain_err(|| {
+ format!("failed to create the {} submodule directory for the workarea",
+ name)
+ })?;
+}