From 26d4b19006dbff2e6fcc4c69a2393b2a6d0f216f Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Sun, 12 Jan 2025 04:06:59 -0500 Subject: [PATCH] build(rust): bump the lib's MSRV to 1.76 --- lib/Cargo.toml | 2 +- lib/binding_rust/lib.rs | 6 +++--- lib/binding_rust/wasm_language.rs | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 8052b94e..b042ff22 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -4,7 +4,7 @@ version.workspace = true description = "Rust bindings to the Tree-sitter parsing library" authors.workspace = true edition.workspace = true -rust-version = "1.65" +rust-version = "1.76" readme = "binding_rust/README.md" homepage.workspace = true repository.workspace = true diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index 2270dad6..749492b6 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -121,7 +121,7 @@ pub struct ParseState(NonNull); impl ParseState { #[must_use] - pub fn current_byte_offset(&self) -> usize { + pub const fn current_byte_offset(&self) -> usize { unsafe { self.0.as_ref() }.current_byte_offset as usize } } @@ -132,7 +132,7 @@ pub struct QueryCursorState(NonNull); impl QueryCursorState { #[must_use] - pub fn current_byte_offset(&self) -> usize { + pub const fn current_byte_offset(&self) -> usize { unsafe { self.0.as_ref() }.current_byte_offset as usize } } @@ -1371,7 +1371,7 @@ impl Parser { if let Some(flag) = flag { ffi::ts_parser_set_cancellation_flag( self.0.as_ptr(), - (flag as *const AtomicUsize).cast::(), + std::ptr::from_ref::(flag).cast::(), ); } else { ffi::ts_parser_set_cancellation_flag(self.0.as_ptr(), ptr::null()); diff --git a/lib/binding_rust/wasm_language.rs b/lib/binding_rust/wasm_language.rs index c7cc0793..7aedad4d 100644 --- a/lib/binding_rust/wasm_language.rs +++ b/lib/binding_rust/wasm_language.rs @@ -45,7 +45,9 @@ impl WasmStore { unsafe { let mut error = MaybeUninit::::uninit(); let store = ffi::ts_wasm_store_new( - (engine as *const wasmtime::Engine).cast_mut().cast(), + std::ptr::from_ref::(engine) + .cast_mut() + .cast(), error.as_mut_ptr(), ); if store.is_null() {