Skip to content

Commit

Permalink
Merge branch 'main' into chore/lint
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe authored Sep 5, 2023
2 parents 745351c + a5ccf9c commit 2395752
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 126 deletions.
275 changes: 184 additions & 91 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions lib/app/src/build/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ impl std::fmt::Display for BuildError {
match self {
Self::ExternalPackageConfigurationFileNotFound { package_name } => write!(
formatter,
"package configuration file not found in external package \"{}\"",
package_name
"package configuration file not found in external package \"{package_name}\""
),
Self::MainFunctionModuleNotFound {
main_function_module_name,
Expand All @@ -38,17 +37,15 @@ impl std::fmt::Display for BuildError {
),
Self::ModuleCircularDependency(file_path) => write!(
formatter,
"circular module dependency detected: {}",
file_path
"circular module dependency detected: {file_path}"
),
Self::ModuleNotFound {
module_path,
source_file_path,
} => {
write!(
formatter,
"module \"{}\" not found imported by \"{}\"",
module_path, source_file_path
"module \"{module_path}\" not found imported by \"{source_file_path}\""
)
}
Self::PackageCircularDependency(external_package) => write!(
Expand Down
2 changes: 1 addition & 1 deletion lib/app/src/common/file_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl FilePath {
let replacement = if extension.is_empty() {
"".into()
} else {
format!(".{}", extension)
format!(".{extension}")
};

Self::new(self.components().take(self.components.len() - 1).chain(
Expand Down
2 changes: 1 addition & 1 deletion lib/app/src/infra/file_path_displayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ impl FakeFilePathDisplayer {
#[cfg(test)]
impl FilePathDisplayer for FakeFilePathDisplayer {
fn display(&self, file_path: &FilePath) -> String {
format!("{}", file_path)
format!("{file_path}")
}
}
2 changes: 1 addition & 1 deletion lib/app/src/infra/file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl FileSystem for FakeFileSystem {
directory_path: &FilePath,
) -> Result<Option<Repository>, Box<dyn std::error::Error>> {
Ok(Some(Repository::new(
url::Url::parse(&format!("{}", directory_path))?,
url::Url::parse(&format!("{directory_path}"))?,
"v1",
)))
}
Expand Down
2 changes: 1 addition & 1 deletion lib/infra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[dependencies]
app = { path = "../app" }
lang = { path = "../lang" }
git2 = "0.16"
git2 = "0.17"
termcolor = "1"
url = "2"
which = "4"
2 changes: 1 addition & 1 deletion lib/infra/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Display for InfrastructureError {
match self {
Self::CommandExit { status_code } => match status_code {
Some(status_code) => {
write!(formatter, "command exited with status code {}", status_code)
write!(formatter, "command exited with status code {status_code}")
}
None => write!(formatter, "command exited without status code"),
},
Expand Down
4 changes: 2 additions & 2 deletions lib/infra/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Logger {
writeln!(
&mut stderr,
": {}",
format!("{}", error).replace('\n', "\n ").trim()
format!("{error}").replace('\n', "\n ").trim()
)?;

if let Some(error) = error.source() {
Expand All @@ -43,7 +43,7 @@ impl app::Logger for Logger {
write!(&mut stderr, "info")?;
stderr.set_color(ColorSpec::new().set_fg(None))?;

writeln!(&mut stderr, ": {}", log)?;
writeln!(&mut stderr, ": {log}")?;

Ok(())
}
Expand Down
30 changes: 12 additions & 18 deletions lib/lang/src/compile/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,23 @@ impl Display for CompileError {
match self {
Self::AnyEqualOperation(source_information) => write!(
formatter,
"cannot compare Any type values\n{}",
source_information
"cannot compare Any type values\n{source_information}"
),
Self::CaseArgumentTypeInvalid(source_information) => write!(
formatter,
"invalid argument type of case expression\n{}",
source_information
"invalid argument type of case expression\n{source_information}"
),
Self::ExportedNameNotFound { name } => {
write!(formatter, "exported name \"{}\" not found", name)
write!(formatter, "exported name \"{name}\" not found")
}
Self::DuplicateNames(one, other) => {
write!(formatter, "duplicate names\n{}\n{}", one, other)
write!(formatter, "duplicate names\n{one}\n{other}")
}
Self::FunctionEqualOperation(source_information) => {
write!(formatter, "cannot compare functions\n{source_information}")
}
Self::FunctionEqualOperation(source_information) => write!(
formatter,
"cannot compare functions\n{}",
source_information
),
Self::FunctionExpected(source_information) => {
write!(formatter, "function expected\n{}", source_information)
write!(formatter, "function expected\n{source_information}")
}
Self::MainFunctionNotFound(path) => write!(
formatter,
Expand All @@ -64,11 +60,10 @@ impl Display for CompileError {
),
Self::RecordEqualOperation(source_information) => write!(
formatter,
"cannot compare records including functions or Any values\n{}",
source_information
"cannot compare records including functions or Any values\n{source_information}"
),
Self::EirFmmCompile(error) => {
write!(formatter, "failed to compile eir to fmm: {:?}", error)
write!(formatter, "failed to compile eir to fmm: {error:?}")
}
Self::TypeNotFound(reference) => write!(
formatter,
Expand All @@ -77,12 +72,11 @@ impl Display for CompileError {
reference.source_information()
),
Self::TypeNotInferred(source_information) => {
write!(formatter, "failed to infer type\n{}", source_information)
write!(formatter, "failed to infer type\n{source_information}")
}
Self::TypesNotMatched(lhs_source_information, rhs_source_information) => write!(
formatter,
"types not matched\n{}\n{}",
lhs_source_information, rhs_source_information
"types not matched\n{lhs_source_information}\n{rhs_source_information}"
),
Self::VariableNotFound(variable) => write!(
formatter,
Expand Down
2 changes: 1 addition & 1 deletion lib/lang/src/compile/module_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl ModuleCompiler {
body: &Expression,
function_type: &eir::types::Function,
) -> Result<Vec<eir::ir::Definition>, CompileError> {
let thunk_name = format!("{}.thunk", name);
let thunk_name = format!("{name}.thunk");
const ARGUMENT_NAME: &str = "$arg";

Ok(vec![
Expand Down
2 changes: 1 addition & 1 deletion lib/lang/src/parse/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ impl ParseError {
pub fn new(source_name: &str, errors: &impl std::error::Error) -> Self {
Self {
source_name: source_name.into(),
details: format!("{}", errors),
details: format!("{errors}"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/lang/src/path/unresolved_module_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl From<InternalUnresolvedModulePath> for UnresolvedModulePath {
impl std::fmt::Display for UnresolvedModulePath {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::External(external_module_path) => write!(formatter, "{}", external_module_path),
Self::Internal(internal_module_path) => write!(formatter, "{}", internal_module_path),
Self::External(external_module_path) => write!(formatter, "{external_module_path}"),
Self::Internal(internal_module_path) => write!(formatter, "{internal_module_path}"),
}
}
}

0 comments on commit 2395752

Please sign in to comment.