@@ -22,7 +22,6 @@ pub fn generate_register() {
22
22
let workspace_dir = env:: var_os ( "CARGO_WORKSPACE_DIR" )
23
23
. map ( PathBuf :: from)
24
24
. unwrap_or_else ( || crate_dir. clone ( ) ) ;
25
- let crate_name = env:: var ( "CARGO_PKG_NAME" ) . unwrap ( ) ;
26
25
let out_dir = PathBuf :: from ( env:: var ( "OUT_DIR" ) . unwrap ( ) ) ;
27
26
28
27
let src_dir = crate_dir. join ( "src" ) ;
@@ -116,8 +115,6 @@ pub fn generate_register() {
116
115
}
117
116
118
117
for ( filename, entry) in entries {
119
- let prefix = crate_name. to_string ( ) ;
120
-
121
118
let mut values = FxHashMap :: default ( ) ;
122
119
123
120
let out_file = out_dir. join ( filename) ;
@@ -139,12 +136,9 @@ pub fn generate_register() {
139
136
140
137
let mut ctx = RegisterContext {
141
138
queue : & mut queue,
142
-
143
139
file_path : & file_path,
144
- crate_prefix : & prefix,
145
140
mod_path,
146
141
attributes,
147
-
148
142
values : & mut values,
149
143
} ;
150
144
@@ -160,48 +154,9 @@ pub fn generate_register() {
160
154
}
161
155
}
162
156
163
- let mut values_code = String :: new ( ) ;
164
- // for ((mod_path, ident), entry) in values {
165
- // for attribute in &entry.attributes {
166
- // values_code.push_str(attribute);
167
- // }
168
- // writeln!(
169
- // values_code,
170
- // "crate{}::{}({}, #[allow(unused_variables)] |value| {{",
171
- // mod_path,
172
- // get_register_value_type_ident(&ident),
173
- // entry.global_name,
174
- // )
175
- // .unwrap();
176
- // // Register all the trait items for each impl so we can dispatch to them as
177
- // turbotasks for trait_ident in &entry.trait_idents {
178
- // writeln!(
179
- // values_code,
180
- // " crate{}::{}(value);",
181
- // mod_path,
182
- // get_register_trait_methods_ident(trait_ident, &ident),
183
- // )
184
- // .unwrap();
185
- // }
186
- // writeln!(values_code, "}}, #[allow(unused_variables)] |value_id| {{").unwrap();
187
- // // Register all the vtables for the impls so we can dispatch to them as normal
188
- // indirect // trait calls.
189
- // for trait_ident in &entry.trait_idents {
190
- // writeln!(
191
- // values_code,
192
- // " crate{}::{}(value_id);",
193
- // mod_path,
194
- // get_register_trait_impls_ident(trait_ident, &ident),
195
- // )
196
- // .unwrap();
197
- // }
198
- // writeln!(values_code, "}});").unwrap();
199
- // }
157
+ let code = "{\n static ONCE: std::sync::Once = std::sync::Once::new();\n ONCE.call_once(|| \
158
+ {\n // dead code to be deleted\n });\n }\n ";
200
159
201
- let code = format ! (
202
- "{{\n static ONCE: std::sync::Once = std::sync::Once::new();\n ONCE.call_once(|| \
203
- {{\n {values_code}}});\n }}\n "
204
- ) ;
205
160
std:: fs:: write ( out_file, code) . unwrap ( ) ;
206
161
207
162
// println!("cargo:warning={}", out_file.display());
@@ -233,8 +188,6 @@ pub fn rerun_if_glob(globs: &str, root: &str) {
233
188
type ValueKey = ( String , Ident ) ;
234
189
/// (global_name, trait_register_fns)
235
190
struct ValueEntry {
236
- attributes : Vec < Arc < String > > ,
237
- global_name : String ,
238
191
trait_idents : Vec < Ident > ,
239
192
}
240
193
@@ -254,7 +207,6 @@ struct RegisterContext<'a> {
254
207
file_path : & ' a PathBuf ,
255
208
mod_path : String ,
256
209
attributes : Vec < Arc < String > > ,
257
- crate_prefix : & ' a str ,
258
210
259
211
values : & ' a mut FxHashMap < ValueKey , ValueEntry > ,
260
212
}
@@ -420,24 +372,9 @@ impl RegisterContext<'_> {
420
372
}
421
373
422
374
impl RegisterContext < ' _ > {
423
- fn get_global_name ( & self , parts : & [ & Ident ] ) -> String {
424
- format ! (
425
- "r##\" {}{}::{}\" ##" ,
426
- self . crate_prefix,
427
- self . mod_path,
428
- parts
429
- . iter( )
430
- . map( ToString :: to_string)
431
- . collect:: <Vec <_>>( )
432
- . join( "::" )
433
- )
434
- }
435
-
436
375
fn add_value ( & mut self , ident : & Ident ) {
437
376
let key: ValueKey = ( self . mod_path . clone ( ) , ident. clone ( ) ) ;
438
377
let value = ValueEntry {
439
- attributes : self . attributes . clone ( ) ,
440
- global_name : self . get_global_name ( & [ ident] ) ,
441
378
trait_idents : Vec :: new ( ) ,
442
379
} ;
443
380
0 commit comments