Skip to content

Commit

Permalink
Remove unused code & data-type 'UseManifest'
Browse files Browse the repository at this point in the history
  If it's unused, it shall be gone. It obfuscate what functions are
  doing and require managing extra complexity for no reason.
  • Loading branch information
KtorZ committed Sep 8, 2023
1 parent 0caf5e8 commit 14ecaef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 40 deletions.
15 changes: 2 additions & 13 deletions crates/aiken-project/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,7 @@ impl From<&Manifest> for LocalPackages {
}
}

pub fn download<T>(
event_listener: &T,
use_manifest: UseManifest,
root_path: &Path,
config: &Config,
) -> Result<Manifest, Error>
pub fn download<T>(event_listener: &T, root_path: &Path, config: &Config) -> Result<Manifest, Error>
where
T: EventListener,
{
Expand All @@ -164,13 +159,7 @@ where

let runtime = tokio::runtime::Runtime::new().expect("Unable to start Tokio");

let (manifest, changed) = Manifest::load(
runtime.handle().clone(),
event_listener,
config,
use_manifest,
root_path,
)?;
let (manifest, changed) = Manifest::load(event_listener, config, root_path)?;

let local = LocalPackages::load(root_path)?;

Expand Down
25 changes: 5 additions & 20 deletions crates/aiken-project/src/deps/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use crate::{
telemetry::{Event, EventListener},
};

use super::UseManifest;

#[derive(Deserialize, Serialize, Debug)]
pub struct Manifest {
pub requirements: Vec<Dependency>,
Expand All @@ -22,10 +20,8 @@ pub struct Manifest {

impl Manifest {
pub fn load<T>(
runtime: tokio::runtime::Handle,
event_listener: &T,
config: &Config,
use_manifest: UseManifest,
root_path: &Path,
) -> Result<(Self, bool), Error>
where
Expand All @@ -35,15 +31,10 @@ impl Manifest {

// If there's no manifest (or we have been asked not to use it) then resolve
// the versions anew
let should_resolve = match use_manifest {
_ if !manifest_path.exists() => true,
UseManifest::No => true,
UseManifest::Yes => false,
};
let should_resolve = !manifest_path.exists();

if should_resolve {
let manifest = resolve_versions(runtime, config, None, event_listener)?;

let manifest = resolve_versions(config, event_listener)?;
return Ok((manifest, true));
}

Expand All @@ -61,13 +52,12 @@ impl Manifest {
help: e.to_string(),
})?;

// If the config has unchanged since the manifest was written then it is up
// If the config is unchanged since the manifest was written then it is up
// to date so we can return it unmodified.
if manifest.requirements == config.dependencies {
Ok((manifest, false))
} else {
let manifest = resolve_versions(runtime, config, Some(&manifest), event_listener)?;

let manifest = resolve_versions(config, event_listener)?;
Ok((manifest, true))
}
}
Expand Down Expand Up @@ -96,12 +86,7 @@ pub struct Package {
pub source: Platform,
}

fn resolve_versions<T>(
_runtime: tokio::runtime::Handle,
config: &Config,
_manifest: Option<&Manifest>,
event_listener: &T,
) -> Result<Manifest, Error>
fn resolve_versions<T>(config: &Config, event_listener: &T) -> Result<Manifest, Error>
where
T: EventListener,
{
Expand Down
8 changes: 1 addition & 7 deletions crates/aiken-project/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use aiken_lang::{
tipo::TypeInfo,
IdGenerator,
};
use deps::UseManifest;
use indexmap::IndexMap;
use miette::NamedSource;
use options::{CodeGenMode, Options};
Expand Down Expand Up @@ -491,12 +490,7 @@ where
}

fn compile_deps(&mut self) -> Result<(), Vec<Error>> {
let manifest = deps::download(
&self.event_listener,
UseManifest::Yes,
&self.root,
&self.config,
)?;
let manifest = deps::download(&self.event_listener, &self.root, &self.config)?;

for package in manifest.packages {
let lib = self.root.join(paths::build_deps_package(&package.name));
Expand Down

0 comments on commit 14ecaef

Please sign in to comment.