diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh index 202d431bb..4a527de76 100644 --- a/.devcontainer/setup.sh +++ b/.devcontainer/setup.sh @@ -27,3 +27,8 @@ echo "export PATH=$DOTNET_PATH:\$PATH" >> ~/.bashrc # Moonbit curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash echo 'export PATH="$HOME/.moon/bin:$PATH"' >> ~/.bashrc + +# Go +curl -OL https://go.dev/dl/go1.25.5.linux-amd64.tar.gz +tar xf go1.25.5.linux-amd64.tar.gz +echo "export PATH=$HOME/go1.25.5.linux-amd64/bin:\$PATH" >> ~/.bashrc diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 97ded62cc..33c60a37c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -262,3 +262,11 @@ jobs: - name: Report failure on cancellation if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }} run: exit 1 + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - run: rustup update stable --no-self-update && rustup default stable + - run: rustup component add clippy + - run: cargo clippy --workspace --all-targets -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index 562c26533..50535377a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ description = """ CLI tool to generate bindings for WIT documents and the component model. """ +[lints] +workspace = true + [workspace] resolver = "2" @@ -52,6 +55,21 @@ wit-bindgen-go = { path = 'crates/go', version = '0.50.0' } wit-bindgen = { path = 'crates/guest-rust', version = '0.50.0', default-features = false } wit-bindgen-test = { path = 'crates/test', version = '0.50.0' } +[workspace.lints.clippy] +# The default set of lints in Clippy is viewed as "too noisy" right now so +# they're all turned off by default. Selective lints are then enabled below as +# necessary. +all = { level = 'allow', priority = -1 } +clone_on_copy = 'warn' +map_clone = 'warn' +unnecessary_to_owned = 'warn' +manual_strip = 'warn' +uninlined_format_args = 'warn' +unnecessary_mut_passed = 'warn' +unnecessary_fallible_conversions = 'warn' +unnecessary_cast = 'warn' +allow_attributes_without_reason = 'warn' + [[bin]] name = "wit-bindgen" diff --git a/crates/c/Cargo.toml b/crates/c/Cargo.toml index 57769651d..a32c12d68 100644 --- a/crates/c/Cargo.toml +++ b/crates/c/Cargo.toml @@ -12,6 +12,9 @@ C bindings generator for WIT and the component model, typically used through the `wit-bindgen-cli` crate. """ +[lints] +workspace = true + [lib] doctest = false test = false diff --git a/crates/c/src/lib.rs b/crates/c/src/lib.rs index 6582236e9..a3b3b8bf4 100644 --- a/crates/c/src/lib.rs +++ b/crates/c/src/lib.rs @@ -662,36 +662,36 @@ impl C { match cast { Bitcast::I32ToF32 | Bitcast::I64ToF32 => { self.needs_union_int32_float = true; - format!("((union int32_float){{ (int32_t) {} }}).b", op) + format!("((union int32_float){{ (int32_t) {op} }}).b") } Bitcast::F32ToI32 | Bitcast::F32ToI64 => { self.needs_union_float_int32 = true; - format!("((union float_int32){{ {} }}).b", op) + format!("((union float_int32){{ {op} }}).b") } Bitcast::I64ToF64 => { self.needs_union_int64_double = true; - format!("((union int64_double){{ (int64_t) {} }}).b", op) + format!("((union int64_double){{ (int64_t) {op} }}).b") } Bitcast::F64ToI64 => { self.needs_union_double_int64 = true; - format!("((union double_int64){{ {} }}).b", op) + format!("((union double_int64){{ {op} }}).b") } Bitcast::I32ToI64 | Bitcast::LToI64 | Bitcast::PToP64 => { - format!("(int64_t) {}", op) + format!("(int64_t) {op}") } Bitcast::I64ToI32 | Bitcast::I64ToL => { - format!("(int32_t) {}", op) + format!("(int32_t) {op}") } // P64 is currently represented as int64_t, so no conversion is needed. Bitcast::I64ToP64 | Bitcast::P64ToI64 => { - format!("{}", op) + format!("{op}") } Bitcast::P64ToP | Bitcast::I32ToP | Bitcast::LToP => { - format!("(uint8_t *) {}", op) + format!("(uint8_t *) {op}") } // Cast to uintptr_t to avoid implicit pointer-to-int conversions. - Bitcast::PToI32 | Bitcast::PToL => format!("(uintptr_t) {}", op), + Bitcast::PToI32 | Bitcast::PToL => format!("(uintptr_t) {op}"), Bitcast::I32ToL | Bitcast::LToI32 | Bitcast::None => op.to_string(), @@ -2034,7 +2034,7 @@ impl InterfaceGenerator<'_> { let mut f = FunctionBindgen::new(self, c_sig, &import_name); for (pointer, param) in f.sig.params.iter() { if *pointer { - f.params.push(format!("*{}", param)); + f.params.push(format!("*{param}")); } else { f.params.push(param.clone()); } @@ -2332,7 +2332,7 @@ void {name}_return({return_ty}) {{ } else if single_ret { "ret".into() } else { - format!("ret{}", i) + format!("ret{i}") }; self.src.h_fns(&name); retptrs.push(name); @@ -2897,7 +2897,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { ) { self.load(ty, offset, operands, results); let result = results.pop().unwrap(); - results.push(format!("(int32_t) {}", result)); + results.push(format!("(int32_t) {result}")); } fn store(&mut self, ty: &str, offset: ArchitectureSize, operands: &[String]) { @@ -2930,10 +2930,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { && self.r#gen.autodrop_enabled() && self.r#gen.contains_droppable_borrow(ty) { - panic!( - "Unable to autodrop borrows in `{}` values, please disable autodrop", - context - ) + panic!("Unable to autodrop borrows in `{context}` values, please disable autodrop") } } } @@ -3055,7 +3052,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { } Instruction::RecordLift { ty, record, .. } => { let name = self.r#gen.r#gen.type_name(&Type::Id(*ty)); - let mut result = format!("({}) {{\n", name); + let mut result = format!("({name}) {{\n"); for (field, op) in record.fields.iter().zip(operands.iter()) { let field_ty = self.r#gen.r#gen.type_name(&field.ty); uwriteln!(result, "({}) {},", field_ty, op); @@ -3067,12 +3064,12 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::TupleLower { tuple, .. } => { let op = &operands[0]; for i in 0..tuple.types.len() { - results.push(format!("({}).f{}", op, i)); + results.push(format!("({op}).f{i}")); } } Instruction::TupleLift { ty, tuple, .. } => { let name = self.r#gen.r#gen.type_name(&Type::Id(*ty)); - let mut result = format!("({}) {{\n", name); + let mut result = format!("({name}) {{\n"); for (ty, op) in tuple.types.iter().zip(operands.iter()) { let ty = self.r#gen.r#gen.type_name(&ty); uwriteln!(result, "({}) {},", ty, op); @@ -3151,7 +3148,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::VariantPayloadName => { let name = self.locals.tmp("payload"); - results.push(format!("*{}", name)); + results.push(format!("*{name}")); self.payloads.push(name); } @@ -3229,7 +3226,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { assert!(block_results.len() == (case.ty.is_some() as usize)); if let Some(_) = case.ty.as_ref() { - let mut dst = format!("{}.val", result); + let mut dst = format!("{result}.val"); dst.push_str("."); dst.push_str(&to_c_ident(&case.name)); self.store_op(&block_results[0], &dst); @@ -3665,7 +3662,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Some(Scalar::OptionBool(_)) => { assert_eq!(operands.len(), 1); let variant = &operands[0]; - self.store_in_retptr(&format!("{}.val", variant)); + self.store_in_retptr(&format!("{variant}.val")); self.src.push_str("return "); self.src.push_str(&variant); self.src.push_str(".is_some;\n"); @@ -3677,7 +3674,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { uwriteln!(self.src, "if (!{}.is_err) {{", variant); if ok.is_some() { if ok.is_some() { - self.store_in_retptr(&format!("{}.val.ok", variant)); + self.store_in_retptr(&format!("{variant}.val.ok")); } else { self.empty_return_value(); } @@ -3689,7 +3686,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { ); if err.is_some() { if err.is_some() { - self.store_in_retptr(&format!("{}.val.err", variant)); + self.store_in_retptr(&format!("{variant}.val.err")); } else { self.empty_return_value(); } @@ -3797,7 +3794,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { } Instruction::Flush { amt } => { - results.extend(operands.iter().take(*amt).map(|v| v.clone())); + results.extend(operands.iter().take(*amt).cloned()); } Instruction::AsyncTaskReturn { name, params } => { @@ -3815,7 +3812,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { params: params .iter() .zip(operands) - .map(|(a, b)| (a.clone(), b.clone())) + .map(|(a, b)| (*a, b.clone())) .collect(), }; } @@ -3928,7 +3925,7 @@ pub fn flags_repr(f: &Flags) -> Int { FlagsRepr::U16 => Int::U16, FlagsRepr::U32(1) => Int::U32, FlagsRepr::U32(2) => Int::U64, - repr => panic!("unimplemented flags {:?}", repr), + repr => panic!("unimplemented flags {repr:?}"), } } diff --git a/crates/core/Cargo.toml b/crates/core/Cargo.toml index 025eeacb6..b0b9a06d4 100644 --- a/crates/core/Cargo.toml +++ b/crates/core/Cargo.toml @@ -12,6 +12,9 @@ Low-level support for bindings generation based on WIT files for use with `wit-bindgen-cli` and other languages. """ +[lints] +workspace = true + [lib] doctest = false diff --git a/crates/core/src/abi.rs b/crates/core/src/abi.rs index 98e2bf998..d92621ae9 100644 --- a/crates/core/src/abi.rs +++ b/crates/core/src/abi.rs @@ -37,7 +37,7 @@ macro_rules! def_instruction { impl $name<'_> { /// How many operands does this instruction pop from the stack? - #[allow(unused_variables)] + #[allow(unused_variables, reason = "match arms bind fields for exhaustiveness, not usage")] pub fn operands_len(&self) -> usize { match self { $( @@ -51,7 +51,7 @@ macro_rules! def_instruction { } /// How many results does this instruction push onto the stack? - #[allow(unused_variables)] + #[allow(unused_variables, reason = "match arms bind fields for exhaustiveness, not usage")] pub fn results_len(&self) -> usize { match self { $( diff --git a/crates/core/src/ns.rs b/crates/core/src/ns.rs index 2cbd1e9d2..a719dddcc 100644 --- a/crates/core/src/ns.rs +++ b/crates/core/src/ns.rs @@ -11,7 +11,7 @@ impl Ns { if self.defined.insert(name.to_string()) { Ok(()) } else { - Err(format!("name `{}` already defined", name)) + Err(format!("name `{name}` already defined")) } } diff --git a/crates/cpp/Cargo.toml b/crates/cpp/Cargo.toml index f727cb448..f99883060 100644 --- a/crates/cpp/Cargo.toml +++ b/crates/cpp/Cargo.toml @@ -10,6 +10,9 @@ description = """ C++ guest and host binding generator for WIT and the component model. """ +[lints] +workspace = true + [lib] doctest = false test = false diff --git a/crates/cpp/src/lib.rs b/crates/cpp/src/lib.rs index b34850b85..a897ce097 100644 --- a/crates/cpp/src/lib.rs +++ b/crates/cpp/src/lib.rs @@ -209,10 +209,7 @@ impl FromStr for APIStyle { match s { "asymmetric" => Ok(APIStyle::Asymmetric), "symmetric" => Ok(APIStyle::Symmetric), - _ => bail!( - "unrecognized API style: `{}`; expected `asymmetric` or `symmetric`", - s - ), + _ => bail!("unrecognized API style: `{s}`; expected `asymmetric` or `symmetric`"), } } } @@ -357,32 +354,32 @@ impl Cpp { match cast { Bitcast::I32ToF32 | Bitcast::I64ToF32 => { self.dependencies.needs_bit = true; - format!("std::bit_cast({})", op) + format!("std::bit_cast({op})") } Bitcast::F32ToI32 | Bitcast::F32ToI64 => { self.dependencies.needs_bit = true; - format!("std::bit_cast({})", op) + format!("std::bit_cast({op})") } Bitcast::I64ToF64 => { self.dependencies.needs_bit = true; - format!("std::bit_cast({})", op) + format!("std::bit_cast({op})") } Bitcast::F64ToI64 => { self.dependencies.needs_bit = true; - format!("std::bit_cast({})", op) + format!("std::bit_cast({op})") } Bitcast::I32ToI64 | Bitcast::LToI64 | Bitcast::PToP64 => { - format!("(int64_t) {}", op) + format!("(int64_t) {op}") } Bitcast::I64ToI32 | Bitcast::PToI32 | Bitcast::LToI32 => { - format!("(int32_t) {}", op) + format!("(int32_t) {op}") } Bitcast::P64ToI64 | Bitcast::None | Bitcast::I64ToP64 => op.to_string(), Bitcast::P64ToP | Bitcast::I32ToP | Bitcast::LToP => { - format!("(uint8_t*) {}", op) + format!("(uint8_t*) {op}") } Bitcast::PToL | Bitcast::I32ToL | Bitcast::I64ToL => { - format!("(size_t) {}", op) + format!("(size_t) {op}") } Bitcast::Sequence(sequence) => { let [first, second] = &**sequence; @@ -1191,7 +1188,7 @@ impl CppInterfaceGenerator<'_> { cpp_sig .arguments .iter() - .map(|(arg, _)| format!("std::move({})", arg)) + .map(|(arg, _)| format!("std::move({arg})")) .collect::>() .join(", ") ); @@ -1485,11 +1482,11 @@ impl CppInterfaceGenerator<'_> { if self.r#gen.types.get(id).has_own_handle { name.to_string() } else { - format!("{}Param", name) + format!("{name}Param") } } Ownership::FineBorrowing => { - format!("{}Param", name) + format!("{name}Param") } } } else { @@ -2266,7 +2263,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { fn let_results(&mut self, amt: usize, results: &mut Vec) { if amt > 0 { let tmp = self.tmp(); - let res = format!("result{}", tmp); + let res = format!("result{tmp}"); self.push_str("auto "); self.push_str(&res); self.push_str(" = "); @@ -2304,7 +2301,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { ) { self.load(ty, offset, operands, results); let result = results.pop().unwrap(); - results.push(format!("(int32_t) ({})", result)); + results.push(format!("(int32_t) ({result})")); } fn store(&mut self, ty: &str, offset: ArchitectureSize, operands: &[String]) { @@ -2395,7 +2392,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { results.push(self.params[*nth].clone()); } } - abi::Instruction::I32Const { val } => results.push(format!("(int32_t({}))", val)), + abi::Instruction::I32Const { val } => results.push(format!("(int32_t({val}))")), abi::Instruction::Bitcasts { casts } => { for (cast, op) in casts.iter().zip(operands) { // let op = op; @@ -2473,9 +2470,9 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { abi::Instruction::BoolFromI32 => top_as("bool"), abi::Instruction::ListCanonLower { realloc, .. } => { let tmp = self.tmp(); - let val = format!("vec{}", tmp); - let ptr = format!("ptr{}", tmp); - let len = format!("len{}", tmp); + let val = format!("vec{tmp}"); + let ptr = format!("ptr{tmp}"); + let len = format!("len{tmp}"); self.push_str(&format!("auto&& {} = {};\n", val, operands[0])); self.push_str(&format!( "auto {} = ({})({}.data());\n", @@ -2483,7 +2480,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { self.r#gen.r#gen.opts.ptr_type(), val )); - self.push_str(&format!("auto {} = (size_t)({}.size());\n", len, val)); + self.push_str(&format!("auto {len} = (size_t)({val}.size());\n")); if realloc.is_none() { results.push(ptr); } else { @@ -2494,9 +2491,9 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { } abi::Instruction::StringLower { realloc } => { let tmp = self.tmp(); - let val = format!("vec{}", tmp); - let ptr = format!("ptr{}", tmp); - let len = format!("len{}", tmp); + let val = format!("vec{tmp}"); + let ptr = format!("ptr{tmp}"); + let len = format!("len{tmp}"); self.push_str(&format!("auto&& {} = {};\n", val, operands[0])); self.push_str(&format!( "auto {} = ({})({}.data());\n", @@ -2504,7 +2501,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { self.r#gen.r#gen.opts.ptr_type(), val )); - self.push_str(&format!("auto {} = (size_t)({}.size());\n", len, val)); + self.push_str(&format!("auto {len} = (size_t)({val}.size());\n")); if realloc.is_none() { results.push(ptr); } else { @@ -2516,9 +2513,9 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { abi::Instruction::ListLower { element, realloc } => { let tmp = self.tmp(); let body = self.blocks.pop().unwrap(); - let val = format!("vec{}", tmp); - let ptr = format!("ptr{}", tmp); - let len = format!("len{}", tmp); + let val = format!("vec{tmp}"); + let ptr = format!("ptr{tmp}"); + let len = format!("len{tmp}"); let size = self.r#gen.sizes.size(element); self.push_str(&format!("auto&& {} = {};\n", val, operands[0])); self.push_str(&format!( @@ -2527,7 +2524,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { self.r#gen.r#gen.opts.ptr_type(), val )); - self.push_str(&format!("auto {} = (size_t)({}.size());\n", len, val)); + self.push_str(&format!("auto {len} = (size_t)({val}.size());\n")); self.push_str(&format!("for (size_t i = 0; i < {len}; ++i) {{\n")); self.push_str(&format!( "auto base = {ptr} + i * {size};\n", @@ -2546,7 +2543,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { } abi::Instruction::ListCanonLift { element, .. } => { let tmp = self.tmp(); - let len = format!("len{}", tmp); + let len = format!("len{tmp}"); let inner = self .r#gen .type_name(element, &self.namespace, Flavor::InStruct); @@ -2565,7 +2562,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { } abi::Instruction::StringLift => { let tmp = self.tmp(); - let len = format!("len{}", tmp); + let len = format!("len{tmp}"); uwriteln!(self.src, "auto {} = {};\n", len, operands[1]); let result = if self.r#gen.r#gen.opts.api_style == APIStyle::Symmetric && matches!(self.variant, AbiVariant::GuestExport) @@ -3276,7 +3273,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { &[WasmType::Pointer], &[], ); - self.src.push_str(&format!(", ret, {})", cabi_post_name)); + self.src.push_str(&format!(", ret, {cabi_post_name})")); } if matches!(func.kind, FunctionKind::Constructor(_)) && self.r#gen.r#gen.opts.is_only_handle(self.variant) @@ -3362,7 +3359,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { abi::Instruction::Flush { amt } => { for i in operands.iter().take(*amt) { let tmp = self.tmp(); - let result = format!("result{}", tmp); + let result = format!("result{tmp}"); uwriteln!(self.src, "auto {result} = {};", move_if_necessary(i)); results.push(result); } @@ -3385,7 +3382,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> { self.r#gen.r#gen.opts.ptr_type(), ); - format!("ptr{}", tmp) + format!("ptr{tmp}") } fn push_block(&mut self) { diff --git a/crates/csharp/Cargo.toml b/crates/csharp/Cargo.toml index 9b4aa062c..47dfa7d5d 100644 --- a/crates/csharp/Cargo.toml +++ b/crates/csharp/Cargo.toml @@ -12,6 +12,9 @@ C# bindings generator for WIT and the component model, typically used through the `wit-bindgen-cli` crate. """ +[lints] +workspace = true + [lib] doctest = false test = false diff --git a/crates/csharp/src/csharp_ident.rs b/crates/csharp/src/csharp_ident.rs index d5be6b16d..9112d18af 100644 --- a/crates/csharp/src/csharp_ident.rs +++ b/crates/csharp/src/csharp_ident.rs @@ -94,7 +94,7 @@ impl ToCSharpIdent for str { fn to_csharp_ident(&self) -> String { // Escape C# keywords if Self::csharp_keywords().contains(&self) { - format!("@{}", self) + format!("@{self}") } else { self.to_lower_camel_case() } @@ -103,7 +103,7 @@ impl ToCSharpIdent for str { fn to_csharp_ident_upper(&self) -> String { // Escape C# keywords if Self::csharp_keywords().contains(&self) { - format!("@{}", self) + format!("@{self}") } else { self.to_upper_camel_case() } diff --git a/crates/csharp/src/function.rs b/crates/csharp/src/function.rs index c22389c2a..cf6e535fe 100644 --- a/crates/csharp/src/function.rs +++ b/crates/csharp/src/function.rs @@ -274,7 +274,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { self.interface_gen.csharp_gen.needs_wit_exception = true; let (var_name, exception_name) = var; let exception_name = match exception_name { - Some(type_name) => &format!("WitException<{}>", type_name), + Some(type_name) => &format!("WitException<{type_name}>"), None => "WitException", }; uwrite!( @@ -549,7 +549,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { self.interface_gen.qualifier(true, ty), name.to_string().to_upper_camel_case() ); - let mut result = format!("new {} (\n", qualified_type_name); + let mut result = format!("new {qualified_type_name} (\n"); result.push_str(&operands.join(", ")); result.push_str(")"); @@ -563,7 +563,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::TupleLower { tuple, ty: _ } => { let op = &operands[0]; match tuple.types.len() { - 1 => results.push(format!("({})", op)), + 1 => results.push(format!("({op})")), _ => { for i in 0..tuple.types.len() { results.push(format!("{}.Item{}", op, i + 1)); @@ -761,7 +761,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::EnumLift { ty, .. } => { let t = self.interface_gen.type_name_with_qualifier(&Type::Id(*ty), true); let op = &operands[0]; - results.push(format!("({}){}", t, op)); + results.push(format!("({t}){op}")); // uwriteln!( // self.src, @@ -896,10 +896,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { let op0 = &operands[0]; let op1 = &operands[1]; - let get_str = format!( - "global::System.Text.Encoding.UTF8.GetString((byte*){}, {})", - op0, op1 - ); + let get_str = format!("global::System.Text.Encoding.UTF8.GetString((byte*){op0}, {op1})"); uwriteln!( self.src, @@ -1373,7 +1370,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { } Instruction::Flush { amt } => { - results.extend(operands.iter().take(*amt).map(|v| v.clone())); + results.extend(operands.iter().take(*amt).cloned()); } Instruction::FutureLower { .. } => { diff --git a/crates/csharp/src/interface.rs b/crates/csharp/src/interface.rs index 4f30b8f68..849df02b1 100644 --- a/crates/csharp/src/interface.rs +++ b/crates/csharp/src/interface.rs @@ -247,7 +247,7 @@ impl InterfaceGenerator<'_> { if param_list.is_empty() { "void *taskResultBuffer".to_string() } else { - format!("{}, void *taskResultBuffer", param_list) + format!("{param_list}, void *taskResultBuffer") } } else { param_list @@ -365,7 +365,7 @@ impl InterfaceGenerator<'_> { | FunctionKind::AsyncStatic(_) | FunctionKind::AsyncMethod(_) => match func.result { None => "Task".to_string(), - Some(_ty) => format!("Task<{}>", base_type), + Some(_ty) => format!("Task<{base_type}>"), }, _ => base_type, }; @@ -604,7 +604,7 @@ impl InterfaceGenerator<'_> { // TODO: The task return function can take up to 16 core parameters. let task_return_param = match &sig.results[..] { [] => "", - [_result] => &format!("{} result", wasm_result_type), + [_result] => &format!("{wasm_result_type} result"), _ => unreachable!(), }; diff --git a/crates/csharp/src/world_generator.rs b/crates/csharp/src/world_generator.rs index 205e47cba..b58bbb026 100644 --- a/crates/csharp/src/world_generator.rs +++ b/crates/csharp/src/world_generator.rs @@ -585,7 +585,7 @@ impl WorldGenerator for CSharp { //TODO: This is currently needed for mono even if it's built as a library. if self.opts.runtime == CSharpRuntime::Mono { files.push( - &"MonoEntrypoint.cs".to_string(), + "MonoEntrypoint.cs", indent(&format!( r#" {access} class MonoEntrypoint() {{ diff --git a/crates/go/Cargo.toml b/crates/go/Cargo.toml index 8234e808c..563125ec0 100644 --- a/crates/go/Cargo.toml +++ b/crates/go/Cargo.toml @@ -12,6 +12,9 @@ Go bindings generator for WIT and the component model, typically used through th `wit-bindgen-cli` crate. """ +[lints] +workspace = true + [dependencies] wit-bindgen-core = { workspace = true } wit-component = { workspace = true } diff --git a/crates/go/src/lib.rs b/crates/go/src/lib.rs index 20858b703..19899fc82 100644 --- a/crates/go/src/lib.rs +++ b/crates/go/src/lib.rs @@ -35,12 +35,12 @@ const PINNER: &str = "pinner"; /// Adds the wit-bindgen GitHub repository prefix to a package name. fn remote_pkg(name: &str) -> String { - format!(r#""github.com/bytecodealliance/wit-bindgen/{}""#, name) + format!(r#""github.com/bytecodealliance/wit-bindgen/{name}""#) } /// Adds the bindings module prefix to a package name. fn mod_pkg(name: &str) -> String { - format!(r#""wit_component/{}""#, name) + format!(r#""wit_component/{name}""#) } /// This is the literal location of the Go package. @@ -358,7 +358,7 @@ impl Go { } } - #[expect(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments, reason = "required context codegen")] fn future_or_stream( &mut self, resolve: &Resolve, @@ -1297,7 +1297,7 @@ func wasm_export_{name}({params}) {results} {{ ) } - #[expect(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments, reason = "required context for codegen")] fn func_params( &mut self, resolve: &Resolve, @@ -1438,7 +1438,7 @@ struct FunctionGenerator<'a> { } impl<'a> FunctionGenerator<'a> { - #[expect(clippy::too_many_arguments)] + #[expect(clippy::too_many_arguments, reason = "required context for codegen")] fn new( generator: &'a mut Go, name: Option<&'a str>, diff --git a/crates/guest-rust/Cargo.toml b/crates/guest-rust/Cargo.toml index 1d6d1ae2c..3ee6d6a8d 100644 --- a/crates/guest-rust/Cargo.toml +++ b/crates/guest-rust/Cargo.toml @@ -12,6 +12,9 @@ Rust bindings generator and runtime support for WIT and the component model. Used when compiling Rust programs to the component model. """ +[lints] +workspace = true + [package.metadata.docs.rs] all-features = true diff --git a/crates/guest-rust/macro/src/lib.rs b/crates/guest-rust/macro/src/lib.rs index b813585c4..6a4671e63 100644 --- a/crates/guest-rust/macro/src/lib.rs +++ b/crates/guest-rust/macro/src/lib.rs @@ -488,7 +488,7 @@ impl Parse for Opt { let _lbrace = braced!(contents in input); let fields: Punctuated<_, Token![,]> = contents.parse_terminated(with_field_parse, Token![,])?; - Ok(Opt::With(HashMap::from_iter(fields.into_iter()))) + Ok(Opt::With(HashMap::from_iter(fields))) } else if l.peek(kw::generate_all) { input.parse::()?; Ok(Opt::GenerateAll) @@ -601,6 +601,6 @@ fn with_field_parse(input: ParseStream<'_>) -> Result<(String, WithOption)> { /// Format a valid Rust string fn fmt(input: &str) -> Result { - let syntax_tree = syn::parse_file(&input)?; + let syntax_tree = syn::parse_file(input)?; Ok(prettyplease::unparse(&syntax_tree)) } diff --git a/crates/guest-rust/src/rt/async_support.rs b/crates/guest-rust/src/rt/async_support.rs index 336898c24..080919a8c 100644 --- a/crates/guest-rust/src/rt/async_support.rs +++ b/crates/guest-rust/src/rt/async_support.rs @@ -40,7 +40,7 @@ macro_rules! extern_wasm { ) => { $( #[cfg(not(target_family = "wasm"))] - #[allow(unused)] + #[allow(unused, reason = "dummy shim for non-wasm compilation, never invoked")] $vis unsafe fn $func_name($($args)*) $(-> $ret)? { unreachable!(); } diff --git a/crates/markdown/Cargo.toml b/crates/markdown/Cargo.toml index ecdc976f2..ef0cf5e5d 100644 --- a/crates/markdown/Cargo.toml +++ b/crates/markdown/Cargo.toml @@ -11,6 +11,9 @@ Markdown generator for WIT and the component model, typically used through the `wit-bindgen-cli` crate. """ +[lints] +workspace = true + [lib] doctest = false test = false diff --git a/crates/markdown/src/lib.rs b/crates/markdown/src/lib.rs index 355ffae27..e221ec6c1 100644 --- a/crates/markdown/src/lib.rs +++ b/crates/markdown/src/lib.rs @@ -506,7 +506,7 @@ impl<'a> wit_bindgen_core::InterfaceGenerator<'a> for InterfaceGenerator<'a> { name = i, )); self.r#gen.hrefs.insert( - format!("{}::{}", name, i), + format!("{name}::{i}"), format!("#{}.{}", name.to_snake_case(), i), ); self.print_ty(ty); diff --git a/crates/moonbit/Cargo.toml b/crates/moonbit/Cargo.toml index 68238e372..fbf246090 100644 --- a/crates/moonbit/Cargo.toml +++ b/crates/moonbit/Cargo.toml @@ -12,6 +12,9 @@ MoonBit bindings generator for WIT and the component model, typically used through the `wit-bindgen-cli` crate. """ +[lints] +workspace = true + [dependencies] anyhow = { workspace = true } wit-bindgen-core = { workspace = true } diff --git a/crates/rust/Cargo.toml b/crates/rust/Cargo.toml index 9b23b0c4d..f36ab8c14 100644 --- a/crates/rust/Cargo.toml +++ b/crates/rust/Cargo.toml @@ -12,6 +12,9 @@ Rust bindings generator for WIT and the component model, typically used through the `wit-bindgen` crate's `generate!` macro. """ +[lints] +workspace = true + [lib] test = false doctest = false diff --git a/crates/rust/src/bindgen.rs b/crates/rust/src/bindgen.rs index df3623476..0ac7f84b2 100644 --- a/crates/rust/src/bindgen.rs +++ b/crates/rust/src/bindgen.rs @@ -73,7 +73,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { 0 => {} 1 => { let tmp = self.tmp(); - let res = format!("result{}", tmp); + let res = format!("result{tmp}"); self.push_str("let "); self.push_str(&res); results.push(res); @@ -83,7 +83,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { let tmp = self.tmp(); self.push_str("let ("); for i in 0..n { - let arg = format!("result{}_{}", tmp, i); + let arg = format!("result{tmp}_{i}"); self.push_str(&arg); self.push_str(","); results.push(arg); @@ -107,7 +107,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { self.push_str("{ "); for field in record.fields.iter() { let name = to_rust_ident(&field.name); - let arg = format!("{}{}", name, tmp); + let arg = format!("{name}{tmp}"); self.push_str(&name); self.push_str(":"); self.push_str(&arg); @@ -142,7 +142,7 @@ impl<'a, 'b> FunctionBindgen<'a, 'b> { let tmp = self.tmp(); self.push_str("let ("); for i in 0..tuple.types.len() { - let arg = format!("t{}_{}", tmp, i); + let arg = format!("t{tmp}_{i}"); self.push_str(&arg); self.push_str(", "); results.push(arg); @@ -249,7 +249,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { "let ptr{tmp} = (&raw mut _RET_AREA.0).cast::();" ); } - format!("ptr{}", tmp) + format!("ptr{tmp}") } fn sizes(&self) -> &SizeAlign { @@ -276,7 +276,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { match inst { Instruction::GetArg { nth } => results.push(self.params[*nth].clone()), - Instruction::I32Const { val } => results.push(format!("{}i32", val)), + Instruction::I32Const { val } => results.push(format!("{val}i32")), Instruction::ConstZero { tys } => { for ty in tys.iter() { match ty { @@ -667,23 +667,22 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::ListCanonLower { realloc, .. } => { let tmp = self.tmp(); - let val = format!("vec{}", tmp); - let ptr = format!("ptr{}", tmp); - let len = format!("len{}", tmp); + let val = format!("vec{tmp}"); + let ptr = format!("ptr{tmp}"); + let len = format!("len{tmp}"); let vec = self.r#gen.path_to_vec(); if realloc.is_none() { self.push_str(&format!("let {} = {};\n", val, operands[0])); } else { let op0 = operands.pop().unwrap(); self.push_str(&format!( - "let {} = <_ as Into<{vec}<_>>>::into({}).into_boxed_slice();\n", - val, op0 + "let {val} = <_ as Into<{vec}<_>>>::into({op0}).into_boxed_slice();\n" )); } - self.push_str(&format!("let {} = {}.as_ptr().cast::();\n", ptr, val)); - self.push_str(&format!("let {} = {}.len();\n", len, val)); + self.push_str(&format!("let {ptr} = {val}.as_ptr().cast::();\n")); + self.push_str(&format!("let {len} = {val}.len();\n")); if realloc.is_some() { - self.push_str(&format!("::core::mem::forget({});\n", val)); + self.push_str(&format!("::core::mem::forget({val});\n")); } results.push(format!("{ptr}.cast_mut()")); results.push(len); @@ -691,7 +690,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::ListCanonLift { .. } => { let tmp = self.tmp(); - let len = format!("len{}", tmp); + let len = format!("len{tmp}"); self.push_str(&format!("let {} = {};\n", len, operands[1])); let vec = self.r#gen.path_to_vec(); let result = format!( @@ -703,19 +702,19 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::StringLower { realloc } => { let tmp = self.tmp(); - let val = format!("vec{}", tmp); - let ptr = format!("ptr{}", tmp); - let len = format!("len{}", tmp); + let val = format!("vec{tmp}"); + let ptr = format!("ptr{tmp}"); + let len = format!("len{tmp}"); if realloc.is_none() { self.push_str(&format!("let {} = {};\n", val, operands[0])); } else { let op0 = format!("{}.into_bytes()", operands[0]); - self.push_str(&format!("let {} = ({}).into_boxed_slice();\n", val, op0)); + self.push_str(&format!("let {val} = ({op0}).into_boxed_slice();\n")); } - self.push_str(&format!("let {} = {}.as_ptr().cast::();\n", ptr, val)); - self.push_str(&format!("let {} = {}.len();\n", len, val)); + self.push_str(&format!("let {ptr} = {val}.as_ptr().cast::();\n")); + self.push_str(&format!("let {len} = {val}.len();\n")); if realloc.is_some() { - self.push_str(&format!("::core::mem::forget({});\n", val)); + self.push_str(&format!("::core::mem::forget({val});\n")); } results.push(format!("{ptr}.cast_mut()")); results.push(len); @@ -724,7 +723,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::StringLift => { let vec = self.r#gen.path_to_vec(); let tmp = self.tmp(); - let len = format!("len{}", tmp); + let len = format!("len{tmp}"); uwriteln!(self.src, "let {len} = {};", operands[1]); uwriteln!( self.src, @@ -945,7 +944,7 @@ impl Bindgen for FunctionBindgen<'_, '_> { Instruction::Flush { amt } => { for i in 0..*amt { let tmp = self.tmp(); - let result = format!("result{}", tmp); + let result = format!("result{tmp}"); uwriteln!(self.src, "let {result} = {};", operands[i]); results.push(result); } diff --git a/crates/rust/src/interface.rs b/crates/rust/src/interface.rs index c9a55eb14..725de62d1 100644 --- a/crates/rust/src/interface.rs +++ b/crates/rust/src/interface.rs @@ -1237,7 +1237,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) let sig = self.resolve.wasm_signature(variant, func); let mut params = Vec::new(); for (i, param) in sig.params.iter().enumerate() { - let name = format!("arg{}", i); + let name = format!("arg{i}"); uwrite!(self.src, "{name}: {},", wasm_type(*param)); params.push(name); } @@ -1259,7 +1259,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) let mut params = Vec::new(); let sig = self.resolve.wasm_signature(AbiVariant::GuestExport, func); for (i, result) in sig.results.iter().enumerate() { - let name = format!("arg{}", i); + let name = format!("arg{i}"); uwrite!(self.src, "{name}: {},", wasm_type(*result)); params.push(name); } @@ -1974,7 +1974,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) self.push_str(&derives.into_iter().collect::>().join(", ")); self.push_str(")]\n") } - self.push_str(&format!("pub struct {}", name)); + self.push_str(&format!("pub struct {name}")); self.print_generics(mode.lifetime); self.push_str(" {\n"); for field in record.fields.iter() { @@ -1997,7 +1997,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) self.push_str( "fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {\n", ); - self.push_str(&format!("f.debug_struct(\"{}\")", name)); + self.push_str(&format!("f.debug_struct(\"{name}\")")); for field in record.fields.iter() { self.push_str(&format!( ".field(\"{}\", &self.{})", @@ -2163,7 +2163,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) self.push_str("(e)"); } self.push_str(" => {\n"); - self.push_str(&format!("f.debug_tuple(\"{}::{}\")", name, case_name)); + self.push_str(&format!("f.debug_tuple(\"{name}::{case_name}\")")); if payload.is_some() { self.push_str(".field(e)"); } @@ -2178,7 +2178,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) fn print_typedef_option(&mut self, id: TypeId, payload: &Type, docs: &Docs) { for (name, mode) in self.modes_of(id) { self.rustdoc(docs); - self.push_str(&format!("pub type {}", name)); + self.push_str(&format!("pub type {name}")); self.print_generics(mode.lifetime); self.push_str("= Option<"); self.print_ty(payload, mode); @@ -2189,7 +2189,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) fn print_typedef_result(&mut self, id: TypeId, result: &Result_, docs: &Docs) { for (name, mode) in self.modes_of(id) { self.rustdoc(docs); - self.push_str(&format!("pub type {}", name)); + self.push_str(&format!("pub type {name}")); self.print_generics(mode.lifetime); self.push_str("= Result<"); self.print_optional_ty(result.ok.as_ref(), mode); @@ -2215,7 +2215,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) let name = to_upper_camel_case(name); self.rustdoc(docs); for attr in attrs { - self.push_str(&format!("{}\n", attr)); + self.push_str(&format!("{attr}\n")); } self.push_str("#[repr("); self.int_repr(enum_.tag()); @@ -2352,7 +2352,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) let info = self.info(ty); let name = to_upper_camel_case(self.resolve.types[ty].name.as_ref().unwrap()); if self.uses_two_names(&info) { - format!("{}Param", name) + format!("{name}Param") } else { name } @@ -2362,7 +2362,7 @@ unsafe fn call_import(&mut self, _params: Self::ParamsLower, _results: *mut u8) let info = self.info(ty); let name = to_upper_camel_case(self.resolve.types[ty].name.as_ref().unwrap()); if self.uses_two_names(&info) { - format!("{}Result", name) + format!("{name}Result") } else { name } @@ -2778,7 +2778,7 @@ impl<'a> {camel}Borrow<'a>{{ fn type_tuple(&mut self, id: TypeId, _name: &str, tuple: &Tuple, docs: &Docs) { for (name, mode) in self.modes_of(id) { self.rustdoc(docs); - self.push_str(&format!("pub type {}", name)); + self.push_str(&format!("pub type {name}")); self.print_generics(mode.lifetime); self.push_str(" = ("); for ty in tuple.types.iter() { @@ -2862,7 +2862,7 @@ impl<'a> {camel}Borrow<'a>{{ fn type_list(&mut self, id: TypeId, _name: &str, ty: &Type, docs: &Docs) { for (name, mode) in self.modes_of(id) { self.rustdoc(docs); - self.push_str(&format!("pub type {}", name)); + self.push_str(&format!("pub type {name}")); self.print_generics(mode.lifetime); self.push_str(" = "); self.print_list(ty, mode); diff --git a/crates/rust/src/lib.rs b/crates/rust/src/lib.rs index 6d2139e4c..5cc958416 100644 --- a/crates/rust/src/lib.rs +++ b/crates/rust/src/lib.rs @@ -1702,52 +1702,51 @@ fn bitcast(casts: &[Bitcast], operands: &[String], results: &mut Vec) { fn perform_cast(operand: &str, cast: &Bitcast) -> String { match cast { Bitcast::None => operand.to_owned(), - Bitcast::I32ToI64 => format!("i64::from({})", operand), - Bitcast::F32ToI32 => format!("({}).to_bits() as i32", operand), - Bitcast::F64ToI64 => format!("({}).to_bits() as i64", operand), - Bitcast::I64ToI32 => format!("{} as i32", operand), - Bitcast::I32ToF32 => format!("f32::from_bits({} as u32)", operand), - Bitcast::I64ToF64 => format!("f64::from_bits({} as u64)", operand), - Bitcast::F32ToI64 => format!("i64::from(({}).to_bits())", operand), - Bitcast::I64ToF32 => format!("f32::from_bits({} as u32)", operand), + Bitcast::I32ToI64 => format!("i64::from({operand})"), + Bitcast::F32ToI32 => format!("({operand}).to_bits() as i32"), + Bitcast::F64ToI64 => format!("({operand}).to_bits() as i64"), + Bitcast::I64ToI32 => format!("{operand} as i32"), + Bitcast::I32ToF32 => format!("f32::from_bits({operand} as u32)"), + Bitcast::I64ToF64 => format!("f64::from_bits({operand} as u64)"), + Bitcast::F32ToI64 => format!("i64::from(({operand}).to_bits())"), + Bitcast::I64ToF32 => format!("f32::from_bits({operand} as u32)"), // Convert an `i64` into a `MaybeUninit`. - Bitcast::I64ToP64 => format!("::core::mem::MaybeUninit::new({} as u64)", operand), + Bitcast::I64ToP64 => format!("::core::mem::MaybeUninit::new({operand} as u64)"), // Convert a `MaybeUninit` holding an `i64` value back into // the `i64` value. - Bitcast::P64ToI64 => format!("{}.assume_init() as i64", operand), + Bitcast::P64ToI64 => format!("{operand}.assume_init() as i64"), // Convert a pointer value into a `MaybeUninit`. Bitcast::PToP64 => { format!( "{{ let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write({}); + t.as_mut_ptr().cast::<*mut u8>().write({operand}); t - }}", - operand + }}" ) } // Convert a `MaybeUninit` holding a pointer value back into // the pointer value. Bitcast::P64ToP => { - format!("{}.as_ptr().cast::<*mut u8>().read()", operand) + format!("{operand}.as_ptr().cast::<*mut u8>().read()") } // Convert an `i32` or a `usize` into a pointer. Bitcast::I32ToP | Bitcast::LToP => { - format!("{} as *mut u8", operand) + format!("{operand} as *mut u8") } // Convert a pointer or length holding an `i32` value back into the `i32`. Bitcast::PToI32 | Bitcast::LToI32 => { - format!("{} as i32", operand) + format!("{operand} as i32") } // Convert an `i32`, `i64`, or pointer holding a `usize` value back into the `usize`. Bitcast::I32ToL | Bitcast::I64ToL | Bitcast::PToL => { - format!("{} as usize", operand) + format!("{operand} as usize") } // Convert a `usize` into an `i64`. Bitcast::LToI64 => { - format!("{} as i64", operand) + format!("{operand} as i64") } Bitcast::Sequence(sequence) => { let [first, second] = &**sequence; diff --git a/crates/rust/tests/codegen.rs b/crates/rust/tests/codegen.rs index 346e21961..44ddf31d8 100644 --- a/crates/rust/tests/codegen.rs +++ b/crates/rust/tests/codegen.rs @@ -1,7 +1,11 @@ -#![allow(unused_macros)] -#![allow(dead_code, unused_variables)] - -#[allow(unused)] +#![allow(unused_macros, reason = "testing codegen, not functionality")] +#![allow( + dead_code, + unused_variables, + reason = "testing codegen, not functionality" +)] + +#[allow(unused, reason = "testing codegen, not functionality")] mod multiple_paths { wit_bindgen::generate!({ inline: r#" @@ -17,7 +21,7 @@ mod multiple_paths { }); } -#[allow(unused)] +#[allow(unused, reason = "testing codegen, not functionality")] mod inline_and_path { wit_bindgen::generate!({ inline: r#" @@ -32,7 +36,7 @@ mod inline_and_path { }); } -#[allow(unused)] +#[allow(unused, reason = "testing codegen, not functionality")] mod newtyped_list { use std::ops::Deref; @@ -138,7 +142,7 @@ mod newtyped_list { } } } -#[allow(unused)] +#[allow(unused, reason = "testing codegen, not functionality")] mod retyped_list { use std::ops::Deref; diff --git a/crates/test-helpers/Cargo.toml b/crates/test-helpers/Cargo.toml index ffc4ceeba..6e7fae822 100644 --- a/crates/test-helpers/Cargo.toml +++ b/crates/test-helpers/Cargo.toml @@ -3,6 +3,9 @@ name = "test-helpers" edition.workspace = true publish = false +[lints] +workspace = true + [lib] doctest = false test = false diff --git a/crates/test/Cargo.toml b/crates/test/Cargo.toml index fb8f45aca..160afdf1a 100644 --- a/crates/test/Cargo.toml +++ b/crates/test/Cargo.toml @@ -11,6 +11,9 @@ Backend of the `wit-bindgen test` subcommand """ readme = "README.md" +[lints] +workspace = true + [lib] test = false doctest = false diff --git a/crates/test/src/cpp.rs b/crates/test/src/cpp.rs index e2a0dd973..c88b9ed5d 100644 --- a/crates/test/src/cpp.rs +++ b/crates/test/src/cpp.rs @@ -131,9 +131,9 @@ impl LanguageMethods for Cpp { .arg("-I") .arg(&compile.bindings_dir) .arg("-I") - .arg(helper_dir.to_str().unwrap().to_string()) + .arg(helper_dir.to_str().unwrap()) .arg("-I") - .arg(helper_dir2.to_str().unwrap().to_string()) + .arg(helper_dir2.to_str().unwrap()) .arg("-fno-exceptions") .arg("-Wall") .arg("-Wextra") @@ -158,9 +158,9 @@ impl LanguageMethods for Cpp { .arg("-I") .arg(&compile.bindings_dir) .arg("-I") - .arg(helper_dir.to_str().unwrap().to_string()) + .arg(helper_dir.to_str().unwrap()) .arg("-I") - .arg(helper_dir2.to_str().unwrap().to_string()) + .arg(helper_dir2.to_str().unwrap()) .arg("-fno-exceptions") .arg("-Wall") .arg("-Wextra") @@ -197,7 +197,7 @@ impl LanguageMethods for Cpp { .arg("-I") .arg(&verify.bindings_dir) .arg("-I") - .arg(helper_dir2.to_str().unwrap().to_string()) + .arg(helper_dir2.to_str().unwrap()) .arg("-Wall") .arg("-Wextra") .arg("-Werror") diff --git a/src/bin/wit-bindgen.rs b/src/bin/wit-bindgen.rs index 7f2ff75a5..a81a2acb0 100644 --- a/src/bin/wit-bindgen.rs +++ b/src/bin/wit-bindgen.rs @@ -160,10 +160,10 @@ fn main() -> Result<()> { Some(path) => path.join(name), None => name.into(), }; - eprintln!("Generating {:?}", dst); + eprintln!("Generating {dst:?}"); if opt.check { - let prev = std::fs::read(&dst).with_context(|| format!("failed to read {:?}", dst))?; + let prev = std::fs::read(&dst).with_context(|| format!("failed to read {dst:?}"))?; if prev != contents { // The contents differ. If it looks like textual contents, do a // line-by-line comparison so that we can tell users what the @@ -191,9 +191,9 @@ fn main() -> Result<()> { if let Some(parent) = dst.parent() { std::fs::create_dir_all(parent) - .with_context(|| format!("failed to create {:?}", parent))?; + .with_context(|| format!("failed to create {parent:?}"))?; } - std::fs::write(&dst, contents).with_context(|| format!("failed to write {:?}", dst))?; + std::fs::write(&dst, contents).with_context(|| format!("failed to write {dst:?}"))?; } Ok(())