Merge pull request #239 from sinhpham/format_strings_option

Format strings option https://github.com/nrc/rustfmt/issues/202
This commit is contained in:
Marcus Klaas de Vries 2015-09-01 20:34:22 +02:00
commit 81c8c020a8
4 changed files with 28 additions and 0 deletions

View File

@ -80,6 +80,7 @@ create_config! {
expr_indent_style: BlockIndentStyle,
closure_indent_style: BlockIndentStyle,
single_line_if_else: bool,
format_strings: bool,
}
impl Default for Config {
@ -104,6 +105,7 @@ impl Default for Config {
expr_indent_style: BlockIndentStyle::Tabbed,
closure_indent_style: BlockIndentStyle::Visual,
single_line_if_else: false,
format_strings: true,
}
}

View File

@ -828,6 +828,9 @@ fn rewrite_string_lit(context: &RewriteContext,
width: usize,
offset: usize)
-> Option<String> {
if context.config.format_strings == false {
return Some(context.snippet(span));
}
// Check if there is anything to fix: we always try to fixup multi-line
// strings, or if the string is too long for the line.
let l_loc = context.codemap.lookup_char_pos(span.lo);

View File

@ -16,3 +16,4 @@ reorder_imports = false
expr_indent_style = "Tabbed"
closure_indent_style = "Visual"
single_line_if_else = false
format_strings = true

View File

@ -0,0 +1,22 @@
// rustfmt-format_strings: false
fn main() {
let expected = "; ModuleID = \'foo\'
; Function Attrs: nounwind
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) #0
declare i32 @write(i32, i8*, i32)
declare i32 @putchar(i32)
declare i32 @getchar()
define i32 @main() {
entry:
ret i32 0
}
attributes #0 = { nounwind }
";
}