Update to 0.20.9 (#2100278)

epel9 imports/e9/rust-tree-sitter-0.20.9-1.el9
Aleksei Bavshin 2 years ago
parent 1d6262dfd7
commit 4269f09f73
No known key found for this signature in database
GPG Key ID: 4F071603387A382A

@ -1,4 +1,4 @@
From 545f8b98b8f614869e5e836c5a05091dfd5472c6 Mon Sep 17 00:00:00 2001
From 801d1f702ff46ee7f0219d9c9ac427f22e1a9a9a Mon Sep 17 00:00:00 2001
From: Aleksei Bavshin <alebastr89@gmail.com>
Date: Sun, 5 Dec 2021 16:08:59 -0800
Subject: [PATCH] binding_rust: generate bindings during build
@ -11,23 +11,23 @@ The recommended way[1] to use bindgen is to invoke it from `build.rs`.
[1]: https://rust-lang.github.io/rust-bindgen/library-usage.html
---
Cargo.lock | 155 +++++++++++++++++++++++++++++++++++++-
lib/Cargo.toml | 1 +
lib/binding_rust/build.rs | 24 ++++++
lib/binding_rust/build.rs | 24 ++++++++++++++++++++++++
lib/binding_rust/ffi.rs | 2 +-
lib/binding_rust/lib.rs | 5 +-
5 files changed, 183 insertions(+), 4 deletions(-)
lib/binding_rust/lib.rs | 5 +++--
4 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index ed173fdf7..3ab8f52b7 100644
index d096efdc..c318cd34 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,5 +31,7 @@
@@ -46,5 +46,8 @@
[dependencies.regex]
version = "1"
+[build-dependencies.bindgen]
+version = "0.59.1"
+
[build-dependencies.cc]
version = "^1.0.58"
diff --git a/binding_rust/build.rs b/binding_rust/build.rs
@ -86,18 +86,19 @@ index 685ed765..5cf93180 100644
extern "C" {
pub(crate) fn dup(fd: std::os::raw::c_int) -> std::os::raw::c_int;
diff --git a/binding_rust/lib.rs b/binding_rust/lib.rs
index cf8437b8..35205cee 100644
index 934915fe..44417c77 100644
--- a/binding_rust/lib.rs
+++ b/binding_rust/lib.rs
@@ -25,11 +25,12 @@ use std::{
/// assigned an ABI version number that corresponds to the current CLI version.
@@ -26,12 +26,13 @@ use std::{
/// The Tree-sitter library is generally backwards-compatible with languages
/// generated using older CLI versions, but is not forwards-compatible.
#[doc(alias = "TREE_SITTER_LANGUAGE_VERSION")]
-pub const LANGUAGE_VERSION: usize = ffi::TREE_SITTER_LANGUAGE_VERSION;
+pub const LANGUAGE_VERSION: usize = ffi::TREE_SITTER_LANGUAGE_VERSION as usize;
/// The earliest ABI version that is supported by the current version of the
/// library.
#[doc(alias = "TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION")]
-pub const MIN_COMPATIBLE_LANGUAGE_VERSION: usize = ffi::TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION;
+pub const MIN_COMPATIBLE_LANGUAGE_VERSION: usize =
+ ffi::TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION as usize;
@ -105,5 +106,5 @@ index cf8437b8..35205cee 100644
pub const PARSER_HEADER: &'static str = include_str!("../include/tree_sitter/parser.h");
--
2.33.1
2.37.1

@ -1,49 +0,0 @@
From fe33599f4695c4ab442e1e5f8682cfda11321308 Mon Sep 17 00:00:00 2001
From: Aleksei Bavshin <alebastr89@gmail.com>
Date: Tue, 22 Mar 2022 22:47:21 -0700
Subject: [PATCH] lib: fix incorrect int ptr cast on big-endian architectures
`*usize` -> `*u32` conversion on 64-bit big-endian machine takes high
halfword of the value. As a consequence, any result returned via
`count` is unexpectedly shifted left:
u32 = 00 00 00 01 // 1
usize = 00 00 00 01 00 00 00 00 // 4294967296
Fixes following test failure:
```
$ cargo test -- tests::corpus_test
<...>
running 13 tests
memory allocation of 206158430208 bytes failed
error: test failed, to rerun pass '--lib'
```
---
lib/binding_rust/lib.rs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/binding_rust/lib.rs b/binding_rust/lib.rs
index e88a411c..1df9e7ac 100644
--- a/binding_rust/lib.rs
+++ b/binding_rust/lib.rs
@@ -705,14 +705,14 @@ impl Tree {
/// after calling one of the [Parser::parse] functions. Call it on the old tree that
/// was passed to parse, and pass the new tree that was returned from `parse`.
pub fn changed_ranges(&self, other: &Tree) -> impl ExactSizeIterator<Item = Range> {
- let mut count = 0;
+ let mut count = 0u32;
unsafe {
let ptr = ffi::ts_tree_get_changed_ranges(
self.0.as_ptr(),
other.0.as_ptr(),
- &mut count as *mut _ as *mut u32,
+ &mut count as *mut u32,
);
- util::CBufferIter::new(ptr, count).map(|r| r.into())
+ util::CBufferIter::new(ptr, count as usize).map(|r| r.into())
}
}
}
--
2.35.1

@ -1,11 +1,13 @@
# Generated by rust2rpm 21
# Generated by rust2rpm 22
%bcond_without check
%global debug_package %{nil}
%global crate tree-sitter
# The bindings version does not match the C library version.
%global ts_ver 0.20.7
Name: rust-%{crate}
Version: 0.20.6
Name: rust-tree-sitter
Version: 0.20.9
Release: %autorelease
Summary: Rust bindings to the Tree-sitter parsing library
@ -15,11 +17,9 @@ License: MIT and Unicode
URL: https://crates.io/crates/tree-sitter
Source: %{crates_source}
# Upstream license file - tree-sitter/tree-sitter#1520
Source1: https://github.com/tree-sitter/tree-sitter/raw/v%{version}/LICENSE#/LICENSE.upstream
Source1: https://github.com/tree-sitter/tree-sitter/raw/v%{ts_ver}/LICENSE#/LICENSE.upstream
# tree-sitter/tree-sitter#1524 modified to apply to the crate source
Patch0: binding_rust-regenerate-bindings-during-build.patch
# fix tree-sitter-cli tests on s390x - tree-sitter/tree-sitter#1692
Patch1: lib-fix-incorrect-int-ptr-cast-on-big-endian-archite.patch
ExclusiveArch: %{rust_arches}
@ -34,7 +34,7 @@ Rust bindings to the Tree-sitter parsing library.}
Summary: %{summary}
BuildArch: noarch
# The create contains a bundled copy of the tree-sitter C library.
Provides: bundled(tree-sitter) = %{version}
Provides: bundled(tree-sitter) = %{ts_ver}
# The tree-sitter C library contains a small subset of files from the ICU library
Provides: bundled(icu) = 65.1

@ -1 +1 @@
SHA512 (tree-sitter-0.20.6.crate) = b1c7425db2903b889c90cd283ab557ad34d0dead01ec1313571fd537f2b783df88849caf4f253d27c65cd84fc43eeb3c5073e2df876b5a5d716186563b37b92a
SHA512 (tree-sitter-0.20.9.crate) = 03e38b5252dd94b65c096ba9d07e6aecbb582c8460e2f1e0ad46122e372be7139462d7c411094ba557abd6566bd89faeaf7ff01bddb9283d2d7285d13e38c5a6

Loading…
Cancel
Save