@@ -23,6 +23,7 @@ pub fn split_input(
23
23
deps : & [ ( String , String ) ] ,
24
24
prelude_items : & [ String ] ,
25
25
bin_name : & str ,
26
+ script_name : & str ,
26
27
toolchain : Option < String > ,
27
28
) -> MainResult < ( String , String ) > {
28
29
fn contains_main_method ( line : & str ) -> bool {
@@ -85,7 +86,7 @@ pub fn split_input(
85
86
info ! ( "source: {:?}" , source) ;
86
87
87
88
// 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) ;
89
90
let dep_mani = deps_manifest ( deps) ?;
90
91
91
92
let mani = merge_manifest ( def_mani, part_mani) ?;
@@ -110,15 +111,16 @@ strip = true
110
111
#[ test]
111
112
fn test_split_input ( ) {
112
113
let bin_name = "binary-name" . to_string ( ) ;
114
+ let script_name = "main.rs" . to_string ( ) ;
113
115
let toolchain = None ;
114
116
macro_rules! si {
115
117
( $i: expr) => {
116
- split_input( & $i, & [ ] , & [ ] , & bin_name, toolchain. clone( ) ) . ok( )
118
+ split_input( & $i, & [ ] , & [ ] , & bin_name, & script_name , toolchain. clone( ) ) . ok( )
117
119
} ;
118
120
}
119
121
120
122
let f = |c : & str | {
121
- let dummy_path: :: std:: path:: PathBuf = "p " . into ( ) ;
123
+ let dummy_path: :: std:: path:: PathBuf = "main.rs " . into ( ) ;
122
124
Input :: File ( "n" . to_string ( ) , dummy_path, c. to_string ( ) )
123
125
} ;
124
126
@@ -203,6 +205,7 @@ fn main() {}"#
203
205
& [ ] ,
204
206
& [ ] ,
205
207
& bin_name,
208
+ "main.rs" ,
206
209
Some ( "stable" . to_string( ) )
207
210
)
208
211
. ok( ) ,
@@ -1089,6 +1092,7 @@ Generates a default Cargo manifest for the given input.
1089
1092
fn default_manifest (
1090
1093
input : & Input ,
1091
1094
bin_name : & str ,
1095
+ script_name : & str ,
1092
1096
toolchain : Option < String > ,
1093
1097
) -> toml:: value:: Table {
1094
1098
let mut package_map = toml:: map:: Map :: new ( ) ;
@@ -1138,7 +1142,7 @@ fn default_manifest(
1138
1142
) ;
1139
1143
bin_map. insert (
1140
1144
"path" . to_string ( ) ,
1141
- toml:: value:: Value :: String ( "main.rs" . to_string ( ) ) ,
1145
+ toml:: value:: Value :: String ( script_name . to_string ( ) ) ,
1142
1146
) ;
1143
1147
1144
1148
let mut mani_map = toml:: map:: Map :: new ( ) ;
0 commit comments