diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7fd69b23..0fbe44f4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -76,4 +76,4 @@ jobs: - name: Run Xi tests run: | # Test the build configuration that Xi uses - cargo test --lib --no-default-features --features "assets dump-load-rs" + cargo test --lib --no-default-features --features "assets dump-load" diff --git a/Cargo.toml b/Cargo.toml index 19a45471..171a2ba8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ lazy_static = "1.0" bitflags = "1.0.4" plist = "1" bincode = { version = "1.0", optional = true } -flate2 = { version = "1.0", optional = true, default-features = false } +flate2 = { version = "1.0", optional = true } fnv = { version = "1.0", optional = true } serde = "1.0" serde_derive = "1.0" @@ -47,27 +47,24 @@ pretty_assertions = "0.6" # will fail, choose one of each. If you are using both creation and loading, # your binary will be smaller if you choose the same one for each. -# Pure Rust dump loading, slower than regular `dump-load` -dump-load-rs = ["flate2/rust_backend", "bincode"] -# Dump loading using flate2, which depends on the miniz C library. -dump-load = ["flate2/default", "bincode"] -# Dump creation using flate2, which depends on the miniz C library. -dump-create = ["flate2/default", "bincode"] -# Pure Rust dump creation, worse compressor so produces larger dumps than dump-create -dump-create-rs = ["flate2/rust_backend", "bincode"] +# Legacy alias for `dump-load` +dump-load-rs = ["dump-load"] +# Dump loading using flate2 +dump-load = ["flate2", "bincode"] +# Dump creation using flate2 +dump-create = ["flate2", "bincode"] +# Legacy alias for `dump-create` +dump-create-rs = ["dump-create"] regex-fancy = ["fancy-regex"] regex-onig = ["onig"] -# If you enable "parsing", you must also enable either "dump-load" or -# "dump-load-rs", and "dump-create" or "dump-create-rs". Otherwise the code that -# enables lazy-loading of syntaxes will not compile. -parsing = ["regex-syntax", "fnv"] +parsing = ["regex-syntax", "fnv", "dump-create", "dump-load"] # Support for .tmPreferenes metadata files (indentation, comment syntax, etc) metadata = ["parsing"] # The `assets` feature enables inclusion of the default theme and syntax packages. -# For `assets` to do anything, it requires one of `dump-load-rs` or `dump-load` to be set. +# For `assets` to do anything, it requires `dump-load` to be set. assets = [] html = ["parsing"] # Support for parsing .sublime-syntax files diff --git a/src/dumps.rs b/src/dumps.rs index 5dc25841..4b20b380 100644 --- a/src/dumps.rs +++ b/src/dumps.rs @@ -13,35 +13,35 @@ //! [`ThemeSet`]: ../highlighting/struct.ThemeSet.html //! [`dump_to_file`]: fn.dump_to_file.html use bincode::Result; -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] use bincode::deserialize_from; -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] use bincode::serialize_into; use std::fs::File; -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] use std::io::{BufRead}; -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] use std::io::{BufWriter, Write}; -#[cfg(all(feature = "parsing", feature = "assets", any(feature = "dump-load", feature = "dump-load-rs")))] +#[cfg(all(feature = "parsing", feature = "assets", feature = "dump-load"))] use crate::parsing::SyntaxSet; -#[cfg(all(feature = "assets", any(feature = "dump-load", feature = "dump-load-rs")))] +#[cfg(all(feature = "assets", feature = "dump-load"))] use crate::highlighting::ThemeSet; use std::path::Path; #[cfg(feature = "dump-create")] use flate2::write::ZlibEncoder; -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] use flate2::bufread::ZlibDecoder; -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] use flate2::Compression; -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] use serde::Serialize; -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] use serde::de::DeserializeOwned; /// Dumps an object to the given writer in a compressed binary format /// /// The writer is encoded with the `bincode` crate and compressed with `flate2`. -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] pub fn dump_to_writer(to_dump: &T, output: W) -> Result<()> { serialize_to_writer_impl(to_dump, output, true) } @@ -49,7 +49,7 @@ pub fn dump_to_writer(to_dump: &T, output: W) -> Result< /// Dumps an object to a binary array in the same format as [`dump_to_writer`] /// /// [`dump_to_writer`]: fn.dump_to_writer.html -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] pub fn dump_binary(o: &T) -> Vec { let mut v = Vec::new(); dump_to_writer(o, &mut v).unwrap(); @@ -62,14 +62,14 @@ pub fn dump_binary(o: &T) -> Vec { /// the `bincode` crate and then compressed with the `flate2` crate. /// /// [`dump_to_writer`]: fn.dump_to_writer.html -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] pub fn dump_to_file>(o: &T, path: P) -> Result<()> { let out = BufWriter::new(File::create(path)?); dump_to_writer(o, out) } /// A helper function for decoding and decompressing data from a reader -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] pub fn from_reader(input: R) -> Result { deserialize_from_reader_impl(input, true) } @@ -77,13 +77,13 @@ pub fn from_reader(input: R) -> Result { /// Returns a fully loaded object from a binary dump. /// /// This function panics if the dump is invalid. -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] pub fn from_binary(v: &[u8]) -> T { from_reader(v).unwrap() } /// Returns a fully loaded object from a binary dump file. -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] pub fn from_dump_file>(path: P) -> Result { let contents = std::fs::read(path)?; from_reader(&contents[..]) @@ -93,7 +93,7 @@ pub fn from_dump_file>(path: P) -> Result /// itself shall not be compressed, because the data for its lazy-loaded /// syntaxes are already compressed. Compressing another time just results in /// bad performance. -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] pub fn dump_to_uncompressed_file>(o: &T, path: P) -> Result<()> { let out = BufWriter::new(File::create(path)?); serialize_to_writer_impl(o, out, false) @@ -101,7 +101,7 @@ pub fn dump_to_uncompressed_file>(o: &T, path: P) - /// To be used when deserializing a [`SyntaxSet`] that was previously written to /// file using [dump_to_uncompressed_file]. -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] pub fn from_uncompressed_dump_file>(path: P) -> Result { let contents = std::fs::read(path)?; deserialize_from_reader_impl(&contents[..], false) @@ -110,13 +110,13 @@ pub fn from_uncompressed_dump_file>(path: P) /// To be used when deserializing a [`SyntaxSet`] from raw data, for example /// data that has been embedded in your own binary with the [`include_bytes!`] /// macro. -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] pub fn from_uncompressed_data(v: &[u8]) -> Result { deserialize_from_reader_impl(v, false) } /// Private low level helper function used to implement the public API. -#[cfg(any(feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(feature = "dump-create")] fn serialize_to_writer_impl(to_dump: &T, output: W, use_compression: bool) -> Result<()> { if use_compression { let mut encoder = ZlibEncoder::new(output, Compression::best()); @@ -127,7 +127,7 @@ fn serialize_to_writer_impl(to_dump: &T, output: W, use_ } /// Private low level helper function used to implement the public API. -#[cfg(any(feature = "dump-load", feature = "dump-load-rs"))] +#[cfg(feature = "dump-load")] fn deserialize_from_reader_impl(input: R, use_compression: bool) -> Result { if use_compression { let mut decoder = ZlibDecoder::new(input); @@ -137,7 +137,7 @@ fn deserialize_from_reader_impl(input: R, use_c } } -#[cfg(all(feature = "parsing", feature = "assets", any(feature = "dump-load", feature = "dump-load-rs")))] +#[cfg(all(feature = "parsing", feature = "assets", feature = "dump-load"))] impl SyntaxSet { /// Instantiates a new syntax set from a binary dump of Sublime Text's default open source /// syntax definitions. @@ -195,7 +195,7 @@ impl SyntaxSet { } } -#[cfg(all(feature = "assets", any(feature = "dump-load", feature = "dump-load-rs")))] +#[cfg(all(feature = "assets", feature = "dump-load"))] impl ThemeSet { /// Loads the set of default themes /// Currently includes (these are the keys for the map): @@ -210,7 +210,7 @@ impl ThemeSet { #[cfg(test)] mod tests { - #[cfg(all(feature = "yaml-load", any(feature = "dump-create", feature = "dump-create-rs"), any(feature = "dump-load", feature = "dump-load-rs")))] + #[cfg(all(feature = "yaml-load", feature = "dump-create", feature = "dump-load"))] #[test] fn can_dump_and_load() { use super::*; @@ -225,7 +225,7 @@ mod tests { assert_eq!(ss.syntaxes().len(), ss2.syntaxes().len()); } - #[cfg(all(feature = "yaml-load", any(feature = "dump-create", feature = "dump-create-rs"), any(feature = "dump-load", feature = "dump-load-rs")))] + #[cfg(all(feature = "yaml-load", feature = "dump-create", feature = "dump-load"))] #[test] fn dump_is_deterministic() { use super::*; @@ -246,7 +246,7 @@ mod tests { assert_eq!(bin1, bin2); } - #[cfg(all(feature = "assets", any(feature = "dump-load", feature = "dump-load-rs")))] + #[cfg(all(feature = "assets", feature = "dump-load"))] #[test] fn has_default_themes() { use crate::highlighting::ThemeSet; diff --git a/src/easy.rs b/src/easy.rs index 4fd4c49e..0da31eaf 100644 --- a/src/easy.rs +++ b/src/easy.rs @@ -251,7 +251,7 @@ impl<'a> Iterator for ScopeRegionIterator<'a> { } } -#[cfg(all(feature = "assets", any(feature = "dump-load", feature = "dump-load-rs")))] +#[cfg(all(feature = "assets", feature = "dump-load"))] #[cfg(test)] mod tests { use super::*; diff --git a/src/highlighting/highlighter.rs b/src/highlighting/highlighter.rs index a154bbae..85a8680f 100644 --- a/src/highlighting/highlighter.rs +++ b/src/highlighting/highlighter.rs @@ -370,7 +370,7 @@ impl<'a> Highlighter<'a> { } } -#[cfg(all(feature = "assets", feature = "parsing", any(feature = "dump-load", feature = "dump-load-rs")))] +#[cfg(all(feature = "assets", feature = "parsing", feature = "dump-load"))] #[cfg(test)] mod tests { use super::*; diff --git a/src/html.rs b/src/html.rs index a97ba0ce..149fb704 100644 --- a/src/html.rs +++ b/src/html.rs @@ -518,7 +518,7 @@ pub fn start_highlighted_html_snippet(t: &Theme) -> (String, Color) { #[cfg(all( feature = "assets", - any(feature = "dump-load", feature = "dump-load-rs") + feature = "dump-load" ))] #[cfg(test)] mod tests { diff --git a/src/lib.rs b/src/lib.rs index 60e4da49..0f46be59 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ extern crate serde_derive; #[macro_use] extern crate pretty_assertions; -#[cfg(any(feature = "dump-load-rs", feature = "dump-load", feature = "dump-create", feature = "dump-create-rs"))] +#[cfg(any(feature = "dump-load", feature = "dump-create"))] pub mod dumps; #[cfg(feature = "parsing")] pub mod easy;