Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump: rust 1.67.0 #515

Merged
merged 1 commit into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/mun/src/ops/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct Args {

fn parse_target_triple(target_triple: &str) -> Result<Target, String> {
Target::search(target_triple)
.ok_or_else(|| format!("could not find target for '{}'", target_triple))
.ok_or_else(|| format!("could not find target for '{target_triple}'"))
}

/// This method is invoked when the executable is run with the `build` argument indicating that a
Expand Down
9 changes: 4 additions & 5 deletions crates/mun/src/ops/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ pub fn create_project(create_in: &Path, project_name: &str) -> Result<ExitStatus
let manifest_path = create_in.join("mun.toml");

write(
&manifest_path,
manifest_path,
format!(
// @TODO. Nothing is done yet to find out who the author is.
r#"[package]
name="{}"
name="{project_name}"
authors=[]
version="0.1.0"
"#,
project_name,
),
)?;
}
Expand All @@ -52,14 +51,14 @@ version="0.1.0"
let main_file_path = src_path.join("mod.mun");

write(
&main_file_path,
main_file_path,
r#"pub fn main() -> f64 {
3.14159
}
"#,
)?;
}
println!("Created `{}` package", project_name);
println!("Created `{project_name}` package");
Ok(ExitStatus::Success)
}

Expand Down
6 changes: 3 additions & 3 deletions crates/mun/src/ops/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ pub fn start(args: Args) -> anyhow::Result<ExitStatus> {
.invoke(&args.entry, ())
.map_err(|e| anyhow!("{}", e))?;

println!("{}", result)
println!("{result}")
} else if return_type.equals::<f64>() {
let result: f64 = runtime
.invoke(&args.entry, ())
.map_err(|e| anyhow!("{}", e))?;

println!("{}", result)
println!("{result}")
} else if return_type.equals::<i64>() {
let result: i64 = runtime
.invoke(&args.entry, ())
.map_err(|e| anyhow!("{}", e))?;

println!("{}", result)
println!("{result}")
} else if return_type.equals::<()>() {
#[allow(clippy::unit_arg)]
runtime
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl serde::Serialize for Guid {
where
S: serde::Serializer,
{
serializer.serialize_str(&format!("{}", self))
serializer.serialize_str(&format!("{self}"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/mun_codegen/src/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ fn find_apple_sdk_root(sdk_name: &str) -> Result<PathBuf, String> {

match res {
Ok(output) => Ok(PathBuf::from(output.trim())),
Err(e) => Err(format!("failed to get SDK path: {}", e)),
Err(e) => Err(format!("failed to get SDK path: {e}")),
}
}
23 changes: 7 additions & 16 deletions crates/mun_codegen/src/code_gen/symbols/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ fn get_type_definition_array<'ink>(
ir::TypeDefinition {
name: CString::new(struct_name.clone())
.expect("typename is not a valid CString")
.intern(format!("type_info::<{}>::name", struct_name), context)
.intern(format!("type_info::<{struct_name}>::name"), context)
.as_value(context),
size_in_bits: context
.type_context
Expand Down Expand Up @@ -170,16 +170,10 @@ fn gen_struct_info<'ink>(
.map(|(idx, field)| {
CString::new(field.name(db).to_string())
.expect("field name is not a valid CString")
.intern(
format!("struct_info::<{}>::field_names.{}", name, idx),
context,
)
.intern(format!("struct_info::<{name}>::field_names.{idx}"), context)
.as_value(context)
})
.into_const_private_pointer_or_null(
format!("struct_info::<{}>::field_names", name),
context,
);
.into_const_private_pointer_or_null(format!("struct_info::<{name}>::field_names"), context);

// Construct an array of field types (or null if there are no fields)
let field_types = fields
Expand All @@ -188,10 +182,7 @@ fn gen_struct_info<'ink>(
let field_type_info = hir_types.type_id(&field.ty(db));
ir_type_builder.construct_from_type_id(&field_type_info)
})
.into_const_private_pointer_or_null(
format!("struct_info::<{}>::field_types", name),
context,
);
.into_const_private_pointer_or_null(format!("struct_info::<{name}>::field_types"), context);

// Construct an array of field offsets (or null if there are no fields)
let field_offsets = fields
Expand All @@ -205,7 +196,7 @@ fn gen_struct_info<'ink>(
.unwrap() as u16
})
.into_const_private_pointer_or_null(
format!("struct_info::<{}>::field_offsets", name),
format!("struct_info::<{name}>::field_offsets"),
context,
);

Expand Down Expand Up @@ -240,7 +231,7 @@ fn get_function_definition_array<'ink, 'a>(
// Get the function from the cloned module and modify the linkage of the function.
let value = module
// If a wrapper function exists, use that (required for struct types)
.get_function(&format!("{}_wrapper", name))
.get_function(&format!("{name}_wrapper"))
// Otherwise, use the normal function
.or_else(|| module.get_function(&name))
.unwrap();
Expand Down Expand Up @@ -500,7 +491,7 @@ fn gen_get_info_fn<'ink>(
.map(|(idx, name)| {
CString::new(name.as_str())
.expect("could not convert dependency name to string")
.intern(format!("dependency{}", idx), context)
.intern(format!("dependency{idx}"), context)
.as_value(context)
})
.into_const_private_pointer_or_null("dependencies", context)
Expand Down
15 changes: 6 additions & 9 deletions crates/mun_codegen/src/ir/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ impl<'db, 'ink, 't> BodyIrGenerator<'db, 'ink, 't> {
.expect("expected a struct field")
.index(self.db);

let field_ir_name = &format!("{}.{}", hir_struct_name, name);
let field_ir_name = &format!("{hir_struct_name}.{name}");
if self.is_place_expr(receiver_expr) {
let receiver_ptr = self.gen_place_expr(receiver_expr)?;
let receiver_ptr = self
Expand All @@ -1378,12 +1378,11 @@ impl<'db, 'ink, 't> BodyIrGenerator<'db, 'ink, 't> {
.build_struct_gep(
receiver_ptr,
field_idx,
&format!("{}->{}", hir_struct_name, name),
&format!("{hir_struct_name}->{name}"),
)
.unwrap_or_else(|_| {
panic!(
"could not get pointer to field `{}::{}` at index {}",
hir_struct_name, name, field_idx
"could not get pointer to field `{hir_struct_name}::{name}` at index {field_idx}"
)
});
Some(self.builder.build_load(field_ptr, field_ir_name))
Expand All @@ -1396,8 +1395,7 @@ impl<'db, 'ink, 't> BodyIrGenerator<'db, 'ink, 't> {
.build_extract_value(receiver_struct, field_idx, field_ir_name)
.ok_or_else(|| {
format!(
"could not extract field {} (index: {}) from struct {}",
name, field_idx, hir_struct_name
"could not extract field {name} (index: {field_idx}) from struct {hir_struct_name}"
)
})
.unwrap(),
Expand Down Expand Up @@ -1431,12 +1429,11 @@ impl<'db, 'ink, 't> BodyIrGenerator<'db, 'ink, 't> {
.build_struct_gep(
receiver_ptr,
field_idx,
&format!("{}->{}", hir_struct_name, name),
&format!("{hir_struct_name}->{name}"),
)
.unwrap_or_else(|_| {
panic!(
"could not get pointer to field `{}::{}` at index {}",
hir_struct_name, name, field_idx
"could not get pointer to field `{hir_struct_name}::{name}` at index {field_idx}"
)
}),
)
Expand Down
9 changes: 3 additions & 6 deletions crates/mun_codegen/src/ir/dispatch_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,14 @@ impl<'ink> DispatchTable<'ink> {
.build_struct_gep(
table_ref.as_pointer_value(),
index as u32,
&format!("{0}_ptr_ptr", function_name),
&format!("{function_name}_ptr_ptr"),
)
.unwrap_or_else(|_| {
panic!(
"could not get {} (index: {}) from dispatch table",
function_name, index
)
panic!("could not get {function_name} (index: {index}) from dispatch table")
});

builder
.build_load(ptr_to_function_ptr, &format!("{0}_ptr", function_name))
.build_load(ptr_to_function_ptr, &format!("{function_name}_ptr"))
.into_pointer_value()
.try_into()
.expect("Pointer value is not a valid function pointer.")
Expand Down
4 changes: 2 additions & 2 deletions crates/mun_codegen/src/ir/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ pub struct FileIr<'ink> {
}

/// Generates IR for the specified file.
pub(crate) fn gen_file_ir<'db, 'ink>(
code_gen: &CodeGenContext<'db, 'ink>,
pub(crate) fn gen_file_ir<'ink>(
code_gen: &CodeGenContext<'_, 'ink>,
group_ir: &FileGroupIr<'ink>,
module_group: &ModuleGroup,
) -> FileIr<'ink> {
Expand Down
4 changes: 2 additions & 2 deletions crates/mun_codegen/src/ir/file_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub struct FileGroupIr<'ink> {
}

/// Generates IR that is shared among the group's files.
pub(crate) fn gen_file_group_ir<'db, 'ink>(
code_gen: &CodeGenContext<'db, 'ink>,
pub(crate) fn gen_file_group_ir<'ink>(
code_gen: &CodeGenContext<'_, 'ink>,
module_group: &ModuleGroup,
) -> FileGroupIr<'ink> {
let llvm_module = code_gen.context.create_module("group_name");
Expand Down
8 changes: 4 additions & 4 deletions crates/mun_codegen/src/ir/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ fn collect_intrinsic<'ink>(

/// Iterates over all expressions and stores information on which intrinsics they use in `entries`.
#[allow(clippy::too_many_arguments)]
fn collect_expr<'db, 'ink>(
fn collect_expr<'ink>(
context: &'ink Context,
target: &TargetData,
db: &'db dyn HirDatabase,
db: &'_ dyn HirDatabase,
intrinsics: &mut IntrinsicsMap<'ink>,
needs_alloc: &mut bool,
expr_id: ExprId,
Expand Down Expand Up @@ -87,10 +87,10 @@ fn collect_expr<'db, 'ink>(
}

/// Collects all intrinsics from the specified `body`.
pub fn collect_fn_body<'db, 'ink>(
pub fn collect_fn_body<'ink>(
context: &'ink Context,
target: TargetData,
db: &'db dyn HirDatabase,
db: &dyn HirDatabase,
intrinsics: &mut IntrinsicsMap<'ink>,
needs_alloc: &mut bool,
body: &Arc<Body>,
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_codegen/src/ir/type_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'ink> TypeTable<'ink> {
.expect("too many types");

let global_index = context.i64_type().const_zero();
let array_index = context.i64_type().const_int(index as u64, false);
let array_index = context.i64_type().const_int(index, false);

let ptr_to_type_info_ptr = unsafe {
builder.build_gep(
Expand Down
11 changes: 5 additions & 6 deletions crates/mun_codegen/src/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ pub enum LinkerError {
impl fmt::Display for LinkerError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
LinkerError::LinkError(e) => write!(f, "{}", e),
LinkerError::LinkError(e) => write!(f, "{e}"),
LinkerError::PathError(path) => write!(
f,
"path contains invalid UTF-8 characters: {}",
path.display()
),
LinkerError::PlatformSdkMissing(err) => {
write!(f, "could not find platform sdk: {}", err)
write!(f, "could not find platform sdk: {err}")
}
}
}
Expand Down Expand Up @@ -143,8 +143,7 @@ impl Ld64Linker {
(_, "macos") => "macosx",
_ => {
return Err(LinkerError::PlatformSdkMissing(format!(
"unsupported arch `{}` for os `{}`",
arch, os
"unsupported arch `{arch}` for os `{os}`"
)));
}
};
Expand Down Expand Up @@ -246,8 +245,8 @@ impl Linker for MsvcLinker {
.push(format!("/EXPORT:{}", abi::GET_VERSION_FN_NAME));
self.args
.push(format!("/EXPORT:{}", abi::SET_ALLOCATOR_HANDLE_FN_NAME));
self.args.push(format!("/IMPLIB:{}", dll_lib_path_str));
self.args.push(format!("/OUT:{}", dll_path_str));
self.args.push(format!("/IMPLIB:{dll_lib_path_str}"));
self.args.push(format!("/OUT:{dll_path_str}"));
Ok(())
}

Expand Down
10 changes: 5 additions & 5 deletions crates/mun_codegen/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,31 @@ impl salsa::Database for MockDatabase {

impl mun_hir::Upcast<dyn mun_hir::AstDatabase> for MockDatabase {
fn upcast(&self) -> &(dyn mun_hir::AstDatabase + 'static) {
&*self
self
}
}

impl mun_hir::Upcast<dyn mun_hir::SourceDatabase> for MockDatabase {
fn upcast(&self) -> &(dyn mun_hir::SourceDatabase + 'static) {
&*self
self
}
}

impl mun_hir::Upcast<dyn mun_hir::DefDatabase> for MockDatabase {
fn upcast(&self) -> &(dyn mun_hir::DefDatabase + 'static) {
&*self
self
}
}

impl mun_hir::Upcast<dyn mun_hir::HirDatabase> for MockDatabase {
fn upcast(&self) -> &(dyn mun_hir::HirDatabase + 'static) {
&*self
self
}
}

impl mun_hir::Upcast<dyn CodeGenDatabase> for MockDatabase {
fn upcast(&self) -> &(dyn CodeGenDatabase + 'static) {
&*self
self
}
}

Expand Down
Loading