@@ -23,6 +23,7 @@ pub fn split_input(
2323 deps : & [ ( String , String ) ] ,
2424 prelude_items : & [ String ] ,
2525 bin_name : & str ,
26+ script_name : & str ,
2627 toolchain : Option < String > ,
2728) -> MainResult < ( String , String ) > {
2829 fn contains_main_method ( line : & str ) -> bool {
@@ -85,7 +86,7 @@ pub fn split_input(
8586 info ! ( "source: {:?}" , source) ;
8687
8788 // It's-a mergin' time!
88- let def_mani = default_manifest ( input, bin_name, toolchain) ;
89+ let def_mani = default_manifest ( input, bin_name, script_name , toolchain) ;
8990 let dep_mani = deps_manifest ( deps) ?;
9091
9192 let mani = merge_manifest ( def_mani, part_mani) ?;
@@ -110,15 +111,16 @@ strip = true
110111#[ test]
111112fn test_split_input ( ) {
112113 let bin_name = "binary-name" . to_string ( ) ;
114+ let script_name = "main.rs" . to_string ( ) ;
113115 let toolchain = None ;
114116 macro_rules! si {
115117 ( $i: expr) => {
116- split_input( & $i, & [ ] , & [ ] , & bin_name, toolchain. clone( ) ) . ok( )
118+ split_input( & $i, & [ ] , & [ ] , & bin_name, & script_name , toolchain. clone( ) ) . ok( )
117119 } ;
118120 }
119121
120122 let f = |c : & str | {
121- let dummy_path: :: std:: path:: PathBuf = "p " . into ( ) ;
123+ let dummy_path: :: std:: path:: PathBuf = "main.rs " . into ( ) ;
122124 Input :: File ( "n" . to_string ( ) , dummy_path, c. to_string ( ) )
123125 } ;
124126
@@ -203,6 +205,7 @@ fn main() {}"#
203205 & [ ] ,
204206 & [ ] ,
205207 & bin_name,
208+ "main.rs" ,
206209 Some ( "stable" . to_string( ) )
207210 )
208211 . ok( ) ,
@@ -1089,6 +1092,7 @@ Generates a default Cargo manifest for the given input.
10891092fn default_manifest (
10901093 input : & Input ,
10911094 bin_name : & str ,
1095+ script_name : & str ,
10921096 toolchain : Option < String > ,
10931097) -> toml:: value:: Table {
10941098 let mut package_map = toml:: map:: Map :: new ( ) ;
@@ -1138,7 +1142,7 @@ fn default_manifest(
11381142 ) ;
11391143 bin_map. insert (
11401144 "path" . to_string ( ) ,
1141- toml:: value:: Value :: String ( "main.rs" . to_string ( ) ) ,
1145+ toml:: value:: Value :: String ( script_name . to_string ( ) ) ,
11421146 ) ;
11431147
11441148 let mut mani_map = toml:: map:: Map :: new ( ) ;
0 commit comments