Skip to content

Commit

Permalink
Remove derivative dependency in favor of manual implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
djc authored and rami3l committed Apr 9, 2024
1 parent bcccd3e commit 1196554
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 49 deletions.
55 changes: 16 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ cfg-if = "1.0"
chrono = { version = "0.4", default-features = false, features = ["std"] }
clap = { version = "4", features = ["wrap_help"] }
clap_complete = "4"
derivative.workspace = true
download = { path = "download", default-features = false }
effective-limits = "0.5.5"
enum-map = "2.5.0"
Expand Down Expand Up @@ -160,7 +159,6 @@ members = ["download", "rustup-macros"]

[workspace.dependencies]
anyhow = "1.0.69"
derivative = "2.2.0"
enum_dispatch = "0.3.11"
fs_at = "0.1.6"
once_cell = "1.18.0"
Expand Down
24 changes: 19 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use std::borrow::Cow;
use std::fmt::{self, Display};
use std::fmt::{self, Debug, Display};
use std::io;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str::FromStr;
use std::sync::Arc;

use anyhow::{anyhow, bail, Context, Result};
use derivative::Derivative;
use serde::Deserialize;
use thiserror::Error as ThisError;

Expand Down Expand Up @@ -172,8 +171,6 @@ impl OverrideCfg {

pub(crate) const UNIX_FALLBACK_SETTINGS: &str = "/etc/rustup/settings.toml";

#[derive(Derivative)]
#[derivative(Debug)]
pub(crate) struct Cfg {
profile_override: Option<dist::Profile>,
pub rustup_dir: PathBuf,
Expand All @@ -186,7 +183,6 @@ pub(crate) struct Cfg {
pub toolchain_override: Option<ResolvableToolchainName>,
pub env_override: Option<LocalToolchainName>,
pub dist_root_url: String,
#[derivative(Debug = "ignore")]
pub notify_handler: Arc<dyn Fn(Notification<'_>)>,
}

Expand Down Expand Up @@ -955,6 +951,24 @@ impl Cfg {
}
}

impl Debug for Cfg {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Cfg")
.field("profile_override", &self.profile_override)
.field("rustup_dir", &self.rustup_dir)
.field("settings_file", &self.settings_file)
.field("fallback_settings", &self.fallback_settings)
.field("toolchains_dir", &self.toolchains_dir)
.field("update_hash_dir", &self.update_hash_dir)
.field("download_dir", &self.download_dir)
.field("temp_cfg", &self.temp_cfg)
.field("toolchain_override", &self.toolchain_override)
.field("env_override", &self.env_override)
.field("dist_root_url", &self.dist_root_url)
.finish()
}
}

fn get_default_host_triple(s: &Settings) -> dist::TargetTriple {
s.default_host_triple
.as_ref()
Expand Down
4 changes: 1 addition & 3 deletions src/toolchain/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::{
};

use anyhow::{anyhow, bail};
use derivative::Derivative;
use fs_at::OpenOptions;
use wait_timeout::ChildExt;

Expand All @@ -30,8 +29,7 @@ use super::{
};

/// A toolchain installed on the local disk
#[derive(Derivative)]
#[derivative(Clone, Debug)]
#[derive(Clone, Debug)]
pub(crate) struct Toolchain<'a> {
cfg: &'a Cfg,
name: LocalToolchainName,
Expand Down

0 comments on commit 1196554

Please sign in to comment.