mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 17:48:10 +00:00
Merge pull request #239 from sinhpham/format_strings_option
Format strings option https://github.com/nrc/rustfmt/issues/202
This commit is contained in:
commit
81c8c020a8
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -16,3 +16,4 @@ reorder_imports = false
|
||||
expr_indent_style = "Tabbed"
|
||||
closure_indent_style = "Visual"
|
||||
single_line_if_else = false
|
||||
format_strings = true
|
||||
|
22
tests/target/string-lit-custom.rs
Normal file
22
tests/target/string-lit-custom.rs
Normal 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 }
|
||||
";
|
||||
}
|
Loading…
Reference in New Issue
Block a user