v0.16.0
Diplomat 0.16.0
syn v3
We've upgraded to syn v3 to stay up to date with newer minor releases of syn (#1228)
.NET backend
Diplomat used to have a .NET backend with the old AST representation. This was removed since we transitioned to the HIR representation, and existing users have been on an old fork of the AST-based backend. Thankfully, first-time contributor irvingoujAtDevolution has been hard at work implementing the new HIR-based .NET backend:
#1164 (co-authored with Claude Code), #1180, #1186, #1191, #1189, #1194, #1195, #1193 (co-authored with Claude Sonnet 4.6), #1201, #1216, #1214, #1213, #1215, #1226, #1225, #1230, #1231
File/Line information in AST Errors
Diplomat Core's MSRV is now 1.88, which enables support for procedural macro locations, which are used in new AST error reports. These new reports highlight line/file information instead of panicking with minimal context. There's a pretty printer that uses annotate-snippets (enabled by default in the tool, enabled elsewhere with the feature flag "pretty-print"), and an ugly printer (uses no extra dependencies, enabled by default in the macro).
This was accomplished in two steps: first, we added proc_macro2::Span information to AST. Subsequently, we made five PRs to replace existing panic!, .expect, and assert! calls in the AST parser with these more detailed reports:
#1172, #1177, #1183, #1206, #1208
Other New Features
Diplomat Core
- Added
#[diplomat::include]for including macro definitions from other files (#917) - Added support for partial comparisons (#1103)
- Added support for tuplable structs (#1101)
- Added Opaque slice support (#1088)
Diplomat Runtime
- Added no_std support for wasm32-unknown-unknown targets (First-time contribution by Brennan Kinney)
C++
Nanobind
- Expanded default arguments support to Nanobind
- Added support for docstrings and stubgen (First-time contribution by twantonie)
Dart
- Added support for null-aware Dart syntax
- Updated backend to use RecordUse syntax (Contributed by mosuem)
Bugfixes
Diplomat Macro
Diplomat Tool
JS Backend
- JS now does not generate mutable slices (which it does not support)
- diplomat_runtime's JS implementation now uses updated WASM target linkage
- JS now calls enum constructors from within struct fields
C++ Backend
- diplomat_runtime.hpp now compiles with Solaris (First-time contribution by Makoto Kato)
- Fixed struct references failing to compile with non-unit types
- Struct references now compile with references of opaques
- UTF-16 string slices now generate correctly (Contributed by Mark Molinaro, Manish Goregaokar and Claude Opus 4.6)
- Callbacks now accept unique_ptr
- Fixed Result<Option, Err> generation
- Fixed function pointer assignment mismatch on embedded toolchains (First-time contribution by obsking2000)
- Fixed returning references of opaques in callbacks
Nanobind Backend
- Fixed overloaded named constructors failing to build in Nanobind (First-time contribution by Mark Molinaro and AI tools)
- Fixed compiler error on fallible structure constructors that return opaques
- Nanobind backend now always defines struct references as mutable
- Enforce
IndexErrorable indexing operations - Fixed check that bound vector exists in memory
- Fixed overloading issue for const methods and empty arguments
- Fixed include generation info for callbacks
- Fixed stub type for
diplomat::result(Contributed by Mark Molinaro and Claude Opus 4.6) - Fixed compiler issue with string_view_for_slice not generating properly in overrides
- Fixed bound vectors with partial comparisons not compiling
- Properly generate out structs
- Fixed taking opaque references in callbacks
- Fixed lifetime annotations absent on read only properties (First-time contribution by Yazan-Reactor and Claude Fable 5)
Dart Backend
- Made DiplomatFfiUse final
- Agent Driven: Fixed fallible struct constructor compilation
- Agent Driven: Fixed Dart structs borrowing opaques
The Book
- C++ and Nanobind now have typing information and how types connect to the C ABI.
- Improved book organization and links within
- Added documentation on async Nanobind and workarounds
- Added documentation for the new .NET backend (Contributed by irvingoujAtDevolution)