diff --git a/.cargo/config.toml b/.cargo/config.toml index 87dbf1c0db..aa2105fa7b 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,3 +9,9 @@ rustflags = [ "-C", "link-args=-z stack-size=2097152", ] + +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "link-arg=/STACK:2097152"] + +[target.x86_64-pc-windows-gnu] +rustflags = ["-C", "link-arg=-Wl,--stack,2097152"] diff --git a/app/gui/config/build.rs b/app/gui/config/build.rs index 6b2a6a3b8a..06d2b8fbd2 100644 --- a/app/gui/config/build.rs +++ b/app/gui/config/build.rs @@ -1,7 +1,7 @@ const CONFIG_PATH: &str = "../config.yaml"; fn main() { - println!("cargo:rerun-if-changed={}", CONFIG_PATH); + println!("cargo:rerun-if-changed={CONFIG_PATH}"); println!("cargo:rerun-if-changed=build.rs"); config_reader::generate_config_module_from_yaml(CONFIG_PATH); diff --git a/app/gui/config/src/lib.rs b/app/gui/config/src/lib.rs index f7138b3632..a2a10cd94a 100644 --- a/app/gui/config/src/lib.rs +++ b/app/gui/config/src/lib.rs @@ -28,7 +28,7 @@ include!(concat!(env!("OUT_DIR"), "/config.rs")); pub use generated::*; pub fn engine_version_requirement() -> semver::VersionReq { - semver::VersionReq::parse(&format!("^{}", engine_version_supported)).unwrap() + semver::VersionReq::parse(&format!("^{engine_version_supported}")).unwrap() } diff --git a/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs b/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs index 8d7f1965f2..8d90816ae5 100644 --- a/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs +++ b/app/gui/controller/double-representation/src/alias_analysis/test_utils.rs @@ -35,7 +35,7 @@ impl Case { pub fn from_markdown(marked_code: impl Str) -> Case { // Regexp that matches either «sth» or »sth« into a group named `introduced` or `used`, // respectively. See: https://regex101.com/r/pboF8O/2 for detailed explanation. - let regex = format!(r"«(?P<{}>[^»]*)»|»(?P<{}>[^«]*)«", INTRODUCED, USED); + let regex = format!(r"«(?P<{INTRODUCED}>[^»]*)»|»(?P<{USED}>[^«]*)«"); // As this is test utils, we don't try nicely handling failure nor reusing the compiled // regexp between calls to save some cycles. let regex = Regex::new(®ex).unwrap(); @@ -87,7 +87,7 @@ impl Replacer for MarkdownReplacer { } else if let Some(used) = captures.name(USED) { (Kind::Used, used) } else { - panic!("Unexpected capture: expected named capture `{}` or `{}`.", INTRODUCED, USED) + panic!("Unexpected capture: expected named capture `{INTRODUCED}` or `{USED}`.") }; let span = self.processor.process_match(captures, &matched, dst); diff --git a/app/gui/controller/double-representation/src/connection.rs b/app/gui/controller/double-representation/src/connection.rs index 0bcec48aed..ff4de4ccca 100644 --- a/app/gui/controller/double-representation/src/connection.rs +++ b/app/gui/controller/double-representation/src/connection.rs @@ -190,7 +190,7 @@ mod tests { fn from_block(code: impl Str) -> TestRun { let body = code.as_ref().lines().map(|line| format!(" {}", line.trim())).join("\n"); - let definition_code = format!("main =\n{}", body); + let definition_code = format!("main =\n{body}"); Self::from_main_def(definition_code) } diff --git a/app/gui/controller/double-representation/src/definition.rs b/app/gui/controller/double-representation/src/definition.rs index 025d5dd73a..f5218e56ef 100644 --- a/app/gui/controller/double-representation/src/definition.rs +++ b/app/gui/controller/double-representation/src/definition.rs @@ -63,10 +63,10 @@ impl Display for Id { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut iter = self.crumbs.iter(); if let Some(crumb) = iter.next() { - write!(f, "{}", crumb)? + write!(f, "{crumb}")? } for crumb in iter { - write!(f, "⮚{}", crumb)? + write!(f, "⮚{crumb}")? } Ok(()) } @@ -218,7 +218,7 @@ impl DefinitionName { impl Display for DefinitionName { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let text = self.name_segments().join(ast::opr::predefined::ACCESS); - write!(f, "{}", text) + write!(f, "{text}") } } @@ -788,7 +788,7 @@ mod tests { let (crumb,) = location.crumbs.expect_tuple(); match crumb { ast::crumbs::Crumb::Module(m) => assert_eq!(m.line_index, expected_line_index), - _ => panic!("Expected module crumb, got: {:?}.", crumb), + _ => panic!("Expected module crumb, got: {crumb:?}."), } } } diff --git a/app/gui/controller/double-representation/src/import.rs b/app/gui/controller/double-representation/src/import.rs index 98a73cbe55..85b15c338c 100644 --- a/app/gui/controller/double-representation/src/import.rs +++ b/app/gui/controller/double-representation/src/import.rs @@ -183,24 +183,20 @@ impl Display for Info { let from_kw = ast::macros::UNQUALIFIED_IMPORT_KEYWORD; match &self.imported { ImportedNames::Module { alias } => { - write!(f, "{} {}", import_kw, module)?; + write!(f, "{import_kw} {module}")?; if let Some(alias) = alias { - write!(f, " {} {}", ALIAS_KEYWORD, alias)?; + write!(f, " {ALIAS_KEYWORD} {alias}")?; } Ok(()) } - ImportedNames::All => write!(f, "{} {} {} {}", from_kw, module, import_kw, ALL_KEYWORD), + ImportedNames::All => write!(f, "{from_kw} {module} {import_kw} {ALL_KEYWORD}"), ImportedNames::List { names } => { let names = names.iter().join(", "); - write!(f, "{} {} {} {}", from_kw, module, import_kw, names) + write!(f, "{from_kw} {module} {import_kw} {names}") } ImportedNames::AllExcept { not_imported: hidden_names } => { let names = hidden_names.iter().join(", "); - write!( - f, - "{} {} {} {} {} {}", - from_kw, module, import_kw, ALL_KEYWORD, HIDING_KEYWORD, names - ) + write!(f, "{from_kw} {module} {import_kw} {ALL_KEYWORD} {HIDING_KEYWORD} {names}") } } } diff --git a/app/gui/controller/double-representation/src/text.rs b/app/gui/controller/double-representation/src/text.rs index 6edc193d7e..41b36ef27d 100644 --- a/app/gui/controller/double-representation/src/text.rs +++ b/app/gui/controller/double-representation/src/text.rs @@ -229,7 +229,7 @@ mod test { let change = enso_text::Change { range, text: inserted_code.to_string() }; Case { code, change } } - _ => panic!("Invalid markdown in the marked code: {}.", marked_code), + _ => panic!("Invalid markdown in the marked code: {marked_code}."), } } @@ -259,7 +259,7 @@ mod test { let ids2 = main_nodes(ast2); debug!("IDs1: {ids1:?}"); debug!("IDs2: {ids2:?}"); - assert_eq!(ids1, ids2, "Node ids mismatch in {:?}", self); + assert_eq!(ids1, ids2, "Node ids mismatch in {self:?}"); } } diff --git a/app/gui/controller/engine-protocol/build.rs b/app/gui/controller/engine-protocol/build.rs index b0aecde7f8..c1d5d5872b 100644 --- a/app/gui/controller/engine-protocol/build.rs +++ b/app/gui/controller/engine-protocol/build.rs @@ -30,9 +30,8 @@ const ENABLE_ENV_VAR_NAME: &str = "ENSO_IDE_ENABLE_FLATC"; /// An URL pointing to engine interface files. pub fn interface_description_url() -> reqwest::Url { - let url = - format!("https://packages.luna-lang.org/fbs-schema/nightly/{}/fbs-schema.zip", COMMIT); - let err = format!("{} is an invalid URL.", url); + let url = format!("https://packages.luna-lang.org/fbs-schema/nightly/{COMMIT}/fbs-schema.zip"); + let err = format!("{url} is an invalid URL."); reqwest::Url::parse(&url).expect(&err) } @@ -68,10 +67,10 @@ impl ApiProvider { pub fn unzip(&self, artifacts: bytes::Bytes) { let zip_path = self.out_dir.join(ZIP_NAME); let display_path = zip_path.display(); - let open_error = format!("Failed to open {}", display_path); - let write_error = format!("Failed to write {}", display_path); - let flush_error = format!("Failed to flush {}", display_path); - let unzip_error = format!("Failed to unzip {}", display_path); + let open_error = format!("Failed to open {display_path}"); + let write_error = format!("Failed to write {display_path}"); + let flush_error = format!("Failed to flush {display_path}"); + let unzip_error = format!("Failed to unzip {display_path}"); let mut file = File::create(&zip_path).expect(&open_error); file.write_all(&artifacts).expect(&write_error); @@ -136,12 +135,12 @@ async fn main() -> std::result::Result<(), Box> { provider.run().await; } else { println!( - "cargo:info=Will not try updating flatc-generated files. Define `{}` environment \ - variable to enable regeneration of the Engine API flatc bindings.", - ENABLE_ENV_VAR_NAME + "cargo:info=Will not try updating flatc-generated files. Define \ + `{ENABLE_ENV_VAR_NAME}` environment variable to enable regeneration of the Engine API \ + flatc bindings.", ); } println!("cargo:rerun-if-changed=build.rs"); - println!("cargo:rerun-if-env-changed={}", ENABLE_ENV_VAR_NAME); + println!("cargo:rerun-if-env-changed={ENABLE_ENV_VAR_NAME}"); Ok(()) } diff --git a/app/gui/controller/engine-protocol/src/binary/client.rs b/app/gui/controller/engine-protocol/src/binary/client.rs index af24275772..5e4db3ea1c 100644 --- a/app/gui/controller/engine-protocol/src/binary/client.rs +++ b/app/gui/controller/engine-protocol/src/binary/client.rs @@ -390,7 +390,7 @@ mod tests { let (event, tail) = event_fut.expect_ready(); match event.expect("Expected some notification.") { Event::Notification(notification) => assert_eq!(notification, expected_notification), - event => panic!("Expected notification event, got: {:?}", event), + event => panic!("Expected notification event, got: {event:?}"), } tail.boxed_local().expect_pending(); } diff --git a/app/gui/controller/engine-protocol/src/handler.rs b/app/gui/controller/engine-protocol/src/handler.rs index 9f342c21ef..ae0cef4d67 100644 --- a/app/gui/controller/engine-protocol/src/handler.rs +++ b/app/gui/controller/engine-protocol/src/handler.rs @@ -287,7 +287,7 @@ mod tests { #[test] fn test_closed_socked_event_passing() { let mut transport = MockTransport::new(); - let processor = |msg| panic!("Must never be called in this test, but got {:?}!", msg); + let processor = |msg| panic!("Must never be called in this test, but got {msg:?}!"); let handler = Handler::::new(transport.clone_ref(), processor); let mut runner = handler.runner().boxed_local(); let mut events = handler.event_stream().boxed_local(); @@ -299,7 +299,7 @@ mod tests { runner.expect_pending(); let event = events.expect_next(); - assert!(matches!(event, Event::Closed), "Event was: {:?}", event); + assert!(matches!(event, Event::Closed), "Event was: {event:?}"); events.expect_pending(); } } diff --git a/app/gui/enso-profiler-enso-data/src/beanpole.rs b/app/gui/enso-profiler-enso-data/src/beanpole.rs index b236edff1c..86d3fa18f5 100644 --- a/app/gui/enso-profiler-enso-data/src/beanpole.rs +++ b/app/gui/enso-profiler-enso-data/src/beanpole.rs @@ -189,12 +189,12 @@ pub mod svg { )?; let y_pos = HEADER_HEIGHT + GRID_INTERVAL_MS * i as f64; let x_len = POLE_SPACING * dia.processes.len() as f64; - let path = format!("M0,{} l{},0", y_pos, x_len); - writeln!(f, "", GRID_COLOR_RGB, path)?; + let path = format!("M0,{y_pos} l{x_len},0"); + writeln!(f, "")?; } for i in 1..dia.processes.len() { let path = format!("M{},{} l0,{}", POLE_SPACING * i as f64, HEADER_HEIGHT, height); - writeln!(f, "", path)?; + writeln!(f, "")?; } let simple_only = "Drawing messages between non-adjacent processes is not implemented."; let mut pairs = std::collections::HashMap::new(); diff --git a/app/gui/enso-profiler-enso-data/src/lib.rs b/app/gui/enso-profiler-enso-data/src/lib.rs index b708db08c3..84f35233ac 100644 --- a/app/gui/enso-profiler-enso-data/src/lib.rs +++ b/app/gui/enso-profiler-enso-data/src/lib.rs @@ -53,7 +53,7 @@ impl Display for Metadata { Metadata::RpcEvent(name) => f.collect_str(name), Metadata::RpcRequest(method) => f.collect_str(&method.to_string()), Metadata::BackendMessage(backend::Message { endpoint, .. }) => f.collect_str(endpoint), - Metadata::RenderStats(stats) => f.collect_str(&format!("{:#?}", stats)), + Metadata::RenderStats(stats) => f.collect_str(&format!("{stats:#?}")), } } } diff --git a/app/gui/language/ast/impl/src/lib.rs b/app/gui/language/ast/impl/src/lib.rs index e60f478e4d..b3109f6f60 100644 --- a/app/gui/language/ast/impl/src/lib.rs +++ b/app/gui/language/ast/impl/src/lib.rs @@ -407,7 +407,7 @@ impl<'de> Visitor<'de> for AstDeserializationVisitor { fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { use ast_schema::*; - write!(formatter, "an object with `{}` and `{}` fields", SHAPE, LENGTH) + write!(formatter, "an object with `{SHAPE}` and `{LENGTH}` fields") } fn visit_map(self, mut map: A) -> Result @@ -1763,7 +1763,7 @@ mod tests { let v = Ast::var(name.clone()); match v.shape() { Shape::Var(var) if *var.name == name => (), - _ => panic!("expected Var with name `{}`", name), + _ => panic!("expected Var with name `{name}`"), } } diff --git a/app/gui/language/ast/impl/src/test_utils.rs b/app/gui/language/ast/impl/src/test_utils.rs index 077c5073ae..6228450f4f 100644 --- a/app/gui/language/ast/impl/src/test_utils.rs +++ b/app/gui/language/ast/impl/src/test_utils.rs @@ -16,7 +16,7 @@ where &'t Shape: TryInto<&'t T> { Ok(shape) => shape, _ => { let expected_typename = std::any::type_name::(); - panic!("failed converting shape into {}, got {:?}", expected_typename, ast) + panic!("failed converting shape into {expected_typename}, got {ast:?}") } } } @@ -46,8 +46,8 @@ pub fn assert_unique_ids(ast: &Ast) { if let Some(id) = node.id { if let Some(id2) = ids.insert(id, node) { panic!( - "Collision for id {} between `{}` and `{}`.\n\nWhole program is:\n{}", - id, id2, node, ast + "Collision for id {id} between `{id2}` and `{node}`.\ + \n\nWhole program is:\n{ast}" ) } } diff --git a/app/gui/language/parser/build.rs b/app/gui/language/parser/build.rs index c8aa3c1f12..925f2b248f 100644 --- a/app/gui/language/parser/build.rs +++ b/app/gui/language/parser/build.rs @@ -30,7 +30,7 @@ pub fn parser_url(version: &ParserVersion) -> reqwest::Url { "https://packages.luna-lang.org/parser-js/nightly/{}/scala-parser.js", version.commit ); - let invalid_url_msg = format!("{} is an invalid URL.", url_string); + let invalid_url_msg = format!("{url_string} is an invalid URL."); reqwest::Url::parse(&url_string).expect(&invalid_url_msg) } @@ -129,7 +129,7 @@ async fn main() -> Result { provider.run().await?; } println!("cargo:rerun-if-changed=build.rs"); - println!("cargo:rerun-if-changed={}", PARSER_PATH); + println!("cargo:rerun-if-changed={PARSER_PATH}"); Ok(()) } diff --git a/app/gui/language/parser/src/api.rs b/app/gui/language/parser/src/api.rs index 4adcefcf81..e6bd45116c 100644 --- a/app/gui/language/parser/src/api.rs +++ b/app/gui/language/parser/src/api.rs @@ -208,7 +208,7 @@ impl TryFrom<&ParsedSourceFile> for String { impl Display for ParsedSourceFile { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.serialize() { - Ok(serialized) => write!(f, "{}", serialized), + Ok(serialized) => write!(f, "{serialized}"), Err(_) => write!(f, "[NOT REPRESENTABLE SOURCE FILE]"), } } diff --git a/app/gui/language/parser/src/lib.rs b/app/gui/language/parser/src/lib.rs index b091abef8c..09b12291a4 100644 --- a/app/gui/language/parser/src/lib.rs +++ b/app/gui/language/parser/src/lib.rs @@ -92,7 +92,7 @@ impl Parser { /// Obtains a default parser implementation, panicking in case of failure. pub fn new_or_panic() -> Parser { - Parser::new().unwrap_or_else(|e| panic!("Failed to create a parser: {:?}", e)) + Parser::new().unwrap_or_else(|e| panic!("Failed to create a parser: {e:?}")) } /// Parse program. @@ -208,7 +208,7 @@ impl DocParser { /// Obtains a default doc parser implementation, panicking in case of failure. pub fn new_or_panic() -> DocParser { - DocParser::new().unwrap_or_else(|e| panic!("Failed to create doc parser: {:?}", e)) + DocParser::new().unwrap_or_else(|e| panic!("Failed to create doc parser: {e:?}")) } /// Parses program with documentation and generates HTML code. diff --git a/app/gui/language/parser/src/test_utils.rs b/app/gui/language/parser/src/test_utils.rs index 7fc2eaaf1a..126f7a4759 100644 --- a/app/gui/language/parser/src/test_utils.rs +++ b/app/gui/language/parser/src/test_utils.rs @@ -44,7 +44,7 @@ impl ParserTestExts for Parser { let ast = self.parse(program.clone(), default()).unwrap(); assert_eq!(ast.shape().len(), program.len().bytes()); validate_spans(&ast); - assert_eq!(ast.repr(), program, "{:?}", ast); + assert_eq!(ast.repr(), program, "{ast:?}"); ast } } diff --git a/app/gui/language/parser/tests/ast.rs b/app/gui/language/parser/tests/ast.rs index 0e7731d6c3..e839cac4e4 100644 --- a/app/gui/language/parser/tests/ast.rs +++ b/app/gui/language/parser/tests/ast.rs @@ -36,10 +36,10 @@ pub fn to_assignment_test() { let expected_not_assignments = vec!["= 5", "a=", "=", "foo", "a->b", "a+b"]; for code in expected_assignments { - assert!(is_assignment(code), "{} expected to be recognized as assignment", code); + assert!(is_assignment(code), "{code} expected to be recognized as assignment"); } for code in expected_not_assignments { - assert!(!is_assignment(code), "{} expected to not be recognized as assignment", code); + assert!(!is_assignment(code), "{code} expected to not be recognized as assignment"); } } diff --git a/app/gui/language/parser/tests/bugs.rs b/app/gui/language/parser/tests/bugs.rs index bb9abb73a9..6ce28fd6b9 100644 --- a/app/gui/language/parser/tests/bugs.rs +++ b/app/gui/language/parser/tests/bugs.rs @@ -19,7 +19,7 @@ fn no_doc_found() { let parser = parser_scala::DocParser::new_or_panic(); let gen_code = parser.generate_html_docs(program).unwrap(); // gen_code should be empty. - assert_eq!(gen_code.len(), 22, "Generated length differs from the expected\"{}\"", gen_code); + assert_eq!(gen_code.len(), 22, "Generated length differs from the expected\"{gen_code}\""); } #[wasm_bindgen_test] diff --git a/app/gui/language/parser/tests/macros.rs b/app/gui/language/parser/tests/macros.rs index 91dcc8b381..afc9ae7129 100644 --- a/app/gui/language/parser/tests/macros.rs +++ b/app/gui/language/parser/tests/macros.rs @@ -21,7 +21,7 @@ fn import_utilities() { let parser = Parser::new_or_panic(); let expect_import = |code: &str| { let ast = parser.parse_line_ast(code).unwrap(); - assert!(is_ast_import(&ast), "Not Ast import: {:?}", ast); + assert!(is_ast_import(&ast), "Not Ast import: {ast:?}"); let ast_match = ast_as_import_match(&ast).unwrap(); assert_eq!(&ast, ast_match.ast()); assert!(is_match_import(&ast_match)); diff --git a/app/gui/language/parser/tests/parsing.rs b/app/gui/language/parser/tests/parsing.rs index 6c935b902a..3c2e79169d 100644 --- a/app/gui/language/parser/tests/parsing.rs +++ b/app/gui/language/parser/tests/parsing.rs @@ -43,7 +43,7 @@ fn assert_opr>(ast: &Ast, name: StringLike) { fn roundtrip_program_with(parser: &parser_scala::Parser, program: &str) { let ast = parser.parse(program.to_string(), Default::default()).unwrap(); - assert_eq!(ast.repr(), program, "{:#?}", ast); + assert_eq!(ast.repr(), program, "{ast:#?}"); } fn roundtrip_program(program: &str) { @@ -414,9 +414,9 @@ impl Fixture { ]; for macro_usage in macro_usages.iter() { - println!(">>>>>>>>>> {}", macro_usage); + println!(">>>>>>>>>> {macro_usage}"); let ast = self.parser.parse_line_ast(*macro_usage).unwrap(); - println!("{:?}", ast); + println!("{ast:?}"); expect_shape::>(&ast); } } diff --git a/app/gui/language/span-tree/src/action.rs b/app/gui/language/span-tree/src/action.rs index 0f9f812f81..6746fde159 100644 --- a/app/gui/language/span-tree/src/action.rs +++ b/app/gui/language/span-tree/src/action.rs @@ -268,8 +268,8 @@ mod test { } .unwrap(); let result_repr = result.repr(); - assert_eq!(result_repr, self.expected, "Wrong answer for case {:?}", self); - assert_eq!(ast_id, result.id, "Changed AST id in case {:?}", self); + assert_eq!(result_repr, self.expected, "Wrong answer for case {self:?}"); + assert_eq!(ast_id, result.id, "Changed AST id in case {self:?}"); } } @@ -351,9 +351,7 @@ mod test { assert_eq!( node.is_action_available(*action), expected.contains(action), - "Availability mismatch for action {:?} in case {:?}", - action, - self + "Availability mismatch for action {action:?} in case {self:?}" ) } } diff --git a/app/gui/language/span-tree/src/generate.rs b/app/gui/language/span-tree/src/generate.rs index 37b9d52a87..a1841b24be 100644 --- a/app/gui/language/span-tree/src/generate.rs +++ b/app/gui/language/span-tree/src/generate.rs @@ -672,7 +672,7 @@ mod test { for id_map_entry in id_map.vec { let (span, id) = id_map_entry; let node = tree.root_ref().find_by_span(&span); - assert!(node.is_some(), "Node with span {} not found", span); + assert!(node.is_some(), "Node with span {span} not found"); assert_eq!(node.unwrap().node.ast_id, Some(id)); } diff --git a/app/gui/src/controller/graph.rs b/app/gui/src/controller/graph.rs index 1fc398065b..04b4847f33 100644 --- a/app/gui/src/controller/graph.rs +++ b/app/gui/src/controller/graph.rs @@ -1567,7 +1567,7 @@ main = let connection = Connection { source, destination }; graph.connect(&connection, &span_tree::generate::context::Empty).unwrap(); let new_main = graph.definition().unwrap().ast.repr(); - assert_eq!(new_main, expected, "Case {:?}", this); + assert_eq!(new_main, expected, "Case {this:?}"); }) } } @@ -1741,7 +1741,7 @@ main = let connection = connections.connections.first().unwrap(); graph.disconnect(connection, &span_tree::generate::context::Empty).unwrap(); let new_main = graph.definition().unwrap().ast.repr(); - assert_eq!(new_main, expected, "Case {:?}", this); + assert_eq!(new_main, expected, "Case {this:?}"); }) } } diff --git a/app/gui/src/controller/project.rs b/app/gui/src/controller/project.rs index 9ba41cdf2c..c3cd7dc628 100644 --- a/app/gui/src/controller/project.rs +++ b/app/gui/src/controller/project.rs @@ -30,7 +30,7 @@ pub const MAIN_DEFINITION_NAME: &str = "main"; /// The code with definition of the default `main` method. pub fn default_main_method_code() -> String { - format!(r#"{} = "Hello, World!""#, MAIN_DEFINITION_NAME) + format!(r#"{MAIN_DEFINITION_NAME} = "Hello, World!""#) } /// The default content of the newly created initial main module file. @@ -57,10 +57,10 @@ pub fn main_method_ptr( pub fn package_yaml_path(project_name: &str) -> String { match platform::current() { Some(Platform::Linux) | Some(Platform::MacOS) => - format!("~/enso/projects/{}/package.yaml", project_name), + format!("~/enso/projects/{project_name}/package.yaml"), Some(Platform::Windows) => - format!("%userprofile%\\enso\\projects\\{}\\package.yaml", project_name), - _ => format!("/{}/package.yaml", project_name), + format!("%userprofile%\\enso\\projects\\{project_name}\\package.yaml"), + _ => format!("/{project_name}/package.yaml"), } } @@ -300,7 +300,7 @@ mod tests { assert_eq!(code, module.ast().repr()); }; expect_intact("main = 5"); - expect_intact(&format!("{}.main = 5", module_name)); + expect_intact(&format!("{module_name}.main = 5")); } diff --git a/app/gui/src/controller/searcher.rs b/app/gui/src/controller/searcher.rs index 02714c5fdd..1e783739e6 100644 --- a/app/gui/src/controller/searcher.rs +++ b/app/gui/src/controller/searcher.rs @@ -2275,7 +2275,7 @@ pub mod test { let parser = Parser::new_or_panic(); let ast = parser.parse_line_ast(self.before).unwrap(); let new_ast = apply_this_argument("foo", &ast); - assert_eq!(new_ast.repr(), self.after, "Case {:?} failed: {:?}", self, ast); + assert_eq!(new_ast.repr(), self.after, "Case {self:?} failed: {ast:?}"); } } diff --git a/app/gui/src/controller/searcher/component.rs b/app/gui/src/controller/searcher/component.rs index 8a5f3521db..48ba84467b 100644 --- a/app/gui/src/controller/searcher/component.rs +++ b/app/gui/src/controller/searcher/component.rs @@ -179,9 +179,9 @@ impl Display for Component { let self_type_not_here = self_type_ref.filter(|t| *t != &entry.defined_in); if let Some(self_type) = self_type_not_here { let self_name = self_type.name().from_case(Case::Snake).to_case(Case::Title); - write!(f, "{} {}", self_name, entry_name) + write!(f, "{self_name} {entry_name}") } else { - write!(f, "{}", entry_name) + write!(f, "{entry_name}") } } Data::Virtual { snippet } => write!(f, "{}", snippet.name), diff --git a/app/gui/src/controller/searcher/component/builder.rs b/app/gui/src/controller/searcher/component/builder.rs index ee18e9a1c0..518972ce4d 100644 --- a/app/gui/src/controller/searcher/component/builder.rs +++ b/app/gui/src/controller/searcher/component/builder.rs @@ -557,7 +557,7 @@ mod tests { builder.extend_list_and_allow_favorites_with_ids(&db, std::iter::once(1)); let list = builder.build(); let favorites = list.favorites; - assert_eq!(favorites.len(), 1, "Expected one group of favorites, got: {:?}.", favorites); + assert_eq!(favorites.len(), 1, "Expected one group of favorites, got: {favorites:?}."); let expected_entry_names = ["test snippet", qn_of_db_entry_1.name()]; check_names_and_order_of_group_entries(&favorites[0], &expected_entry_names); } @@ -585,7 +585,7 @@ mod tests { builder.extend_list_and_allow_favorites_with_ids(&db, std::iter::once(1)); let list = builder.build(); let favorites = list.favorites; - assert_eq!(favorites.len(), 2, "Expected two groups of favorites, got: {:?}.", favorites); + assert_eq!(favorites.len(), 2, "Expected two groups of favorites, got: {favorites:?}."); let group_at_0 = &favorites[0]; assert_eq!(group_at_0.name, "Group 2"); check_names_and_order_of_group_entries(group_at_0, &["test snippet"]); diff --git a/app/gui/src/controller/searcher/component/group.rs b/app/gui/src/controller/searcher/component/group.rs index 71ac8348a2..6a39b7cc90 100644 --- a/app/gui/src/controller/searcher/component/group.rs +++ b/app/gui/src/controller/searcher/component/group.rs @@ -96,7 +96,7 @@ impl Group { let name = if entry.defined_in.is_top_element() || entry.defined_in.is_main_module() { let project = &entry.defined_in.project().project; let module = entry.defined_in.name(); - format!("{}.{}", project, module) + format!("{project}.{module}") } else { entry.defined_in.name().to_owned() }; diff --git a/app/gui/src/controller/upload.rs b/app/gui/src/controller/upload.rs index 3e17d54947..9f52e44020 100644 --- a/app/gui/src/controller/upload.rs +++ b/app/gui/src/controller/upload.rs @@ -308,11 +308,11 @@ impl NodeFromDroppedFileHandler { } fn uploading_node_expression(name: &str) -> String { - format!("File_Uploading.file_uploading Enso_Project.data/\"{}\"", name) + format!("File_Uploading.file_uploading Enso_Project.data/\"{name}\"") } fn uploaded_node_expression(name: &str) -> String { - format!("enso_project.data/\"{}\" . read", name) + format!("enso_project.data/\"{name}\" . read") } fn data_path(&self) -> Path { diff --git a/app/gui/src/model/project/synchronized.rs b/app/gui/src/model/project/synchronized.rs index d7c6423bb2..35c4eceb0e 100644 --- a/app/gui/src/model/project/synchronized.rs +++ b/app/gui/src/model/project/synchronized.rs @@ -228,8 +228,7 @@ impl Display for UnsupportedEngineVersion { write!( f, "Failed to open project: unsupported engine version. Please update \ - engine_version in {} to {}.", - package_yaml_path, version_supported + engine_version in {package_yaml_path} to {version_supported}." ) } } diff --git a/app/gui/src/model/registry.rs b/app/gui/src/model/registry.rs index 944d0c3cf3..d501d8e77c 100644 --- a/app/gui/src/model/registry.rs +++ b/app/gui/src/model/registry.rs @@ -66,7 +66,7 @@ impl CloneRef for Entry { impl Debug for Entry { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> { match self { - Entry::Loaded(handle) => write!(f, "Entry::Loaded({:?})", handle), + Entry::Loaded(handle) => write!(f, "Entry::Loaded({handle:?})"), Entry::Loading(_) => write!(f, "Entry::Loading"), } } diff --git a/app/gui/src/model/undo_redo.rs b/app/gui/src/model/undo_redo.rs index 887cc1235a..f4d1b408c4 100644 --- a/app/gui/src/model/undo_redo.rs +++ b/app/gui/src/model/undo_redo.rs @@ -166,13 +166,13 @@ impl Display for Frame { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "Name: {}; ", self.name)?; if let Some(m) = &self.module { - write!(f, "Module: {}; ", m)?; + write!(f, "Module: {m}; ")?; } if let Some(g) = &self.graph { - write!(f, "Graph: {}; ", g)?; + write!(f, "Graph: {g}; ")?; } for (id, code) in &self.snapshots { - write!(f, "Code for {}: {}; ", id, code)?; + write!(f, "Code for {id}: {code}; ")?; } Ok(()) } @@ -592,7 +592,7 @@ main = let node = &nodes[0]; // Check initial state. - assert_eq!(urm.repository.len(Stack::Undo), 0, "Undo stack not empty: {:?}", urm); + assert_eq!(urm.repository.len(Stack::Undo), 0, "Undo stack not empty: {urm:?}"); assert_eq!(module.ast().to_string(), "main = \n 2 + 2"); // Perform an action. diff --git a/app/gui/src/presenter.rs b/app/gui/src/presenter.rs index 5443c5946a..2d40e36e34 100644 --- a/app/gui/src/presenter.rs +++ b/app/gui/src/presenter.rs @@ -74,7 +74,7 @@ impl Model { *self.current_project.borrow_mut() = Some(project); } Err(err) => { - let err_msg = format!("Failed to initialize project: {}", err); + let err_msg = format!("Failed to initialize project: {err}"); error!("{err_msg}"); self.controller.status_notifications().publish_event(err_msg); } diff --git a/app/gui/src/presenter/graph/visualization/manager.rs b/app/gui/src/presenter/graph/visualization/manager.rs index e57a9e841b..de23ba9fe1 100644 --- a/app/gui/src/presenter/graph/visualization/manager.rs +++ b/app/gui/src/presenter/graph/visualization/manager.rs @@ -639,7 +639,7 @@ mod tests { let attached_id = if let ExecutionContextRequest::Attach(vis) = request { vis.id } else { - panic!("Expected request to be `ExecutionContextRequest::Attach`, found {:?}", request) + panic!("Expected request to be `ExecutionContextRequest::Attach`, found {request:?}") }; // Multiple detach-attach requests are collapsed into a single modify request. @@ -678,7 +678,7 @@ mod tests { match requests.expect_next() { ExecutionContextRequest::Detach(id) => assert_eq!(id, visualization_so_far.latest_id().unwrap()), - other => panic!("Expected a detach request, got: {:?}", other), + other => panic!("Expected a detach request, got: {other:?}"), } assert_matches!(requests.expect_next(), ExecutionContextRequest::Attach(vis) if matching_metadata(&vis,&desired_vis_3.metadata)); diff --git a/app/gui/suggestion-database/src/example.rs b/app/gui/suggestion-database/src/example.rs index 017dae6b8b..377e1b3b0f 100644 --- a/app/gui/suggestion-database/src/example.rs +++ b/app/gui/suggestion-database/src/example.rs @@ -83,7 +83,7 @@ impl Example { /// Creates a pretty documentation from hardcoded inner text. pub fn documentation_html_from(inner: &str) -> String { - format!("

{}

", inner) + format!("

{inner}

") } // ========================= diff --git a/app/gui/suggestion-database/src/lib.rs b/app/gui/suggestion-database/src/lib.rs index 31a01c09b0..35258e88e5 100644 --- a/app/gui/suggestion-database/src/lib.rs +++ b/app/gui/suggestion-database/src/lib.rs @@ -1071,19 +1071,19 @@ pub mod test { /// methods or constructors of the Type or Types defined in the module. fn verify_hierarchy_index(db: &SuggestionDatabase, name: &str, expected: &[&str]) { let id = lookup_id_by_name(db, name); - let id = id.unwrap_or_else(|| panic!("No entry with name {}", name)); + let id = id.unwrap_or_else(|| panic!("No entry with name {name}")); let hierarchy_index = db.hierarchy_index.borrow(); let actual_ids = hierarchy_index.get(&id); - let actual_ids = actual_ids.unwrap_or_else(|| panic!("No entry for id {}", id)); + let actual_ids = actual_ids.unwrap_or_else(|| panic!("No entry for id {id}")); let id_from_name = |name: &&str| { - lookup_id_by_name(db, name).unwrap_or_else(|| panic!("No entry with name {}", name)) + lookup_id_by_name(db, name).unwrap_or_else(|| panic!("No entry with name {name}")) }; let expected_ids: HashSet<_> = expected.iter().map(id_from_name).collect(); let name_from_id = |id: &entry::Id| { db.lookup(*id).map(|e| e.name.clone()).unwrap_or_else(|_| "".to_string()) }; let actual = actual_ids.iter().map(name_from_id).collect::>(); - assert_eq!(actual_ids, &expected_ids, "Actual {:?} != expected {:?}", actual, expected); + assert_eq!(actual_ids, &expected_ids, "Actual {actual:?} != expected {expected:?}"); } /// Test that hierarchy index is populated when the database is created from the language server diff --git a/app/gui/view/component-browser/component-list-panel/grid/src/lib.rs b/app/gui/view/component-browser/component-list-panel/grid/src/lib.rs index 395c807be5..9630ce3b7b 100644 --- a/app/gui/view/component-browser/component-list-panel/grid/src/lib.rs +++ b/app/gui/view/component-browser/component-list-panel/grid/src/lib.rs @@ -474,8 +474,7 @@ impl Model { } fn entry_to_select_after_reset(&self, info: &content::Info) -> Option<(Row, Col)> { - let top_module_sections = - (0..info.namespace_section_count).into_iter().map(SectionId::Namespace); + let top_module_sections = (0..info.namespace_section_count).map(SectionId::Namespace); let sections = iter::once(SectionId::Popular) .chain(top_module_sections) .chain(iter::once(SectionId::LocalScope)); diff --git a/app/gui/view/component-browser/component-list-panel/src/lib.rs b/app/gui/view/component-browser/component-list-panel/src/lib.rs index 022b5530a7..ca7c7d1806 100644 --- a/app/gui/view/component-browser/component-list-panel/src/lib.rs +++ b/app/gui/view/component-browser/component-list-panel/src/lib.rs @@ -178,7 +178,7 @@ pub mod background { ensogl_core::shape! { below = [grid::entry::background, grid_view::entry::overlay, grid_view::selectable::highlight::shape]; (style:Style,bg_color:Vector4) { - let alpha = Var::::from(format!("({0}.w)",bg_color)); + let alpha = Var::::from(format!("({bg_color}.w)")); let bg_color = &Var::::from(bg_color.clone()); let grid_padding = style.get_number(theme::grid::padding); diff --git a/app/gui/view/debug_scene/interface/src/lib.rs b/app/gui/view/debug_scene/interface/src/lib.rs index 8624775133..0d6719e2f5 100644 --- a/app/gui/view/debug_scene/interface/src/lib.rs +++ b/app/gui/view/debug_scene/interface/src/lib.rs @@ -322,7 +322,7 @@ fn init(app: &Application) { pub fn expression_mock_string(label: &str) -> Expression { let pattern = Some(label.to_string()); - let code = format!("\"{}\"", label); + let code = format!("\"{label}\""); let parser = Parser::new_or_panic(); let parameters = vec![]; let ast = parser.parse_line_ast(&code).unwrap(); diff --git a/app/gui/view/debug_scene/text-grid-visualization/src/lib.rs b/app/gui/view/debug_scene/text-grid-visualization/src/lib.rs index d41d4090bb..cfc8c4f4ce 100644 --- a/app/gui/view/debug_scene/text-grid-visualization/src/lib.rs +++ b/app/gui/view/debug_scene/text-grid-visualization/src/lib.rs @@ -46,8 +46,7 @@ fn sample_text() -> String { } _ => { text.push_str(&format!( - "{0:?} bottles of beer on the wall, {0:?} bottles of beer.", - n + "{n:?} bottles of beer on the wall, {n:?} bottles of beer." )); text.push_str(&format!( "Take one down and pass it around, {} bottles of beer on the wall.\n", diff --git a/app/gui/view/documentation/src/html.rs b/app/gui/view/documentation/src/html.rs index 9565f967f9..9a79c27fce 100644 --- a/app/gui/view/documentation/src/html.rs +++ b/app/gui/view/documentation/src/html.rs @@ -525,7 +525,7 @@ fn arguments_list<'a>(arguments: &'a [Argument]) -> Box { fn single_argument(argument: &Argument) -> impl Render { let Argument { name, default_value, .. } = argument; let text = if let Some(default_value) = default_value { - format!("{} = {},", name, default_value) + format!("{name} = {default_value},") } else { name.to_string() }; diff --git a/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs b/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs index 688bf534b0..80faec4f64 100644 --- a/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs +++ b/app/gui/view/graph-editor/src/builtin/visualization/native/error.rs @@ -178,7 +178,7 @@ impl Model { let messages = default(); let styles = StyleWatch::new(&scene.style_sheet); - let padding_text = format!("{}px", PADDING_TEXT); + let padding_text = format!("{PADDING_TEXT}px"); dom.dom().set_attribute_or_warn("class", "visualization scrollable"); dom.dom().set_style_or_warn("overflow-x", "hidden"); diff --git a/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/grid_view_entry.rs b/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/grid_view_entry.rs index c15ed9238f..61c7078bae 100644 --- a/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/grid_view_entry.rs +++ b/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/grid_view_entry.rs @@ -75,8 +75,8 @@ impl Entry { let height = size.y as u32; let mut style = "position: absolute; white-space: pre; pointer-events: auto;".to_string(); - write!(style, "left: {}px; top: {}px;", left, top).ok(); - write!(style, "width: {}px; height: {}px;", width, height).ok(); + write!(style, "left: {left}px; top: {top}px;").ok(); + write!(style, "width: {width}px; height: {height}px;").ok(); self.text.set_attribute_or_warn("style", style); } diff --git a/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/text_provider.rs b/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/text_provider.rs index 8616742a93..0c6932908f 100644 --- a/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/text_provider.rs +++ b/app/gui/view/graph-editor/src/builtin/visualization/native/text_visualization/text_provider.rs @@ -285,7 +285,7 @@ impl TryFrom for LazyGridDataUpdate { serde_json::to_string_pretty(&*content) }; let data_str = - data_str.unwrap_or_else(|e| format!("", e)); + data_str.unwrap_or_else(|e| format!("")); (data_str.into(), UpdateType::FullUpdate) } }; diff --git a/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs b/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs index 1726eb3aa3..4762637ab2 100644 --- a/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs +++ b/app/gui/view/graph-editor/src/component/breadcrumbs/breadcrumb.rs @@ -82,7 +82,7 @@ mod icon { let arrow = Triangle(size.px(),size.px()).rotate((PI/2.0).radians()); let arrow = arrow.translate_x(0.5.px()); let shape = ring + arrow; - let color = format!("vec4({},{},{},{})",red,green,blue,alpha); + let color = format!("vec4({red},{green},{blue},{alpha})"); let color : Var = color.into(); shape.fill(color).into() } @@ -104,7 +104,7 @@ mod separator { let size = SEPARATOR_SIZE; let angle = PI/2.0; let triangle = Triangle(size.px(),size.px()).rotate(angle.radians()); - let color = format!("vec4({},{},{},{})",red,green,blue,alpha); + let color = format!("vec4({red},{green},{blue},{alpha})"); let color : Var = color.into(); triangle.fill(color).into() } diff --git a/app/gui/view/graph-editor/src/component/node/error.rs b/app/gui/view/graph-editor/src/component/node/error.rs index b889db47a9..d6066913ef 100644 --- a/app/gui/view/graph-editor/src/component/node/error.rs +++ b/app/gui/view/graph-editor/src/component/node/error.rs @@ -122,10 +122,10 @@ impl Container { let div = web::document.create_div_or_panic(); let background_dom = DomSymbol::new(&div); let (width, height) = SIZE; - let width = format!("{}.px", width); - let height = format!("{}.px", height); + let width = format!("{width}.px"); + let height = format!("{height}.px"); let z_index = Z_INDEX.to_string(); - let border_radius = format!("{}.px", BORDER_RADIUS); + let border_radius = format!("{BORDER_RADIUS}.px"); background_dom.dom().set_style_or_warn("width", width); background_dom.dom().set_style_or_warn("height", height); background_dom.dom().set_style_or_warn("z-index", z_index); diff --git a/app/gui/view/graph-editor/src/component/node/profiling.rs b/app/gui/view/graph-editor/src/component/node/profiling.rs index 6ecf856ca3..777d3bb54a 100644 --- a/app/gui/view/graph-editor/src/component/node/profiling.rs +++ b/app/gui/view/graph-editor/src/component/node/profiling.rs @@ -61,13 +61,13 @@ impl Display for Status { let minutes = seconds / 60.0; let hours = minutes / 60.0; if hours >= 1.0 { - write!(f, "{:.1} h", hours) + write!(f, "{hours:.1} h") } else if minutes >= 1.0 { - write!(f, "{:.1} m", minutes) + write!(f, "{minutes:.1} m") } else if seconds >= 1.0 { - write!(f, "{:.1} s", seconds) + write!(f, "{seconds:.1} s") } else { - write!(f, "{:.0} ms", milliseconds) + write!(f, "{milliseconds:.0} ms") } } } diff --git a/app/gui/view/graph-editor/src/component/visualization/definition.rs b/app/gui/view/graph-editor/src/component/visualization/definition.rs index 653804b0a2..af07ef14c6 100644 --- a/app/gui/view/graph-editor/src/component/visualization/definition.rs +++ b/app/gui/view/graph-editor/src/component/visualization/definition.rs @@ -107,8 +107,7 @@ impl Display for InstantiationError { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { InstantiationError::ConstructorError(value) => f.write_fmt(format_args!( - "Could not construct visualisation because of error: {:?}", - value + "Could not construct visualisation because of error: {value:?}" )), } } diff --git a/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/definition.rs b/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/definition.rs index 4dc5bc632b..31d4c5ad50 100644 --- a/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/definition.rs +++ b/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/definition.rs @@ -130,9 +130,9 @@ impl Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Error::InvalidFunction(value) => - f.write_fmt(format_args!("Provided value is not a valid function: {:?}", value)), + f.write_fmt(format_args!("Provided value is not a valid function: {value:?}")), Error::InvalidClass(value) => - f.write_fmt(format_args!("Provided value is not a valid class: {:?}", value)), + f.write_fmt(format_args!("Provided value is not a valid class: {value:?}")), } } } diff --git a/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs b/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs index 8271893800..018392acb4 100644 --- a/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs +++ b/app/gui/view/graph-editor/src/component/visualization/foreign/java_script/instance.rs @@ -51,15 +51,13 @@ impl Display for Error { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Error::ValueIsNotAnObject { object } => f.write_fmt(format_args!( - "JsValue was expected to be of type `object`, but was not: {:?}", - object + "JsValue was expected to be of type `object`, but was not: {object:?}" )), Error::PropertyNotFoundOnObject { object, property } => f.write_fmt(format_args!( - "Object was expected to have property {:?} but has not: {:?}", - property, object + "Object was expected to have property {property:?} but has not: {object:?}" )), Error::ConstructorError { js_error } => - f.write_fmt(format_args!("Error while constructing object: {:?}", js_error)), + f.write_fmt(format_args!("Error while constructing object: {js_error:?}")), } } } diff --git a/app/gui/view/graph-editor/src/new_node_position/free_place_finder.rs b/app/gui/view/graph-editor/src/new_node_position/free_place_finder.rs index 4b901f3931..addbc84dda 100644 --- a/app/gui/view/graph-editor/src/new_node_position/free_place_finder.rs +++ b/app/gui/view/graph-editor/src/new_node_position/free_place_finder.rs @@ -160,7 +160,7 @@ mod tests { fn run(&self) { let occupied = self.occupied.iter().cloned(); let result = find_free_place(self.starting_point, self.direction, occupied).unwrap(); - assert_eq!(result, self.expected_result, "Case {:?} gave wrong result.", self); + assert_eq!(result, self.expected_result, "Case {self:?} gave wrong result."); } fn flip(&self, on_x: bool, on_y: bool) -> Self { diff --git a/app/gui/view/welcome-screen/src/side_menu.rs b/app/gui/view/welcome-screen/src/side_menu.rs index 168aa95943..0c8ceda556 100644 --- a/app/gui/view/welcome-screen/src/side_menu.rs +++ b/app/gui/view/welcome-screen/src/side_menu.rs @@ -83,7 +83,7 @@ impl Model { fn create_project_list_entry(project_name: &str) -> ClickableElement { let element = web::document.create_element_or_panic("li"); - element.set_inner_html(&format!(r#" {}"#, project_name)); + element.set_inner_html(&format!(r#" {project_name}"#)); ClickableElement::new(element) } } diff --git a/build/base/src/extensions/os_str.rs b/build/base/src/extensions/os_str.rs index 03a5299ef8..cf434c0096 100644 --- a/build/base/src/extensions/os_str.rs +++ b/build/base/src/extensions/os_str.rs @@ -16,6 +16,6 @@ pub trait OsStrExt { impl OsStrExt for OsStr { fn as_str(&self) -> &str { - self.to_str().unwrap_or_else(|| panic!("String is not valid UTF-8: {:?}", self)) + self.to_str().unwrap_or_else(|| panic!("String is not valid UTF-8: {self:?}")) } } diff --git a/build/base/src/extensions/path.rs b/build/base/src/extensions/path.rs index 4831258d81..015a9822f5 100644 --- a/build/base/src/extensions/path.rs +++ b/build/base/src/extensions/path.rs @@ -56,7 +56,7 @@ pub trait PathExt: AsRef { #[context("Failed to deserialize file `{}` as type `{}`.", self.as_ref().display(), std::any::type_name::())] fn read_to_json(&self) -> Result { let content = crate::fs::read_to_string(self)?; - serde_json::from_str(&content).with_context(|| format!("File content was: {}", content)) + serde_json::from_str(&content).with_context(|| format!("File content was: {content}")) } /// Write this file with a JSON-serialized value. diff --git a/build/build/src/aws/s3.rs b/build/build/src/aws/s3.rs index 1a610e3993..162dc81f6e 100644 --- a/build/build/src/aws/s3.rs +++ b/build/build/src/aws/s3.rs @@ -41,7 +41,7 @@ impl BucketContext { let path = path.as_ref(); let normalized = path_slash::PathExt::to_slash_lossy(path); if let Some(prefix) = &self.key_prefix { - format!("{}/{}", prefix, normalized) + format!("{prefix}/{normalized}") } else { normalized.into() } diff --git a/build/build/src/ci_gen.rs b/build/build/src/ci_gen.rs index 238fb8572b..eb052a89cc 100644 --- a/build/build/src/ci_gen.rs +++ b/build/build/src/ci_gen.rs @@ -184,9 +184,7 @@ pub fn setup_customized_script_steps( steps.extend(customize(run(command_line))); steps.extend(list_everything_on_failure()); steps.push( - clean_step - .with_if(format!("always() && {}", post_clean_condition)) - .with_name("Clean after"), + clean_step.with_if(format!("always() && {post_clean_condition}")).with_name("Clean after"), ); steps } diff --git a/build/build/src/context.rs b/build/build/src/context.rs index 1d2dda29d9..06f359b293 100644 --- a/build/build/src/context.rs +++ b/build/build/src/context.rs @@ -62,7 +62,7 @@ impl BuildContext { }; Result::Ok(release) } - .with_context(move || format!("Failed to resolve release designator `{}`", designator_cp)) + .with_context(move || format!("Failed to resolve release designator `{designator_cp}`")) .boxed() } diff --git a/build/build/src/engine.rs b/build/build/src/engine.rs index a88f970f8b..5cb98560c6 100644 --- a/build/build/src/engine.rs +++ b/build/build/src/engine.rs @@ -51,7 +51,7 @@ pub async fn download_project_templates(client: reqwest::Client, enso_root: Path let mut futures = Vec::>::new(); for (project_name, relative_paths) in to_handle { for relative_path in relative_paths { - let relative_url_base = url_base.join(&format!("{}/", project_name))?; + let relative_url_base = url_base.join(&format!("{project_name}/"))?; let relative_output_base = output_base.join(project_name.to_lowercase()); let client = client.clone(); let future = async move { diff --git a/build/build/src/paths.rs b/build/build/src/paths.rs index 42d4fedb05..42e18ecf3c 100644 --- a/build/build/src/paths.rs +++ b/build/build/src/paths.rs @@ -58,7 +58,7 @@ pub fn pretty_print_arch(arch: Arch) -> &'static str { match arch { Arch::X86_64 => "amd64", Arch::AArch64 => "aarch64", - _ => panic!("Unrecognized architecture {}", arch), + _ => panic!("Unrecognized architecture {arch}"), } } diff --git a/build/build/src/project.rs b/build/build/src/project.rs index 7a20309602..cb4aee0817 100644 --- a/build/build/src/project.rs +++ b/build/build/src/project.rs @@ -182,7 +182,7 @@ pub trait IsTarget: Clone + Debug + Sized + Send + Sync + 'static { let artifact_fut = self.build_internal(context, job); let this = self.clone(); async move { - let artifact = artifact_fut.await.context(format!("Failed to build {:?}.", this))?; + let artifact = artifact_fut.await.context(format!("Failed to build {this:?}."))?; // We upload only built artifacts. There would be no point in uploading something that // we've just downloaded. That's why the uploading code is here. if upload_artifacts { @@ -255,8 +255,8 @@ pub trait IsTarget: Clone + Debug + Sized + Send + Sync + 'static { release.assets.iter().find(|asset| self.matches_asset(asset)).with_context(|| { let asset_names = release.assets.iter().map(|asset| &asset.name).join(", "); format!( - "No matching asset for target {:?} in release {:?}. Available assets: {}", - self, release, asset_names + "No matching asset for target {self:?} in release {release:?}. \ + Available assets: {asset_names}" ) }) } diff --git a/build/build/src/project/ide.rs b/build/build/src/project/ide.rs index bf0bd97e92..609644c33b 100644 --- a/build/build/src/project/ide.rs +++ b/build/build/src/project/ide.rs @@ -43,9 +43,9 @@ impl Artifact { } .into(); let image = dist_dir.as_ref().join(match target_os { - OS::Linux => format!("enso-linux-{}.AppImage", version), - OS::MacOS => format!("enso-mac-{}.dmg", version), - OS::Windows => format!("enso-win-{}.exe", version), + OS::Linux => format!("enso-linux-{version}.AppImage"), + OS::MacOS => format!("enso-mac-{version}.dmg"), + OS::Windows => format!("enso-win-{version}.exe"), _ => todo!("{target_os}-{target_arch} combination is not supported"), }); @@ -59,10 +59,10 @@ impl Artifact { pub async fn upload_as_ci_artifact(&self) -> Result { if is_in_env() { - upload_compressed_directory(&self.unpacked, format!("ide-unpacked-{}", TARGET_OS)) + upload_compressed_directory(&self.unpacked, format!("ide-unpacked-{TARGET_OS}")) .await?; - upload_single_file(&self.image, format!("ide-{}", TARGET_OS)).await?; - upload_single_file(&self.image_checksum, format!("ide-{}", TARGET_OS)).await?; + upload_single_file(&self.image, format!("ide-{TARGET_OS}")).await?; + upload_single_file(&self.image_checksum, format!("ide-{TARGET_OS}")).await?; } else { info!("Not in the CI environment, will not upload the artifacts.") } diff --git a/build/build/src/project/wasm/test.rs b/build/build/src/project/wasm/test.rs index 421e59d35f..59790ed5df 100644 --- a/build/build/src/project/wasm/test.rs +++ b/build/build/src/project/wasm/test.rs @@ -89,7 +89,7 @@ pub fn has_wasm_tests(member: &Path) -> bool { // We go over selected subdirectories only to avoid entering into sources of other crates // that are nested within this crate subtree. for subdir in SOURCE_SUBDIRECTORIES { - let pattern = format!("{}/{}/**/*.rs", member, subdir); + let pattern = format!("{member}/{subdir}/**/*.rs"); for entry in glob::glob(&pattern).unwrap() { let contents = ide_ci::fs::read_to_string(entry.unwrap()).unwrap(); if contents.lines().any(is_wasm_test_attribute) { @@ -169,7 +169,7 @@ pub async fn test_all(repo_root: PathBuf, browsers: &[Browser]) -> Result { .run_ok() .await?; } else { - println!("No wasm tests in {}", member_str); + println!("No wasm tests in {member_str}"); } } Ok(()) diff --git a/build/build/src/version.rs b/build/build/src/version.rs index d5f781b441..1a3b03ce22 100644 --- a/build/build/src/version.rs +++ b/build/build/src/version.rs @@ -233,7 +233,7 @@ pub fn same_core_version(a: &Version, b: &Version) -> bool { } pub fn generate_rc_prerelease(index: u32) -> Result { - Prerelease::from_str(&format!("{}.{}", RC_BUILD_PREFIX, index)) + Prerelease::from_str(&format!("{RC_BUILD_PREFIX}.{index}")) } #[instrument(ret)] diff --git a/build/build/src/version/nightly.rs b/build/build/src/version/nightly.rs index 6468e1b6a9..418c2ee110 100644 --- a/build/build/src/version/nightly.rs +++ b/build/build/src/version/nightly.rs @@ -61,7 +61,7 @@ impl TryFrom<&Prerelease> for NightlyPrerelease { let index = identifiers.get(4).map(|index| index.parse2()).transpose().context("Invalid index")?; let date = chrono::NaiveDate::from_ymd_opt(year, month, day) - .with_context(|| format!("Invalid date: {}-{}-{}", year, month, day))?; + .with_context(|| format!("Invalid date: {year}-{month}-{day}"))?; Ok(Self::new(date, index)) } } @@ -78,7 +78,7 @@ impl Display for NightlyPrerelease { date.day() )?; if let Some(index) = index { - write!(f, ".{}", index)?; + write!(f, ".{index}")?; } Ok(()) } diff --git a/build/ci_utils/src/actions/artifacts/raw.rs b/build/ci_utils/src/actions/artifacts/raw.rs index 06661a0480..89ebd3f4b3 100644 --- a/build/ci_utils/src/actions/artifacts/raw.rs +++ b/build/ci_utils/src/actions/artifacts/raw.rs @@ -228,7 +228,7 @@ pub async fn check_response( .map_err(|e| anyhow!("Also failed to obtain the response body: {}", e))?; if let Ok(body_text) = std::str::from_utf8(body.as_ref()) { - err = err.context(format!("Error response body was: {}", body_text)); + err = err.context(format!("Error response body was: {body_text}")); } let err = additional_context(status, err); diff --git a/build/ci_utils/src/actions/workflow/definition.rs b/build/ci_utils/src/actions/workflow/definition.rs index a65ba62d73..aaa06031f4 100644 --- a/build/ci_utils/src/actions/workflow/definition.rs +++ b/build/ci_utils/src/actions/workflow/definition.rs @@ -955,7 +955,7 @@ pub fn checkout_repo_step_customized(f: impl FnOnce(Step) -> Step) -> Vec let submodules_workaround_win = Step { // We can't add git-bash to PATH because this would break the Rust build. // Instead we manually spawn the bash with a given command from CMD shell. - run: Some(format!(r#""c:\Program Files\Git\bin\bash.exe" -c "{}""#, git_bash_command)), + run: Some(format!(r#""c:\Program Files\Git\bin\bash.exe" -c "{git_bash_command}""#)), shell: Some(Shell::Cmd), r#if: Some(is_windows_runner()), name: Some( diff --git a/build/ci_utils/src/cache.rs b/build/ci_utils/src/cache.rs index 002ee78bc7..1887256ef6 100644 --- a/build/ci_utils/src/cache.rs +++ b/build/ci_utils/src/cache.rs @@ -106,7 +106,7 @@ pub fn digest(storable: &S) -> Result { let mut digest = sha2::Sha224::default(); sha2::Digest::update(&mut digest, [VERSION]); - sha2::Digest::update(&mut digest, &key_serialized); + sha2::Digest::update(&mut digest, key_serialized); std::any::TypeId::of::().hash(&mut HashToDigest(&mut digest)); std::any::TypeId::of::().hash(&mut HashToDigest(&mut digest)); let digest = digest.finalize(); @@ -159,7 +159,7 @@ impl Cache { trace!("Value cannot be retrieved from cache because: {e}"); crate::fs::reset_dir(&entry_dir)?; let key = storable.key(); - tracing::Span::current().record("key", &tracing::field::debug(&key)); + tracing::Span::current().record("key", tracing::field::debug(&key)); let metadata = storable .generate(this, entry_dir.clone()) .instrument(info_span!("Generating value to fill the cache.")) diff --git a/build/ci_utils/src/cache/goodie/graalvm.rs b/build/ci_utils/src/cache/goodie/graalvm.rs index 72f72bb974..85cc707c8e 100644 --- a/build/ci_utils/src/cache/goodie/graalvm.rs +++ b/build/ci_utils/src/cache/goodie/graalvm.rs @@ -113,7 +113,7 @@ impl GraalVM { other_arch => unimplemented!("Architecture `{}` is not supported!", other_arch), }; let java_version = format!("java{}", java_version.0); - format!("{}-{}-{}-{}", PACKAGE_PREFIX, java_version, os_name, arch_name) + format!("{PACKAGE_PREFIX}-{java_version}-{os_name}-{arch_name}") } pub fn root_directory_name(&self) -> PathBuf { diff --git a/build/ci_utils/src/env/accessor.rs b/build/ci_utils/src/env/accessor.rs index b90aa6c6f4..d8f90c28ae 100644 --- a/build/ci_utils/src/env/accessor.rs +++ b/build/ci_utils/src/env/accessor.rs @@ -119,7 +119,7 @@ impl TypedVariable for PathBufVariable { fn generate(&self, value: &Self::Borrowed) -> Result { value .to_str() - .with_context(|| format!("Path is not a valid string: {:?}.", value)) + .with_context(|| format!("Path is not a valid string: {value:?}.")) .map(ToString::to_string) } } diff --git a/build/ci_utils/src/extensions/command.rs b/build/ci_utils/src/extensions/command.rs index 0c428cce73..98a3568644 100644 --- a/build/ci_utils/src/extensions/command.rs +++ b/build/ci_utils/src/extensions/command.rs @@ -16,7 +16,7 @@ pub trait CommandExt { fn describe(&self) -> String { let mut ret = String::new(); let pretty_printed = format!("{:?}", self.as_std()); - let _ = write!(ret, "Command:\n\t{}", pretty_printed); + let _ = write!(ret, "Command:\n\t{pretty_printed}"); if let Some(cwd) = self.as_std().get_current_dir() { let _ = write!(ret, "\n\twith working directory: {}", cwd.display()); }; diff --git a/build/ci_utils/src/github.rs b/build/ci_utils/src/github.rs index 9044f8f5b2..8daa3600b3 100644 --- a/build/ci_utils/src/github.rs +++ b/build/ci_utils/src/github.rs @@ -172,7 +172,7 @@ pub async fn latest_runner_url(octocrab: &Octocrab, os: OS) -> Result { other_arch => unimplemented!("Architecture `{}` is not yet supported!", other_arch), }; - let platform_name = format!("{}-{}", os_name, arch_name); + let platform_name = format!("{os_name}-{arch_name}"); find_asset_url_by_text(&latest_release, &platform_name).cloned() } diff --git a/build/ci_utils/src/github/release.rs b/build/ci_utils/src/github/release.rs index 351b8d8304..f0d0d734b7 100644 --- a/build/ci_utils/src/github/release.rs +++ b/build/ci_utils/src/github/release.rs @@ -197,7 +197,7 @@ mod tests { dbg!(&release); let mut header_map = HeaderMap::new(); - header_map.append(reqwest::header::AUTHORIZATION, format!("Bearer {}", pat).parse()?); + header_map.append(reqwest::header::AUTHORIZATION, format!("Bearer {pat}").parse()?); let client = reqwest::Client::builder() .user_agent("enso-build") .default_headers(header_map) diff --git a/build/ci_utils/src/github/repo.rs b/build/ci_utils/src/github/repo.rs index e7c4b2a9a2..f67c08302d 100644 --- a/build/ci_utils/src/github/repo.rs +++ b/build/ci_utils/src/github/repo.rs @@ -27,7 +27,7 @@ use reqwest::Response; /// /// See also [`RepoRef`] for a non-owning equivalent. #[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize, derive_more::Display)] -#[display(fmt = "{}/{}", owner, name)] +#[display(fmt = "{owner}/{name}")] pub struct Repo { /// Owner - an organization's or user's name. pub owner: String, @@ -78,7 +78,7 @@ impl Repo { /// /// Particularly useful for defining `const` repositories. #[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize, derive_more::Display)] -#[display(fmt = "{}/{}", owner, name)] +#[display(fmt = "{owner}/{name}")] pub struct RepoRef<'a> { /// Owner - an organization's or user's name. pub owner: &'a str, @@ -399,8 +399,7 @@ impl Handle { pub async fn default_branch(&self) -> Result { self.get().await?.default_branch.with_context(|| { format!( - "Failed to get the default branch of the {} repository. Missing field: `default_branch`.", - self + "Failed to get the default branch of the {self} repository. Missing field: `default_branch`.", ) }) } diff --git a/build/ci_utils/src/io/web/client.rs b/build/ci_utils/src/io/web/client.rs index b66f8f3ef5..e720fe4c7c 100644 --- a/build/ci_utils/src/io/web/client.rs +++ b/build/ci_utils/src/io/web/client.rs @@ -13,7 +13,7 @@ use std::time::Duration; pub async fn get(client: &Client, url: impl IntoUrl) -> Result { let url = url.into_url()?; - web::execute(client.get(url.clone())).await.with_context(|| format!("Failed to get {}", url)) + web::execute(client.get(url.clone())).await.with_context(|| format!("Failed to get {url}")) } /// Get the the response body as a byte stream. @@ -31,9 +31,9 @@ pub async fn download_all(client: &Client, url: impl IntoUrl) -> Result { let url = url.into_url()?; let bar = progress_bar(indicatif::ProgressBar::new_spinner); bar.enable_steady_tick(Duration::from_millis(100)); - bar.set_message(format!("Downloading {}", url)); + bar.set_message(format!("Downloading {url}")); let response = web::execute(client.get(url.clone())).await?; - response.bytes().await.with_context(|| format!("Failed to download body of {}", url)) + response.bytes().await.with_context(|| format!("Failed to download body of {url}")) } /// Downloads archive from URL and extracts it into an output path. diff --git a/build/ci_utils/src/paths.rs b/build/ci_utils/src/paths.rs index 15d4d54654..26dba3e105 100644 --- a/build/ci_utils/src/paths.rs +++ b/build/ci_utils/src/paths.rs @@ -124,7 +124,7 @@ impl<'a> Generator<'a> { .iter() .find(|node| node.matches_ref(r#type)) .copied() - .context(format!("Could not find node for type reference: {}", r#type)) + .context(format!("Could not find node for type reference: {type}")) } pub fn generate(&mut self) -> Result { diff --git a/build/ci_utils/src/program/command.rs b/build/ci_utils/src/program/command.rs index 75fd7a5e74..2dcd87cfb0 100644 --- a/build/ci_utils/src/program/command.rs +++ b/build/ci_utils/src/program/command.rs @@ -345,7 +345,7 @@ impl Command { tracing::Span::current().record("status", exit_status.code()); }) .await?; - status_checker(status).context(format!("Command failed: {}", pretty)) + status_checker(status).context(format!("Command failed: {pretty}")) } .instrument(span.exit()) .boxed() @@ -379,7 +379,7 @@ impl Command { })?; Result::Ok(output) } - .map_err(move |e| e.context(format!("Failed to get output of the command: {}", pretty))) + .map_err(move |e| e.context(format!("Failed to get output of the command: {pretty}"))) .instrument(span.exit()) .boxed() } @@ -400,13 +400,13 @@ impl Command { let current_span = tracing::Span::current(); if current_span.field("command").is_some() { - tracing::Span::current().record("command", &field::display(&pretty)); + tracing::Span::current().record("command", field::display(&pretty)); debug!("Spawning."); } else { debug!("Spawning {}.", pretty); } - self.inner.spawn().context(format!("Failed to spawn: {}", pretty)).inspect(|child| { + self.inner.spawn().context(format!("Failed to spawn: {pretty}")).inspect(|child| { if let Some(pid) = child.id() { current_span.record("pid", pid); } diff --git a/build/ci_utils/src/programs/cmd.rs b/build/ci_utils/src/programs/cmd.rs index 90d28744d0..16d6c31967 100644 --- a/build/ci_utils/src/programs/cmd.rs +++ b/build/ci_utils/src/programs/cmd.rs @@ -52,14 +52,14 @@ impl Shell for Cmd { fn modify_env(&self, change: &Modification) -> Result { let name = &change.variable_name; Ok(match &change.action { - Action::Remove => format!("set {}=", name), - Action::Set(value) => format!("set {}={}", name, value), + Action::Remove => format!("set {name}="), + Action::Set(value) => format!("set {name}={value}"), Action::PrependPaths(paths) => self.set_prepended_paths(name, paths)?, }) } fn access_environment_variable(&self, name: &str) -> String { - format!("%{}%", name) + format!("%{name}%") } } diff --git a/build/ci_utils/src/programs/docker.rs b/build/ci_utils/src/programs/docker.rs index 6f25292c43..7025e76abf 100644 --- a/build/ci_utils/src/programs/docker.rs +++ b/build/ci_utils/src/programs/docker.rs @@ -353,7 +353,7 @@ impl RestartPolicy { let value = match self { RestartPolicy::No => "no".into(), RestartPolicy::OnFailure { max_retries: Some(max_retries) } => - format!("on-failure:{}", max_retries).into(), + format!("on-failure:{max_retries}").into(), RestartPolicy::OnFailure { max_retries: None } => "on-failure:{}".into(), RestartPolicy::Always => "always".into(), RestartPolicy::UnlessStopped => "unless-stopped".into(), @@ -381,8 +381,8 @@ impl Display for Network { match self { Network::Bridge => write!(f, "bridge"), Network::Host => write!(f, "host"), - Network::User(name) => write!(f, "{}", name), - Network::Container(name_or_id) => write!(f, "container:{}", name_or_id), + Network::User(name) => write!(f, "{name}"), + Network::Container(name_or_id) => write!(f, "container:{name_or_id}"), } } } @@ -501,7 +501,7 @@ impl RunOptions { if let Some(storage_size_gb) = self.storage_size_gb { // e.g. --storage-opt size=120G ret.push("--storage-opt".into()); - ret.push(format!("size={}G", storage_size_gb).into()); + ret.push(format!("size={storage_size_gb}G").into()); } if let Some(sig_proxy) = self.sig_proxy { diff --git a/build/ci_utils/src/programs/git.rs b/build/ci_utils/src/programs/git.rs index 20e9881986..56509c81f8 100644 --- a/build/ci_utils/src/programs/git.rs +++ b/build/ci_utils/src/programs/git.rs @@ -383,7 +383,7 @@ mod tests { async fn repo_root() -> Result { let git = Context::new(".").await?; let diff = git.repository_root().await?; - println!("{:?}", diff); + println!("{diff:?}"); Ok(()) } @@ -392,7 +392,7 @@ mod tests { async fn call_diff() -> Result { let git = Context::new(".").await?; let diff = git.diff_against("origin/develop").await?; - println!("{:?}", diff); + println!("{diff:?}"); Ok(()) } } diff --git a/build/ci_utils/src/programs/git/pretty_format.rs b/build/ci_utils/src/programs/git/pretty_format.rs index 3382df8c6f..5b24ad26d7 100644 --- a/build/ci_utils/src/programs/git/pretty_format.rs +++ b/build/ci_utils/src/programs/git/pretty_format.rs @@ -167,7 +167,7 @@ impl Display for Placeholder { match self { Placeholder::Newline => write!(f, "%n"), Placeholder::Percent => write!(f, "%%"), - Placeholder::HexCode(code) => write!(f, "%{:02x}", code), + Placeholder::HexCode(code) => write!(f, "%{code:02x}"), Placeholder::Hash => write!(f, "%H"), Placeholder::AbbreviatedHash => write!(f, "%h"), Placeholder::TreeHash => write!(f, "%T"), diff --git a/build/ci_utils/src/programs/pwsh.rs b/build/ci_utils/src/programs/pwsh.rs index 96b1a39bb4..b6ab02d12a 100644 --- a/build/ci_utils/src/programs/pwsh.rs +++ b/build/ci_utils/src/programs/pwsh.rs @@ -48,16 +48,16 @@ impl Shell for PwSh { fn modify_env(&self, change: &Modification) -> Result { let name = &change.variable_name; Ok(match &change.action { - Action::Remove => format!(r"Remove-Item Env:\{}", name), + Action::Remove => format!(r"Remove-Item Env:\{name}"), Action::Set(value) => { - format!(r#"$env:{} = "{}""#, name, value) + format!(r#"$env:{name} = "{value}""#) } Action::PrependPaths(paths) => self.set_prepended_paths(name, paths)?, }) } fn access_environment_variable(&self, name: &str) -> String { - format!(r"$env:{}", name) + format!(r"$env:{name}") } } diff --git a/build/ci_utils/src/programs/sh.rs b/build/ci_utils/src/programs/sh.rs index fae38d8961..b578bd6961 100644 --- a/build/ci_utils/src/programs/sh.rs +++ b/build/ci_utils/src/programs/sh.rs @@ -43,16 +43,16 @@ impl Shell for Bash { fn modify_env(&self, change: &Modification) -> Result { let name = &change.variable_name; Ok(match &change.action { - Action::Remove => format!("unset {}", name), + Action::Remove => format!("unset {name}"), Action::Set(value) => { - format!("export {}={}", name, value) + format!("export {name}={value}") } Action::PrependPaths(paths) => self.set_prepended_paths(name, paths)?, }) } fn access_environment_variable(&self, name: &str) -> String { - format!("${}", name) + format!("${name}") } } diff --git a/build/ci_utils/src/programs/vswhere.rs b/build/ci_utils/src/programs/vswhere.rs index 669a844256..e1c63076b4 100644 --- a/build/ci_utils/src/programs/vswhere.rs +++ b/build/ci_utils/src/programs/vswhere.rs @@ -39,7 +39,7 @@ impl VsWhere { let stdout = command.run_stdout().await?; let instances = serde_json::from_str::>(&stdout)?; instances.into_iter().next().with_context(|| { - format!("No Visual Studio installation found with component {}.", component) + format!("No Visual Studio installation found with component {component}.") }) } diff --git a/build/deprecated/rust-scripts/src/bin/test_all.rs b/build/deprecated/rust-scripts/src/bin/test_all.rs index d6b9148ed3..1b62e69ddc 100644 --- a/build/deprecated/rust-scripts/src/bin/test_all.rs +++ b/build/deprecated/rust-scripts/src/bin/test_all.rs @@ -26,7 +26,7 @@ fn get_all_crates() -> Vec { let valid_paths = all_paths.filter_map(|path| match path { Ok(path) => Some(path.parent().unwrap().to_owned()), Err(err) => { - println!("cargo:warning={}", err); + println!("cargo:warning={err}"); None } }); @@ -44,7 +44,7 @@ fn has_wasm_tests(member: &Path) -> bool { // We go over selected subdirectories only to avoid entering into sources of other crates // that are nested within this crate subtree. for subdir in SOURCE_SUBDIRECTORIES { - let pattern = format!("{}/{}/**/*.rs", member, subdir); + let pattern = format!("{member}/{subdir}/**/*.rs"); for entry in glob::glob(&pattern).unwrap() { let contents = std::fs::read_to_string(entry.unwrap()).unwrap(); if contents.lines().any(is_wasm_test_attribute) { @@ -97,23 +97,23 @@ fn main() { for member in all_members { let member_str = member.to_string_lossy(); if blacklisted(&member) { - println!("Skipping blacklisted crate {}", member_str); + println!("Skipping blacklisted crate {member_str}"); } else if is_proc_macro_crate(&member) { - println!("Skipping proc-macro crate {}", member_str); + println!("Skipping proc-macro crate {member_str}"); } else if has_wasm_tests(&member) { - println!("Running tests for {}", member_str); + println!("Running tests for {member_str}"); let mut command = std::process::Command::new("wasm-pack"); command.arg("test").args(&wasm_pack_args).arg(&member); - println!("{:?}", command); + println!("{command:?}"); let status = command.status().unwrap(); if !status.success() { panic!("Process for {} failed!{}", member_str, match status.code() { - Some(code) => format!(" Code: {}", code), + Some(code) => format!(" Code: {code}"), None => String::new(), }); } } else { - println!("No wasm tests in {}", member_str); + println!("No wasm tests in {member_str}"); } } } diff --git a/build/enso-formatter/src/lib.rs b/build/enso-formatter/src/lib.rs index f80eadda03..64ca45f8fd 100644 --- a/build/enso-formatter/src/lib.rs +++ b/build/enso-formatter/src/lib.rs @@ -207,7 +207,7 @@ impl HeaderElement { /// Regex constructor that starts on the beginning of a line, can be surrounded by whitespaces and /// ends with a line break. fn header_line_regex(input: &str) -> Regex { - let str = format!(r"^ *{} *(; *)?((\r\n?)|\n)", input); + let str = format!(r"^ *{input} *(; *)?((\r\n?)|\n)"); Regex::new(&str).unwrap() } @@ -274,7 +274,7 @@ fn print_h1( if tokens.iter().any(|tok| map.contains_key(tok)) { writeln!(out).unwrap(); writeln!(out, "// ===={}====", "=".repeat(str.len())).unwrap(); - writeln!(out, "// === {} ===", str).unwrap(); + writeln!(out, "// === {str} ===").unwrap(); writeln!(out, "// ===={}====", "=".repeat(str.len())).unwrap(); writeln!(out).unwrap(); } @@ -290,7 +290,7 @@ fn print_h2( use std::fmt::Write; if tokens.iter().map(|tok| map.contains_key(tok)).any(|t| t) { - writeln!(out, "// === {} ===", str).unwrap() + writeln!(out, "// === {str} ===").unwrap() } } @@ -440,7 +440,7 @@ pub async fn process_file( let (hash, input) = read_file_with_hash(path).await?; let out = process_file_content(input, is_main_file)?; if action == Action::DryRun { - println!("{}", out) + println!("{out}") } else if action == Action::Format || action == Action::FormatAndCheck { fs::write(path, out).await?; } @@ -542,7 +542,7 @@ pub fn process_file_content(input: String, is_main_file: bool) -> Result map.remove(&ModuleAttribWarn); } - let std_linter_attribs = STD_LINTER_ATTRIBS.iter().map(|t| format!("#![{}]\n", t)); + let std_linter_attribs = STD_LINTER_ATTRIBS.iter().map(|t| format!("#![{t}]\n")); map.entry(StandardLinterConfig).or_default().extend(std_linter_attribs); } diff --git a/integration-test/tests/graph_editor.rs b/integration-test/tests/graph_editor.rs index 1a3b95817b..3f8954b268 100644 --- a/integration-test/tests/graph_editor.rs +++ b/integration-test/tests/graph_editor.rs @@ -57,13 +57,11 @@ async fn debug_mode() { let message = expect_popup_message.expect(); assert!( message.contains("Debug Mode enabled"), - "Message \"{}\" does not mention enabling Debug mode", - message + "Message \"{message}\" does not mention enabling Debug mode" ); assert!( message.contains(enso_gui::view::debug_mode_popup::DEBUG_MODE_SHORTCUT), - "Message \"{}\" does not inform about shortcut to turn mode off", - message + "Message \"{message}\" does not inform about shortcut to turn mode off" ); assert!(graph_editor.debug_mode.value()); @@ -75,8 +73,7 @@ async fn debug_mode() { let message = expect_popup_message.expect(); assert!( message.contains("Debug Mode disabled"), - "Message \"{}\" does not mention disabling of debug mode", - message + "Message \"{message}\" does not mention disabling of debug mode" ); assert!(!graph_editor.debug_mode.value()); } diff --git a/lib/rust/automata/src/dfa.rs b/lib/rust/automata/src/dfa.rs index d14ef77681..40db8b9e76 100644 --- a/lib/rust/automata/src/dfa.rs +++ b/lib/rust/automata/src/dfa.rs @@ -75,7 +75,7 @@ impl Dfa { let mut out = String::new(); for row in 0..self.links.rows { - writeln!(out, "node_{}[label=\"{}\"]", row, row)?; + writeln!(out, "node_{row}[label=\"{row}\"]")?; for column in 0..self.links.columns { let state = self.links[(row, column)]; if !state.is_invalid() { @@ -85,7 +85,7 @@ impl Dfa { } let opts = "node [shape=circle style=filled fillcolor=\"#4385f5\" fontcolor=\"#FFFFFF\" \ color=white penwidth=5.0 margin=0.1 width=0.5 height=0.5 fixedsize=true]"; - Ok(format!("digraph G {{\n{}\n{}\n}}\n", opts, out)) + Ok(format!("digraph G {{\n{opts}\n{out}\n}}\n")) } } diff --git a/lib/rust/automata/src/nfa.rs b/lib/rust/automata/src/nfa.rs index 406f7e6acf..5b202e0534 100644 --- a/lib/rust/automata/src/nfa.rs +++ b/lib/rust/automata/src/nfa.rs @@ -249,7 +249,7 @@ impl Nfa { for (ix, state) in self.states.iter().enumerate() { let opts = if state.export { "" } else { "[fillcolor=\"#EEEEEE\" fontcolor=\"#888888\"]" }; - writeln!(out, "node_{}[label=\"{}\"]{}", ix, ix, opts)?; + writeln!(out, "node_{ix}[label=\"{ix}\"]{opts}")?; for link in &state.links { writeln!( out, @@ -265,7 +265,7 @@ impl Nfa { } let opts = "node [shape=circle style=filled fillcolor=\"#4385f5\" fontcolor=\"#FFFFFF\" \ color=white penwidth=5.0 margin=0.1 width=0.5 height=0.5 fixedsize=true]"; - Ok(format!("digraph G {{\n{}\n{}\n}}\n", opts, out)) + Ok(format!("digraph G {{\n{opts}\n{out}\n}}\n")) } } diff --git a/lib/rust/automata/src/state.rs b/lib/rust/automata/src/state.rs index 889d993659..f585aff62f 100644 --- a/lib/rust/automata/src/state.rs +++ b/lib/rust/automata/src/state.rs @@ -69,7 +69,7 @@ impl Default for State { impl Debug for State { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let name = if *self == Self::INVALID { "INVALID".into() } else { format!("{:?}", self.id) }; - write!(f, "State({})", name) + write!(f, "State({name})") } } diff --git a/lib/rust/automata/src/symbol.rs b/lib/rust/automata/src/symbol.rs index b1a526063b..64263ef3aa 100644 --- a/lib/rust/automata/src/symbol.rs +++ b/lib/rust/automata/src/symbol.rs @@ -126,7 +126,7 @@ impl From for Symbol { impl From for Symbol { fn from(ch: char) -> Symbol { - Symbol::new_named(ch as u64, format!("{}", ch)) + Symbol::new_named(ch as u64, format!("{ch}")) } } diff --git a/lib/rust/config-reader/src/lib.rs b/lib/rust/config-reader/src/lib.rs index 69bb6b52cb..8a49b1a98f 100644 --- a/lib/rust/config-reader/src/lib.rs +++ b/lib/rust/config-reader/src/lib.rs @@ -96,12 +96,11 @@ pub fn generate_config_module_from_yaml(config_path: impl AsRef for (key, value) in mapping { let key = key.as_str().unwrap().to_snake_case(); let value = value.as_str().unwrap(); - writeln!(def, "{}pub {}: &'static str,", indent, key).unwrap(); - writeln!(inst, "{}{}: \"{}\",", indent, key, value).unwrap(); + writeln!(def, "{indent}pub {key}: &'static str,").unwrap(); + writeln!(inst, "{indent}{key}: \"{value}\",").unwrap(); writeln!( vars, - "#[allow(non_upper_case_globals)]\npub const {}: &str = \"{}\";", - key, value + "#[allow(non_upper_case_globals)]\npub const {key}: &str = \"{value}\";" ) .unwrap(); }, diff --git a/lib/rust/data-structures/src/hash_map_tree.rs b/lib/rust/data-structures/src/hash_map_tree.rs index 44f0c372f5..9e5a56c994 100644 --- a/lib/rust/data-structures/src/hash_map_tree.rs +++ b/lib/rust/data-structures/src/hash_map_tree.rs @@ -517,7 +517,7 @@ mod tests { tree.set(path.clone(), *val) } let new_tree: HashMapTree<_, _, RandomState> = - tree.iter().map(|(p, v)| (p, format!("{}", v))).collect(); + tree.iter().map(|(p, v)| (p, format!("{v}"))).collect(); for (val, path) in values.iter().zip(&paths) { let path = path.clone(); let output = new_tree.get(path.iter()).unwrap().clone(); diff --git a/lib/rust/data-structures/src/opt_vec.rs b/lib/rust/data-structures/src/opt_vec.rs index 70e3433de1..c70a7b1a6c 100644 --- a/lib/rust/data-structures/src/opt_vec.rs +++ b/lib/rust/data-structures/src/opt_vec.rs @@ -165,14 +165,14 @@ impl OptVec { impl std::ops::Index for OptVec { type Output = T; fn index(&self, index: I) -> &Self::Output { - let error = || panic!("Trying to access removed index `{:?}`.", index); + let error = || panic!("Trying to access removed index `{index:?}`."); self.items.index(index.into()).as_ref().unwrap_or_else(error) } } impl std::ops::IndexMut for OptVec { fn index_mut(&mut self, index: I) -> &mut Self::Output { - let error = || panic!("Trying to access removed index `{:?}`.", index); + let error = || panic!("Trying to access removed index `{index:?}`."); self.items.index_mut(index.into()).as_mut().unwrap_or_else(error) } } diff --git a/lib/rust/ensogl/build.rs b/lib/rust/ensogl/build.rs index fd176ee1c1..91dafff754 100644 --- a/lib/rust/ensogl/build.rs +++ b/lib/rust/ensogl/build.rs @@ -35,7 +35,7 @@ mod huge_text_generator { let offset = hash_from(line_index) % 32; let prefix = (0..offset).map(|_| '|').collect::(); writeln!(file).unwrap(); - write!(file, "{}", prefix).unwrap(); + write!(file, "{prefix}").unwrap(); } } } diff --git a/lib/rust/ensogl/component/label/src/lib.rs b/lib/rust/ensogl/component/label/src/lib.rs index e3294faa3f..67bf50411d 100644 --- a/lib/rust/ensogl/component/label/src/lib.rs +++ b/lib/rust/ensogl/component/label/src/lib.rs @@ -49,7 +49,7 @@ mod background { let radius = &height / 2.0; let base_shape = Rect((&width,&height)).corners_radius(radius); let shape = base_shape.fill(Var::::from(bg_color.clone())); - let alpha = Var::::from(format!("({0}.w)",bg_color)); + let alpha = Var::::from(format!("({bg_color}.w)")); let shadow = shadow::from_shape_with_alpha(base_shape.into(),&alpha,style); (shadow+shape).into() diff --git a/lib/rust/ensogl/component/selector/src/bounds.rs b/lib/rust/ensogl/component/selector/src/bounds.rs index d62503ce4c..b162d42ce3 100644 --- a/lib/rust/ensogl/component/selector/src/bounds.rs +++ b/lib/rust/ensogl/component/selector/src/bounds.rs @@ -276,7 +276,7 @@ mod tests { fn test_value_in_bounds() { let test = |start, end, value, expected| { let result = value_in_bounds(value, Bounds::new(start, end)); - assert_eq!(result, expected, "Testing whether {} in ]{},{}[", value, start, end) + assert_eq!(result, expected, "Testing whether {value} in ]{start},{end}[") }; test(0.0, 1.0, 0.0, true); @@ -303,11 +303,7 @@ mod tests { fn test_bounds_in_bounds() { let test = |start1, end1, start2, end2, expected| { let result = bounds_in_bounds(Bounds::new(start1, start2), Bounds::new(start2, end2)); - assert_eq!( - result, expected, - "Testing whether ]{},{}[ in ]{},{}[", - start1, end1, start2, end2 - ); + assert_eq!(result, expected, "Testing whether ]{start1},{end1}[ in ]{start2},{end2}["); }; test(0.0, 1.0, 0.0, 1.0, true); diff --git a/lib/rust/ensogl/component/selector/src/decimal_aligned.rs b/lib/rust/ensogl/component/selector/src/decimal_aligned.rs index 76a2d350ae..15dd950863 100644 --- a/lib/rust/ensogl/component/selector/src/decimal_aligned.rs +++ b/lib/rust/ensogl/component/selector/src/decimal_aligned.rs @@ -72,7 +72,7 @@ impl Frp { let network = &frp.network; frp::extend! { network - formatted <- frp.set_content.map(|value| format!("{:.2}", value).to_im_string()); + formatted <- frp.set_content.map(|value| format!("{value:.2}").to_im_string()); // FIXME: the next line is locale dependent as it is meant to split on the decimal // separator, which might be different from "." in some locales. We need a way to get // the current locale dependent decimal separator for this. diff --git a/lib/rust/ensogl/component/selector/src/model.rs b/lib/rust/ensogl/component/selector/src/model.rs index 46134e9f66..afbb6d39ee 100644 --- a/lib/rust/ensogl/component/selector/src/model.rs +++ b/lib/rust/ensogl/component/selector/src/model.rs @@ -219,12 +219,12 @@ impl Model { /// Set the label at the left edge of the background to show the given numeric value. pub fn set_left_label_content(&self, value: f32) { - self.label_left.frp.set_content.emit(format!("{:.2}", value)) + self.label_left.frp.set_content.emit(format!("{value:.2}")) } /// Set the label at the right edge of the background to show the given numeric value. pub fn set_right_label_content(&self, value: f32) { - self.label_right.frp.set_content.emit(format!("{:.2}", value)) + self.label_right.frp.set_content.emit(format!("{value:.2}")) } pub fn set_caption_left(&self, caption: Option) { diff --git a/lib/rust/ensogl/component/shadow/src/lib.rs b/lib/rust/ensogl/component/shadow/src/lib.rs index d1b5cbe85f..fd021f4708 100644 --- a/lib/rust/ensogl/component/shadow/src/lib.rs +++ b/lib/rust/ensogl/component/shadow/src/lib.rs @@ -124,7 +124,7 @@ pub fn add_to_dom_element(element: &DomSymbol, style: &StyleWatch) { let alpha = style.get_number(ensogl_hardcoded_theme::shadow::html::alpha); let blur = style.get_number(ensogl_hardcoded_theme::shadow::html::blur); let spread = style.get_number(ensogl_hardcoded_theme::shadow::html::spread); - let shadow = format!("{}px {}px {}px {}px rgba(0,0,0,{})", off_x, off_y, blur, spread, alpha); + let shadow = format!("{off_x}px {off_y}px {blur}px {spread}px rgba(0,0,0,{alpha})"); element.dom().set_style_or_warn("box-shadow", shadow); } diff --git a/lib/rust/ensogl/component/slider/src/lib.rs b/lib/rust/ensogl/component/slider/src/lib.rs index 9758874b79..d783fef95e 100644 --- a/lib/rust/ensogl/component/slider/src/lib.rs +++ b/lib/rust/ensogl/component/slider/src/lib.rs @@ -633,9 +633,7 @@ impl Slider { precision <- output.precision.on_change().gate(&component_drag); model.tooltip.frp.set_style <+ precision.map(|precision| { let prec_text = format!( - "Precision: {:.digits$}", - precision, - digits=MAX_DISP_DECIMAL_PLACES_DEFAULT + "Precision: {precision:.MAX_DISP_DECIMAL_PLACES_DEFAULT$}", ); let prec_text = prec_text.trim_end_matches('0'); let prec_text = prec_text.trim_end_matches('.'); @@ -674,7 +672,7 @@ impl Slider { ); tooltip_show <- input.set_tooltip.sample(&tooltip_anim.on_end); model.tooltip.frp.set_style <+ tooltip_show.map(|tooltip| { - tooltip::Style::set_label(format!("{}", tooltip)) + tooltip::Style::set_label(format!("{tooltip}")) }); model.tooltip.frp.set_style <+ tooltip_anim.on_reset.map(|_| tooltip::Style::unset_label() @@ -898,9 +896,9 @@ fn value_text_truncate((value, precision, max_digits): &(f32, f32, usize)) -> St if *precision < 1.0 || *max_digits == 0 { let digits = (-precision.log10()).ceil() as usize; let digits = digits.min(*max_digits); - format!("{:.prec$}", value, prec = digits) + format!("{value:.digits$}") } else { - format!("{:.0}", value) + format!("{value:.0}") } } diff --git a/lib/rust/ensogl/component/text/src/font/embedded/build.rs b/lib/rust/ensogl/component/text/src/font/embedded/build.rs index 2d58351099..65e5fe0d12 100644 --- a/lib/rust/ensogl/component/text/src/font/embedded/build.rs +++ b/lib/rust/ensogl/component/text/src/font/embedded/build.rs @@ -44,8 +44,8 @@ impl CodeGenerator { fn add_variable_font_definition(&mut self, family: &str, file: &str) { let key = format!("\"{family}\".into()"); let family_def = format!("family::VariableDefinition::new(\"{file}\")"); - let value = format!("family::Definition::Variable({})", family_def); - ln!(1, &mut self.definitions, "map.insert({},{});", key, value); + let value = format!("family::Definition::Variable({family_def})"); + ln!(1, &mut self.definitions, "map.insert({key},{value});"); } fn add_non_variable_font_definition(&mut self, family_name: &str, def: &str) { @@ -99,7 +99,7 @@ mod deja_vu { let archive_file = ide_ci::fs::open(package_path)?; let mut archive = zip::ZipArchive::new(archive_file).unwrap(); for file_name in FILE_NAMES { - let font_in_package_path = format!("{}/{}", PACKAGE_FONTS_PREFIX, file_name); + let font_in_package_path = format!("{PACKAGE_FONTS_PREFIX}/{file_name}"); let mut input_stream = archive.by_name(&font_in_package_path).with_context(|| { format!( "Cannot find font file {} in the package {}", diff --git a/lib/rust/ensogl/core/src/data/color/space/def.rs b/lib/rust/ensogl/core/src/data/color/space/def.rs index fcf8f6b00c..41c9c0c52e 100644 --- a/lib/rust/ensogl/core/src/data/color/space/def.rs +++ b/lib/rust/ensogl/core/src/data/color/space/def.rs @@ -444,7 +444,7 @@ impl Rgb { let red = (self.red * 255.0).round() as i32; let green = (self.green * 255.0).round() as i32; let blue = (self.blue * 255.0).round() as i32; - format!("rgb({},{},{})", red, green, blue) + format!("rgb({red},{green},{blue})") } } diff --git a/lib/rust/ensogl/core/src/display/scene/dom.rs b/lib/rust/ensogl/core/src/display/scene/dom.rs index d626476f9b..ec49d5e0a7 100644 --- a/lib/rust/ensogl/core/src/display/scene/dom.rs +++ b/lib/rust/ensogl/core/src/display/scene/dom.rs @@ -204,7 +204,7 @@ impl DomScene { /// Sets the CSS property `filter: grayscale({value})` on this element. A value of 0.0 displays /// the element normally. A value of 1.0 will make the element completely gray. pub fn filter_grayscale(&self, value: f32) { - self.data.dom.set_style_or_warn("filter", format!("grayscale({})", value)); + self.data.dom.set_style_or_warn("filter", format!("grayscale({value})")); } /// Creates a new instance of DomSymbol and adds it to parent. diff --git a/lib/rust/ensogl/core/src/display/scene/pointer_target.rs b/lib/rust/ensogl/core/src/display/scene/pointer_target.rs index b9d13bab94..3ae47045dd 100644 --- a/lib/rust/ensogl/core/src/display/scene/pointer_target.rs +++ b/lib/rust/ensogl/core/src/display/scene/pointer_target.rs @@ -228,7 +228,7 @@ impl Display for DecodeError { Self::WrongAlpha(alpha) => { let err1 = "Failed to decode mouse target."; let err2 = "The alpha channel should be either 0 or 255, got"; - write!(f, "{} {} {}.", err1, err2, alpha) + write!(f, "{err1} {err2} {alpha}.") } Self::Overflow => { write!(f, "ID overflow error, too many objects on the scene.") diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs b/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs index 65abcb6f3b..71b6825653 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/def/var.rs @@ -158,7 +158,7 @@ where T: Abs fn abs(&self) -> Self { match self { Self::Static(t) => Var::Static(t.abs()), - Self::Dynamic(t) => Var::Dynamic(format!("abs({})", t).into()), + Self::Dynamic(t) => Var::Dynamic(format!("abs({t})").into()), } } } @@ -536,7 +536,7 @@ where T: Sin fn sin(&self) -> Self { match self { Self::Static(t) => Var::Static(t.sin()), - Self::Dynamic(t) => Var::Dynamic(format!("sin({})", t).into()), + Self::Dynamic(t) => Var::Dynamic(format!("sin({t})").into()), } } } @@ -548,7 +548,7 @@ where T: Asin fn asin(&self) -> Self { match self { Self::Static(t) => Var::Static(t.asin()), - Self::Dynamic(t) => Var::Dynamic(format!("asin({})", t).into()), + Self::Dynamic(t) => Var::Dynamic(format!("asin({t})").into()), } } } @@ -561,7 +561,7 @@ where T: Cos fn cos(&self) -> Self { match self { Self::Static(t) => Var::Static(t.cos()), - Self::Dynamic(t) => Var::Dynamic(format!("cos({})", t).into()), + Self::Dynamic(t) => Var::Dynamic(format!("cos({t})").into()), } } } @@ -573,7 +573,7 @@ where T: Acos fn acos(&self) -> Self { match self { Self::Static(t) => Var::Static(t.acos()), - Self::Dynamic(t) => Var::Dynamic(format!("acos({})", t).into()), + Self::Dynamic(t) => Var::Dynamic(format!("acos({t})").into()), } } } @@ -591,7 +591,7 @@ where T: Sqrt fn sqrt(&self) -> Self { match self { Self::Static(t) => Var::Static(t.sqrt()), - Self::Dynamic(t) => Var::Dynamic(format!("sqrt({})", t).into()), + Self::Dynamic(t) => Var::Dynamic(format!("sqrt({t})").into()), } } } @@ -635,7 +635,7 @@ where T: Signum fn signum(self) -> Self { match self { Self::Static(t) => Var::Static(t.signum()), - Self::Dynamic(t) => Var::Dynamic(format!("sign({})", t).into()), + Self::Dynamic(t) => Var::Dynamic(format!("sign({t})").into()), } } } @@ -705,7 +705,7 @@ impl From>> for Var { fn from(other: Var>) -> Self { match other { Var::Static(t) => Var::Static(color::Rgba::new(t.x, t.y, t.z, t.w)), - Var::Dynamic(t) => Var::Dynamic(format!("srgba({0}.x,{0}.y,{0}.z,{0}.w)", t).into()), + Var::Dynamic(t) => Var::Dynamic(format!("srgba({t}.x,{t}.y,{t}.z,{t}.w)").into()), } } } @@ -719,7 +719,7 @@ impl Var { (t, alpha) => { let t = t.glsl(); let alpha = alpha.glsl(); - let var = format!("srgba({0}.raw.x,{0}.raw.y,{0}.raw.z,{1})", t, alpha); + let var = format!("srgba({t}.raw.x,{t}.raw.y,{t}.raw.z,{alpha})"); Var::Dynamic(var.into()) } } @@ -737,7 +737,7 @@ impl Var { (t, alpha) => { let t = t.glsl(); let alpha = alpha.glsl(); - let var = format!("srgba({0}.raw.x,{0}.raw.y,{0}.raw.z,{0}.raw.w*{1})", t, alpha); + let var = format!("srgba({t}.raw.x,{t}.raw.y,{t}.raw.z,{t}.raw.w*{alpha})"); Var::Dynamic(var.into()) } } diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/glsl/codes.rs b/lib/rust/ensogl/core/src/display/shape/primitive/glsl/codes.rs index 5330a7c010..6f627ab309 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/glsl/codes.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/glsl/codes.rs @@ -49,7 +49,7 @@ impl DisplayModes { /// Name of the code. pub fn name(self) -> String { - format!("display_mode_{:?}", self).to_snake_case() + format!("display_mode_{self:?}").to_snake_case() } /// Check if the display mode allows mouse interactions in GUI. The display modes that do not diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs b/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs index ca9ba00074..e746596831 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/shader/builder.rs @@ -47,10 +47,8 @@ impl Builder { canvas.submit_shape_constructor("run"); let shape_def = overload::allow_overloading(&canvas.to_glsl()); let code = [GLSL_BOILERPLATE.as_str(), "", &shape_header, &shape_def].join("\n\n"); - let main = format!( - "bool pointer_events_enabled = {};\n{}", - pointer_events_enabled, FRAGMENT_RUNNER - ); + let main = + format!("bool pointer_events_enabled = {pointer_events_enabled};\n{FRAGMENT_RUNNER}"); CodeTemplate::new(code, main, "") } @@ -83,13 +81,13 @@ fn glsl_codes() -> String { .join("\n"); let error_codes = format!("const int ID_ENCODING_OVERFLOW_ERROR = {};", codes::ID_ENCODING_OVERFLOW_ERROR); - format!("{}\n\n{}\n{}", header, display_modes, error_codes) + format!("{header}\n\n{display_modes}\n{error_codes}") } /// The GLSL common code and debug codes. pub fn glsl_prelude_and_codes() -> String { let codes = glsl_codes(); - format!("{}\n\n{}", GLSL_PRELUDE, codes) + format!("{GLSL_PRELUDE}\n\n{codes}") } fn gen_glsl_boilerplate() -> String { diff --git a/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs b/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs index 821c13bf82..2ce487f928 100644 --- a/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs +++ b/lib/rust/ensogl/core/src/display/shape/primitive/shader/canvas.rs @@ -43,7 +43,7 @@ pub struct ShapeData { impl ShapeData { /// Constructor. pub fn new(shape_id: usize) -> Self { - let name = format!("shape_{}", shape_id); + let name = format!("shape_{shape_id}"); Self { name } } diff --git a/lib/rust/ensogl/core/src/display/style/data.rs b/lib/rust/ensogl/core/src/display/style/data.rs index 59328a120e..e82bb86990 100644 --- a/lib/rust/ensogl/core/src/display/style/data.rs +++ b/lib/rust/ensogl/core/src/display/style/data.rs @@ -96,10 +96,10 @@ impl From<&str> for Data { impl Display for Data { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Invalid(s) => write!(f, "{}", s), - Self::Number(t) => write!(f, "Number({})", t), - Self::Color(t) => write!(f, "Color({:?})", t), - Self::Text(t) => write!(f, "Text({:?})", t), + Self::Invalid(s) => write!(f, "{s}"), + Self::Number(t) => write!(f, "Number({t})"), + Self::Color(t) => write!(f, "Color({t:?})"), + Self::Text(t) => write!(f, "Text({t:?})"), } } } @@ -177,13 +177,10 @@ macro_rules! _define_binary_number_operator { }; } -define_binary_number_operator!(Mul::mul, |lhs, rhs| format!("Cannot multiply {} by {}.", lhs, rhs)); -define_binary_number_operator!(Div::div, |lhs, rhs| format!("Cannot divide {} by {}.", lhs, rhs)); -define_binary_number_operator!(Add::add, |lhs, rhs| format!("Cannot add {} to {}.", lhs, rhs)); -define_binary_number_operator!(Sub::sub, |lhs, rhs| format!( - "Cannot subtract {} from {}.", - rhs, lhs -)); +define_binary_number_operator!(Mul::mul, |lhs, rhs| format!("Cannot multiply {lhs} by {rhs}.")); +define_binary_number_operator!(Div::div, |lhs, rhs| format!("Cannot divide {lhs} by {rhs}.")); +define_binary_number_operator!(Add::add, |lhs, rhs| format!("Cannot add {lhs} to {rhs}.")); +define_binary_number_operator!(Sub::sub, |lhs, rhs| format!("Cannot subtract {rhs} from {lhs}.")); diff --git a/lib/rust/ensogl/core/src/display/style/sheet.rs b/lib/rust/ensogl/core/src/display/style/sheet.rs index 466e180841..32f7468d08 100644 --- a/lib/rust/ensogl/core/src/display/style/sheet.rs +++ b/lib/rust/ensogl/core/src/display/style/sheet.rs @@ -694,7 +694,7 @@ impl SheetData { } } } - format!("digraph G {{\nnode [shape=box style=rounded]\n{}\n}}", dot) + format!("digraph G {{\nnode [shape=box style=rounded]\n{dot}\n}}") } fn sheet_node_map_to_graphviz(&self, dot: &mut String, node_map: &NodeMap) { diff --git a/lib/rust/ensogl/core/src/display/style/theme.rs b/lib/rust/ensogl/core/src/display/style/theme.rs index 2c4ee5b306..b0a538e84e 100644 --- a/lib/rust/ensogl/core/src/display/style/theme.rs +++ b/lib/rust/ensogl/core/src/display/style/theme.rs @@ -61,7 +61,7 @@ impl Theme { E: Into, { let path = path.into(); let value = value.into(); - self.tree.borrow_mut().set(&path.rev_segments, Some(value)); + self.tree.borrow_mut().set(path.rev_segments, Some(value)); self.on_mut.run_all(); } @@ -304,7 +304,7 @@ impl Manager { if self.enabled_dirty.check_all() { self.current_dirty.take(); let names = self.enabled_dirty.take().vec; - self.data.borrow_mut().set_enabled(&names); + self.data.borrow_mut().set_enabled(names); } else if self.current_dirty.take().check() { self.data.borrow_mut().refresh() } diff --git a/lib/rust/ensogl/core/src/display/symbol/gpu.rs b/lib/rust/ensogl/core/src/display/symbol/gpu.rs index c1c9786cc5..06c8babf7a 100644 --- a/lib/rust/ensogl/core/src/display/symbol/gpu.rs +++ b/lib/rust/ensogl/core/src/display/symbol/gpu.rs @@ -712,9 +712,8 @@ impl SymbolData { Some(ScopeType::Global) => global_variables.get(name), _ => todo!(), }; - let uniform = uniform.unwrap_or_else(|| { - panic!("Internal error. Variable {} not found in program.", name) - }); + let uniform = uniform + .unwrap_or_else(|| panic!("Internal error. Variable {name} not found in program.")); match uniform { AnyUniform::Prim(uniform) => self .bindings diff --git a/lib/rust/ensogl/core/src/system/gpu/context/native.rs b/lib/rust/ensogl/core/src/system/gpu/context/native.rs index d9cb1b680e..6ec3be509b 100644 --- a/lib/rust/ensogl/core/src/system/gpu/context/native.rs +++ b/lib/rust/ensogl/core/src/system/gpu/context/native.rs @@ -129,11 +129,11 @@ impl BlockingGetErrorLog for WebGl2RenderingContext { let preview_line_start = std::cmp::max(0, line_num.saturating_sub(preview_radius)); let preview_line_end = std::cmp::min(lines_num, line_num + preview_radius); let preview = lines_with_num[preview_line_start..preview_line_end].join("\n"); - format!("...\n{}\n...", preview) + format!("...\n{preview}\n...") } else { code_with_num }; - format!("{}\n{}", message, preview_code) + format!("{message}\n{preview_code}") }) } } diff --git a/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs b/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs index 43ed65af31..acc0c6cd36 100644 --- a/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs +++ b/lib/rust/ensogl/core/src/system/gpu/shader/compiler.rs @@ -693,8 +693,8 @@ impl Error { Self::ProgramCreationError => "WebGl was unable to create a new program shader.".into(), Self::ProgramLinkingError(shader) => { let unwrap_error = |name: &str, err: Option| { - let header = format!("----- {} Shader -----", name); - err.map(|t| format!("\n\n{}\n\n{}", header, t)).unwrap_or_else(|| "".into()) + let header = format!("----- {name} Shader -----"); + err.map(|t| format!("\n\n{header}\n\n{t}")).unwrap_or_else(|| "".into()) }; let vertex = &shader.vertex; @@ -709,7 +709,7 @@ impl Error { let dbg_object = web::Reflect::get_nested_object_or_create(&web::window, dbg_path); let dbg_object = dbg_object.unwrap(); let dbg_shaders_count = web::Object::keys(&dbg_object).length(); - let dbg_var_name = format!("shader_{}", dbg_shaders_count); + let dbg_var_name = format!("shader_{dbg_shaders_count}"); let dbg_shader_object = web::Object::new(); let vertex_code = vertex.code.to_string().into(); let fragment_code = fragment.code.to_string().into(); @@ -718,16 +718,12 @@ impl Error { web::Reflect::set(&dbg_shader_object, &"fragment".into(), &fragment_code).ok(); let dbg_js_path = format!("window.{}.{}", dbg_path.join("."), dbg_var_name); - let run_msg = |n| { - format!("Run `console.log({}.{})` to inspect the {} shader.", dbg_js_path, n, n) - }; + let run_msg = + |n| format!("Run `console.log({dbg_js_path}.{n})` to inspect the {n} shader."); let dbg_msg = format!("{}\n{}", run_msg("vertex"), run_msg("fragment")); - format!( - "Unable to compile shader.\n{}\n{}{}", - dbg_msg, vertex_error, fragment_error - ) + format!("Unable to compile shader.\n{dbg_msg}\n{vertex_error}{fragment_error}") } } } diff --git a/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs b/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs index 1e67e62f2f..0f480ab477 100644 --- a/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs +++ b/lib/rust/ensogl/core/src/system/gpu/shader/glsl.rs @@ -803,7 +803,7 @@ impl Display for Precision { Self::Medium => "mediump", Self::High => "highp", }; - write!(f, "{}", prec) + write!(f, "{prec}") } } diff --git a/lib/rust/ensogl/pack/src/lib.rs b/lib/rust/ensogl/pack/src/lib.rs index 12cc3f157b..4b993ce9eb 100644 --- a/lib/rust/ensogl/pack/src/lib.rs +++ b/lib/rust/ensogl/pack/src/lib.rs @@ -509,7 +509,7 @@ fn extract_main_shader_code(code: &str) -> Result { .collect(); let declarations = declarations.join("\n"); let main_content = &code[main_start + main_start_str.len()..main_end]; - Ok(format!("{}\n{}", declarations, main_content)) + Ok(format!("{declarations}\n{main_content}")) } /// Wrapper over `wasm-pack build` command. diff --git a/lib/rust/frp/src/debug.rs b/lib/rust/frp/src/debug.rs index 48c9a1f52b..427011a940 100644 --- a/lib/rust/frp/src/debug.rs +++ b/lib/rust/frp/src/debug.rs @@ -176,7 +176,7 @@ pub trait GraphvizBuilder { fn display_graphviz(&self) { let code = self.to_graphviz(); let url = percent_encoding::utf8_percent_encode(&code, percent_encoding::NON_ALPHANUMERIC); - let url = format!("https://dreampuf.github.io/GraphvizOnline/#{}", url); + let url = format!("https://dreampuf.github.io/GraphvizOnline/#{url}"); crate::web::window.open_with_url_and_target(&url, "_blank").unwrap(); } } @@ -184,7 +184,7 @@ pub trait GraphvizBuilder { pub fn display_graphviz(viz: Graphviz) { let code: String = viz.into(); let url = percent_encoding::utf8_percent_encode(&code, percent_encoding::NON_ALPHANUMERIC); - let url = format!("https://dreampuf.github.io/GraphvizOnline/#{}", url); + let url = format!("https://dreampuf.github.io/GraphvizOnline/#{url}"); crate::web::window.open_with_url_and_target(&url, "_blank").unwrap(); } diff --git a/lib/rust/json-rpc/src/messages.rs b/lib/rust/json-rpc/src/messages.rs index a31a10a20a..553c47adbe 100644 --- a/lib/rust/json-rpc/src/messages.rs +++ b/lib/rust/json-rpc/src/messages.rs @@ -263,7 +263,7 @@ mod tests { fn expect_field<'a, Obj: 'a>(obj: &'a Map, field_name: &str) -> &'a Value where &'a Obj: Into<&'a Value> { - let missing_msg = format!("missing field {}", field_name); + let missing_msg = format!("missing field {field_name}"); obj.get(field_name).expect(&missing_msg) } @@ -360,7 +360,7 @@ mod tests { assert_eq!(message, "Service error"); assert!(data.is_none()); } - _ => panic!("Invalid decoding result of {}: {:?}", text, decoding_result), + _ => panic!("Invalid decoding result of {text}: {decoding_result:?}"), } } } diff --git a/lib/rust/json-rpc/tests/test.rs b/lib/rust/json-rpc/tests/test.rs index f171ed7c8b..ab87a563f1 100644 --- a/lib/rust/json-rpc/tests/test.rs +++ b/lib/rust/json-rpc/tests/test.rs @@ -109,7 +109,7 @@ impl Client { if let MockEvent::Notification(notification) = event { notification } else { - panic!("Expected a notification, got different kind of event: {:?}", event) + panic!("Expected a notification, got different kind of event: {event:?}") } } @@ -118,7 +118,7 @@ impl Client { if let json_rpc::handler::Event::Error(err) = event { err } else { - panic!("Expected an error event, got different kind of event: {:?}", event) + panic!("Expected an error event, got different kind of event: {event:?}") } } } diff --git a/lib/rust/launcher-shims/src/lib.rs b/lib/rust/launcher-shims/src/lib.rs index 419d1768f9..aae60c96bd 100644 --- a/lib/rust/launcher-shims/src/lib.rs +++ b/lib/rust/launcher-shims/src/lib.rs @@ -68,7 +68,7 @@ pub fn wrap_launcher(version: impl AsRef) { exit(1) }, Err(error) => { - eprintln!("{}", error); + eprintln!("{error}"); exit(1) } }; diff --git a/lib/rust/logging/macros/build.rs b/lib/rust/logging/macros/build.rs index 558f100e1f..ac34acf59f 100644 --- a/lib/rust/logging/macros/build.rs +++ b/lib/rust/logging/macros/build.rs @@ -21,8 +21,8 @@ fn main() { /// Make cargo aware that the result of compiling this crate depends on an environment variable. fn declare_env_dependence(env: &str) { - println!("cargo:rerun-if-env-changed={}", env); + println!("cargo:rerun-if-env-changed={env}"); // This is a no-op assignment, except it makes cargo aware that the output depends on the env. let value = std::env::var(env).unwrap_or_default(); - println!("cargo:rustc-env={}={}", env, value); + println!("cargo:rustc-env={env}={value}"); } diff --git a/lib/rust/metamodel/lexpr/src/lib.rs b/lib/rust/metamodel/lexpr/src/lib.rs index 903001bf93..0bcd9d2e73 100644 --- a/lib/rust/metamodel/lexpr/src/lib.rs +++ b/lib/rust/metamodel/lexpr/src/lib.rs @@ -106,7 +106,7 @@ impl<'g> ToSExpr<'g> { let data = bincoder.serialize(input).unwrap(); let mut data = &data[..]; let value = self.value_(id, &mut data); - assert_eq!(data, &[0; 0], "{}", value); + assert_eq!(data, &[0; 0], "{value}"); value } } diff --git a/lib/rust/metamodel/src/graphviz.rs b/lib/rust/metamodel/src/graphviz.rs index 681119ebc1..c75547d2d1 100644 --- a/lib/rust/metamodel/src/graphviz.rs +++ b/lib/rust/metamodel/src/graphviz.rs @@ -58,7 +58,7 @@ impl std::fmt::Display for Graph { ]; let variant_attrs = vec![ format!("style=filled"), - format!("fillcolor={:?}", variant_color), + format!("fillcolor={variant_color:?}"), format!("shape=oval"), ]; let struct_attrs = vec![ @@ -71,7 +71,7 @@ impl std::fmt::Display for Graph { format!("fillcolor={:?}", "#6D1321"), format!("fontcolor={:?}", "white"), ]; - let variant_edge_attrs = vec![format!("color={:?}", variant_color)]; + let variant_edge_attrs = vec![format!("color={variant_color:?}")]; let field_edge_attrs = vec![]; let optional_field_edge_attrs = vec![format!("style=dashed")]; let subtype_edge_attrs = vec![format!("arrowhead=dot")]; @@ -101,7 +101,7 @@ impl std::fmt::Display for Graph { NodeType::Struct => "box", NodeType::AbstractStruct => "diamond", }; - attrs.push(format!("shape={}", shape)); + attrs.push(format!("shape={shape}")); writeln!(f, "{:?} [{}];", id, attrs.join(","))?; } for (x, y, edgetype) in &self.edges { diff --git a/lib/rust/metamodel/src/java/bincode.rs b/lib/rust/metamodel/src/java/bincode.rs index 5a89c2dfd9..879ca5f235 100644 --- a/lib/rust/metamodel/src/java/bincode.rs +++ b/lib/rust/metamodel/src/java/bincode.rs @@ -218,9 +218,9 @@ impl DeserializerBuilder { } value } - FieldData::Primitive(Primitive::Int { .. }) => format!("{}.get32()", message), - FieldData::Primitive(Primitive::Long { .. }) => format!("{}.get64()", message), - FieldData::Primitive(Primitive::Bool) => format!("{}.getBoolean()", message), + FieldData::Primitive(Primitive::Int { .. }) => format!("{message}.get32()"), + FieldData::Primitive(Primitive::Long { .. }) => format!("{message}.get64()"), + FieldData::Primitive(Primitive::Bool) => format!("{message}.getBoolean()"), } }; let expr = match self.mappers.remove(&field.id()) { diff --git a/lib/rust/metamodel/src/java/implementation.rs b/lib/rust/metamodel/src/java/implementation.rs index 4e8a5828b9..fdea1f6d8b 100644 --- a/lib/rust/metamodel/src/java/implementation.rs +++ b/lib/rust/metamodel/src/java/implementation.rs @@ -229,7 +229,7 @@ fn implement_hash_code(graph: &TypeGraph, class: &Class) -> syntax::Method { let fields: Vec<_> = class_fields(graph, class).into_iter().map(|field| field.name.as_str()).collect(); let fields = fields.join(", "); - let body = format!("return java.util.Objects.hash({});", fields); + let body = format!("return java.util.Objects.hash({fields});"); let return_ = FieldData::Primitive(Primitive::Int { unsigned: false }); let return_ = quote_type(graph, &return_); let mut method = syntax::Method::new("hashCode", return_); @@ -262,7 +262,7 @@ fn implement_equals(graph: &TypeGraph, class: &Class) -> syntax::Method { format!("if ({} == this) return true;", &object), format!("if (!({} instanceof {})) return false;", &object, &class.name), format!("{} {} = ({}){};", &class.name, &that, &class.name, &object), - format!("return {};", expr), + format!("return {expr};"), ]; let return_ = FieldData::Primitive(Primitive::Bool); let return_ = quote_type(graph, &return_); diff --git a/lib/rust/metamodel/src/java/mod.rs b/lib/rust/metamodel/src/java/mod.rs index 5fa765051c..737a0ecb66 100644 --- a/lib/rust/metamodel/src/java/mod.rs +++ b/lib/rust/metamodel/src/java/mod.rs @@ -226,8 +226,8 @@ pub enum FieldData { impl FieldData { fn fmt_equals(&self, a: &str, b: &str) -> String { match self { - FieldData::Object { .. } => format!("{}.equals({})", a, b), - FieldData::Primitive(_) => format!("({} == {})", a, b), + FieldData::Object { .. } => format!("{a}.equals({b})"), + FieldData::Primitive(_) => format!("({a} == {b})"), } } } diff --git a/lib/rust/metamodel/src/java/syntax.rs b/lib/rust/metamodel/src/java/syntax.rs index 547039e90e..ad35d2d3af 100644 --- a/lib/rust/metamodel/src/java/syntax.rs +++ b/lib/rust/metamodel/src/java/syntax.rs @@ -164,7 +164,7 @@ impl fmt::Display for Class { sealed, } = &self; if let Some(package) = package { - writeln!(f, "package {};", package)?; + writeln!(f, "package {package};")?; } let mut modifiers = vec!["public".to_string()]; static_.then(|| modifiers.push("static".to_string())); @@ -187,15 +187,15 @@ impl fmt::Display for Class { } } let tokens = tokens.join(" "); - writeln!(f, "{} {{", tokens)?; + writeln!(f, "{tokens} {{")?; for field in fields { - write!(f, "{}", field)?; + write!(f, "{field}")?; } for method in methods { - write!(f, "{}", method)?; + write!(f, "{method}")?; } for class in nested { - write!(f, "{}", class)?; + write!(f, "{class}")?; } writeln!(f, "}}")?; Ok(()) @@ -210,7 +210,7 @@ impl fmt::Display for Field { tokens.push(type_.to_string()); tokens.push(name.clone()); let tokens = tokens.join(" "); - writeln!(f, "{};", tokens) + writeln!(f, "{tokens};") } } @@ -249,10 +249,9 @@ impl fmt::Display for Method { } tokens.push(name.to_string()); let tokens = tokens.join(" "); - let arguments: Vec<_> = - arguments.iter().map(|(ty, name)| format!("{} {}", ty, name)).collect(); + let arguments: Vec<_> = arguments.iter().map(|(ty, name)| format!("{ty} {name}")).collect(); let arguments = arguments.join(", "); - writeln!(f, "{}({})", tokens, arguments)?; + writeln!(f, "{tokens}({arguments})")?; if !throws.is_empty() { let types: Vec<_> = throws.iter().map(|ty| ty.to_string()).collect(); let types = types.join(", "); diff --git a/lib/rust/metamodel/src/meta/serialization.rs b/lib/rust/metamodel/src/meta/serialization.rs index ff3da1f160..0e4e3e34e5 100644 --- a/lib/rust/metamodel/src/meta/serialization.rs +++ b/lib/rust/metamodel/src/meta/serialization.rs @@ -92,9 +92,9 @@ pub fn testcases(graph: &TypeGraph, root: TypeId) -> TestCases { impl TestCases { /// Produce a JSON representation of test case data. pub fn to_json(&self) -> String { - let accept: Vec<_> = self.accept.iter().map(|case| format!("{:?}", case)).collect(); + let accept: Vec<_> = self.accept.iter().map(|case| format!("{case:?}")).collect(); let accept = accept.join(", \n\t"); - let reject: Vec<_> = self.reject.iter().map(|case| format!("{:?}", case)).collect(); + let reject: Vec<_> = self.reject.iter().map(|case| format!("{case:?}")).collect(); let reject = reject.join(", \n\t"); let mut out = String::new(); writeln!(out, "{{").unwrap(); @@ -124,16 +124,16 @@ fn fmt_program(program: &[Op], debuginfo: &BTreeMap) -> String { if *op == Op::SwitchPop { indent -= 1 } - write!(out, "{:>4}: ", i).unwrap(); + write!(out, "{i:>4}: ").unwrap(); for _ in 0..indent { write!(out, " ").unwrap(); } - write!(out, "{:?}", op).unwrap(); + write!(out, "{op:?}").unwrap(); if let Some(debuginfo) = debuginfo.get(&i) { - write!(out, " -- {}", debuginfo).unwrap(); + write!(out, " -- {debuginfo}").unwrap(); } if let Some(continuation) = continuations.get(&i) { - write!(out, " [{}]", continuation).unwrap(); + write!(out, " [{continuation}]").unwrap(); } if *op == Op::Case(Case::Accept) { write!(out, " # accept{accept}").unwrap(); @@ -624,7 +624,7 @@ impl<'p> Interpreter<'p> { } return pc; } - Op::Case(Case::Reject) => panic!("Rejected base case at {}.", pc), + Op::Case(Case::Reject) => panic!("Rejected base case at {pc}."), } pc += 1; } diff --git a/lib/rust/parser/debug/src/main.rs b/lib/rust/parser/debug/src/main.rs index 8ad50177d3..6828323afd 100644 --- a/lib/rust/parser/debug/src/main.rs +++ b/lib/rust/parser/debug/src/main.rs @@ -41,8 +41,8 @@ fn check_file(path: &str, mut code: &str) { } let ast = enso_parser::Parser::new().run(code); for (parsed, original) in ast.code().lines().zip(code.lines()) { - assert_eq!(parsed, original, "Bug: dropped tokens, while parsing: {}", path); + assert_eq!(parsed, original, "Bug: dropped tokens, while parsing: {path}"); } let s_expr = enso_parser_debug::to_s_expr(&ast, code); - println!("{}", s_expr); + println!("{s_expr}"); } diff --git a/lib/rust/parser/generate-java/src/bin/graph-java.rs b/lib/rust/parser/generate-java/src/bin/graph-java.rs index 9f0ce46697..74d64b4831 100644 --- a/lib/rust/parser/generate-java/src/bin/graph-java.rs +++ b/lib/rust/parser/generate-java/src/bin/graph-java.rs @@ -28,5 +28,5 @@ fn main() { let (graph, _) = java::from_meta(&graph, enso_parser_generate_java::EITHER_TYPE); let graph = java::transform::optional_to_null(graph); let rendered = graphviz::Graph::from(&graph); - println!("{}", rendered); + println!("{rendered}"); } diff --git a/lib/rust/parser/generate-java/src/bin/graph-meta.rs b/lib/rust/parser/generate-java/src/bin/graph-meta.rs index 8b89694253..c3546718d2 100644 --- a/lib/rust/parser/generate-java/src/bin/graph-meta.rs +++ b/lib/rust/parser/generate-java/src/bin/graph-meta.rs @@ -23,5 +23,5 @@ use enso_reflect::Reflect; fn main() { let (graph, _) = enso_metamodel::rust::to_meta(enso_parser::syntax::Tree::reflect()); let rendered = enso_metamodel::graphviz::Graph::from(&graph); - println!("{}", rendered); + println!("{rendered}"); } diff --git a/lib/rust/parser/generate-java/src/bin/graph-rust.rs b/lib/rust/parser/generate-java/src/bin/graph-rust.rs index 7151c1213c..baead635c8 100644 --- a/lib/rust/parser/generate-java/src/bin/graph-rust.rs +++ b/lib/rust/parser/generate-java/src/bin/graph-rust.rs @@ -20,5 +20,5 @@ fn main() { let rendered = enso_reflect::graph::(); - println!("{}", rendered); + println!("{rendered}"); } diff --git a/lib/rust/parser/src/lexer.rs b/lib/rust/parser/src/lexer.rs index 59b536a97a..00c8b9ae1b 100644 --- a/lib/rust/parser/src/lexer.rs +++ b/lib/rust/parser/src/lexer.rs @@ -385,7 +385,7 @@ pub fn is_newline_char(t: char) -> bool { /// Check whether the provided character is a decimal digit. #[inline(always)] fn is_decimal_digit(t: char) -> bool { - ('0'..='9').contains(&t) + t.is_ascii_digit() } /// Check whether the provided character is a binary digit. @@ -900,8 +900,7 @@ impl<'s> Lexer<'s> { text_type: TextType, ) { let open_quote_end = self.mark(); - let token = - self.make_token(open_quote_start, open_quote_end.clone(), token::Variant::text_start()); + let token = self.make_token(open_quote_start, open_quote_end, token::Variant::text_start()); self.output.push(token); let mut initial_indent = None; if text_type.expects_initial_newline() && let Some(newline) = self.line_break() { @@ -1049,7 +1048,7 @@ impl<'s> Lexer<'s> { let splice_quote_end = self.mark(); let token = self.make_token( splice_quote_start, - splice_quote_end.clone(), + splice_quote_end, token::Variant::open_symbol(), ); self.output.push(token); @@ -1516,7 +1515,7 @@ mod tests { "a'b''", ])); for zero_space in UNICODE_ZERO_SPACES.chars() { - let var = format!("pre{}post", zero_space); + let var = format!("pre{zero_space}post"); test_lexer(&var, vec![ident_("", &var)]) } } diff --git a/lib/rust/parser/src/lib.rs b/lib/rust/parser/src/lib.rs index d36c2953fa..305dce799f 100644 --- a/lib/rust/parser/src/lib.rs +++ b/lib/rust/parser/src/lib.rs @@ -188,7 +188,7 @@ impl Parser { let result = tokens.map(|tokens| resolver.run(&self.macros, tokens)); let value = result.value; if let Some(error) = result.internal_error { - return value.with_error(format!("Internal error: {}", error)); + return value.with_error(format!("Internal error: {error}")); } value } diff --git a/lib/rust/parser/src/main.rs b/lib/rust/parser/src/main.rs index 11521fbbaa..a758033f7d 100644 --- a/lib/rust/parser/src/main.rs +++ b/lib/rust/parser/src/main.rs @@ -94,6 +94,6 @@ fn check_file(path: &str, mut code: &str) { }; } for (parsed, original) in ast.code().lines().zip(code.lines()) { - assert_eq!(parsed, original, "Bug: dropped tokens, while parsing: {}", path); + assert_eq!(parsed, original, "Bug: dropped tokens, while parsing: {path}"); } } diff --git a/lib/rust/parser/src/syntax/tree.rs b/lib/rust/parser/src/syntax/tree.rs index fd5e6e3973..19929b93bb 100644 --- a/lib/rust/parser/src/syntax/tree.rs +++ b/lib/rust/parser/src/syntax/tree.rs @@ -781,7 +781,7 @@ pub fn apply<'s>(mut func: Tree<'s>, mut arg: Tree<'s>) -> Tree<'s> { (_, Variant::OprApp(OprApp { lhs: Some(lhs), opr: Ok(opr), rhs: Some(rhs) })) if opr.properties.is_assignment() && let Variant::Ident(lhs) = &*lhs.variant => { let mut lhs = lhs.token.clone(); - lhs.left_offset += arg.span.left_offset.clone(); + lhs.left_offset += arg.span.left_offset; Tree::named_app(func, None, lhs, opr.clone(), rhs.clone(), None) } (_, Variant::Group(Group { open: Some(open), body: Some(body), close: Some(close) })) @@ -789,14 +789,14 @@ pub fn apply<'s>(mut func: Tree<'s>, mut arg: Tree<'s>) -> Tree<'s> { = &body.variant && opr.properties.is_assignment() && let Variant::Ident(lhs) = &*lhs.variant => { let mut open = open.clone(); - open.left_offset += arg.span.left_offset.clone(); + open.left_offset += arg.span.left_offset; let open = Some(open); let close = Some(close.clone()); Tree::named_app(func, open, lhs.token.clone(), opr.clone(), rhs.clone(), close) } (_, Variant::Ident(Ident { token })) if token.is_default => { let mut token = token.clone(); - token.left_offset += arg.span.left_offset.clone(); + token.left_offset += arg.span.left_offset; Tree::default_app(func, token) } _ => Tree::app(func, arg) diff --git a/lib/rust/prelude/src/result.rs b/lib/rust/prelude/src/result.rs index 3022249fa2..096b5d6860 100644 --- a/lib/rust/prelude/src/result.rs +++ b/lib/rust/prelude/src/result.rs @@ -25,7 +25,7 @@ pub trait ResultOps { /// Print an error log if [`Err`]. The error message will be added to the `message` argument. fn log_err(&self, message: &str) where Self::Error: Display { - self.log_err_fmt(format_args!("{}", message)) + self.log_err_fmt(format_args!("{message}")) } } diff --git a/lib/rust/prelude/src/string.rs b/lib/rust/prelude/src/string.rs index c0b679c377..af433eb524 100644 --- a/lib/rust/prelude/src/string.rs +++ b/lib/rust/prelude/src/string.rs @@ -273,7 +273,7 @@ pub trait ToImString { impl ToImString for T { default fn to_im_string(&self) -> ImString { - format!("{}", self).into() + format!("{self}").into() } } diff --git a/lib/rust/prelude/src/test/stream.rs b/lib/rust/prelude/src/test/stream.rs index 0333dd1229..260064ec3c 100644 --- a/lib/rust/prelude/src/test/stream.rs +++ b/lib/rust/prelude/src/test/stream.rs @@ -63,7 +63,7 @@ pub trait StreamTestExt { match self.manual_poll_next() { Poll::Pending => {} Poll::Ready(Some(item)) => - panic!("There should be no value ready, yet the stream yielded {:?}", item), + panic!("There should be no value ready, yet the stream yielded {item:?}"), Poll::Ready(None) => { panic!("Stream has terminated, while it should be waiting for the next value.") } @@ -93,8 +93,7 @@ pub trait StreamTestExt { } _ => panic!( "Stream yielded item that did not match to any of the given predicates. \ - Item: {:?}", - item + Item: {item:?}" ), } } diff --git a/lib/rust/profiler/data/src/bin/intervals.rs b/lib/rust/profiler/data/src/bin/intervals.rs index 46544b4ff9..923916172a 100644 --- a/lib/rust/profiler/data/src/bin/intervals.rs +++ b/lib/rust/profiler/data/src/bin/intervals.rs @@ -56,13 +56,13 @@ fn main() { println!("self_duration total_duration count profiler"); for Func { label, timings } in funcs.iter().rev() { let FuncTimings { total_duration, self_duration, count } = timings; - println!("{:>6.1} {:>6.1} {} {}", self_duration, total_duration, count, label); + println!("{self_duration:>6.1} {total_duration:>6.1} {count} {label}"); } let mut total_duration = 0.0; for Func { timings, .. } in funcs.iter() { total_duration += timings.self_duration; } - println!("0.0 {:>6.1} 1 (total_self_duration)", total_duration); + println!("0.0 {total_duration:>6.1} 1 (total_self_duration)"); } diff --git a/lib/rust/profiler/data/src/bin/measurements.rs b/lib/rust/profiler/data/src/bin/measurements.rs index e03bc2b854..4a034b94b1 100644 --- a/lib/rust/profiler/data/src/bin/measurements.rs +++ b/lib/rust/profiler/data/src/bin/measurements.rs @@ -48,7 +48,7 @@ fn print_measurement( indent.push_str(" "); } println!("{}{}", indent, measurement.label); - print!("{}", indent); + print!("{indent}"); print!(" {:.1}", measurement.created.into_ms()); for active in &measurement.intervals { let interval = &profile[*active]; @@ -73,7 +73,7 @@ fn print_measurement( fn fmt_interval(interval: profiler_data::Interval) -> String { let start = interval.start.into_ms(); let end = interval.end.map(|x| format!("{:.1}", x.into_ms())).unwrap_or_default(); - format!("{:.1}-{}", start, end) + format!("{start:.1}-{end}") } diff --git a/lib/rust/profiler/data/src/bin/processes.rs b/lib/rust/profiler/data/src/bin/processes.rs index 18a94131d6..26021f60f6 100644 --- a/lib/rust/profiler/data/src/bin/processes.rs +++ b/lib/rust/profiler/data/src/bin/processes.rs @@ -235,7 +235,7 @@ fn main() { let argv0 = args.next().unwrap(); let labels = "foreign_process_label1,foreign_process_label2,..."; let profiles = "profile1.json profile2.json ..."; - let usage = &format!("Usage: {} {} {}", argv0, labels, profiles); + let usage = &format!("Usage: {argv0} {labels} {profiles}"); let processes = Processes::from_str(&args.next().expect(usage)).expect(usage); let mut cols = vec!["profile".into(), "main".into()]; cols.extend(processes.in_order.iter().map(|p| processes.names[p].clone())); diff --git a/lib/rust/profiler/data/src/lib.rs b/lib/rust/profiler/data/src/lib.rs index f523b3fb18..5348dd3168 100644 --- a/lib/rust/profiler/data/src/lib.rs +++ b/lib/rust/profiler/data/src/lib.rs @@ -128,7 +128,7 @@ pub enum Error { impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self) + write!(f, "{self:?}") } } @@ -167,7 +167,7 @@ pub struct EventError { impl fmt::Display for EventError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self) + write!(f, "{self:?}") } } @@ -483,7 +483,7 @@ impl Label { "@on_frame" => Class::OnFrame, "@set_context" => Class::SetContext, // Data producer is probably newer than consumer. Forward compatibility isn't necessary. - name if name.starts_with('@') => panic!("Unrecognized special profiler: {:?}", name), + name if name.starts_with('@') => panic!("Unrecognized special profiler: {name:?}"), _ => Class::Normal, } } @@ -660,7 +660,7 @@ mod tests { assert_eq!(errors.len(), 1); with_missing_data } - other => panic!("Expected RecoverableFormatError, found: {:?}", other), + other => panic!("Expected RecoverableFormatError, found: {other:?}"), }; assert_eq!(root.root_interval().metadata.len(), 1); assert_eq!(root.root_interval().metadata[0].data, MyMetadata::MyDataA(MyDataA(23))); diff --git a/lib/rust/profiler/data/src/parse.rs b/lib/rust/profiler/data/src/parse.rs index b4b9d45ec1..a9c35a9785 100644 --- a/lib/rust/profiler/data/src/parse.rs +++ b/lib/rust/profiler/data/src/parse.rs @@ -147,7 +147,7 @@ pub enum DataError { impl fmt::Display for DataError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self) + write!(f, "{self:?}") } } diff --git a/lib/rust/profiler/flame-graph/src/lib.rs b/lib/rust/profiler/flame-graph/src/lib.rs index 6b44ea7432..6015fa7aeb 100644 --- a/lib/rust/profiler/flame-graph/src/lib.rs +++ b/lib/rust/profiler/flame-graph/src/lib.rs @@ -25,7 +25,7 @@ type RowNumber = i32; // ======================= fn with_timing_info(base: &str, [t1, t2]: [f64; 2]) -> String { - format!("{}\n[{:.2},{:.2}]", base, t1, t2) + format!("{base}\n[{t1:.2},{t2:.2}]") } // ================== diff --git a/lib/rust/profiler/macros/build.rs b/lib/rust/profiler/macros/build.rs index a2f0985d55..621e6a58f4 100644 --- a/lib/rust/profiler/macros/build.rs +++ b/lib/rust/profiler/macros/build.rs @@ -20,8 +20,8 @@ fn main() { /// Make cargo aware that the result of compiling this crate depends on an environment variable. fn declare_env_dependence(env: &str) { - println!("cargo:rerun-if-env-changed={}", env); + println!("cargo:rerun-if-env-changed={env}",); // This is a no-op assignment, except it makes cargo aware that the output depends on the env. let value = std::env::var(env).unwrap_or_default(); - println!("cargo:rustc-env={}={}", env, value); + println!("cargo:rustc-env={env}={value}"); } diff --git a/lib/rust/profiler/macros/src/profile_attribute.rs b/lib/rust/profiler/macros/src/profile_attribute.rs index da796c5b6f..8156d9aa6f 100644 --- a/lib/rust/profiler/macros/src/profile_attribute.rs +++ b/lib/rust/profiler/macros/src/profile_attribute.rs @@ -49,7 +49,7 @@ fn make_label(name: L) -> String { let file = span.source_file().path(); let path = file.as_path().to_string_lossy(); let line = span.start().line; - format!("{} ({}:{})", name, path, line) + format!("{name} ({path}:{line})") } diff --git a/lib/rust/profiler/src/lib.rs b/lib/rust/profiler/src/lib.rs index 0e01332024..56bc3ff1c4 100644 --- a/lib/rust/profiler/src/lib.rs +++ b/lib/rust/profiler/src/lib.rs @@ -513,7 +513,7 @@ mod log_tests { assert!(m0.label.0.starts_with("test ")); assert!(*end_time >= m0.start.unwrap()); } - _ => panic!("log: {:?}", log), + _ => panic!("log: {log:?}"), } } @@ -529,7 +529,7 @@ mod log_tests { assert_eq!(m0.parent, profiler::EventId::IMPLICIT); assert_eq!(id0.0, 0); } - _ => panic!("log: {:?}", log), + _ => panic!("log: {log:?}"), } } @@ -559,7 +559,7 @@ mod log_tests { profiler::Event::Resume { id: profiler::internal::EventId(0), .. }, profiler::Event::End { id: profiler::internal::EventId(0), .. }, ] => (), - _ => panic!("log: {:#?}", log), + _ => panic!("log: {log:#?}"), }; } @@ -600,7 +600,7 @@ mod log_tests { profiler::Event::Resume { id: profiler::internal::EventId( 0, ), .. }, profiler::Event::End { id: profiler::internal::EventId( 0, ), .. }, ] => (), - _ => panic!("log: {:#?}", log), + _ => panic!("log: {log:#?}"), }; } } diff --git a/lib/rust/reflect/macros/src/lib.rs b/lib/rust/reflect/macros/src/lib.rs index e5429b080e..6aa61ac894 100644 --- a/lib/rust/reflect/macros/src/lib.rs +++ b/lib/rust/reflect/macros/src/lib.rs @@ -264,7 +264,7 @@ fn subtype_field_type(data: &Data) -> Option { for field in fields { if field.subtype { let err = "A struct cannot have more than one field with #[reflect(subtype)]."; - assert_eq!(type_, None, "{}", err); + assert_eq!(type_, None, "{err}"); type_ = Some(field.type_.clone()); } } diff --git a/lib/rust/shapely/macros/src/derive_clone_ref.rs b/lib/rust/shapely/macros/src/derive_clone_ref.rs index eb6a8eaf0a..58c3cbf61c 100644 --- a/lib/rust/shapely/macros/src/derive_clone_ref.rs +++ b/lib/rust/shapely/macros/src/derive_clone_ref.rs @@ -149,32 +149,27 @@ pub fn clone_ref_bounds(attr: &Attribute) -> Option> { Meta::List(ml) => ml.nested, _ => panic!("Attribute contents does not conform to meta item."), }; - assert!( - list.len() <= 1, - "Only a single entry within `{}` attribute is allowed.", - CLONE_REF_ATTR - ); + assert!(list.len() <= 1, "Only a single entry within `{CLONE_REF_ATTR}` attribute is allowed."); let bound_value = match list.first() { Some(NestedMeta::Meta(Meta::NameValue(name_val))) => if is_custom_bound(name_val) { &name_val.lit } else { - panic!("`{}` attribute can define value only for `{}`.", CLONE_REF_ATTR, BOUND_NAME) + panic!("`{CLONE_REF_ATTR}` attribute can define value only for `{BOUND_NAME}`.") }, Some(_) => - panic!("`{}` attribute must contain a single name=value assignment.", CLONE_REF_ATTR), - None => panic!("`{}` attribute must not be empty.", CLONE_REF_ATTR), + panic!("`{CLONE_REF_ATTR}` attribute must contain a single name=value assignment."), + None => panic!("`{CLONE_REF_ATTR}` attribute must not be empty."), }; let bound_str = if let Lit::Str(lit_str) = bound_value { lit_str } else { - panic!("`{}` value must be a string literal describing `where` predicates.", BOUND_NAME) + panic!("`{BOUND_NAME}` value must be a string literal describing `where` predicates.") }; let bounds_text = format!("where {}", bound_str.value()); let bounds = syn::parse_str::(&bounds_text); - let bounds = bounds.unwrap_or_else(|_| { - panic!("Failed to parse user-provided where clause: `{}`.", bounds_text) - }); + let bounds = bounds + .unwrap_or_else(|_| panic!("Failed to parse user-provided where clause: `{bounds_text}`.")); let ret = bounds.predicates.into_iter().collect(); Some(ret) } diff --git a/lib/rust/shapely/macros/src/derive_entry_point.rs b/lib/rust/shapely/macros/src/derive_entry_point.rs index 2228cfc68c..80586f6540 100644 --- a/lib/rust/shapely/macros/src/derive_entry_point.rs +++ b/lib/rust/shapely/macros/src/derive_entry_point.rs @@ -16,7 +16,7 @@ fn crate_name_to_base_name(name: &str) -> String { } fn base_name_to_fn_name(name: &str) -> String { - format!("entry_point_{}", name) + format!("entry_point_{name}") } pub fn derive( diff --git a/lib/rust/shapely/macros/src/derive_iterator.rs b/lib/rust/shapely/macros/src/derive_iterator.rs index af2f01b9ab..a289b8cb33 100644 --- a/lib/rust/shapely/macros/src/derive_iterator.rs +++ b/lib/rust/shapely/macros/src/derive_iterator.rs @@ -234,7 +234,7 @@ impl DerivingIterator<'_> { let data = &decl.data; let params = decl.generics.params.iter().collect(); let ident = &decl.ident; - let t_iterator = format!("{}Iterator{}", ident, mut_or_not); + let t_iterator = format!("{ident}Iterator{mut_or_not}"); let iterator = t_iterator.to_snake_case(); let t_iterator = syn::Ident::new(&t_iterator, Span::call_site()); let iterator = syn::Ident::new(&iterator, Span::call_site()); diff --git a/lib/rust/shapely/macros/src/gen.rs b/lib/rust/shapely/macros/src/gen.rs index f93ab4ef60..022d4a89a7 100644 --- a/lib/rust/shapely/macros/src/gen.rs +++ b/lib/rust/shapely/macros/src/gen.rs @@ -109,13 +109,13 @@ fn parse_args(args: &syn::AttributeArgs) -> Opts { let param_name = path.segments[0].ident.to_string(); opts.parse(&opt_name, Some((param_name, "".to_string()))); } - _ => panic!("Unrecognized argument [1]: {:#?}", arg), + _ => panic!("Unrecognized argument [1]: {arg:#?}"), } } } - _ => panic!("Unrecognized argument [2]: {:#?}", arg), + _ => panic!("Unrecognized argument [2]: {arg:#?}"), }, - _ => panic!("Unrecognized argument [3]: {:#?}", arg), + _ => panic!("Unrecognized argument [3]: {arg:#?}"), } } opts @@ -145,7 +145,7 @@ fn discover_special_cases(arg: &syn::Type) -> Option { "Vector2" => vec!["x", "y"], "Vector3" => vec!["x", "y", "z"], "Vector4" => vec!["x", "y", "z", "w"], - _ => panic!("Unknown vector type: {}", name), + _ => panic!("Unknown vector type: {name}"), }; Some(SpecialCase::Vector(tokens, fields)) } @@ -176,7 +176,7 @@ pub fn run( let input_fn_name = &input_fn.sig.ident; let input_fn_name_str = input_fn_name.to_string(); if !input_fn_name_str.starts_with(MODIFY_NAME_PREFIX) { - panic!("Method name must start with '{}'", MODIFY_NAME_PREFIX); + panic!("Method name must start with '{MODIFY_NAME_PREFIX}'"); } let core_fn_name = &input_fn_name_str[MODIFY_NAME_PREFIX.len()..]; diff --git a/lib/rust/shapely/macros/src/overlappable.rs b/lib/rust/shapely/macros/src/overlappable.rs index 32dbe17369..7631330a27 100644 --- a/lib/rust/shapely/macros/src/overlappable.rs +++ b/lib/rust/shapely/macros/src/overlappable.rs @@ -21,7 +21,7 @@ pub fn overlappable( let path = &mut t.1; path.segments.last_mut().iter_mut().for_each(|s| { let rr = repr(&s); - s.ident = Ident::new(&format!("MarketCtx_{}", rr), Span::call_site()); + s.ident = Ident::new(&format!("MarketCtx_{rr}"), Span::call_site()); }); }); diff --git a/lib/rust/shapely/macros/src/tagged_enum.rs b/lib/rust/shapely/macros/src/tagged_enum.rs index 4293f43169..3b94de5481 100644 --- a/lib/rust/shapely/macros/src/tagged_enum.rs +++ b/lib/rust/shapely/macros/src/tagged_enum.rs @@ -59,7 +59,7 @@ pub fn run( if attrs.len() == 1 && &attrs[0].to_string() == "boxed" { is_boxed = true; } else if !attrs.is_empty() { - panic!("Unsupported attributes: {:?}", attrs); + panic!("Unsupported attributes: {attrs:?}"); } let mut decl = syn::parse_macro_input!(input as DeriveInput); let (enum_attrs, variant_types_attrs, variants_attrs) = @@ -382,7 +382,7 @@ fn parse_attr(attr: &Attribute) -> Option { _ => panic!("Unexpected value in string argument to helper-attribute."), } })), - _ => panic!("Unsupported helper-attribute name: {:?}.", path), + _ => panic!("Unsupported helper-attribute name: {path:?}."), } } diff --git a/lib/rust/shortcuts/src/lib.rs b/lib/rust/shortcuts/src/lib.rs index e66fac1c44..ab86cb33ba 100644 --- a/lib/rust/shortcuts/src/lib.rs +++ b/lib/rust/shortcuts/src/lib.rs @@ -49,7 +49,7 @@ pub fn print_matrix(matrix: &data::Matrix) { for column in 0..matrix.columns { let elem = matrix.safe_index(row, column).unwrap(); let repr = if elem.is_invalid() { "-".into() } else { format!("{}", elem.id()) }; - print!("{} ", repr); + print!("{repr} "); } println!(); } @@ -150,7 +150,7 @@ impl HashSetRegistryModel { fn init(mut self) -> Self { for key in SIDE_KEYS { - let alts = vec![format!("{}-left", key), format!("{}-right", key), (*key).to_string()]; + let alts = vec![format!("{key}-left"), format!("{key}-right"), (*key).to_string()]; self.side_keys.insert((*key).to_string(), alts); } self @@ -258,7 +258,7 @@ impl HashSetRegistryModel { } else { let local_out = mem::take(&mut out); for alt in alts { - out.extend(local_out.iter().map(|expr| format!("{} {}", expr, alt))); + out.extend(local_out.iter().map(|expr| format!("{expr} {alt}"))); } }, None => @@ -266,7 +266,7 @@ impl HashSetRegistryModel { out.push(key.into()); } else { for el in out.iter_mut() { - *el = format!("{} {}", el, key); + *el = format!("{el} {key}"); } }, } @@ -289,9 +289,9 @@ fn key_aliases() -> HashMap { }; #[allow(clippy::useless_format)] let insert_side_key = |map: &mut HashMap, k: &str, v: &str| { - map.insert(format!("{}", k), format!("{}", v)); - map.insert(format!("{}-left", k), format!("{}-left", v)); - map.insert(format!("{}-right", k), format!("{}-right", v)); + map.insert(format!("{k}"), format!("{v}")); + map.insert(format!("{k}-left"), format!("{v}-left")); + map.insert(format!("{k}-right"), format!("{v}-right")); }; let insert = |map: &mut HashMap, k: &str, v: &str| { map.insert(k.into(), v.into()); @@ -589,7 +589,7 @@ mod benchmarks { let registry: T = default(); let max_count = test::black_box(10); for i in 0..max_count { - registry.add(Press, format!("{} a{}", i, input), i); + registry.add(Press, format!("{i} a{input}"), i); } if optimize { registry.optimize(); @@ -611,12 +611,12 @@ mod benchmarks { let nothing = Vec::::new(); let max_count = test::black_box(100); for i in 0..max_count { - registry.add(Press, format!("ctrl shift a{}", i), i); + registry.add(Press, format!("ctrl shift a{i}"), i); } registry.optimize(); bencher.iter(|| { for i in 0..max_count { - let key = format!("a{}", i); + let key = format!("a{i}"); assert_eq!(registry.on_press("ctrl-left"), nothing); assert_eq!(registry.on_press("shift-left"), nothing); assert_eq!(registry.on_press(&key), vec![i]); diff --git a/lib/rust/types/build.rs b/lib/rust/types/build.rs index 39374400ec..b62d063c33 100644 --- a/lib/rust/types/build.rs +++ b/lib/rust/types/build.rs @@ -148,7 +148,7 @@ fn gen_swizzling_macro(unique: bool) -> String { out.write_str("/// Swizzling data for the given dimension.\n").unwrap(); out.write_str("/// See the [`build.rs`] file to learn more.\n").unwrap(); out.write_str("#[macro_export]\n").unwrap(); - out.write_str(&format!("macro_rules! with_swizzling_for_dim{} {{\n", sfx)).unwrap(); + out.write_str(&format!("macro_rules! with_swizzling_for_dim{sfx} {{\n")).unwrap(); out.write_str(&gen_swizzling_macro_branch(1, unique)).unwrap(); out.write_str(&gen_swizzling_macro_branch(2, unique)).unwrap(); out.write_str(&gen_swizzling_macro_branch(3, unique)).unwrap(); @@ -166,9 +166,9 @@ fn main() { let mut out = String::new(); out.write_str("//! Macros allowing generation of swizzling getters and setters.\n").unwrap(); out.write_str("//! See the docs of [`build.rs`] and usage places to learn more.\n").unwrap(); - out.write_str(&format!("\n\n\n// {}\n", border)).unwrap(); + out.write_str(&format!("\n\n\n// {border}\n")).unwrap(); out.write_str("// THIS IS AN AUTO-GENERATED FILE. DO NOT EDIT IT DIRECTLY!\n").unwrap(); - out.write_str(&format!("// {}\n\n\n", border)).unwrap(); + out.write_str(&format!("// {border}\n\n\n")).unwrap(); out.write_str(&gen_swizzling_macro(false)).unwrap(); out.write_str("\n\n").unwrap(); out.write_str(&gen_swizzling_macro(true)).unwrap(); diff --git a/lib/rust/web/src/lib.rs b/lib/rust/web/src/lib.rs index f130e00879..d4a00860b8 100644 --- a/lib/rust/web/src/lib.rs +++ b/lib/rust/web/src/lib.rs @@ -578,14 +578,14 @@ ops! { NodeOps for Node impl { fn append_or_warn(&self, node: &Self) { - let warn_msg: &str = &format!("Failed to append child {:?} to {:?}", node, self); + let warn_msg: &str = &format!("Failed to append child {node:?} to {self:?}"); if self.append_child(node).is_err() { warn!("{warn_msg}") }; } fn prepend_or_warn(&self, node: &Self) { - let warn_msg: &str = &format!("Failed to prepend child \"{:?}\" to \"{:?}\"", node, self); + let warn_msg: &str = &format!("Failed to prepend child \"{node:?}\" to \"{self:?}\""); let first_c = self.first_child(); if self.insert_before(node, first_c.as_ref()).is_err() { warn!("{warn_msg}") @@ -594,7 +594,7 @@ ops! { NodeOps for Node fn insert_before_or_warn(&self, node: &Self, ref_node: &Self) { let warn_msg: &str = - &format!("Failed to insert {:?} before {:?} in {:?}", node, ref_node, self); + &format!("Failed to insert {node:?} before {ref_node:?} in {self:?}"); if self.insert_before(node, Some(ref_node)).is_err() { warn!("{warn_msg}") } @@ -602,7 +602,7 @@ ops! { NodeOps for Node fn remove_from_parent_or_warn(&self) { if let Some(parent) = self.parent_node() { - let warn_msg: &str = &format!("Failed to remove {:?} from parent", self); + let warn_msg: &str = &format!("Failed to remove {self:?} from parent"); if parent.remove_child(self).is_err() { warn!("{warn_msg}") } @@ -610,7 +610,7 @@ ops! { NodeOps for Node } fn remove_child_or_warn(&self, node: &Self) { - let warn_msg: &str = &format!("Failed to remove child {:?} from {:?}", node, self); + let warn_msg: &str = &format!("Failed to remove child {node:?} from {self:?}"); if self.remove_child(node).is_err() { warn!("{warn_msg}") } @@ -633,8 +633,8 @@ ops! { ElementOps for Element fn set_attribute_or_warn, U: AsRef>(&self, name: T, value: U) { let name = name.as_ref(); let value = value.as_ref(); - let values = format!("\"{}\" = \"{}\" on \"{:?}\"", name, value, self); - let warn_msg: &str = &format!("Failed to set attribute {}", values); + let values = format!("\"{name}\" = \"{value}\" on \"{self:?}\""); + let warn_msg: &str = &format!("Failed to set attribute {values}"); if self.set_attribute(name, value).is_err() { warn!("{warn_msg}") } @@ -657,8 +657,8 @@ ops! { HtmlElementOps for HtmlElement fn set_style_or_warn(&self, name: impl AsRef, value: impl AsRef) { let name = name.as_ref(); let value = value.as_ref(); - let values = format!("\"{}\" = \"{}\" on \"{:?}\"", name, value, self); - let warn_msg: &str = &format!("Failed to set style {}", values); + let values = format!("\"{name}\" = \"{value}\" on \"{self:?}\""); + let warn_msg: &str = &format!("Failed to set style {values}"); if self.style().set_property(name, value).is_err() { warn!("{warn_msg}"); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d360e8aaf0..0533ecdc89 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "nightly-2022-11-22" +channel = "nightly-2023-01-12" components = ["clippy", "rustfmt"] profile = "default" targets = ["wasm32-unknown-unknown"] diff --git a/tools/language-server/logstat/src/main.rs b/tools/language-server/logstat/src/main.rs index 5601f691d0..3b938b53bc 100644 --- a/tools/language-server/logstat/src/main.rs +++ b/tools/language-server/logstat/src/main.rs @@ -96,7 +96,7 @@ impl Display for Operation { let timestamp = self.timestamp.format(&Rfc3339).unwrap(); let truncated_line = self.line.chars().take(80).collect::(); - write!(f, "{}ms [{}] {}...", duration_millis, timestamp, truncated_line) + write!(f, "{duration_millis}ms [{timestamp}] {truncated_line}...") } } @@ -227,7 +227,7 @@ async fn read_logfile(path: &PathBuf, spec: &Spec) -> Result> { } }, _ => { - eprintln!("[ERR] Invalid log line [{}]", line); + eprintln!("[ERR] Invalid log line [{line}]"); } } } @@ -368,7 +368,7 @@ async fn main() -> Result<()> { println!("avg [min..max] (of {} records)", iterations.len()); for s in &stats { - println!("{}", s); + println!("{s}"); } Ok(()) diff --git a/tools/language-server/wstest/src/format.rs b/tools/language-server/wstest/src/format.rs index f8c52b90f2..e5d3029a08 100644 --- a/tools/language-server/wstest/src/format.rs +++ b/tools/language-server/wstest/src/format.rs @@ -26,32 +26,32 @@ static FMT_MODULE: &str = "main"; /// Message for logging the initialization request pub fn init_request(message: &str) -> String { - fmt(format!("{} [{}]", INIT_REQUEST_SENT, message).as_str()) + fmt(format!("{INIT_REQUEST_SENT} [{message}]").as_str()) } /// Message for logging the warmup request pub fn warmup_request(message: &str) -> String { - fmt(format!("{} [{}]", WARMUP_REQUEST_SENT, message).as_str()) + fmt(format!("{WARMUP_REQUEST_SENT} [{message}]").as_str()) } /// Message for logging the benchmarking request pub fn bench_request(message: &str) -> String { - fmt(format!("{} [{}]", BENCH_REQUEST_SENT, message).as_str()) + fmt(format!("{BENCH_REQUEST_SENT} [{message}]").as_str()) } /// Message for logging the text response pub fn response_text(message: &str) -> String { - fmt(format!("{} [{}]", RESPONSE_HANDLED, message).as_str()) + fmt(format!("{RESPONSE_HANDLED} [{message}]").as_str()) } /// Message for logging the binary response pub fn response_binary() -> String { - fmt(format!("{} [{}]", RESPONSE_HANDLED, MESSAGE_BINARY).as_str()) + fmt(format!("{RESPONSE_HANDLED} [{MESSAGE_BINARY}]").as_str()) } /// Message for logging the ignored response pub fn response_ignored(message: &str) -> String { - fmt(format!("{} [{}]", RESPONSE_IGNORED, message).as_str()) + fmt(format!("{RESPONSE_IGNORED} [{message}]").as_str()) } fn fmt(message: &str) -> String {