From 48b6f43255d428927c90fd3333edda6942b53f63 Mon Sep 17 00:00:00 2001 From: Hana Date: Tue, 17 Dec 2024 16:43:38 +0800 Subject: [PATCH 1/2] style: init --- Cargo.toml | 1 + .../src/build_chunk_graph/code_splitter.rs | 17 +++------- .../src/chunk_graph/chunk_graph_module.rs | 6 ++-- crates/rspack_core/src/concatenated_module.rs | 31 ++++++++----------- crates/rspack_core/src/context_module.rs | 6 ++-- .../rspack_core/src/context_module_factory.rs | 2 +- .../dependency/context_element_dependency.rs | 2 +- .../src/dependency/runtime_template.rs | 2 +- crates/rspack_core/src/external_module.rs | 2 +- .../rspack_core/src/incremental/mutations.rs | 10 +++--- crates/rspack_core/src/init_fragment.rs | 4 +-- crates/rspack_core/src/options/filename.rs | 2 +- crates/rspack_core/src/options/output.rs | 2 +- crates/rspack_core/src/resolver/mod.rs | 4 +-- .../rspack_core/src/resolver/resolver_impl.rs | 2 +- crates/rspack_core/src/self_module.rs | 2 +- crates/rspack_core/src/utils/comment.rs | 2 +- .../src/utils/compile_boolean_matcher.rs | 8 ++--- .../rspack_core/src/utils/file_counter/mod.rs | 2 +- crates/rspack_core/src/utils/identifier.rs | 2 +- crates/rspack_core/src/utils/task_loop.rs | 4 +-- .../src/dll_reference/delegated_module.rs | 4 +-- .../src/dll_reference/delegated_plugin.rs | 6 ++-- .../dll_reference_agency_plugin.rs | 2 +- .../src/lib_manifest_plugin.rs | 4 +-- 25 files changed, 58 insertions(+), 71 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b05b62519b1..23ea4fe86cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -262,6 +262,7 @@ no_effect_underscore_binding = "warn" ref_binding_to_reference = "warn" ref_option_ref = "warn" stable_sort_primitive = "warn" +uninlined_format_args = "warn" unnecessary_box_returns = "warn" unnecessary_join = "warn" unnested_or_patterns = "warn" diff --git a/crates/rspack_core/src/build_chunk_graph/code_splitter.rs b/crates/rspack_core/src/build_chunk_graph/code_splitter.rs index 68b0176bb3a..25c00f9ba14 100644 --- a/crates/rspack_core/src/build_chunk_graph/code_splitter.rs +++ b/crates/rspack_core/src/build_chunk_graph/code_splitter.rs @@ -1208,10 +1208,7 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on } let ordinal = self.ordinal_by_module.get(&module).unwrap_or_else(|| { - panic!( - "expected a module ordinal for identifier '{}', but none was found.", - module - ) + panic!("expected a module ordinal for identifier '{module}', but none was found.") }); if active_state.is_true() && min_available_modules.bit(*ordinal) { // already in parent chunks, skip it for now @@ -1298,7 +1295,7 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on let chunk_ukey = if let Some(chunk_name) = compilation .get_module_graph() .block_by_id(&block_id) - .unwrap_or_else(|| panic!("should have block: {:?}", block_id)) + .unwrap_or_else(|| panic!("should have block: {block_id:?}")) .get_group_options() .and_then(|x| x.name()) { @@ -1696,10 +1693,7 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on .iter() .filter_map(|module| { let ordinal = self.ordinal_by_module.get(module).unwrap_or_else(|| { - panic!( - "expected a module ordinal for identifier '{}', but none was found.", - module - ) + panic!("expected a module ordinal for identifier '{module}', but none was found.") }); if !cgi.min_available_modules.bit(*ordinal) { Some(*module) @@ -1736,10 +1730,7 @@ Or do you want to use the entrypoints '{name}' and '{runtime}' independently on if active_state.is_true() { active_connections.push(i); let module_ordinal = self.ordinal_by_module.get(module).unwrap_or_else(|| { - panic!( - "expected a module ordinal for identifier '{}', but none was found.", - module - ) + panic!("expected a module ordinal for identifier '{module}', but none was found.") }); if cgi.min_available_modules.bit(*module_ordinal) { cgi.skipped_items.insert(*module); diff --git a/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs b/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs index 0521ba4b7d6..5b16f836b8c 100644 --- a/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs +++ b/crates/rspack_core/src/chunk_graph/chunk_graph_module.rs @@ -128,7 +128,7 @@ impl ChunkGraph { self .chunk_graph_module_by_module_identifier .get_mut(&module_identifier) - .unwrap_or_else(|| panic!("Module({}) should be added before using", module_identifier)) + .unwrap_or_else(|| panic!("Module({module_identifier}) should be added before using")) } pub(crate) fn expect_chunk_graph_module( @@ -138,7 +138,7 @@ impl ChunkGraph { self .chunk_graph_module_by_module_identifier .get(&module_identifier) - .unwrap_or_else(|| panic!("Module({}) should be added before using", module_identifier)) + .unwrap_or_else(|| panic!("Module({module_identifier}) should be added before using")) } pub(crate) fn get_chunk_graph_module_mut( @@ -154,7 +154,7 @@ impl ChunkGraph { let chunk_graph_module = self .chunk_graph_module_by_module_identifier .get(&module_identifier) - .unwrap_or_else(|| panic!("Module({}) should be added before using", module_identifier)); + .unwrap_or_else(|| panic!("Module({module_identifier}) should be added before using")); &chunk_graph_module.chunks } diff --git a/crates/rspack_core/src/concatenated_module.rs b/crates/rspack_core/src/concatenated_module.rs index 230264b0c40..4b87057d969 100644 --- a/crates/rspack_core/src/concatenated_module.rs +++ b/crates/rspack_core/src/concatenated_module.rs @@ -754,7 +754,7 @@ impl Module for ConcatenatedModule { let low = span.real_lo(); let high = span.real_hi(); if identifier.shorthand { - source.insert(high, &format!(": {}", new_name), None); + source.insert(high, &format!(": {new_name}"), None); continue; } @@ -1195,11 +1195,7 @@ impl Module for ConcatenatedModule { match info { ModuleInfo::Concatenated(info) => { result.add(RawStringSource::from( - format!( - "\n;// CONCATENATED MODULE: {}\n", - module_readable_identifier - ) - .as_str(), + format!("\n;// CONCATENATED MODULE: {module_readable_identifier}\n").as_str(), )); // https://github.com/webpack/webpack/blob/ac7e531436b0d47cd88451f497cdfd0dad41535d/lib/optimize/ConcatenatedModule.js#L1582 result.add(info.source.clone().expect("should have source")); @@ -1213,8 +1209,7 @@ impl Module for ConcatenatedModule { } ModuleInfo::External(info) => { result.add(RawStringSource::from(format!( - "\n// EXTERNAL MODULE: {}\n", - module_readable_identifier + "\n// EXTERNAL MODULE: {module_readable_identifier}\n" ))); runtime_requirements.insert(RuntimeGlobals::REQUIRE); @@ -1230,7 +1225,7 @@ impl Module for ConcatenatedModule { if condition != "true" { is_conditional = true; - result.add(RawStringSource::from(format!("if ({}) {{\n", condition))); + result.add(RawStringSource::from(format!("if ({condition}) {{\n"))); } result.add(RawStringSource::from(format!( @@ -1704,7 +1699,7 @@ impl ConcatenatedModule { let module_graph = compilation.get_module_graph(); let module = module_graph .module_by_identifier(&module_id) - .unwrap_or_else(|| panic!("should have module {}", module_id)); + .unwrap_or_else(|| panic!("should have module {module_id}")); let codegen_res = module.code_generation(compilation, runtime, Some(concatenation_scope))?; let CodeGenerationResult { mut inner, @@ -1850,7 +1845,7 @@ impl ConcatenatedModule { info .internal_names .iter() - .map(|(name, symbol)| format!("{}: {}", name, symbol)) + .map(|(name, symbol)| format!("{name}: {symbol}")) .collect::>() .join(", ") ) @@ -1867,11 +1862,11 @@ impl ConcatenatedModule { }; if is_property_access && as_call && !call_context { return if asi_safe.unwrap_or_default() { - format!("(0,{})", reference) + format!("(0,{reference})") } else if let Some(_asi_safe) = asi_safe { - format!(";(0,{})", reference) + format!(";(0,{reference})") } else { - format!("/*#__PURE__*/Object({})", reference) + format!("/*#__PURE__*/Object({reference})") }; } reference @@ -1989,13 +1984,13 @@ impl ConcatenatedModule { .cloned() .expect("should have default access name"); let default_export = if as_call { - format!("{}()", default_access_name) + format!("{default_access_name}()") } else if let Some(true) = asi_safe { - format!("({}())", default_access_name) + format!("({default_access_name}())") } else if let Some(false) = asi_safe { - format!(";({}())", default_access_name) + format!(";({default_access_name}())") } else { - format!("{}.a", default_access_name) + format!("{default_access_name}.a") }; return Binding::Raw(RawBinding { diff --git a/crates/rspack_core/src/context_module.rs b/crates/rspack_core/src/context_module.rs index 647d9978320..f9ac2b724c3 100644 --- a/crates/rspack_core/src/context_module.rs +++ b/crates/rspack_core/src/context_module.rs @@ -1113,13 +1113,13 @@ fn create_identifier(options: &ContextModuleOptions) -> Identifier { } id += "|groupOptions: {"; if let Some(o) = group.prefetch_order { - id.push_str(&format!("prefetchOrder: {},", o)); + id.push_str(&format!("prefetchOrder: {o},")); } if let Some(o) = group.preload_order { - id.push_str(&format!("preloadOrder: {},", o)); + id.push_str(&format!("preloadOrder: {o},")); } if let Some(o) = group.fetch_priority { - id.push_str(&format!("fetchPriority: {},", o)); + id.push_str(&format!("fetchPriority: {o},")); } id += "}"; } diff --git a/crates/rspack_core/src/context_module_factory.rs b/crates/rspack_core/src/context_module_factory.rs index d89b8a0d868..d0f4324f6ee 100644 --- a/crates/rspack_core/src/context_module_factory.rs +++ b/crates/rspack_core/src/context_module_factory.rs @@ -521,7 +521,7 @@ fn alternative_requests( items.push(item.clone()); for module in resolve_options.modules() { let dir = module.cow_replace('\\', "/"); - if item.request.starts_with(&format!("./{}/", dir)) { + if item.request.starts_with(&format!("./{dir}/")) { items.push(AlternativeRequest::new( item.context.clone(), item.request[dir.len() + 3..].to_string(), diff --git a/crates/rspack_core/src/dependency/context_element_dependency.rs b/crates/rspack_core/src/dependency/context_element_dependency.rs index fdcc42c3e0e..8f4a141566a 100644 --- a/crates/rspack_core/src/dependency/context_element_dependency.rs +++ b/crates/rspack_core/src/dependency/context_element_dependency.rs @@ -41,7 +41,7 @@ impl ContextElementDependency { path: &Utf8Path, attributes: Option<&ImportAttributes>, ) -> String { - let mut ident = format!("context{}|{}", resource, path); + let mut ident = format!("context{resource}|{path}"); if let Some(attributes) = attributes { ident += &json_stringify(&attributes); } diff --git a/crates/rspack_core/src/dependency/runtime_template.rs b/crates/rspack_core/src/dependency/runtime_template.rs index d0d4e227872..627ea8a563c 100644 --- a/crates/rspack_core/src/dependency/runtime_template.rs +++ b/crates/rspack_core/src/dependency/runtime_template.rs @@ -700,7 +700,7 @@ fn throw_missing_module_error_function(request: &str) -> String { } pub fn throw_missing_module_error_block(request: &str) -> String { - let e = format!("Cannot find module '{}'", request); + let e = format!("Cannot find module '{request}'"); format!( "var e = new Error({}); e.code = 'MODULE_NOT_FOUND'; throw e;", json!(e) diff --git a/crates/rspack_core/src/external_module.rs b/crates/rspack_core/src/external_module.rs index 9babe861505..669e907ecf0 100644 --- a/crates/rspack_core/src/external_module.rs +++ b/crates/rspack_core/src/external_module.rs @@ -375,7 +375,7 @@ impl ExternalModule { ); if let Some(concatenation_scope) = concatenation_scope { - let external_module_id = format!("__WEBPACK_EXTERNAL_MODULE_{}__", id); + let external_module_id = format!("__WEBPACK_EXTERNAL_MODULE_{id}__"); let namespace_export_with_name = format!("{}{}", NAMESPACE_OBJECT_EXPORT, &external_module_id); concatenation_scope.register_namespace_export(&namespace_export_with_name); diff --git a/crates/rspack_core/src/incremental/mutations.rs b/crates/rspack_core/src/incremental/mutations.rs index be50afd1496..3035fc20714 100644 --- a/crates/rspack_core/src/incremental/mutations.rs +++ b/crates/rspack_core/src/incremental/mutations.rs @@ -38,7 +38,7 @@ impl fmt::Display for Mutations { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f, "[")?; for mutation in self.iter() { - writeln!(f, "{},", mutation)?; + writeln!(f, "{mutation},")?; } writeln!(f, "]") } @@ -60,10 +60,10 @@ pub enum Mutation { impl fmt::Display for Mutation { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Mutation::ModuleBuild { module } => write!(f, "build module {}", module), - Mutation::ModuleRemove { module } => write!(f, "remove module {}", module), - Mutation::ModuleSetAsync { module } => write!(f, "set async module {}", module), - Mutation::ModuleSetId { module } => write!(f, "set id module {}", module), + Mutation::ModuleBuild { module } => write!(f, "build module {module}"), + Mutation::ModuleRemove { module } => write!(f, "remove module {module}"), + Mutation::ModuleSetAsync { module } => write!(f, "set async module {module}"), + Mutation::ModuleSetId { module } => write!(f, "set id module {module}"), Mutation::ChunkSetId { chunk } => write!(f, "set id chunk {}", chunk.as_u32()), Mutation::ChunkAdd { chunk } => write!(f, "add chunk {}", chunk.as_u32()), Mutation::ChunkSplit { from, to } => { diff --git a/crates/rspack_core/src/init_fragment.rs b/crates/rspack_core/src/init_fragment.rs index ac2b0941581..efe6b3dfdc6 100644 --- a/crates/rspack_core/src/init_fragment.rs +++ b/crates/rspack_core/src/init_fragment.rs @@ -140,7 +140,7 @@ impl InitFragmentKey { | InitFragmentKey::CommonJsExports(_) | InitFragmentKey::Const(_) => first(fragments), InitFragmentKey::ESMCompatibility | InitFragmentKey::Unique(_) => { - debug_assert!(fragments.len() == 1, "fragment = {:?}", self); + debug_assert!(fragments.len() == 1, "fragment = {self:?}"); first(fragments) } } @@ -657,7 +657,7 @@ impl InitFragment for ExternalModuleInitFragmen if imports_string.is_empty() { String::new() } else { - format!(", {}", imports_string) + format!(", {imports_string}") } ); } diff --git a/crates/rspack_core/src/options/filename.rs b/crates/rspack_core/src/options/filename.rs index 1e8dee66161..ca2a4675f84 100644 --- a/crates/rspack_core/src/options/filename.rs +++ b/crates/rspack_core/src/options/filename.rs @@ -248,7 +248,7 @@ fn render_template( replace_all_placeholder( t, EXT_PLACEHOLDER, - &ext.map(|ext| format!(".{}", ext)).unwrap_or_default(), + &ext.map(|ext| format!(".{ext}")).unwrap_or_default(), ) }); } else if let Some(ResourceParsedData { diff --git a/crates/rspack_core/src/options/output.rs b/crates/rspack_core/src/options/output.rs index d4dec95b4b7..af09ac99aef 100644 --- a/crates/rspack_core/src/options/output.rs +++ b/crates/rspack_core/src/options/output.rs @@ -201,7 +201,7 @@ impl std::fmt::Display for CrossOriginLoading { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { CrossOriginLoading::Disable => write!(f, "false"), - CrossOriginLoading::Enable(value) => write!(f, "\"{}\"", value), + CrossOriginLoading::Enable(value) => write!(f, "\"{value}\""), } } } diff --git a/crates/rspack_core/src/resolver/mod.rs b/crates/rspack_core/src/resolver/mod.rs index 20afe2c546b..cbea1e10856 100644 --- a/crates/rspack_core/src/resolver/mod.rs +++ b/crates/rspack_core/src/resolver/mod.rs @@ -138,7 +138,7 @@ pub fn resolve_for_error_hints( { // If the specifier is a relative path pointing to the current directory, // we can suggest the path relative to the current directory. - format!("{}{}", prefix, relative_path) + format!("{prefix}{relative_path}") } else if PARENT_PATH_REGEX.is_match(args.specifier) { // If the specifier is a relative path to which the parent directory is, // then we return the relative path directly. @@ -244,7 +244,7 @@ which tries to resolve these kind of requests in the current directory too.", let mut suggestion = file.path().relative(&args.context).assert_utf8(); if !suggestion.as_str().starts_with('.') { - suggestion = Utf8PathBuf::from(format!("./{}", suggestion)); + suggestion = Utf8PathBuf::from(format!("./{suggestion}")); } Some(suggestion) } else { diff --git a/crates/rspack_core/src/resolver/resolver_impl.rs b/crates/rspack_core/src/resolver/resolver_impl.rs index cf77ec82990..194167b3635 100644 --- a/crates/rspack_core/src/resolver/resolver_impl.rs +++ b/crates/rspack_core/src/resolver/resolver_impl.rs @@ -39,7 +39,7 @@ impl fmt::Debug for ResolveInnerOptions<'_> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Self::RspackResolver(options) => { - write!(f, "{:?}", options) + write!(f, "{options:?}") } } } diff --git a/crates/rspack_core/src/self_module.rs b/crates/rspack_core/src/self_module.rs index 46abd7cd07c..acf8f266c0e 100644 --- a/crates/rspack_core/src/self_module.rs +++ b/crates/rspack_core/src/self_module.rs @@ -30,7 +30,7 @@ pub struct SelfModule { impl SelfModule { pub fn new(module_identifier: ModuleIdentifier) -> Self { - let identifier = format!("self {}", module_identifier); + let identifier = format!("self {module_identifier}"); Self { identifier: ModuleIdentifier::from(identifier.as_str()), readable_identifier: identifier, diff --git a/crates/rspack_core/src/utils/comment.rs b/crates/rspack_core/src/utils/comment.rs index a0d5e5428b0..f7258fa90f5 100644 --- a/crates/rspack_core/src/utils/comment.rs +++ b/crates/rspack_core/src/utils/comment.rs @@ -13,5 +13,5 @@ pub fn to_comment(str: &str) -> String { let result = COMMENT_END_REGEX.replace_all(str, "* /"); - format!("/*! {} */", result) + format!("/*! {result} */") } diff --git a/crates/rspack_core/src/utils/compile_boolean_matcher.rs b/crates/rspack_core/src/utils/compile_boolean_matcher.rs index e2630b37051..47274d39a9e 100644 --- a/crates/rspack_core/src/utils/compile_boolean_matcher.rs +++ b/crates/rspack_core/src/utils/compile_boolean_matcher.rs @@ -36,21 +36,21 @@ pub fn compile_boolean_matcher_from_lists( BooleanMatcher::Matcher(Box::new(|_| "true".to_string())) } else if positive_items.len() == 1 { let item = to_simple_string(&positive_items[0]); - BooleanMatcher::Matcher(Box::new(move |value| format!("{} == {}", item, value))) + BooleanMatcher::Matcher(Box::new(move |value| format!("{item} == {value}"))) } else if negative_items.len() == 1 { let item = to_simple_string(&negative_items[0]); - BooleanMatcher::Matcher(Box::new(move |value| format!("{} != {}", item, value))) + BooleanMatcher::Matcher(Box::new(move |value| format!("{item} != {value}"))) } else { let positive_regexp = items_to_regexp(positive_items); let negative_regexp = items_to_regexp(negative_items); if positive_regexp.len() <= negative_regexp.len() { BooleanMatcher::Matcher(Box::new(move |value| { - format!("/^{}$/.test({})", positive_regexp, value) + format!("/^{positive_regexp}$/.test({value})") })) } else { BooleanMatcher::Matcher(Box::new(move |value| { - format!("!/^{}$/.test({})", negative_regexp, value) + format!("!/^{negative_regexp}$/.test({value})") })) } } diff --git a/crates/rspack_core/src/utils/file_counter/mod.rs b/crates/rspack_core/src/utils/file_counter/mod.rs index a0955f152a8..83690b47cee 100644 --- a/crates/rspack_core/src/utils/file_counter/mod.rs +++ b/crates/rspack_core/src/utils/file_counter/mod.rs @@ -53,7 +53,7 @@ impl FileCounter { self.inner.remove(path); } } else { - panic!("can not remove file {:?}", path); + panic!("can not remove file {path:?}"); } } diff --git a/crates/rspack_core/src/utils/identifier.rs b/crates/rspack_core/src/utils/identifier.rs index baf3fc70755..a01148ea790 100644 --- a/crates/rspack_core/src/utils/identifier.rs +++ b/crates/rspack_core/src/utils/identifier.rs @@ -43,7 +43,7 @@ pub fn stringify_loaders_and_resource<'a>( .map(|i| &*i.loader) .collect::>() .join("!"); - Cow::Owned(format!("{s}!{}", resource)) + Cow::Owned(format!("{s}!{resource}")) } else { Cow::Borrowed(resource) } diff --git a/crates/rspack_core/src/utils/task_loop.rs b/crates/rspack_core/src/utils/task_loop.rs index 8b9e9d04f86..8f8a1c901e6 100644 --- a/crates/rspack_core/src/utils/task_loop.rs +++ b/crates/rspack_core/src/utils/task_loop.rs @@ -220,7 +220,7 @@ mod test { ) .await; assert!( - format!("{:?}", res).contains("throw sync error"), + format!("{res:?}").contains("throw sync error"), "should return sync error" ); assert_eq!(context.call_sync_task_count, 0); @@ -239,7 +239,7 @@ mod test { ) .await; assert!( - format!("{:?}", res).contains("throw async error"), + format!("{res:?}").contains("throw async error"), "should return async error" ); assert_eq!(context.call_sync_task_count, 1); diff --git a/crates/rspack_plugin_dll/src/dll_reference/delegated_module.rs b/crates/rspack_plugin_dll/src/dll_reference/delegated_module.rs index 8f7786d204a..ef3149958f7 100644 --- a/crates/rspack_plugin_dll/src/dll_reference/delegated_module.rs +++ b/crates/rspack_plugin_dll/src/dll_reference/delegated_module.rs @@ -160,10 +160,10 @@ impl Module for DelegatedModule { match self.delegation_type.as_ref() { "require" => { - s += &format!("({})", request); + s += &format!("({request})"); } "object" => { - s += &format!("[{}]", request); + s += &format!("[{request}]"); } _ => panic!("delegation_type should be 'require' or 'object'"), } diff --git a/crates/rspack_plugin_dll/src/dll_reference/delegated_plugin.rs b/crates/rspack_plugin_dll/src/dll_reference/delegated_plugin.rs index 05760e35400..444dd18bbcd 100644 --- a/crates/rspack_plugin_dll/src/dll_reference/delegated_plugin.rs +++ b/crates/rspack_plugin_dll/src/dll_reference/delegated_plugin.rs @@ -83,7 +83,7 @@ async fn compilation( async fn factorize(&self, data: &mut ModuleFactoryCreateData) -> Result> { if let Some(scope) = &self.options.scope { if let Some(dependency) = data.dependencies[0].as_module_dependency() { - let scope_prefix = format!("{}/", scope); + let scope_prefix = format!("{scope}/"); let request = dependency.request(); if request.starts_with(&scope_prefix) { let inner_request = format!( @@ -102,7 +102,7 @@ async fn factorize(&self, data: &mut ModuleFactoryCreateData) -> Result Result Result<()> { let format = self.options.format.unwrap_or_default(); let manifest_json = if format { - serde_json::to_string_pretty(&manifest).map_err(|e| Error::msg(format!("{}", e)))? + serde_json::to_string_pretty(&manifest).map_err(|e| Error::msg(format!("{e}")))? } else { - serde_json::to_string(&manifest).map_err(|e| Error::msg(format!("{}", e)))? + serde_json::to_string(&manifest).map_err(|e| Error::msg(format!("{e}")))? }; let asset = Arc::new(RawStringSource::from(manifest_json)) as BoxSource; From 343bc34d598177ce84cf29beded84390a7d50457 Mon Sep 17 00:00:00 2001 From: LingyuCoder Date: Thu, 26 Dec 2024 10:45:48 +0800 Subject: [PATCH 2/2] style: module graph --- crates/rspack_core/src/module_graph/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rspack_core/src/module_graph/mod.rs b/crates/rspack_core/src/module_graph/mod.rs index d3f5cb912e7..1fb2e6d4d5f 100644 --- a/crates/rspack_core/src/module_graph/mod.rs +++ b/crates/rspack_core/src/module_graph/mod.rs @@ -945,7 +945,7 @@ impl<'a> ModuleGraph<'a> { pub fn do_update_module(&mut self, dep_id: &DependencyId, module_id: &ModuleIdentifier) { let connection = self .connection_by_dependency_id_mut(dep_id) - .unwrap_or_else(|| panic!("{:?}", dep_id)); + .unwrap_or_else(|| panic!("{dep_id:?}")); let old_module_identifier = *connection.module_identifier(); connection.set_module_identifier(*module_id);