Skip to content

Commit bc96526

Browse files
committed
Fix clippy issues
1 parent 53697c2 commit bc96526

File tree

9 files changed

+10
-306
lines changed

9 files changed

+10
-306
lines changed

turbopack/crates/turbo-tasks-build/src/lib.rs

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub fn generate_register() {
2222
let workspace_dir = env::var_os("CARGO_WORKSPACE_DIR")
2323
.map(PathBuf::from)
2424
.unwrap_or_else(|| crate_dir.clone());
25-
let crate_name = env::var("CARGO_PKG_NAME").unwrap();
2625
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
2726

2827
let src_dir = crate_dir.join("src");
@@ -116,8 +115,6 @@ pub fn generate_register() {
116115
}
117116

118117
for (filename, entry) in entries {
119-
let prefix = crate_name.to_string();
120-
121118
let mut values = FxHashMap::default();
122119

123120
let out_file = out_dir.join(filename);
@@ -139,12 +136,9 @@ pub fn generate_register() {
139136

140137
let mut ctx = RegisterContext {
141138
queue: &mut queue,
142-
143139
file_path: &file_path,
144-
crate_prefix: &prefix,
145140
mod_path,
146141
attributes,
147-
148142
values: &mut values,
149143
};
150144

@@ -160,48 +154,9 @@ pub fn generate_register() {
160154
}
161155
}
162156

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 = "{\nstatic ONCE: std::sync::Once = std::sync::Once::new();\nONCE.call_once(|| \
158+
{\n // dead code to be deleted\n});\n}\n";
200159

201-
let code = format!(
202-
"{{\nstatic ONCE: std::sync::Once = std::sync::Once::new();\nONCE.call_once(|| \
203-
{{\n{values_code}}});\n}}\n"
204-
);
205160
std::fs::write(out_file, code).unwrap();
206161

207162
// println!("cargo:warning={}", out_file.display());
@@ -233,8 +188,6 @@ pub fn rerun_if_glob(globs: &str, root: &str) {
233188
type ValueKey = (String, Ident);
234189
/// (global_name, trait_register_fns)
235190
struct ValueEntry {
236-
attributes: Vec<Arc<String>>,
237-
global_name: String,
238191
trait_idents: Vec<Ident>,
239192
}
240193

@@ -254,7 +207,6 @@ struct RegisterContext<'a> {
254207
file_path: &'a PathBuf,
255208
mod_path: String,
256209
attributes: Vec<Arc<String>>,
257-
crate_prefix: &'a str,
258210

259211
values: &'a mut FxHashMap<ValueKey, ValueEntry>,
260212
}
@@ -420,24 +372,9 @@ impl RegisterContext<'_> {
420372
}
421373

