Remove unused code & data-type 'UseManifest'

If it's unused, it shall be gone. It obfuscate what functions are
  doing and require managing extra complexity for no reason.
This commit is contained in:
KtorZ 2023-09-08 15:10:48 +02:00 committed by Lucas
parent 5381762e50
commit 15efeb3069
3 changed files with 8 additions and 40 deletions

View File

@ -133,12 +133,7 @@ impl From<&Manifest> for LocalPackages {
} }
} }
pub fn download<T>( pub fn download<T>(event_listener: &T, root_path: &Path, config: &Config) -> Result<Manifest, Error>
event_listener: &T,
use_manifest: UseManifest,
root_path: &Path,
config: &Config,
) -> Result<Manifest, Error>
where where
T: EventListener, T: EventListener,
{ {
@ -164,13 +159,7 @@ where
let runtime = tokio::runtime::Runtime::new().expect("Unable to start Tokio"); let runtime = tokio::runtime::Runtime::new().expect("Unable to start Tokio");
let (manifest, changed) = Manifest::load( let (manifest, changed) = Manifest::load(event_listener, config, root_path)?;
runtime.handle().clone(),
event_listener,
config,
use_manifest,
root_path,
)?;
let local = LocalPackages::load(root_path)?; let local = LocalPackages::load(root_path)?;

View File

@ -12,8 +12,6 @@ use crate::{
telemetry::{Event, EventListener}, telemetry::{Event, EventListener},
}; };
use super::UseManifest;
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
pub struct Manifest { pub struct Manifest {
pub requirements: Vec<Dependency>, pub requirements: Vec<Dependency>,
@ -22,10 +20,8 @@ pub struct Manifest {
impl Manifest { impl Manifest {
pub fn load<T>( pub fn load<T>(
runtime: tokio::runtime::Handle,
event_listener: &T, event_listener: &T,
config: &Config, config: &Config,
use_manifest: UseManifest,
root_path: &Path, root_path: &Path,
) -> Result<(Self, bool), Error> ) -> Result<(Self, bool), Error>
where where
@ -35,15 +31,10 @@ impl Manifest {
// If there's no manifest (or we have been asked not to use it) then resolve // If there's no manifest (or we have been asked not to use it) then resolve
// the versions anew // the versions anew
let should_resolve = match use_manifest { let should_resolve = !manifest_path.exists();
_ if !manifest_path.exists() => true,
UseManifest::No => true,
UseManifest::Yes => false,
};
if should_resolve { if should_resolve {
let manifest = resolve_versions(runtime, config, None, event_listener)?; let manifest = resolve_versions(config, event_listener)?;
return Ok((manifest, true)); return Ok((manifest, true));
} }
@ -61,13 +52,12 @@ impl Manifest {
help: e.to_string(), 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. // to date so we can return it unmodified.
if manifest.requirements == config.dependencies { if manifest.requirements == config.dependencies {
Ok((manifest, false)) Ok((manifest, false))
} else { } else {
let manifest = resolve_versions(runtime, config, Some(&manifest), event_listener)?; let manifest = resolve_versions(config, event_listener)?;
Ok((manifest, true)) Ok((manifest, true))
} }
} }
@ -96,12 +86,7 @@ pub struct Package {
pub source: Platform, pub source: Platform,
} }
fn resolve_versions<T>( fn resolve_versions<T>(config: &Config, event_listener: &T) -> Result<Manifest, Error>
_runtime: tokio::runtime::Handle,
config: &Config,
_manifest: Option<&Manifest>,
event_listener: &T,
) -> Result<Manifest, Error>
where where
T: EventListener, T: EventListener,
{ {

View File

@ -27,7 +27,6 @@ use aiken_lang::{
tipo::TypeInfo, tipo::TypeInfo,
IdGenerator, IdGenerator,
}; };
use deps::UseManifest;
use indexmap::IndexMap; use indexmap::IndexMap;
use miette::NamedSource; use miette::NamedSource;
use options::{CodeGenMode, Options}; use options::{CodeGenMode, Options};
@ -491,12 +490,7 @@ where
} }
fn compile_deps(&mut self) -> Result<(), Vec<Error>> { fn compile_deps(&mut self) -> Result<(), Vec<Error>> {
let manifest = deps::download( let manifest = deps::download(&self.event_listener, &self.root, &self.config)?;
&self.event_listener,
UseManifest::Yes,
&self.root,
&self.config,
)?;
for package in manifest.packages { for package in manifest.packages {
let lib = self.root.join(paths::build_deps_package(&package.name)); let lib = self.root.join(paths::build_deps_package(&package.name));