From 21de99de8770e1d887b4cf7b5a99ede027125388 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 16 Mar 2020 22:35:27 +0100 Subject: [PATCH 1/3] Remove non-building doctests (#578) --- lib/binding_rust/bindings.rs | 4 ++-- lib/binding_rust/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/binding_rust/bindings.rs b/lib/binding_rust/bindings.rs index e1c3ceac..cba87fa3 100644 --- a/lib/binding_rust/bindings.rs +++ b/lib/binding_rust/bindings.rs @@ -172,9 +172,9 @@ extern "C" { #[doc = " the given ranges must be ordered from earliest to latest in the document,"] #[doc = " and they must not overlap. That is, the following must hold for all"] #[doc = " `i` < `length - 1`:"] - #[doc = ""] + #[doc = " ```text"] #[doc = " ranges[i].end_byte <= ranges[i + 1].start_byte"] - #[doc = ""] + #[doc = " ```"] #[doc = " If this requirement is not satisfied, the operation will fail, the ranges"] #[doc = " will not be assigned, and this function will return `false`. On success,"] #[doc = " this function returns `true`"] diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index bf732faa..02be62f6 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -541,9 +541,9 @@ impl Parser { /// the given ranges must be ordered from earliest to latest in the document, /// and they must not overlap. That is, the following must hold for all /// `i` < `length - 1`: - /// + /// ```text /// ranges[i].end_byte <= ranges[i + 1].start_byte - /// + /// ``` /// If this requirement is not satisfied, method will panic. pub fn set_included_ranges<'a>( &mut self, From d0325579ad2ac408a067cd0f7637e8fef82823ab Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 16 Mar 2020 14:45:16 -0700 Subject: [PATCH 2/3] Use Arc to avoid use-after-free in threaded cancellation unit test Fixes #579 --- cli/src/tests/parser_test.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/src/tests/parser_test.rs b/cli/src/tests/parser_test.rs index 0384bce8..392d1a9d 100644 --- a/cli/src/tests/parser_test.rs +++ b/cli/src/tests/parser_test.rs @@ -450,7 +450,7 @@ fn test_parsing_on_multiple_threads() { #[test] fn test_parsing_cancelled_by_another_thread() { - let cancellation_flag = Box::new(AtomicUsize::new(0)); + let cancellation_flag = std::sync::Arc::new(AtomicUsize::new(0)); let mut parser = Parser::new(); parser.set_language(get_language("javascript")).unwrap(); @@ -471,9 +471,10 @@ fn test_parsing_cancelled_by_another_thread() { ); assert!(tree.is_some()); + let flag = cancellation_flag.clone(); let cancel_thread = thread::spawn(move || { thread::sleep(time::Duration::from_millis(100)); - cancellation_flag.store(1, Ordering::SeqCst); + flag.store(1, Ordering::SeqCst); }); // Infinite input From f453178ca2c97a77aff6d5e9e0457a1b8b3c26bc Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 16 Mar 2020 14:46:00 -0700 Subject: [PATCH 3/3] rust: Remove unnecessary dependencies from core library --- Cargo.lock | 3 --- lib/Cargo.toml | 3 --- lib/binding_rust/lib.rs | 5 ----- 3 files changed, 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 172e2d78..e57779cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -741,9 +741,6 @@ version = "0.6.3" dependencies = [ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.80 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 5e0bbb5c..78829420 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -20,9 +20,6 @@ include = [ [dependencies] regex = "1" -serde = "1.0" -serde_json = "1.0" -serde_derive = "1.0" [build-dependencies] cc = "1.0" diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index 02be62f6..b40d97e5 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -1,11 +1,6 @@ mod ffi; mod util; -extern crate regex; -extern crate serde; -extern crate serde_derive; -extern crate serde_json; - #[cfg(unix)] use std::os::unix::io::AsRawFd;