@@ -164,8 +164,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
164164
165165 debug ! ( "next up: {:?}" , file) ;
166166 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( ) ) ) ?;
169169 let suggestions =
170170 rustfix:: get_suggestions_from_json ( & errors, & HashSet :: new ( ) , filter_suggestions)
171171 . context ( "could not load suggestions" ) ?;
@@ -175,10 +175,8 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
175175 }
176176
177177 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( ) ) ) ?;
182180 let expected_suggestions =
183181 rustfix:: get_suggestions_from_json ( & expected_json, & HashSet :: new ( ) , filter_suggestions)
184182 . context ( "could not load expected suggestions" ) ?;
@@ -194,7 +192,7 @@ fn test_rustfix_with_file<P: AsRef<Path>>(file: P, mode: &str) -> Result<(), Err
194192 }
195193
196194 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( ) ) ) ?
198196 . replace ( '\r' , "" ) ;
199197
200198 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
209207 }
210208
211209 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( ) ) ) ?
213211 . replace ( '\r' , "" ) ;
214212 ensure ! (
215213 fixed. trim( ) == expected_fixed. trim( ) ,
@@ -236,7 +234,7 @@ fn get_fixture_files(p: &str) -> Result<Vec<PathBuf>, Error> {
236234
237235fn assert_fixtures ( dir : & str , mode : & str ) {
238236 let files = get_fixture_files ( dir)
239- . context ( format ! ( "couldn't load dir `{}`" , dir ) )
237+ . with_context ( || format ! ( "couldn't load dir `{dir }`" ) )
240238 . unwrap ( ) ;
241239 let mut failures = 0 ;
242240
0 commit comments