Skip to content

Commit e2d9662

Browse files
Fix warnings, fix CI integration
1 parent c14326a commit e2d9662

3 files changed

Lines changed: 14 additions & 53 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
- name: Setup D
115115
uses: dlang-community/setup-dlang@v2
116116
with:
117-
compiler: ldc2-1.41
117+
compiler: ldc-1.41
118118
if: matrix.lang == 'd'
119119

120120
# Hacky work-around for https://github.com/dotnet/runtime/issues/80619

crates/d/src/lib.rs

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ use wit_bindgen_core::{
1313
type DType = String;
1414
#[derive(Default, Debug)]
1515
struct DSig {
16-
const_member: bool,
1716
static_member: bool,
1817
result: DType,
1918
arguments: Vec<(String, DType)>,
2019
name: String,
21-
//namespace: Vec<String>,
2220
implicit_self: bool,
2321
post_return: bool,
2422
}
@@ -1166,7 +1164,7 @@ impl<'a> DInterfaceGenerator<'a> {
11661164
if d_sig.implicit_self {
11671165
params.push("this");
11681166
}
1169-
for (arg, ty) in &d_sig.arguments {
1167+
for (arg, _ty) in &d_sig.arguments {
11701168
params.push(arg);
11711169
}
11721170

@@ -1924,7 +1922,7 @@ impl<'a> InterfaceGenerator<'a> for DInterfaceGenerator<'a> {
19241922
"/// ditto\nbool is{escaped_upper_case_name}() const => _tag == Tag.{escaped_lower_case_name};\n",
19251923
));
19261924

1927-
if let Some(ty) = &case.ty {
1925+
if case.ty.is_some() {
19281926
self.src.push_str(&format!(
19291927
"///ditto\nalias get{escaped_upper_case_name} = _get!(Tag.{escaped_lower_case_name});\n",
19301928
));
@@ -2538,7 +2536,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
25382536
abi::Instruction::RecordLift { ty, record, .. } => {
25392537
let name = self.r#gen.type_name(&Type::Id(*ty), self.r#gen.fqn);
25402538

2541-
let mut tmpvar = tempname("_record", self.tmp());
2539+
let tmpvar = tempname("_record", self.tmp());
25422540

25432541
self.push_str(&format!("{name} {tmpvar} = {{\n"));
25442542
for (field, op) in record.fields.iter().zip(operands.iter()) {
@@ -2566,7 +2564,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
25662564
results.push(format!("{}[{i}]", &operands[0]));
25672565
}
25682566
}
2569-
abi::Instruction::TupleLift { tuple, ty, .. } => {
2567+
abi::Instruction::TupleLift { ty, .. } => {
25702568
let name = tempname("_tuple", self.tmp());
25712569
self.push_str(&format!(
25722570
"auto {name} = {}(\n",
@@ -2660,9 +2658,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
26602658
self.push_str(&format!("alias {tag_type} = {ty_name}.Tag;\n"));
26612659
self.push_str(&format!("final switch ({}.tag) {{\n", operands[0]));
26622660

2663-
for (i, ((case, block), payload)) in
2664-
variant.cases.iter().zip(blocks).zip(payloads).enumerate()
2665-
{
2661+
for ((case, block), payload) in variant.cases.iter().zip(blocks).zip(payloads) {
26662662
let lower_name = case.name.to_lower_camel_case();
26672663
let lower_escaped_name = escape_d_identifier(&lower_name);
26682664

@@ -2705,7 +2701,7 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
27052701

27062702
self.push_str(&format!("alias {tag_type} = {ty}.Tag;\n"));
27072703
self.push_str(&format!("final switch (cast({ty}.Tag){tag}) {{\n"));
2708-
for (i, (case, block)) in variant.cases.iter().zip(blocks).enumerate() {
2704+
for (case, block) in variant.cases.iter().zip(blocks) {
27092705
let lower_name = case.name.to_lower_camel_case();
27102706
let escaped_name = escape_d_identifier(&lower_name);
27112707

@@ -2777,12 +2773,11 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
27772773
}
27782774
abi::Instruction::OptionLift { ty, .. } => {
27792775
let Block {
2780-
body: mut some,
2776+
body: some,
27812777
results: some_results,
27822778
..
27832779
} = self.blocks.pop().unwrap();
27842780
let Block {
2785-
body: mut none,
27862781
results: none_results,
27872782
..
27882783
} = self.blocks.pop().unwrap();
@@ -2866,13 +2861,13 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
28662861
}
28672862
abi::Instruction::ResultLift { result, ty, .. } => {
28682863
let Block {
2869-
body: mut err,
2864+
body: err,
28702865
results: err_results,
28712866
..
28722867
} = self.blocks.pop().unwrap();
28732868
assert!(err_results.len() == (result.err.is_some() as usize));
28742869
let Block {
2875-
body: mut ok,
2870+
body: ok,
28762871
results: ok_results,
28772872
..
28782873
} = self.blocks.pop().unwrap();
@@ -3019,15 +3014,14 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
30193014
abi::Instruction::GuestDeallocateList { element } => {
30203015
let Block {
30213016
body,
3022-
results: block_results,
3017+
results: _,
30233018
element: block_element,
30243019
base,
30253020
} = self.blocks.pop().unwrap();
30263021
let tmp = self.tmp();
30273022
let size = self.r#gen.sizes.size(element);
30283023
let size_str = size.format("size_t.sizeof");
30293024

3030-
let list = tempname("_list", tmp);
30313025
let list_len = tempname("_listLen", tmp);
30323026
let list_src = tempname("_listSrcPtr", tmp);
30333027
self.push_str(&format!("auto {list_src} = {};\n", operands[0]));
@@ -3122,33 +3116,3 @@ impl<'a, 'b> Bindgen for FunctionBindgen<'a, 'b> {
31223116
self.r#gen.resolve.all_bits_valid(ty)
31233117
}
31243118
}
3125-
3126-
/// This describes the common ABI function referenced or implemented, the C++ side might correspond to a different type
3127-
enum SpecialMethod {
3128-
None,
3129-
ResourceDrop, // ([export]) [resource-drop]
3130-
ResourceNew, // [export][resource-new]
3131-
ResourceRep, // [export][resource-rep]
3132-
Dtor, // [dtor] (guest export only)
3133-
Allocate, // internal: allocate new object (called from generated code)
3134-
}
3135-
3136-
fn is_special_method(func: &Function) -> SpecialMethod {
3137-
if matches!(func.kind, FunctionKind::Static(_)) {
3138-
if func.name.starts_with("[resource-drop]") {
3139-
SpecialMethod::ResourceDrop
3140-
} else if func.name.starts_with("[resource-new]") {
3141-
SpecialMethod::ResourceNew
3142-
} else if func.name.starts_with("[resource-rep]") {
3143-
SpecialMethod::ResourceRep
3144-
} else if func.name.starts_with("[dtor]") {
3145-
SpecialMethod::Dtor
3146-
} else if func.name == "$alloc" {
3147-
SpecialMethod::Allocate
3148-
} else {
3149-
SpecialMethod::None
3150-
}
3151-
} else {
3152-
SpecialMethod::None
3153-
}
3154-
}

crates/test/src/d.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use crate::config::StringList;
21
use crate::{Compile, LanguageMethods, Runner, Verify};
3-
use anyhow::{Context, Result};
2+
use anyhow::Result;
43
use clap::Parser;
5-
use heck::ToSnakeCase;
6-
use serde::Deserialize;
74
use std::env;
85
use std::fs;
96
use std::path::{Path, PathBuf};
@@ -14,7 +11,7 @@ pub struct DOpts {}
1411

1512
pub struct D;
1613

17-
fn ldc2(runner: &Runner) -> PathBuf {
14+
fn ldc2(_runner: &Runner) -> PathBuf {
1815
format!("ldc2").into()
1916
}
2017

@@ -107,7 +104,7 @@ fn search_for_world_package(bindings_root: &Path) -> Option<PathBuf> {
107104
.find(|p| p.is_file() && p.file_name().unwrap() == "package.d")
108105
}
109106

110-
fn compile(runner: &Runner, compile: &Compile<'_>, compiler: PathBuf) -> Result<()> {
107+
fn compile(_runner: &Runner, _compile: &Compile<'_>, _compiler: PathBuf) -> Result<()> {
111108
todo!();
112109
}
113110

0 commit comments

Comments
 (0)