@@ -7,7 +7,6 @@ mod traits;
7
7
mod method_resolution;
8
8
mod macros;
9
9
10
- use std:: fmt:: Write ;
11
10
use std:: sync:: Arc ;
12
11
13
12
use hir_def:: {
@@ -26,6 +25,7 @@ use ra_syntax::{
26
25
algo,
27
26
ast:: { self , AstNode } ,
28
27
} ;
28
+ use stdx:: format_to;
29
29
30
30
use crate :: { db:: HirDatabase , display:: HirDisplay , test_db:: TestDB , InferenceResult } ;
31
31
@@ -63,7 +63,7 @@ fn infer(ra_fixture: &str) -> String {
63
63
fn infer_with_mismatches ( content : & str , include_mismatches : bool ) -> String {
64
64
let ( db, file_id) = TestDB :: with_single_file ( content) ;
65
65
66
- let mut acc = String :: new ( ) ;
66
+ let mut buf = String :: new ( ) ;
67
67
68
68
let mut infer_def = |inference_result : Arc < InferenceResult > ,
69
69
body_source_map : Arc < BodySourceMap > | {
@@ -106,15 +106,14 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
106
106
( src_ptr. value . range ( ) , node. text ( ) . to_string ( ) . replace ( "\n " , " " ) )
107
107
} ;
108
108
let macro_prefix = if src_ptr. file_id != file_id. into ( ) { "!" } else { "" } ;
109
- writeln ! (
110
- acc ,
111
- "{}{} '{}': {}" ,
109
+ format_to ! (
110
+ buf ,
111
+ "{}{} '{}': {}\n " ,
112
112
macro_prefix,
113
113
range,
114
114
ellipsize( text, 15 ) ,
115
115
ty. display( & db)
116
- )
117
- . unwrap ( ) ;
116
+ ) ;
118
117
}
119
118
if include_mismatches {
120
119
mismatches. sort_by_key ( |( src_ptr, _) | {
@@ -123,15 +122,14 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
123
122
for ( src_ptr, mismatch) in & mismatches {
124
123
let range = src_ptr. value . range ( ) ;
125
124
let macro_prefix = if src_ptr. file_id != file_id. into ( ) { "!" } else { "" } ;
126
- writeln ! (
127
- acc ,
128
- "{}{}: expected {}, got {}" ,
125
+ format_to ! (
126
+ buf ,
127
+ "{}{}: expected {}, got {}\n " ,
129
128
macro_prefix,
130
129
range,
131
130
mismatch. expected. display( & db) ,
132
131
mismatch. actual. display( & db) ,
133
- )
134
- . unwrap ( ) ;
132
+ ) ;
135
133
}
136
134
}
137
135
} ;
@@ -158,8 +156,8 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
158
156
infer_def ( infer, source_map) ;
159
157
}
160
158
161
- acc . truncate ( acc . trim_end ( ) . len ( ) ) ;
162
- acc
159
+ buf . truncate ( buf . trim_end ( ) . len ( ) ) ;
160
+ buf
163
161
}
164
162
165
163
fn visit_module (
0 commit comments