Skip to content

Rust edition 2024 (toolchain 1.85.0) #12

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

Merged
merged 2 commits into from
Feb 25, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.84.0
- uses: dtolnay/rust-toolchain@1.85.0
with:
components: clippy, rustfmt
- name: Set environment variables
Expand All @@ -29,6 +29,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.84.0
- uses: dtolnay/rust-toolchain@1.85.0
- name: Run test
run: cargo test -p tests
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions buffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "buffi"
description = "A tool to generate ergonomic, buffer-based C++ APIs."
version = "0.2.5+rust.1.84.0"
edition = "2021"
version = "0.2.6+rust.1.85.0"
edition = "2024"
license = "MIT OR Apache-2.0"
documentation = "https://docs.rs/buffi"
repository = "https://github.com/GiGainfosystems/BuFFI"
Expand Down
38 changes: 20 additions & 18 deletions buffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ fn generate_function_definitions(

// ensure that we always order the type definitions in the same way
relevant_impls.sort_by_key(|(t, _)| {
if let rustdoc_types::Type::ResolvedPath(ref p) = t {
if let rustdoc_types::Type::ResolvedPath(p) = t {
get_name_without_path(&p.name)
} else {
unreachable!()
Expand Down Expand Up @@ -699,7 +699,11 @@ fn generate_function_def(
" serde::Serializable<{tpe}>::serialize({name}, serializer_{name});"
)
.unwrap();
writeln!(out_functions, " std::vector<uint8_t> {name}_serialized = std::move(serializer_{name}).bytes();").unwrap();
writeln!(
out_functions,
" std::vector<uint8_t> {name}_serialized = std::move(serializer_{name}).bytes();"
)
.unwrap();
}
writeln!(out_functions, " uint8_t* out_ptr = nullptr;").unwrap();
writeln!(out_functions).unwrap();
Expand Down Expand Up @@ -940,7 +944,7 @@ fn to_serde_reflect_type(

/// This is here for DRY (used by primitives and arrays.)
fn reflect_primitive(p: &rustdoc_types::Type) -> Vec<(Format, Option<ContainerFormat>)> {
let rustdoc_types::Type::Primitive(ref p) = p else {
let rustdoc_types::Type::Primitive(p) = p else {
unreachable!("Primitive!")
};
match p.as_ref() {
Expand Down Expand Up @@ -1044,7 +1048,9 @@ fn to_serde_reflect_type(
type_map,
)
} else {
unreachable!("Could not find docs for `SerializableError`! Maybe the `errors` module or the type itself is still private?")
unreachable!(
"Could not find docs for `SerializableError`! Maybe the `errors` module or the type itself is still private?"
)
};
(ok, err)
} else {
Expand All @@ -1055,22 +1061,18 @@ fn to_serde_reflect_type(
0,
serde_reflection::Named {
name: "Ok".into(),
value: serde_reflection::VariantFormat::Tuple(vec![ok
.last()
.unwrap()
.0
.clone()]),
value: serde_reflection::VariantFormat::Tuple(vec![
ok.last().unwrap().0.clone(),
]),
},
);
result_enum.insert(
1,
serde_reflection::Named {
name: "Err".into(),
value: serde_reflection::VariantFormat::Tuple(vec![error
.last()
.unwrap()
.0
.clone()]),
value: serde_reflection::VariantFormat::Tuple(vec![
error.last().unwrap().0.clone(),
]),
},
);
let ok_name = to_type_name(&ok.last().unwrap().0);
Expand Down Expand Up @@ -1238,7 +1240,7 @@ fn to_serde_reflect_type(
rustdoc_types::Type::DynTrait(_) => unimplemented!(),
rustdoc_types::Type::Generic(p) => {
if parent_args.len() == 1 {
if let rustdoc_types::GenericArg::Type(ref t) = &parent_args[0] {
if let rustdoc_types::GenericArg::Type(t) = &parent_args[0] {
to_serde_reflect_type(
t,
crate_map,
Expand Down Expand Up @@ -1351,7 +1353,7 @@ fn extract_crate_from_span(t: &rustdoc_types::Item) -> Option<String> {
if (e == ".cargo" || e == "cargo")
&& matches!(components.peek(), Some(Component::Normal(e)) if *e == "registry") =>
{
break
break;
}
None => panic!("Unexpected end of path: {}", p.display()),
_ => {}
Expand Down Expand Up @@ -1567,7 +1569,7 @@ fn generate_exported_struct(
let mut name = get_name_without_path(&p.name).to_owned();
if let Some(rustdoc_types::GenericArgs::AngleBracketed { args, .. }) = p.args.as_deref() {
for arg in args {
if let rustdoc_types::GenericArg::Type(ref t) = arg {
if let rustdoc_types::GenericArg::Type(t) = arg {
let tpe = to_serde_reflect_type(
t,
crate_map,
Expand All @@ -1592,7 +1594,7 @@ fn generate_exported_struct(
.iter()
.map(|id| crate_map.resolve_index(None, id, parent_crate))
.filter_map(|s| {
if let Some(ref mut comment_map) = comment_map {
if let Some(comment_map) = comment_map {
if let Some(ref doc) = s.docs {
comment_map.insert(
vec![
Expand Down
2 changes: 1 addition & 1 deletion buffi_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "buffi_macro"
description = "A proc-macro to generate ergonomic, buffer-based C++ APIs."
version = "0.2.5"
edition = "2021"
edition = "2024"
license = "MIT OR Apache-2.0"
documentation = "https://docs.rs/buffi_macro"
repository = "https://github.com/GiGainfosystems/BuFFI/"
Expand Down
2 changes: 1 addition & 1 deletion buffi_macro/src/proc_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ fn generate_exported_function<'a>(
#[cfg(not(generated_extern_function_marker))]
#tracing_skip
#allow_unwrap_default
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn #fn_name(#(#arg_list,)*) -> usize {
let r = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
#inner_block
Expand Down
2 changes: 1 addition & 1 deletion example/buffi_example/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "buffi_example"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[lib]
Expand Down
2 changes: 1 addition & 1 deletion example/buffi_example/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.84.0
1.85.0
4 changes: 2 additions & 2 deletions example/buffi_example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn free_standing_function(input: i64) -> Result<i64, String> {
}

/// Get a client to call functions
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn get_test_client() -> *mut TestClient {
let client = TestClient {
runtime: Arc::new(Runtime::new().unwrap()),
Expand Down Expand Up @@ -65,7 +65,7 @@ impl TestClient {
///
/// Calling this function outside a destructor is highly unsafe
/// and result in a use-after-free
#[no_mangle]
#[unsafe(no_mangle)]
pub unsafe extern "C" fn buffi_free_byte_buffer(ptr: *mut u8, size: usize) {
if !ptr.is_null() {
// SAFETY: We checked for null above
Expand Down
2 changes: 1 addition & 1 deletion example/generate_bindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "generate_bindings"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "1.84.0"
channel = "1.85.0"
components = ["rustfmt", "clippy"]
profile = "minimal"
2 changes: 1 addition & 1 deletion tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "tests"
version = "0.1.0"
edition = "2021"
edition = "2024"
publish = false

[dependencies]
Expand Down