Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

Fix clippy lints for Rust v1.88

+27 -36
+2 -2
compiler-cli/src/beam_compiler.rs
··· 58 58 59 59 tracing::debug!(args=?args, "call_beam_compiler"); 60 60 61 - writeln!(inner.stdin, "{}.", args).map_err(|e| Error::ShellCommand { 61 + writeln!(inner.stdin, "{args}.").map_err(|e| Error::ShellCommand { 62 62 program: "escript".into(), 63 63 reason: ShellCommandFailureReason::IoError(e.kind()), 64 64 })?; ··· 83 83 } 84 84 } 85 85 _ => match stdio { 86 - Stdio::Inherit => print!("{}", buf), 86 + Stdio::Inherit => print!("{buf}"), 87 87 Stdio::Null => {} 88 88 }, 89 89 }
+1 -1
compiler-cli/src/dependencies.rs
··· 147 147 ); 148 148 149 149 tree.iter() 150 - .try_for_each(|line| writeln!(buffer, "{}", line)) 150 + .try_for_each(|line| writeln!(buffer, "{line}")) 151 151 .map_err(|e| Error::StandardIo { 152 152 action: StandardIoAction::Write, 153 153 err: Some(e.kind()),
-1
compiler-cli/src/lib.rs
··· 8 8 clippy::needless_continue, 9 9 clippy::needless_borrow, 10 10 clippy::match_wildcard_for_single_variants, 11 - clippy::match_on_vec_items, 12 11 clippy::imprecise_flops, 13 12 clippy::suboptimal_flops, 14 13 clippy::lossy_float_literal,
+4 -4
compiler-cli/src/new.rs
··· 374 374 } 375 375 _ => None, 376 376 }, 377 - InvalidProjectNameReason::ErlangReservedWord => Some(format!("{}_app", invalid_name)), 377 + InvalidProjectNameReason::ErlangReservedWord => Some(format!("{invalid_name}_app")), 378 378 InvalidProjectNameReason::ErlangStandardLibraryModule => { 379 - Some(format!("{}_app", invalid_name)) 379 + Some(format!("{invalid_name}_app")) 380 380 } 381 - InvalidProjectNameReason::GleamReservedWord => Some(format!("{}_app", invalid_name)), 382 - InvalidProjectNameReason::GleamReservedModule => Some(format!("{}_app", invalid_name)), 381 + InvalidProjectNameReason::GleamReservedWord => Some(format!("{invalid_name}_app")), 382 + InvalidProjectNameReason::GleamReservedModule => Some(format!("{invalid_name}_app")), 383 383 InvalidProjectNameReason::FormatNotLowercase => Some(invalid_name.to_lowercase()), 384 384 InvalidProjectNameReason::Format => { 385 385 let suggestion = regex::Regex::new(r"[^a-z0-9]")
+5 -8
compiler-core/src/error.rs
··· 779 779 // Check one isn't less than half the length of the other. If this is true then there is a 780 780 // big difference in length. 781 781 let big_len_diff = (n * 2) < m || (m * 2) < n; 782 - let len_diff = if n < m { m - n } else { n - m }; 782 + let len_diff = m.abs_diff(n); 783 783 let distance = edit_distance(a, b, limit + len_diff)?; 784 784 785 785 // This is the crux, subtracting length difference means exact substring matches will now be 0 ··· 1135 1135 OS::MacOS => { 1136 1136 fn brew_install(name: &str, pkg: &str) -> String { 1137 1137 format!( 1138 - "\n\nYou can install {} via homebrew: brew install {}", 1139 - name, pkg 1138 + "\n\nYou can install {name} via homebrew: brew install {pkg}", 1140 1139 ) 1141 1140 } 1142 1141 match program.as_str() { ··· 1155 1154 OS::Linux(distro) => { 1156 1155 fn apt_install(name: &str, pkg: &str) -> String { 1157 1156 format!( 1158 - "\n\nYou can install {} via apt: sudo apt install {}", 1159 - name, pkg 1157 + "\n\nYou can install {name} via apt: sudo apt install {pkg}" 1160 1158 ) 1161 1159 } 1162 1160 match distro { ··· 1263 1261 reason: ShellCommandFailureReason::ShellCommandError(err), 1264 1262 } => { 1265 1263 let text = format!( 1266 - "There was a problem when running the shell command `{}`. 1264 + "There was a problem when running the shell command `{command}`. 1267 1265 1268 1266 The error from the shell command was: 1269 1267 1270 - {}", 1271 - command, err 1268 + {err}" 1272 1269 ); 1273 1270 vec![Diagnostic { 1274 1271 title: "Shell command failure".into(),
+4 -4
compiler-core/src/exhaustiveness.rs
··· 408 408 BitArrayMatchedValue::Variable(_) 409 409 | BitArrayMatchedValue::Discard(_) 410 410 | BitArrayMatchedValue::Assign { .. } => { 411 - panic!("aliased non constant value: {:#?}", value) 411 + panic!("aliased non constant value: {value:#?}") 412 412 } 413 413 }; 414 414 ··· 2866 2866 type_ if type_.is_string() => ReadType::String, 2867 2867 type_ if type_.is_bit_array() => ReadType::BitArray, 2868 2868 type_ if type_.is_utf_codepoint() => ReadType::UtfCodepoint, 2869 - x => panic!("invalid segment type in exhaustiveness {:?}", x), 2869 + x => panic!("invalid segment type in exhaustiveness {x:?}"), 2870 2870 }; 2871 2871 2872 2872 let read_action = ReadAction { ··· 2941 2941 name: name.clone(), 2942 2942 value: Box::new(segment_matched_value(segment, Some(pattern))), 2943 2943 }, 2944 - x => panic!("unexpected segment value pattern {:?}", x), 2944 + x => panic!("unexpected segment value pattern {x:?}"), 2945 2945 } 2946 2946 } 2947 2947 ··· 2974 2974 unit: segment.unit(), 2975 2975 } 2976 2976 } 2977 - Some(x) => panic!("invalid pattern size made it to code generation {:?}", x), 2977 + Some(x) => panic!("invalid pattern size made it to code generation {x:?}"), 2978 2978 2979 2979 // If a segment has the `bits`/`bytes` option and has no size, that 2980 2980 // means it's the final catch all segment: we'll have to read any number
+1 -3
compiler-core/src/io/memory.rs
··· 290 290 let read_dir = ReadDir::from_iter( 291 291 self.files 292 292 .deref() 293 - .borrow() 294 - .iter() 295 - .map(|(file_path, _)| file_path.to_path_buf()) 293 + .borrow().keys().map(|file_path| file_path.to_path_buf()) 296 294 .filter(|file_path| file_path.parent().is_some_and(|parent| path == parent)) 297 295 .map(DirEntry::from_pathbuf) 298 296 .map(Ok),
+1 -2
compiler-core/src/javascript/decision.rs
··· 1373 1373 ReadType::Float => self.bit_array_slice_to_float(bit_array, start, end, endianness), 1374 1374 ReadType::BitArray => self.bit_array_slice_with_end(bit_array, from, end), 1375 1375 _ => panic!( 1376 - "invalid slice type made it to code generation: {:#?}", 1377 - type_ 1376 + "invalid slice type made it to code generation: {type_:#?}" 1378 1377 ), 1379 1378 } 1380 1379 }
+6 -6
compiler-core/src/language_server/code_action.rs
··· 1669 1669 } = self.qualified_constructor; 1670 1670 if !module_aliased { 1671 1671 // Case: import module 1672 - (location.end, format!(".{{{}}}", name)) 1672 + (location.end, format!(".{{{name}}}")) 1673 1673 } else { 1674 1674 // Case: import module as alias 1675 1675 let import_code = &self.get_import_code(); ··· 1681 1681 .and_then(|s| s.rfind(|c: char| !c.is_whitespace())) 1682 1682 .map(|pos| location.start as usize + pos + 1) 1683 1683 .expect("Expected non-whitespace character before ' as '"); 1684 - (before_as_pos as u32, format!(".{{{}}}", name)) 1684 + (before_as_pos as u32, format!(".{{{name}}}")) 1685 1685 } 1686 1686 } 1687 1687 ··· 1694 1694 if let Some((pos, c)) = self.find_last_char_before_closing_brace() { 1695 1695 // Case: import module.{Existing, } (as alias) 1696 1696 if c == ',' { 1697 - (pos as u32 + 1, format!(" {}", name)) 1697 + (pos as u32 + 1, format!(" {name}")) 1698 1698 } else { 1699 1699 // Case: import module.{Existing} (as alias) 1700 - (pos as u32 + 1, format!(", {}", name)) 1700 + (pos as u32 + 1, format!(", {name}")) 1701 1701 } 1702 1702 } else { 1703 1703 // Case: import module.{} (as alias) ··· 2452 2452 // ^ No parentheses 2453 2453 // 2454 2454 self.edits 2455 - .insert(use_line_end, format!("(fn({}) {{", assignments)) 2455 + .insert(use_line_end, format!("(fn({assignments}) {{")) 2456 2456 }; 2457 2457 2458 2458 // Then we have to increase indentation for all the lines of the use ··· 7132 7132 .replace(truncation.value_location, replacement.clone()); 7133 7133 7134 7134 let mut action = Vec::with_capacity(1); 7135 - CodeActionBuilder::new(&format!("Replace with `{}`", replacement)) 7135 + CodeActionBuilder::new(&format!("Replace with `{replacement}`")) 7136 7136 .kind(CodeActionKind::REFACTOR_REWRITE) 7137 7137 .changes(self.params.text_document.uri.clone(), self.edits.edits) 7138 7138 .preferred(true)
-1
compiler-core/src/lib.rs
··· 9 9 clippy::needless_continue, 10 10 clippy::needless_borrow, 11 11 clippy::match_wildcard_for_single_variants, 12 - clippy::match_on_vec_items, 13 12 clippy::imprecise_flops, 14 13 clippy::suboptimal_flops, 15 14 clippy::lossy_float_literal,
+3 -4
compiler-core/src/warning.rs
··· 1306 1306 1307 1307 type_::Warning::TopLevelDefinitionShadowsImport { location, name } => { 1308 1308 let text = format!( 1309 - "Definition of {} shadows an imported value. 1310 - The imported value could not be used in this module anyway.", 1311 - name 1309 + "Definition of {name} shadows an imported value. 1310 + The imported value could not be used in this module anyway." 1312 1311 ); 1313 1312 Diagnostic { 1314 1313 title: "Shadowed Import".into(), ··· 1318 1317 path: path.clone(), 1319 1318 src: src.clone(), 1320 1319 label: diagnostic::Label { 1321 - text: Some(wrap(&format!("`{}` is defined here", name))), 1320 + text: Some(wrap(&format!("`{name}` is defined here"))), 1322 1321 span: *location, 1323 1322 }, 1324 1323 extra_labels: Vec::new(),