@@ -164,8 +164,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
164
164
165
165
debug ! ( "next up: {:?}" , file) ;
166
166
let code = fs:: read_to_string ( file) ?;
167
- let errors =
168
- compile_and_get_json_errors ( file ) . context ( format ! ( "could compile {}" , file. display( ) ) ) ?;
167
+ let errors = compile_and_get_json_errors ( file )
168
+ . with_context ( || format ! ( "could not compile {}" , file. display( ) ) ) ?;
169
169
let suggestions =
170
170
rustfix:: get_suggestions_from_json ( & errors, & HashSet :: new ( ) , filter_suggestions)
171
171
. context ( "could not load suggestions" ) ?;
@@ -175,10 +175,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
175
175
}
176
176
177
177
if std:: env:: var ( settings:: CHECK_JSON ) . is_ok ( ) {
178
- let expected_json = fs:: read_to_string ( & json_file) . context ( format ! (
179
- "could not load json fixtures for {}" ,
180
- file. display( )
181
- ) ) ?;
178
+ let expected_json = fs:: read_to_string ( & json_file)
179
+ . with_context ( || format ! ( "could not load json fixtures for {}" , file. display( ) ) ) ?;
182
180
let expected_suggestions =
183
181
rustfix:: get_suggestions_from_json ( & expected_json, & HashSet :: new ( ) , filter_suggestions)
184
182
. context ( "could not load expected suggestions" ) ?;
@@ -194,7 +192,7 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
194
192
}
195
193
196
194
let fixed = apply_suggestions ( & code, & suggestions)
197
- . context ( format ! ( "could not apply suggestions to {}" , file. display( ) ) ) ?
195
+ . with_context ( || format ! ( "could not apply suggestions to {}" , file. display( ) ) ) ?
198
196
. replace ( '\r' , "" ) ;
199
197
200
198
if std:: env:: var ( settings:: RECORD_FIXED_RUST ) . is_ok ( ) {
@@ -209,7 +207,7 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
209
207
}
210
208
211
209
let expected_fixed = fs:: read_to_string ( & fixed_file)
212
- . context ( format ! ( "could read fixed file for {}" , file. display( ) ) ) ?
210
+ . with_context ( || format ! ( "could read fixed file for {}" , file. display( ) ) ) ?
213
211
. replace ( '\r' , "" ) ;
214
212
ensure ! (
215
213
fixed. trim( ) == expected_fixed. trim( ) ,
@@ -236,7 +234,7 @@ fn get_fixture_files(p: &str) -> Result<Vec<PathBuf>, Error> {
236
234
237
235
fn assert_fixtures ( dir : & str , mode : & str ) {
238
236
let files = get_fixture_files ( dir)
239
- . context ( format ! ( "couldn't load dir `{}`" , dir) )
237
+ . with_context ( || format ! ( "couldn't load dir `{}`" , dir) )
240
238
. unwrap ( ) ;
241
239
let mut failures = 0 ;
242
240
0 commit comments