@@ -4252,14 +4252,34 @@ impl<'test> TestCx<'test> {
4252
4252
if self . props . run_rustfix && self . config . compare_mode . is_none ( ) {
4253
4253
// And finally, compile the fixed code and make sure it both
4254
4254
// succeeds and has no diagnostics.
4255
- let rustc = self . make_compile_args (
4255
+ let mut rustc = self . make_compile_args (
4256
4256
& self . expected_output_path ( UI_FIXED ) ,
4257
4257
TargetLocation :: ThisFile ( self . make_exe_name ( ) ) ,
4258
4258
emit_metadata,
4259
4259
AllowUnused :: No ,
4260
4260
LinkToAux :: Yes ,
4261
4261
Vec :: new ( ) ,
4262
4262
) ;
4263
+
4264
+ // If a test is revisioned, it's fixed source file can be named "a.foo.fixed", which,
4265
+ // well, "a.foo" isn't a valid crate name. So we explicitly mangle the test name
4266
+ // (including the revision) here to avoid the test writer having to manually specify a
4267
+ // `#![crate_name = "..."]` as a workaround. This is okay since we're only checking if
4268
+ // the fixed code is compilable.
4269
+ if self . revision . is_some ( ) {
4270
+ let crate_name =
4271
+ self . testpaths . file . file_stem ( ) . expect ( "test must have a file stem" ) ;
4272
+ // crate name must be alphanumeric or `_`.
4273
+ let crate_name =
4274
+ crate_name. to_str ( ) . expect ( "crate name implies file name must be valid UTF-8" ) ;
4275
+ // replace `a.foo` -> `a__foo` for crate name purposes.
4276
+ // replace `revision-name-with-dashes` -> `revision_name_with_underscore`
4277
+ let crate_name = crate_name. replace ( "." , "__" ) ;
4278
+ let crate_name = crate_name. replace ( "-" , "_" ) ;
4279
+ rustc. arg ( "--crate-name" ) ;
4280
+ rustc. arg ( crate_name) ;
4281
+ }
4282
+
4263
4283
let res = self . compose_and_run_compiler ( rustc, None ) ;
4264
4284
if !res. status . success ( ) {
4265
4285
self . fatal_proc_rec ( "failed to compile fixed code" , & res) ;
0 commit comments