diff options
| author | bors <bors@rust-lang.org> | 2019-12-23 02:47:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-12-23 02:47:52 +0000 |
| commit | a916ac22b9f7f1f0f7aba0a41a789b3ecd765018 (patch) | |
| tree | 139cba4184f0f290fdbdff1aa0aa68352b16ccbb /src/libsyntax_pos/source_map | |
| parent | 9b98af84c4aa66392236fff59c86da2130d46d46 (diff) | |
| parent | 0f24ccd21d9f734a21daaf3566900127167556d1 (diff) | |
Auto merge of #67540 - Mark-Simulacrum:fmt-the-world, r=Centril
Format the world This PR modifies the formatting infrastructure a bit in the first commit (to enable the forgotten 2018 edition), as well as removes most directories from the ignore list in rustfmt.toml. It then follows that up with the second commit which runs `x.py fmt` and formats the entire repository. We continue to not format the test directory (`src/test`) because of interactions with pretty printing and, in part, because re-blessing all of those files is somewhat harder to review, so is best suited for a follow up PR in my opinion.
Diffstat (limited to 'src/libsyntax_pos/source_map')
| -rw-r--r-- | src/libsyntax_pos/source_map/tests.rs | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/src/libsyntax_pos/source_map/tests.rs b/src/libsyntax_pos/source_map/tests.rs index 15254336bbf..79df1884f0d 100644 --- a/src/libsyntax_pos/source_map/tests.rs +++ b/src/libsyntax_pos/source_map/tests.rs @@ -4,18 +4,9 @@ use rustc_data_structures::sync::Lrc; fn init_source_map() -> SourceMap { let sm = SourceMap::new(FilePathMapping::empty()); - sm.new_source_file( - PathBuf::from("blork.rs").into(), - "first line.\nsecond line".to_string(), - ); - sm.new_source_file( - PathBuf::from("empty.rs").into(), - String::new(), - ); - sm.new_source_file( - PathBuf::from("blork2.rs").into(), - "first line.\nsecond line".to_string(), - ); + sm.new_source_file(PathBuf::from("blork.rs").into(), "first line.\nsecond line".to_string()); + sm.new_source_file(PathBuf::from("empty.rs").into(), String::new()); + sm.new_source_file(PathBuf::from("blork2.rs").into(), "first line.\nsecond line".to_string()); sm } @@ -68,10 +59,14 @@ fn t5() { fn init_source_map_mbc() -> SourceMap { let sm = SourceMap::new(FilePathMapping::empty()); // "€" is a three-byte UTF8 char. - sm.new_source_file(PathBuf::from("blork.rs").into(), - "fir€st €€€€ line.\nsecond line".to_string()); - sm.new_source_file(PathBuf::from("blork2.rs").into(), - "first line€€.\n€ second line".to_string()); + sm.new_source_file( + PathBuf::from("blork.rs").into(), + "fir€st €€€€ line.\nsecond line".to_string(), + ); + sm.new_source_file( + PathBuf::from("blork2.rs").into(), + "first line€€.\n€ second line".to_string(), + ); sm } @@ -112,7 +107,7 @@ fn t7() { fn span_from_selection(input: &str, selection: &str) -> Span { assert_eq!(input.len(), selection.len()); let left_index = selection.find('~').unwrap() as u32; - let right_index = selection.rfind('~').map(|x|x as u32).unwrap_or(left_index); + let right_index = selection.rfind('~').map(|x| x as u32).unwrap_or(left_index); Span::with_root_ctxt(BytePos(left_index), BytePos(right_index + 1)) } @@ -134,8 +129,8 @@ fn span_to_snippet_and_lines_spanning_multiple_lines() { let expected = vec![ LineInfo { line_index: 1, start_col: CharPos(4), end_col: CharPos(6) }, LineInfo { line_index: 2, start_col: CharPos(0), end_col: CharPos(3) }, - LineInfo { line_index: 3, start_col: CharPos(0), end_col: CharPos(5) } - ]; + LineInfo { line_index: 3, start_col: CharPos(0), end_col: CharPos(5) }, + ]; assert_eq!(lines.lines, expected); } @@ -154,7 +149,7 @@ fn t8() { fn t9() { let sm = init_source_map(); let span = Span::with_root_ctxt(BytePos(12), BytePos(23)); - let sstr = sm.span_to_string(span); + let sstr = sm.span_to_string(span); assert_eq!(sstr, "blork.rs:2:1: 2:12"); } @@ -163,7 +158,7 @@ fn t9() { #[test] fn span_merging_fail() { let sm = SourceMap::new(FilePathMapping::empty()); - let inputtext = "bbbb BB\ncc CCC\n"; + let inputtext = "bbbb BB\ncc CCC\n"; let selection1 = " ~~\n \n"; let selection2 = " \n ~~~\n"; sm.new_source_file(Path::new("blork.rs").to_owned().into(), inputtext.to_owned()); |
