Skip to content
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

Remove dependencies from public API #512

Open
Enselic opened this issue Dec 29, 2023 · 0 comments
Open

Remove dependencies from public API #512

Enselic opened this issue Dec 29, 2023 · 0 comments
Milestone

Comments

@Enselic
Copy link
Collaborator

Enselic commented Dec 29, 2023

The public API of syntect includes types defined in other crates. This makes it tricky to bump dependencies within a minor syntect release since bumping a dependency can change the syntect public API in incompatible ways.

It would be nice if we for syntect 6.0.0 could go over the public API and remove external types from the public API.

See #513 for why we want to do this.

How to find inappropriate types in the current public API

Adding

cargo-features = ["public-dependency"]

to Cargo.toml (see https://doc.rust-lang.org/cargo/reference/unstable.html#public-dependency) and building with Rust nightly currently gives these warnings:

output
warning: type `bincode::ErrorKind` from private dependency 'bincode' in public interface
  --> src/dumps.rs:45:1
   |
45 | pub fn dump_to_writer<T: Serialize, W: Write>(to_dump: &T, output: W) -> Result<()> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(exported_private_dependencies)]` on by default

warning: type `bincode::ErrorKind` from private dependency 'bincode' in public interface
  --> src/dumps.rs:66:1
   |
66 | pub fn dump_to_file<T: Serialize, P: AsRef<Path>>(o: &T, path: P) -> Result<()> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `bincode::ErrorKind` from private dependency 'bincode' in public interface
  --> src/dumps.rs:73:1
   |
73 | pub fn from_reader<T: DeserializeOwned, R: BufRead>(input: R) -> Result<T> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `bincode::ErrorKind` from private dependency 'bincode' in public interface
  --> src/dumps.rs:87:1
   |
87 | pub fn from_dump_file<T: DeserializeOwned, P: AsRef<Path>>(path: P) -> Result<T> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `bincode::ErrorKind` from private dependency 'bincode' in public interface
  --> src/dumps.rs:97:1
   |
97 | pub fn dump_to_uncompressed_file<T: Serialize, P: AsRef<Path>>(o: &T, path: P) -> Result<()> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `bincode::ErrorKind` from private dependency 'bincode' in public interface
   --> src/dumps.rs:105:1
    |
105 | pub fn from_uncompressed_dump_file<T: DeserializeOwned, P: AsRef<Path>>(path: P) -> Result<T> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `bincode::ErrorKind` from private dependency 'bincode' in public interface
   --> src/dumps.rs:114:1
    |
114 | pub fn from_uncompressed_data<T: DeserializeOwned>(v: &[u8]) -> Result<T> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
  --> src/highlighting/settings.rs:10:5
   |
10 |     fn parse_settings(settings: Settings) -> Result<Self, Self::Error>;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `plist::Error` from private dependency 'plist' in public interface
  --> src/highlighting/settings.rs:19:11
   |
19 |     Plist(PlistError),
   |           ^^^^^^^^^^

warning: type `plist::Error` from private dependency 'plist' in public interface
  --> src/highlighting/settings.rs:23:5
   |
23 |     fn from(error: PlistError) -> SettingsError {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
  --> src/highlighting/settings.rs:28:1
   |
28 | pub fn read_plist<R: Read + Seek>(reader: R) -> Result<Settings, SettingsError> {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
  --> src/highlighting/theme_load.rs:60:5
   |
60 |     fn parse_settings(settings: Settings) -> Result<UnderlineOption, Self::Error> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
  --> src/highlighting/theme_load.rs:90:5
   |
90 |     fn parse_settings(settings: Settings) -> Result<FontStyle, Self::Error> {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
   --> src/highlighting/theme_load.rs:143:5
    |
143 |     fn parse_settings(settings: Settings) -> Result<Color, Self::Error> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
   --> src/highlighting/theme_load.rs:154:5
    |
154 |     fn parse_settings(settings: Settings) -> Result<StyleModifier, Self::Error> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
   --> src/highlighting/theme_load.rs:186:5
    |
186 |     fn parse_settings(settings: Settings) -> Result<ThemeItem, Self::Error> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
   --> src/highlighting/theme_load.rs:209:5
    |
209 |     fn parse_settings(json: Settings) -> Result<ThemeSettings, Self::Error> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `serde_json::Value` from private dependency 'serde_json' in public interface
   --> src/highlighting/theme_load.rs:283:5
    |
283 |     fn parse_settings(settings: Settings) -> Result<Theme, Self::Error> {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `ScanError` from private dependency 'yaml_rust' in public interface
  --> src/parsing/yaml_load.rs:16:25
   |
16 |     InvalidYaml(#[from] ScanError),
   |                         ^^^^^^^^^

warning: type `onig::Region` from private dependency 'onig' in public interface
   --> src/parsing/regex.rs:144:5
    |
144 |     pub fn new_region() -> Region {
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `onig::Region` from private dependency 'onig' in public interface
   --> src/parsing/regex.rs:167:9
    |
167 | /         pub fn search(
168 | |             &self,
169 | |             text: &str,
170 | |             begin: usize,
171 | |             end: usize,
172 | |             region: Option<&mut Region>,
173 | |         ) -> bool {
    | |_________________^

warning: type `WalkDir` from private dependency 'walkdir' in public interface
 --> src/utils.rs:9:1
  |
9 | pub fn walk_dir<P: AsRef<Path>>(folder: P) -> WalkDir {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: type `walkdir::Error` from private dependency 'walkdir' in public interface
  --> src/lib.rs:74:21
   |
74 |     WalkDir(#[from] walkdir::Error),
   |                     ^^^^^^^^^^^^^^

warning: `syntect` (lib) generated 23 warnings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant