forked from rust-lang/rustfmt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request rust-lang#3073 from scampi/format_strings
format_strings: take into account newline occurring within a rewritten line
- Loading branch information
Showing
5 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// rustfmt-format_strings: true | ||
|
||
#[test] | ||
fn compile_empty_program() { | ||
let result = get_result(); | ||
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 } | ||
"; | ||
assert_eq!(result, CString::new(expected).unwrap()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// rustfmt-format_strings: true | ||
// rustfmt-max_width: 80 | ||
|
||
fn test1() { | ||
let expected = "\ | ||
but Doctor Watson has to have it taken out for him and dusted, | ||
"; | ||
} | ||
|
||
fn test2() { | ||
let expected = "\ | ||
[Omitted long matching line] | ||
but Doctor Watson has to have it taken out for him and dusted, | ||
"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// rustfmt-format_strings: true | ||
|
||
fn foo() -> &'static str { | ||
let sql = "ATTACH DATABASE ':memory:' AS my_attached; | ||
BEGIN; | ||
CREATE TABLE my_attached.foo(x INTEGER); | ||
INSERT INTO my_attached.foo VALUES(42); | ||
END;"; | ||
sql | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// rustfmt-format_strings: true | ||
|
||
const USAGE: &'static str = " | ||
Usage: codegen project <name> <digits> <len> <codes> <prizes> <step> <shift> | ||
codegen regenerate <name> | ||
codegen verify <name> <code> | ||
"; |