Skip to content

Commit

Permalink
Rust bump, reduce dependencices (#10803)
Browse files Browse the repository at this point in the history
Updated rust version, removed some unnecessary or problematic dependencies. Ported some changes from bazel branch.
  • Loading branch information
Frizi authored Aug 13, 2024
1 parent a8551c7 commit f14b79f
Show file tree
Hide file tree
Showing 134 changed files with 1,159 additions and 2,807 deletions.
1,655 changes: 640 additions & 1,015 deletions Cargo.lock

Large diffs are not rendered by default.

35 changes: 8 additions & 27 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ resolver = "2"
members = [
"app/rust-ffi",
"build/cli",
"build/macros/proc-macro",
"build/ci-gen",
"build/cli",
"build/install",
Expand All @@ -28,12 +27,6 @@ members = [
"tools/language-server/wstest",
]

# We are using a version with extended functionality. The changes have been PR'd upstream:
# https://github.com/rustwasm/console_error_panic_hook/pull/24
# Remove this patch when the issue is resolved.
[patch.crates-io]
console_error_panic_hook = { git = 'https://github.com/enso-org/console_error_panic_hook' }

[profile.dev]
opt-level = 0
lto = false
Expand Down Expand Up @@ -73,7 +66,6 @@ opt-level = 2
inherits = "dev"
opt-level = 1
lto = false
debug = "line-tables-only"
debug-assertions = true

[workspace.lints.rust]
Expand Down Expand Up @@ -106,17 +98,18 @@ directories = { version = "5.0.1" }
dirs = { version = "5.0.1" }
flate2 = { version = "1.0.28" }
indicatif = { version = "0.17.7", features = ["tokio"] }
mime = "0.3.16"
new_mime_guess = "4.0.1"
multimap = { version = "0.9.1" }
native-windows-gui = { version = "1.0.13" }
nix = { version = "0.27.1" }
octocrab = { git = "https://github.com/enso-org/octocrab", default-features = false, features = [
"rustls",
] }
path-absolutize = "3.1.1"
platforms = { version = "3.2.0", features = ["serde"] }
portpicker = { version = "0.1.1" }
regex = { version = "1.6.0" }
serde = { version = "1.0.130", features = ["derive", "rc"] }
serde = { version = "1", features = ["derive", "rc"] }
serde_yaml = { version = "0.9.16" }
sha2 = { version = "0.10.8" }
sysinfo = { version = "0.30.7" }
Expand All @@ -127,26 +120,22 @@ tokio-util = { version = "0.7.10", features = ["full"] }
tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
walkdir = { version = "2.5.0" }
wasm-bindgen = { version = "0.2.92", features = [] }
wasm-bindgen = { version = "0.2.92", default-features = false }
wasm-bindgen-test = { version = "0.3.34" }
windows = { version = "0.52.0", features = ["Win32", "Win32_UI", "Win32_UI_Shell", "Win32_System", "Win32_System_LibraryLoader", "Win32_Foundation", "Win32_System_Com"] }
windows = { version = "0.52.0", features = ["Win32_UI", "Win32_UI_Shell", "Win32_System_LibraryLoader", "Win32_System_Com"] }
winreg = { version = "0.52.0" }
anyhow = { version = "1.0.66" }
failure = { version = "0.1.8" }
derive_more = { version = "0.99" }
derive_more = { version = "1.0", features = ["index", "index_mut", "deref", "deref_mut", "display", "from", "into", "as_ref", "add", "add_assign"] }
boolinator = { version = "2.4.0" }
derivative = { version = "2.2" }
futures = { version = "0.3" }
futures = { version = "0.3", default-features = false, features = ["std", "executor"]}
futures-util = { version = "0.3", default-features = false }
itertools = { version = "0.12.1" }
lazy_static = { version = "1.4" }
serde_json = { version = "1.0", features = ["raw_value"] }
owned_ttf_parser = { version = "0.15.1" }
convert_case = { version = "0.6.0" }
rustybuzz = { version = "0.5.1" }
bincode = { version = "2.0.0-rc.1" }
byte-unit = { version = "5.1.4", features = ["serde"] }
bytes = { version = "1.1.0" }
matches = { version = "0.1" }
console_error_panic_hook = { version = "0.1.6" }
reqwest = { version = "0.11.27", default-features = false, features = [
"rustls-tls",
Expand All @@ -161,14 +150,6 @@ syn = { version = "2.0", features = [
"visit",
"visit-mut",
] }
syn_1 = { package = "syn", version = "1.0", features = [
"full",
"extra-traits",
"printing",
"parsing",
"visit",
"visit-mut",
] }
quote = { version = "1.0.23" }
semver = { version = "1.0.0", features = ["serde"] }
strum = { version = "0.26.2", features = ["derive"] }
5 changes: 2 additions & 3 deletions build/base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ edition = "2021"
[dependencies]
anyhow = { workspace = true }
fn-error-context = "0.2.0"
futures-util = "0.3.24"
futures-util = { workspace = true }
futures = { workspace = true }
serde = "1.0.145"
serde = { workspace = true }
serde_json = { workspace = true }
serde_yaml = { workspace = true }
tracing = { workspace = true }

[lints]
Expand Down
3 changes: 0 additions & 3 deletions build/base/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
// === Export ===
// ==============

pub mod from_string;
pub mod future;
pub mod iterator;
pub mod maps;
pub mod option;
pub mod os_str;
pub mod path;
pub mod pathbuf;
pub mod result;
pub mod str;
41 changes: 0 additions & 41 deletions build/base/src/extensions/from_string.rs

This file was deleted.

51 changes: 1 addition & 50 deletions build/base/src/extensions/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,17 @@
use crate::prelude::*;

use futures_util::future::ErrInto;
use futures_util::future::Map;
use futures_util::future::MapErr;
use futures_util::future::MapOk;
use futures_util::stream;
use futures_util::FutureExt as _;
use futures_util::TryFutureExt as _;



/// Extension methods for [`Future`].
pub trait FutureExt: Future {
/// Discard the result of this future.
fn void(self) -> Map<Self, fn(Self::Output) -> ()>
where Self: Sized {
self.map(drop)
}
}
pub trait FutureExt: Future {}

impl<T: ?Sized> FutureExt for T where T: Future {}

type FlattenResultFn<T, E> =
fn(std::result::Result<std::result::Result<T, E>, E>) -> std::result::Result<T, E>;

/// Extension methods for [`TryFuture`], i.e. the Result-yielding [`Future`]
pub trait TryFutureExt: TryFuture {
/// Discard the result of successful future.
Expand Down Expand Up @@ -55,42 +42,6 @@ pub trait TryFutureExt: TryFuture {
C: Display + Send + Sync + 'static, {
self.into_future().map(|res| res.with_context(context)).boxed()
}

/// Convert the error type of this future to [`anyhow::Error`].
fn anyhow_err(self) -> MapErr<Self, fn(Self::Error) -> anyhow::Error>
where
Self: Sized,
// TODO: we should rely on `into` rather than `from`
anyhow::Error: From<Self::Error>, {
self.map_err(anyhow::Error::from)
}

/// If the future is successful, apply the function to the result and return the new future.
fn and_then_sync<T2, E2, F>(
self,
f: F,
) -> Map<MapOk<ErrInto<Self, E2>, F>, FlattenResultFn<T2, E2>>
where
Self: Sized,
F: FnOnce(Self::Ok) -> std::result::Result<T2, E2>,
Self::Error: Into<E2>,
{
self.err_into().map_ok(f).map(std::result::Result::flatten)
}
}

impl<T: ?Sized> TryFutureExt for T where T: TryFuture {}

/// Extension methods for [`TryStream`], i.e. a [`Stream`] that produces [`Result`]s.
pub trait TryStreamExt: TryStream {
/// Wrap all the errors into [`anyhow::Error`].
fn anyhow_err(self) -> stream::MapErr<Self, fn(Self::Error) -> anyhow::Error>
where
Self: Sized,
// TODO: we should rely on `into` rather than `from`
anyhow::Error: From<Self::Error>, {
self.map_err(anyhow::Error::from)
}
}

impl<T: ?Sized> TryStreamExt for T where T: TryStream {}
66 changes: 0 additions & 66 deletions build/base/src/extensions/iterator.rs

This file was deleted.

34 changes: 1 addition & 33 deletions build/base/src/extensions/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,7 @@ pub trait PathExt: AsRef<Path> {
fn write_as_json<T: Serialize>(&self, value: &T) -> Result {
trace!("Writing JSON to {}.", self.as_ref().display());
let file = crate::fs::create(self)?;
serde_json::to_writer(file, value).anyhow_err()
}

/// Parse this file's contents as a YAML-serialized value.
fn read_to_yaml<T: DeserializeOwned>(&self) -> Result<T> {
let content = crate::fs::read_to_string(self)?;
serde_yaml::from_str(&content).anyhow_err()
}

/// Write this file with a YAML-serialized value.
fn write_as_yaml<T: Serialize>(&self, value: &T) -> Result {
trace!("Writing YAML to {}.", self.as_ref().display());
let file = crate::fs::create(self)?;
serde_yaml::to_writer(file, value).anyhow_err()
Ok(serde_json::to_writer(file, value)?)
}

/// Get the path as `str`.
Expand Down Expand Up @@ -163,25 +150,6 @@ pub trait PathExt: AsRef<Path> {

impl<T: AsRef<Path>> PathExt for T {}

/// A method that outputs a path to a formatter using [`Path::display`].
///
/// This is useful in combination with macros like `Derivative`, as demonstrated in the example
/// below.
///
/// # Example
/// ```ignore
/// #[derive(Derivative)]
/// #[derivative(Debug)]
/// pub struct Foo {
/// #[derivative(Debug(format_with = "display_fmt"))]
/// path: PathBuf,
/// }
/// ```
pub fn display_fmt(path: &Path, f: &mut Formatter) -> std::fmt::Result {
Display::fmt(&path.display(), f)
}


/// A result of splitting a path into its filename components.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SplitFilename<'a> {
Expand Down
Loading

0 comments on commit f14b79f

Please sign in to comment.