@@ -335,12 +335,11 @@ fn run_compiler(
335335 config. input = input;
336336 true // has input: normal compilation
337337 }
338- Ok ( None ) => match matches. free. len( ) {
339- 0 => false , // no input: we will exit early
340- 1 => panic!( "make_input should have provided valid inputs" ) ,
341- _ => default_early_dcx. early_fatal( format!(
342- "multiple input filenames provided (first two filenames are `{}` and `{}`)" ,
343- matches. free[ 0 ] , matches. free[ 1 ] ,
338+ Ok ( None ) => match & * matches. free {
339+ [ ] => false , // no input: we will exit early
340+ [ _] => panic!( "make_input should have provided valid inputs" ) ,
341+ [ fst, snd, ..] => default_early_dcx. early_fatal( format!(
342+ "multiple input filenames provided (first two filenames are `{fst}` and `{snd}`)"
344343 ) ) ,
345344 } ,
346345 } ;
@@ -488,34 +487,30 @@ fn make_input(
488487 early_dcx: & EarlyDiagCtxt ,
489488 free_matches: & [ String ] ,
490489) -> Result <Option <Input >, ErrorGuaranteed > {
491- if free_matches. len( ) == 1 {
492- let ifile = & free_matches[ 0 ] ;
493- if ifile == "-" {
494- let mut src = String :: new( ) ;
495- if io:: stdin( ) . read_to_string( & mut src) . is_err( ) {
496- // Immediately stop compilation if there was an issue reading
497- // the input (for example if the input stream is not UTF-8).
498- let reported = early_dcx
499- . early_err( "couldn't read from stdin, as it did not contain valid UTF-8" ) ;
500- return Err ( reported) ;
501- }
502- if let Ok ( path) = env:: var( "UNSTABLE_RUSTDOC_TEST_PATH" ) {
503- let line = env:: var( "UNSTABLE_RUSTDOC_TEST_LINE" ) . expect(
504- "when UNSTABLE_RUSTDOC_TEST_PATH is set \
490+ let [ ifile] = free_matches else { return Ok ( None ) } ;
491+ if ifile == "-" {
492+ let mut src = String :: new( ) ;
493+ if io:: stdin( ) . read_to_string( & mut src) . is_err( ) {
494+ // Immediately stop compilation if there was an issue reading
495+ // the input (for example if the input stream is not UTF-8).
496+ let reported =
497+ early_dcx. early_err( "couldn't read from stdin, as it did not contain valid UTF-8" ) ;
498+ return Err ( reported) ;
499+ }
500+ if let Ok ( path) = env:: var( "UNSTABLE_RUSTDOC_TEST_PATH" ) {
501+ let line = env:: var( "UNSTABLE_RUSTDOC_TEST_LINE" ) . expect(
502+ "when UNSTABLE_RUSTDOC_TEST_PATH is set \
505503 UNSTABLE_RUSTDOC_TEST_LINE also needs to be set",
506- ) ;
507- let line = isize :: from_str_radix( & line, 10 )
508- . expect( "UNSTABLE_RUSTDOC_TEST_LINE needs to be an number" ) ;
509- let file_name = FileName :: doc_test_source_code( PathBuf :: from( path) , line) ;
510- Ok ( Some ( Input :: Str { name: file_name, input: src } ) )
511- } else {
512- Ok ( Some ( Input :: Str { name: FileName :: anon_source_code( & src) , input: src } ) )
513- }
504+ ) ;
505+ let line = isize :: from_str_radix( & line, 10 )
506+ . expect( "UNSTABLE_RUSTDOC_TEST_LINE needs to be an number" ) ;
507+ let file_name = FileName :: doc_test_source_code( PathBuf :: from( path) , line) ;
508+ Ok ( Some ( Input :: Str { name: file_name, input: src } ) )
514509 } else {
515- Ok ( Some ( Input :: File ( PathBuf :: from ( ifile ) ) ) )
510+ Ok ( Some ( Input :: Str { name : FileName :: anon_source_code ( & src ) , input : src } ) )
516511 }
517512 } else {
518- Ok ( None )
513+ Ok ( Some ( Input :: File ( PathBuf :: from ( ifile ) ) ) )
519514 }
520515}
521516
0 commit comments