422374
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-
436375
fn add_value(&mut self, ident: &Ident) {
437376
let key: ValueKey = (self.mod_path.clone(), ident.clone());
438377
let value = ValueEntry {
439-
attributes: self.attributes.clone(),
440-
global_name: self.get_global_name(&[ident]),
441378
trait_idents: Vec::new(),
442379
};
443380

turbopack/crates/turbo-tasks-macros-shared/src/ident.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
use quote::ToTokens;
22
use syn::{GenericArgument, Ident, Path, PathArguments, Type, TypeParamBound, spanned::Spanned};
33

4-
pub fn get_register_value_type_ident(struct_ident: &Ident) -> Ident {
5-
Ident::new(
6-
&format!("__register_{struct_ident}_value_type"),
7-
struct_ident.span(),
8-
)
9-
}
10-
11-
pub fn get_register_trait_methods_ident(trait_ident: &Ident, struct_ident: &Ident) -> Ident {
12-
Ident::new(
13-
&format!("__register_{struct_ident}_{trait_ident}_trait_methods"),
14-
trait_ident.span(),
15-
)
16-
}
17-
184
pub fn get_cast_to_fat_pointer_ident(trait_ident: &Ident, struct_ident: &Ident) -> Ident {
195
Ident::new(
206
&format!("_cast_to_fat_pointer_{struct_ident}_{trait_ident}"),
@@ -101,13 +87,6 @@ pub fn get_trait_impl_function_id_ident(
10187
)
10288
}
10389

104-
pub fn get_internal_trait_impl_function_ident(trait_ident: &Ident, ident: &Ident) -> Ident {
105-
Ident::new(
106-
&format!("__trait_call_{trait_ident}_{ident}"),
107-
trait_ident.span(),
108-
)
109-
}
110-
11190
pub fn get_path_ident(path: &Path) -> Ident {
11291
let mut result = String::new();
11392

@@ -203,10 +182,3 @@ pub fn get_value_type_ident(ident: &Ident) -> Ident {
203182
ident.span(),
204183
)
205184
}
206-
207-
pub fn get_value_type_init_ident(ident: &Ident) -> Ident {
208-
Ident::new(
209-
&format!("{}_VALUE_TYPE_INIT", ident.to_string().to_uppercase()),
210-
ident.span(),
211-
)
212-
}

turbopack/crates/turbo-tasks-macros/src/value_impl_macro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use syn::{
1010
};
1111
use turbo_tasks_macros_shared::{
1212
get_cast_to_fat_pointer_ident, get_inherent_impl_function_ident, get_path_ident,
13-
get_register_trait_methods_ident, get_trait_impl_function_ident, get_type_ident, is_self_used,
13+
get_trait_impl_function_ident, get_type_ident, is_self_used,
1414
};
1515

1616
use crate::func::{

turbopack/crates/turbo-tasks-macros/src/value_macro.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use syn::{
1111
parse_macro_input, parse_quote,
1212
spanned::Spanned,
1313
};
14-
use turbo_tasks_macros_shared::{
15-
get_register_value_type_ident, get_value_type_ident, get_value_type_init_ident,
16-
};
14+
use turbo_tasks_macros_shared::get_value_type_ident;
1715

1816
enum IntoMode {
1917
None,

turbopack/crates/turbo-tasks/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ mod manager;
6262
mod marker_trait;
6363
pub mod message_queue;
6464
mod native_function;
65-
mod no_move_vec;
6665
mod once_map;
6766
mod output;
6867
pub mod panic_hooks;

turbopack/crates/turbo-tasks/src/macro_helpers.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
//! Runtime helpers for [turbo-tasks-macro].
22
3-
use std::ptr;
4-
53
pub use async_trait::async_trait;
64
pub use once_cell::sync::{Lazy, OnceCell};
75
use rustc_hash::FxHashMap;
@@ -11,7 +9,7 @@ pub use tracing;
119

1210
use crate::{
1311
FxDashMap, NonLocalValue, RawVc, TaskInput, TaskPersistence, TraitTypeId, ValueType,
14-
ValueTypeId, Vc, VcValueTrait, debug::ValueDebugFormatString, task::TaskOutput,
12+
ValueTypeId, Vc, debug::ValueDebugFormatString, task::TaskOutput,
1513
};
1614
pub use crate::{
1715
magic_any::MagicAny,
@@ -148,14 +146,17 @@ pub struct CollectableTraitCastFunctions(
148146
unsafe impl Sync for CollectableTraitCastFunctions {}
149147
inventory::collect! {CollectableTraitCastFunctions}
150148

149+
#[allow(clippy::type_complexity)]
151150
pub struct CollectableTraitMethods(
151+
// A value type name
152152
pub &'static str,
153153
pub fn() -> (TraitTypeId, Vec<(&'static str, &'static NativeFunction)>),
154154
);
155155
inventory::collect! {CollectableTraitMethods}
156156

157157
// Called when initializing ValueTypes by value_impl
158158
pub fn register_trait_methods(value: &mut ValueType) {
159+
#[allow(clippy::type_complexity)]
159160
static TRAIT_METHODS_BY_VALUE: Lazy<
160161
FxDashMap<&'static str, Vec<(TraitTypeId, Vec<(&'static str, &'static NativeFunction)>)>>,
161162
> = Lazy::new(|| {

0 commit comments

Comments
 (0)